[news.admin] Help on Relaynews

guy@auspex.auspex.com (Guy Harris) (05/25/91)

>You said "yes" when build asked whether you could do setuid(geteuid()).
>Wrong.  (On SunOS, yet... sigh.)

Really?  I tried running a program that read:

	main()
	{
		printf("ruid %d, euid %d\n", getuid(), geteuid());
		if (setuid(geteuid()) < 0)
			perror("setuid");
		else
			printf("ruid %d, euid %d\n", getuid(), geteuid());
	}

set-UID to "bin", while running as myself, and on both a 4.0.3 and a
4.1.1 machine it printed:

	ruid 126, euid 3
	ruid 3, euid 3

so it did, indeed, set the real UID to match the effective UID, which is
exactly what "setuid(geteuid())" is supposed to do.

It did the same when I ran it as "root":

	ruid 0, euid 3
	ruid 3, euid 3

and when it was set-UID to "root" and run as me:

	ruid 126, euid 0
	ruid 0, euid 0