doing setreuid with setuid in modern sysv

Guy Harris guy at auspex.auspex.com
Tue Jan 16 06:49:59 AEST 1990


>Could someone set me straight on this please?  How does one flip back and
>forth between uid 0 and uid != 0 in a process started by uid 0 on a modern
>System V ?

By changing your kernel, or perhaps running S5R4.0 if it has
"seteuid()".

The problem with the saved set-user ID is that it works only if you're
*NOT* running as "root".  There are (at least) two separate "set UID"
functions you want for UNIX programs: one that sets *only* the effective
UID, and that lets you toggle it an indefinite number of times between
the real and saved set-user ID, and one that sets *all* the UIDs.  The
former would be used by most set-UID programs, and the latter would be
used by, say, "login" or "su".

Unfortunately, both of those functions are called "setuid()" in System
V; the way the S5 kernel distinguishes between them is that "setuid()"
is the first function if the effective UID isn't 0, and the second
function if it is.

S5R4 may have picked up "seteuid()" from 4BSD; if so, with any luck it
sets only the effective UID, even if the current effective UID is 0.



More information about the Comp.unix.questions mailing list