Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jun 2020 23:35:54 +0000
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        "freebsd-current@FreeBSD.org" <freebsd-current@FreeBSD.org>
Cc:        Kirk McKusick <mckusick@FreeBSD.org>
Subject:   getgrouplist duplication of cr_groups[0] as cr_groups[1]
Message-ID:  <QB1PR01MB36494F0D8BD7E6D41B8B31A6DD880@QB1PR01MB3649.CANPRD01.PROD.OUTLOOK.COM>

index | next in thread | raw e-mail

Hi,

During testing of a mountd.c patch I have, I found an "old bug" where the
mountd.c code assumed that getgrouplist() would always duplicate
cr_groups[0] in cr_groups[1].

If I read the commit logs correctly, this was always the case until
r174547 (only 12years ago), which switched getgrouplist() to
use __getgroupmembership().
Kirk fixed the deduplication code in gr_addgid() in r328304 so that
gr_addgid() would not deduplicate cr_groups[0,1].
However, the case where the "user" is not also listed in the group
database for the same group as their gid in the password database
will not be duplicated.
--> It also implies that getgrouplist() can return with ngroups == 1,
      with only the basegid in it.

So, is getgrouplist(3) always returning with cr_groups[0] and cr_groups[1]
duplicated required behaviour?

If the duplication is not required, then I can easily fix mountd to
check for the non-duplicated case.
I will probably patch it anyhow, since the one line change will be
harmless even if getgrouplist() is changed to always return the
duplicate of cr_groups[0] in cr_groups[1].

rick



help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?QB1PR01MB36494F0D8BD7E6D41B8B31A6DD880>