git: 0c0cd622f279 - stable/13 - mountd(8): parsecred(): Remove "duplicate compression"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 17 Jan 2025 12:27:10 UTC
The branch stable/13 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=0c0cd622f2797214e76d19bd45bbbfaa4dd21cf4 commit 0c0cd622f2797214e76d19bd45bbbfaa4dd21cf4 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2024-09-26 17:00:26 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2025-01-17 12:24:51 +0000 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 (cherry picked from commit f2d2318fafbb16c8a7773fe20c724c986f424fa2) --- usr.sbin/mountd/mountd.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/usr.sbin/mountd/mountd.c b/usr.sbin/mountd/mountd.c index 47bb5758ee1e..ebd88d3fdd66 100644 --- a/usr.sbin/mountd/mountd.c +++ b/usr.sbin/mountd/mountd.c @@ -3569,7 +3569,6 @@ static void parsecred(char *namelist, struct expcred *cr) { char *name; - int inpos; char *names; struct passwd *pw; struct group *gr; @@ -3611,23 +3610,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; } /*