Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

setreuid - set real and effective user IDs

&pagelevel(4)&pagelevel

Syntax

#include <unistd.h>

int setreuid(uid_t ruid, uid_t euid); 

Description

setreuid() is used to set the real and the 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 can be set to different values in the same call.

If the effective user ID of the calling process matches the superuser, the real user ID and the effective user ID can be set to any permissible value.

If the effective user ID of the calling process does not match that of the superuser, either the real user ID can be set to the effective user ID, or the effective user ID can be set to either the saved “set-user-ID“ from execv or the real user ID.

If a process for setting the user ID (UID) sets its effective user ID to its real user ID, it can still reset its effective user ID to the saved “set-user-ID“.

Both when the real user ID is changed (i.e. if ruid is not -1) and when the effective user ID is changed to a value that does not match the real user ID, the saved “set-user-ID“ is set to the same as the new effective user ID.

Return val.

0

-1

if executed successfully

if an error occurs. errno is set to indicate the error

Errors

setreuid() will fail if:

 

EINVAL

The value of the ruid or euid argument is invalid or outside the permitted value range.

 

EPERM

The effective user ID of the calling process does not match that of the superuser, and a different modification was specified, i.e. something other than changing the real user ID to the effective user ID or the effective user ID into the real or saved “set-user-ID“.

See also

getuid(), setuid(), unistd.h.