getgrouplist duplication of cr_groups[0] as cr_groups[1]

From: Rick Macklem <rmacklem_at_uoguelph.ca>
Date: Wed, 3 Jun 2020 23:35:54 +0000
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


Received on Wed Jun 03 2020 - 21:35:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:24 UTC