| Skip Navigation Links | |
| Exit Print View | |
![]() | man pages section 2: System Calls Oracle Solaris 11 Information Library |
- set real and effective user IDs
#include <unistd.h>intsetreuid(uid_truid,uid_teuid);
Thesetreuid() function is used to set the real and effective user IDsof the calling process. Ifruid is -1, the real user IDis not changed; ifeuid is -1, the effective user ID isnot changed. The real and effective user IDs may be set todifferent values in the same call.
If the {PRIV_PROC_SETID} privilege is asserted in the effective set of thecalling process, the real user ID and the effective user ID canbe set to any legal value.
If the {PRIV_PROC_SETID} privilege is not asserted in the effective set ofthe calling process, either the real user ID can be set tothe effective user ID, or the effective user ID can either beset to the saved set-user ID fromexecve() (seeexec(2)) or the realuser ID.
In either case, if the real user ID is being changed (thatis, ifruid is not-1), or the effective user IDis being changed to a value not equal to the real userID, the saved set-user ID is set equal to the new effectiveuser ID.
All privileges are required to change to uid 0.
Upon successful completion, 0 is returned. Otherwise, -1 is returned,errno isset to indicate the error, and neither of the user IDs willbe changed.
Thesetreuid() function will fail if:
The value ofruid oreuid is less than0 or greater thanUID_MAX (defined in <limits.h>).
The {PRIV_PROC_SETID} privilege is not asserted in the effective set of the calling processes and a change was specified 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. Seeprivileges(5) for additional restrictions which apply when changing to UID 0.
If a set-user-ID process sets its effective user ID to its realuser ID, it can still set its effective user ID back tothe saved set-user ID.
Seeattributes(5) for descriptions of the following attributes:
|
exec(2),getuid(2),setregid(2),setuid(2),attributes(5),privileges(5),standards(5)
Copyright © 2011, Oracle and/or its affiliates. All rights reserved.Legal Notices | ![]() ![]() |