SETUID(2)

NAME
setuid, seteuid - get user identity

SYNOPSIS
#include <unistd.h>

intsetuid(uid_t uid )
intseteuid(uid_tuid)

DESCRIPTION
setuid sets the real user ID of the current process. seteuid sets the effective user ID of the current process. The real ID corresponds to the ID of the calling process. The effective ID corresponds to the set ID bit on the file being executed.

NOTES FROM THE KERNEL SOURCE
Under Linux 0.99.11, setuid is implemented like SysV w/ SAVED_IDS Note that SAVED_ID's is deficient in that a setuid root program like sendmail, for example, cannot set its uid to be a normal user and then switch back, because if you're root, setuid sets the saved uid too. If you don't like this, blame the bright people in the POSIX committee and/or USG. Note that the BSD-style setreuid will allow a root program to temporarily drop privileges and be able to regain them by swapping the real and effective uid.

RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

ERRORS

EPERM
    The user is not the super-user, and uid does not match the real or effective user ID of the calling process.

CONFORMING TO
POSIX, System V

SEE ALSO
getuid(2), setreuid(2)