SETUID(2)
NAME
setuid, setgid − set user and group IDs
SYNOPSIS
int setuid (uid)
int uid;
int setgid (gid)
int gid;
HP-UX COMPATIBILITY
Level: HP-UX/RUN ONLY
Origin: System V
DESCRIPTION
Setuid sets the real, effective, and/or saved user ID of the calling process ("ruid", "euid", and "suid", respectively).
If uid is not equal to the super-user’s ID, and is equal to ruid, then setuid sets euid to uid.
Otherwise, if uid is not equal to the super-user’s ID, and is equal to euid, then setuid sets ruid to uid.
Otherwise, if uid is not equal to the super-user’s ID, and is equal to suid, then setuid sets euid to uid.
Otherwise, if euid is equal to the super-user’s user ID then setuid sets ruid, euid, and suid to uid.
Setgid sets the real, effective, and/or saved group ID of the calling process ("rgid", "egid", and "sgid", respectively).
If gid is equal to rgid then setgid sets egid to gid.
Otherwise, if gid is equal to egid then setgid sets rgid to gid.
Otherwise, if gid is equal to sgid then setgid sets egid to gid.
Otherwise, if euid is equal to the super-user’s user ID then setgid sets rgid, egid, and sgid to gid.
Setuid and setgid will fail and return -1 if:
[EPERM] None of the conditions above are met.
[EINVAL] Uid (gid) is not a valid user (group) ID.
RETURN VALUE
Upon successful completion, a value of 0 is returned. Otherwise, a value of −1 is returned and errno is set to indicate the error.
HARDWARE DEPENDENCIES
The Integral PC does not currently support saved user IDs or saved group IDs.
SEE ALSO
exec(2), getuid(2), setgroups(2).
Hewlett-Packard — last mod. May 11, 2021