setgid on Xenix != setgid on BSD

Tan Bronson tan at bronson.UUCP
Wed Sep 27 13:48:39 AEST 1989


    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 at microvation.com (or tan at bronson.uucp)
Microvation Consultants (work) bronson at multiflow.com
Madison, CT 06443



More information about the Comp.unix.xenix mailing list