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>
next in thread | raw e-mail | index | archive | help
Hi,=0A= =0A= During testing of a mountd.c patch I have, I found an "old bug" where the= =0A= mountd.c code assumed that getgrouplist() would always duplicate=0A= cr_groups[0] in cr_groups[1].=0A= =0A= If I read the commit logs correctly, this was always the case until=0A= r174547 (only 12years ago), which switched getgrouplist() to=0A= use __getgroupmembership().=0A= Kirk fixed the deduplication code in gr_addgid() in r328304 so that=0A= gr_addgid() would not deduplicate cr_groups[0,1].=0A= However, the case where the "user" is not also listed in the group=0A= database for the same group as their gid in the password database=0A= will not be duplicated.=0A= --> It also implies that getgrouplist() can return with ngroups =3D=3D 1,= =0A= with only the basegid in it.=0A= =0A= So, is getgrouplist(3) always returning with cr_groups[0] and cr_groups[1]= =0A= duplicated required behaviour?=0A= =0A= If the duplication is not required, then I can easily fix mountd to=0A= check for the non-duplicated case.=0A= I will probably patch it anyhow, since the one line change will be=0A= harmless even if getgrouplist() is changed to always return the=0A= duplicate of cr_groups[0] in cr_groups[1].=0A= =0A= rick=0A= =0A=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?QB1PR01MB36494F0D8BD7E6D41B8B31A6DD880>