Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!pasteur!ucbvax!agate!ig!uwmcsd1!dogie!rhesus!bin
From: bin@rhesus.primate.wisc.edu (Brain in Neutral)
Newsgroups: comp.unix.wizards
Subject: setgid and process group list
Message-ID: <339@rhesus.primate.wisc.edu>
Date: 11 Jul 88 17:03:21 GMT
Organization: UW-Madison Primate Center
Lines: 15

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?