setreuid
Purpose
Sets real and effective user ID.
Library
Berkeley Library (libbsd.a)
Syntax
int setreuid (ruid, uid)
int ruid, euid;
Description
The setreuid subroutine sets the real and effective user
ID of the current process according to the parameters
ruid and euid. If either of these parameters equals -1,
the current user ID is used.
Any process can change the real user ID or the effective
user ID to the other, but only a process with an effec-
tive user ID of superuser can make other kinds of
changes.
If you need the setruid or seteuid functions, they can be
constructed as:
#define seteuid(id) setreuid(-1, (id))
#define setruid(id) setreuid((id), -1)
Return Value
When the call succeeds, a value of 0 is returned. If the
setreuid subroutine fails, a value of -1 is returned and
errno is set to indicate the error.
Diagnostics
EPERM The current process does not have an effective
user ID of superuser. This process attempted
a change other than from the effective user ID
to the real user ID.
Related Information
In this book: "getuid, geteuid, getgid, getegid" and
"setuid, setgid."