[1389] in Athena Bugs
Bug in setgid()
daemon@ATHENA.MIT.EDU (Chris D. Peterson)
Fri Nov 18 17:41:34 1988
To: bugs@ATHENA.MIT.EDU
Date: Fri, 18 Nov 88 17:40:56 EST
From: Chris D. Peterson <kit@ATHENA.MIT.EDU>
MACHINE: all, release 6.0R
SYNSOPSIS:
Set gid removes you from group wheel if the gid is not wheel's gid.
DISCUSSION:
If a setgroups() call is made and then followed by a setgid() the
group list will have wheel (gid = 0) removed from it.
REPEAT BY:
compile and run the following as root.
#include<sys/param.h>
void
main()
{
int i, ngroups, groups[NGROUPS], foo[NGROUPS];
ngroups = 4;
groups[0] = 101;
groups[1] = 200;
groups[2] = 0;
groups[3] = 1000;
for (i = 0 ; i < ngroups ; i++)
printf("This user is in group[%d] # %d.\n", i, groups[i]);
printf("Setting Groups.\n");
if ( setgroups(ngroups, groups) != 0) /* set gid(s). */
printf("Could not set groups.\n");
ngroups = getgroups(NGROUPS, foo);
for (i = 0 ; i < ngroups ; i++)
printf("This user is in group[%d] # %d\n", i, foo[i]);
setgid(groups[0]);
ngroups = getgroups(NGROUPS, foo);
for (i = 0 ; i < ngroups ; i++)
printf("This user is in group[%d] # %d\n", i, foo[i]);
}
FIX
It would be nice to have one :-)