![]() |
![]() |
![]() |
Set real and effect user IDs
#include <unistd.h> int setreuid( uit_t ruid, uid_t euid );
libc
The setreuid() function sets the real and effective user IDs of the calling process. If ruid or euid is -1, the corresponding real or effective user ID isn't changed.
If the effective user ID of the calling process is the superuser, 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 isn't the superuser, either the real user ID can be set to the effective user ID, or the effective user ID can be set to the saved set-user ID or the real user ID.
![]() |
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-UID. |
In either case, if the real user ID is being changed (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.
The "superuser" is defined as any process with an effective user ID of 0, or an effective user ID of root.
Zero on success, or -1 if an error occurs (errno is set).
Or
The calling process isn't the superuser, and an attempt was made to change the real user ID to a value other than the effective user ID.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |
execve(), getuid(), setregid(), setuid()
![]() |
![]() |
![]() |