diff options
author | Rick Macklem <rmacklem@FreeBSD.org> | 2020-06-04 00:28:20 +0000 |
---|---|---|
committer | Rick Macklem <rmacklem@FreeBSD.org> | 2020-06-04 00:28:20 +0000 |
commit | 01f13218a31d89f25aac435e7eb5d0896052146b (patch) | |
tree | 6615fc7d9c853ce3a0d6b02fa720327738f36210 /usr.sbin | |
parent | 8c27b7a98bcf4d1a0c9a77c53d46b82893e919c5 (diff) | |
download | src-01f13218a31d89f25aac435e7eb5d0896052146b.tar.gz src-01f13218a31d89f25aac435e7eb5d0896052146b.zip |
Fix mountd to handle getgrouplist() not returning groups[0] == groups[1].
Prior to r174547, getgrouplist(3) always returned a groups list with
element 0 and 1 set to the basegid argument, so long as ngroups was > 1.
Post-r174547 this is not the case. r328304 disabled the deduplication that
removed the duplicate, but the duplicate still does not occur unless the
group for a user in the password database is also entered in the group
database.
This patch fixes mountd so that it handles the case where a user specified
with the -maproot or -mapall exports option has a getgrouplist(3) groups
list where groups[0] != groups[1].
Found while testing another mountd patch.
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=361780
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/mountd/mountd.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 36b3659ea487..d119bb9199d6 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -3434,10 +3434,16 @@ parsecred(char *namelist, struct xucred *cr) /* * Compress out duplicate. */ - cr->cr_ngroups = ngroups - 1; cr->cr_groups[0] = groups[0]; - for (cnt = 2; cnt < ngroups; cnt++) - cr->cr_groups[cnt - 1] = groups[cnt]; + if (ngroups > 1 && groups[0] == groups[1]) { + cr->cr_ngroups = ngroups - 1; + for (cnt = 2; cnt < ngroups; cnt++) + cr->cr_groups[cnt - 1] = groups[cnt]; + } else { + cr->cr_ngroups = ngroups; + for (cnt = 1; cnt < ngroups; cnt++) + cr->cr_groups[cnt] = groups[cnt]; + } return; } /* |