setreuid(3C) setreuid(3C)
NAME
setreuid - set real and effective user IDs
SYNOPSIS
#include <unistd.h>
int setreuid(uidt ruid, uidt euid);
DESCRIPTION
setreuid() is used to set the real and effective user IDs of the cal-
ling process. If ruid is -1, the real user ID is not changed; if euid
is -1, the effective user ID is not changed. The real and effective
user IDs may be set to different values in the same call.
If the effective user ID of the calling process is super-user, the
real user ID and the effective user ID can be set to any legal value.
If the effective user ID of the calling process is not super-user,
either the real user ID can be set to the effective user ID, or the
effective user ID can either be set to the saved set-user ID from
execv or the real user ID.
Note: If a set-UID process sets its effective user ID to its real user
ID, it can still set its effective user ID back to the saved set-user
ID.
In either case, if the real user ID is being changed (that is, if ruid
is not -1), or the effective user ID is being changed to a value not
equal to the real user ID, the saved set-user ID is set equal to the
new effective user ID.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
ERRORS
The following error code descriptions are function-specific. You will
find a general description in introprm2(2) or in errno(5).
setreuid fails and neither of the user IDs is changed.
EINVAL The value of the ruid or euid argument is invalid or out-
of-range.
EPERM The calling process' effective user ID is not the super-user
and a change other than changing the real user ID to the
effective user ID, or changing the effective user ID to the
real user ID or the saved set-user ID, was specified.
SEE ALSO
exec(2), getuid(2), setuid(2), setregid(3C), unistd(4).
Page 1 Reliant UNIX 5.44 Printed 11/98