setreuid(2) System Calls Manual setreuid(2)NAME
setreuid - Sets real and effective user IDs
SYNOPSIS
#include <unistd.h> setreuid( uid_t ruid, uid_t euid );
STANDARDS
Interfaces documented on this reference page conform to industry standards as follows:
setreuid: XPG4-UNIX
Refer to the standards(5) reference page for more information about industry standards and associated tags.
PARAMETERS
Specifies the new real user ID. Specifies the new effective user ID.
DESCRIPTION
The setreuid() function sets the real and effective user IDs of the current process to the values specified by the ruid and euid parame-
ters. If ruid or euid is -1, the corresponding effective or real user ID of the current process is not changed.
Users may change the effective user ID to the real user ID; only processes with superuser privilege may make other changes. This task is
normally done by the system's authentication program (for example, login), but is not done for system daemons.
RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
ERRORS
The setreuid() function sets errno to the specified values for the following conditions: The value of the ruid or euid parameter is invalid
or out of range. The current process is not the superuser and a change other than changing the effective user ID to the real user ID was
specified.
RELATED INFORMATION
Functions: getuid(2), setgid(2), setregid(2), setruid(3)
Standards: standards(5) delim off
setreuid(2)
Check Out this Related Man Page
setreuid(2) System Calls Manual 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 Values
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 and matches with the real user ID, the effective user ID, or the saved set-user-id (as described in ), then
the real, effective, and the saved set-user-id are set to and respectively.
POSIX
SYSTEM-FIVE
When your program is compiled in the POSIX or SYSTEM-FIVE mode, if both arguments to are -1, the system call returns a value of -1 and
errno is set to [EINVAL].
The following semantics apply when using the function:
If the process is the superuser, the real, effective, and saved set-user-id (as described in ) are set to and respectively.
If the process is not the superuser, but the and 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 The real user ID and the saved set-user-id are left unchanged.
Diagnostics
[EPERM] The current process is not the superuser and the and 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.
See Alsogetuid(2), setregid(2), setuid(3)setreuid(2)