|
|
#include <unistd.h>int setuid(uid_t uid);
int setgid(gid_t gid);
int seteuid(uid_t euid);
int setegid(gid_t egid);
int setreuid(uid_t ruid, uid_t euid);
int setregid(gid_t rgid, uid_t egid);
setgid- set group IDs
seteuid- set effective user IDs
setegid- set effective group IDs
setreuid- set real and effective user IDs
setregid- set real and effective group IDs
The setuid function is used to set the real user ID and effective user ID of the calling process to the same value. If the effective user ID of the calling process is root, the real user ID and effective user ID are set to uid. If the effective user ID of the calling process is not root, but its real user ID is equal to uid, the effective user ID is set to uid. If the effective user ID of the calling process is not root, but the saved set-user ID from exec(S-osr5) is equal to uid, the effective user ID is set to uid, except when the saved set-user ID from exec is root.
The setgid function precisely parallels the setuid function except that it sets group IDs rather than user IDs.
The seteuid and setegid functions precisely parallel setuid and setgid respectively, except that they set only the effective user and group IDs.
The setreuid function 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 effective user ID of the calling process is root, 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 root, 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 execve(S-osr5) 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-user ID.
If the real user ID is changed (ruid is not -1), the saved set-user ID is changed to that same value.
The setregid function precisely parallels setreuid, except that it sets the real and effective group IDs instead of user IDs.
AT&T SVID Issue 2
;
X/Open Portability Guide, Issue 3, 1989
;
X/Open Portability Guide Issue 4, Version 2 (Spec-1170)
;
IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C Language] (ISO/IEC 9945-1)
;
and
NIST FIPS 151-1
.