setgid and process group list

Brain in Neutral bin at rhesus.primate.wisc.edu
Tue Jul 12 03:03:21 AEST 1988


Why does setgid screw up the list of groups that getgroups returns?

E.g., in a setuid root program:

	ngroups = getgroups (NGROUPS, grparry)
	print groups here...
	setgid (somegid);
	ngroups = getgroups (NGROUPS, grparry)
	print groups here...

The group lists printed before and after the setgid are different,
at least under Ultrix 1.2 and 2.2.  (Typically a group is missing after
the setgid).
Doing an initgroups after the setgid fixes things (I think).  I notice
that BSD 4.3 login.c does this.  Why is it necessary?



More information about the Comp.unix.wizards mailing list