setreuid(3C)


setreuid -- set real and effective user IDs

Synopsis

   #include <unistd.h>
   

int setreuid(uid_t ruid, uid_t euid);

Description

setreuid is used to set the real and effective user IDs of the calling 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 calling process has the P_SETUID privilege, the effective user ID can be set to any legal value, and the real user ID can be set to the same value as the effective user ID.

If the calling process does not have the P_SETUID privilege, the effective user ID can be set to either the saved set-user ID, or the effective 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

setreuid will fail and neither of the user IDs will be changed if:

EINVAL
The value of ruid or euid is invalid or out of range.

EPERM
The calling process does not have the P_SETUID privilege, 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.

Compatibility

If a user application making this call was compiled on SCO OpenServer, then the P_SETUID privilege is not required.

References

exec(2), getuid(2), setregid(3C), setuid(2)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004