svn commit: r362602 - stable/12/usr.sbin/mountd
Rick Macklem
rmacklem at FreeBSD.org
Thu Jun 25 02:45:49 UTC 2020
Author: rmacklem
Date: Thu Jun 25 02:45:49 2020
New Revision: 362602
URL: https://svnweb.freebsd.org/changeset/base/362602
Log:
MFC: r361780, r361956
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].
Relnotes: yes
Modified:
stable/12/usr.sbin/mountd/mountd.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/usr.sbin/mountd/mountd.c
==============================================================================
--- stable/12/usr.sbin/mountd/mountd.c Thu Jun 25 02:00:51 2020 (r362601)
+++ stable/12/usr.sbin/mountd/mountd.c Thu Jun 25 02:45:49 2020 (r362602)
@@ -3434,10 +3434,18 @@ 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;
+ if (cr->cr_ngroups > XU_NGROUPS)
+ cr->cr_ngroups = XU_NGROUPS;
+ for (cnt = 1; cnt < cr->cr_ngroups; cnt++)
+ cr->cr_groups[cnt] = groups[cnt];
+ }
return;
}
/*
More information about the svn-src-stable-12
mailing list