setreuid(2)
Name
setreuid − set real and effective user ID’s
Syntax
setreuid(ruid, euid)
intruid, euid;
Description
The real and effective user ID’s of the current process are set according to the arguments. If ruid or euid is −1, the current uid is filled in by the system.
Return Value
Upon successful completion, a value of zero (0) is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
Environment
BSD
If the process is superuser, or ruid and euid matches with the real user ID, the effective user ID, or the saved set-user-id (as described in execve() ), then the real, effective, and the saved set-user-id are set to ruid, euid, and euid, respectively.
POSIX
SYSTEM-FIVE
When your program is compiled in the POSIX or SYSTEM-FIVE mode, if both arguments to setreuid are −1, the system call returns a value of −1 and errno is set to [EINVAL].
The following semantics apply when using the setreuid function:
If the process is the superuser, the real, effective, and saved set-user-id (as described in execve() ) are set to ruid, euid, and euid, respectively.
If the process is not the superuser, but the ruid and euid matches with the real user ID, the effective user ID (only in the SYSTEM-FIVE and BSD environments), or the saved set-user-id, then the effective ID is set to euid. The real user ID and the saved set-user-id are left unchanged.
Diagnostics
[EPERM] The current process is not the superuser and the euid and ruid specified does not match with the real user ID, the effective user ID (only in SYSTEM-FIVE and BSD environment), or the saved set-user-id.