Path: utzoo!attcan!uunet!mfci!bronson!tan
From: tan@bronson.UUCP (Tan Bronson)
Newsgroups: comp.unix.xenix
Subject: setgid on Xenix != setgid on BSD
Message-ID: <7@bronson.UUCP>
Date: 27 Sep 89 03:48:39 GMT
Reply-To: tan@bronson.UUCP (Tan Bronson)
Organization: Microvation Consultants Madison, Ct 06443
Lines: 34


    The program below demonstrates the Xenix 2.3.3 does not allow me to
write a setgid program, and change the effective gid to the real gid.
(This works on BSD4.3). Is there some workaround, or is this another
reason to wait for System V.4?

#include 
main ()
{
    int egid, gid;
    egid = getegid();
    gid  = getgid();
    printf("egid = %d gid = %d\n", egid, gid);
    if (egid != 1) {
	fprintf(stderr, "must install this file setgid '1'");
	exit(0);
    }
    if (setgid(1) < 0) {
	fprintf(stderr, "failed to setgid(1)");
	exit(0);
    }
    egid = getegid();
    gid  = getgid();
    printf("egid = %d gid = %d\n", egid, gid);
    if (gid != 1) {
	fprintf(stderr, "setgid(1) does not work!");
	exit(0);
    }
    printf("setgid(1) does work!");
}
-- 
Tan Bronson		(home) tan@microvation.com (or tan@bronson.uucp)
Microvation Consultants (work) bronson@multiflow.com
Madison, CT 06443