SETUID(S) UNIX System V SETUID(S)
Name
setuid, setgid - set user and group IDs
Syntax
int setuid (uid)
int uid;
int setgid (gid)
int gid;
Description
The setuid (setgid) system call is used to set the real user
(group) ID and effective user (group) ID of the calling
process.
If the effective user ID of the calling process is super-
user, the real user (group) ID and effective user (group) ID
are set to uid (gid).
If the effective user ID of the calling process is not
super-user, but its real user (group) ID is equal to uid
(gid), the effective user (group) ID is set to uid (gid).
If the effective user ID of the calling process is not
super-user, but the saved set-user (group) ID from exec(S)
is equal to uid (gid), the effective user (group) ID is set
to uid (gid).
The setuid (setgid) system call will fail if the real user
(group) ID of the calling process is not equal to uid (gid)
and its effective user ID is not super-user. [EPERM]
The uid (gid) is out of range. [EINVAL]
See Also
getuid(S), intro(S)
Diagnostics
Upon successful completion, a value of 0 is returned.
Otherwise, a value of -1 is returned, and errno is set to
indicate the error.
Standards Conformance
setgid and setuid are conformant with:
AT&T SVID Issue 2, Select Code 307-127;
The X/Open Portability Guide II of January 1987;
IEEE POSIX Std 1003.1-1988 with C Standard Language-
Dependent System Support;
and NIST FIPS 151-1.
(printed 6/20/89)