[3909] in Athena Bugs
suggestion/patch: initgroups()
daemon@ATHENA.MIT.EDU (probe@ATHENA.MIT.EDU)
Sat Jan 6 16:13:42 1990
From: probe@ATHENA.MIT.EDU
Date: Sat, 6 Jan 90 16:13:27 -0500
To: bugs@ATHENA.MIT.EDU
Reply-To: Richard Basch <probe@ATHENA.MIT.EDU>
It is possible to be in the same group twice, if the group is listed
twice in /etc/group. May I suggest the following change:
*** /paris/source/4.3/lib/libc/gen/initgroups.c Sun Apr 27 05:41:09 1986
--- /tmp//initgroups.c Sat Jan 6 16:10:44 1990
***************
*** 23,36 ****
{
int groups[NGROUPS], ngroups = 0;
register struct group *grp;
! register int i;
if (agroup >= 0)
groups[ngroups++] = agroup;
setgrent();
while (grp = getgrent()) {
! if (grp->gr_gid == agroup)
! continue;
for (i = 0; grp->gr_mem[i]; i++)
if (!strcmp(grp->gr_mem[i], uname)) {
if (ngroups == NGROUPS) {
--- 23,39 ----
{
int groups[NGROUPS], ngroups = 0;
register struct group *grp;
! register int i, j;
if (agroup >= 0)
groups[ngroups++] = agroup;
setgrent();
while (grp = getgrent()) {
! for (j = 0; j < ngroups; j++)
! if (grp->gr_gid == groups[j])
! break;
! if (j < ngroups)
! continue;
for (i = 0; grp->gr_mem[i]; i++)
if (!strcmp(grp->gr_mem[i], uname)) {
if (ngroups == NGROUPS) {
Admittedly, I have not yet tested it, but the change is rather
straight-forward.
-Richard