/* Orion Lawlor's Short UNIX Examples, olawlor@acm.org 2003/8/20

Shows how to write a set-uid executable.

This program, to do its thing, should be "chmod +s".
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>

int main() {
	int old_uid=getuid();
	int uid=geteuid();
	printf("Changing from uid %d to %d\n",old_uid,uid);
	fflush(stdout);
	setuid(uid);
	system("id");
	return 0;
}
/*<@>
<@> ******** Program output: ********
<@> Changing from uid 501 to 501
<@> uid=501(olawlor) gid=1000(family) groups=20(dialout),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),100(users),104(scanner),106(fuse),108(lpadmin),110(admin),503(photomaker),1000(family)
<@> */
