SETUID(2) — HP-UX
NAME
setuid, setgid − set user and group IDs
SYNOPSIS
int setuid (uid)
int uid;
int setgid (gid)
int gid;
DESCRIPTION
Setuid sets the real and/or effective user ID of the calling process. The real, effective, and saved user IDs are called "ruid", "euid", and "suid", respectively. The super user’s user ID is zero.
If uid and suid are both zero then setuid sets ruid and euid to zero.
Otherwise, if uid is not zero and is equal to ruid then setuid sets euid to ruid.
Otherwise, if uid is not zero and is equal to euid then setuid sets ruid to euid.
Otherwise, if uid is not zero and is equal to suid then setuid sets euid to suid.
Otherwise, if euid is zero then setuid sets ruid and euid 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 rgid.
Otherwise, if gid is equal to egid then setgid sets rgid to egid.
Otherwise, if gid is equal to sgid then setgid sets egid to sgid.
Otherwise, if euid is zero then setgid sets rgid, egid, and sgid to gid.
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.
ERRORS
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.
SEE ALSO
Hewlett-Packard Company — May 11, 2021