[comp.unix.xenix] setgid on Xenix != setgid on BSD

tan@bronson.UUCP (Tan Bronson) (09/27/89)

    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 <stdio.h>
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