aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2024-09-26 17:00:26 +0000
committerOlivier Certner <olce@FreeBSD.org>2024-12-16 14:42:29 +0000
commitf2d2318fafbb16c8a7773fe20c724c986f424fa2 (patch)
tree195b56cb25df66df07057cbbd291dd3a3acecd57
parentae22a4bb7437019e34fc593e101a6ac14c9d7959 (diff)
mountd(8): parsecred(): Remove "duplicate compression"
No functional change (intended). This code dates back to 4.4BSD, became wrong after some getgrouplist() (nssswitch-related) change in 2007, was fixed only in 2020 and since then underwent cosmetic changes. It is likely that in fact it never served any useful purpose in FreeBSD, except perhaps at the very beginning. It's most probably not the case today: NFS credentials are normally only used to check for file accesses, whose group is checked against all groups of a credentials indiscriminately (except for the real GID). Consequently, having a single duplicate, which the code would actually remove only if in the first supplementary group slot, doesn't change behavior. Moreover, we are going to regain one slot in a subsequent commit. Discussed with: rmacklem Approved by: markj (mentor) MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D46920
-rw-r--r--usr.sbin/mountd/mountd.c14
1 files changed, 1 insertions, 13 deletions
diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c
index c903431c2ecf..22ed57d8669d 100644
--- a/usr.sbin/mountd/mountd.c
+++ b/usr.sbin/mountd/mountd.c
@@ -3610,7 +3610,6 @@ static void
parsecred(char *namelist, struct expcred *cr)
{
char *name;
- int inpos;
char *names;
struct passwd *pw;
struct group *gr;
@@ -3652,23 +3651,12 @@ parsecred(char *namelist, struct expcred *cr)
ngroups = NGROUPS_MAX + 1;
}
- /*
- * Compress out duplicate.
- */
- if (ngroups > 1 && groups[0] == groups[1]) {
- ngroups--;
- inpos = 2;
- } else {
- inpos = 1;
- }
if (ngroups > NGROUPS_MAX)
ngroups = NGROUPS_MAX;
if (ngroups > SMALLNGROUPS)
cr->cr_groups = malloc(ngroups * sizeof(gid_t));
cr->cr_ngroups = ngroups;
- cr->cr_groups[0] = groups[0];
- memcpy(&cr->cr_groups[1], &groups[inpos], (ngroups - 1) *
- sizeof(gid_t));
+ memcpy(cr->cr_groups, groups, ngroups * sizeof(gid_t));
return;
}
/*