1 /* $Id: seteuid.c 3839 2000-08-29 04:50:18Z rra $
3 ** Replacement for a missing seteuid.
5 ** Written by Russ Allbery <rra@stanford.edu>
6 ** This work is hereby placed in the public domain by its author.
8 ** Some systems don't have seteuid but do have setreuid. setreuid with
9 ** -1 given for the real UID is equivalent to seteuid on systems with
10 ** POSIX saved UIDs. On systems without POSIX saved UIDs, we'd lose our
11 ** ability to regain privileges if we just set the effective UID, so
12 ** instead fake a saved UID by setting the real UID to the current
13 ** effective UID, using the real UID as the saved UID.
15 ** Note that swapping UIDs doesn't work on AIX, but AIX has saved UIDs.
16 ** Note also that systems without setreuid lose, and that we assume that
17 ** any system with seteuid has saved UIDs.
28 #ifdef _POSIX_SAVED_IDS
33 return setreuid(ruid, euid);