SETUID(2-POSIX) RISC/os Reference Manual SETUID(2-POSIX)
NAME
setuid, setgid - set user and group IDs
SYNOPSIS
#include <sys/types.h>
int setuid (uid)
uidt uid;
int setgid (gid)
gidt gid;
DESCRIPTION
setuid (setgid) 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, effective user (group) ID,
and saved set-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(2)
is equal to uid (gid), the effective user (group) ID is set
to uid (gid).
setuid (setgid) 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.
RETURN VALUES
Upon successful completion, a value of 0 is returned. Oth-
erwise, a value of -1 is returned and errno is set to indi-
cate the error.
ERRORS
If the following condition occurs, setuid and setgid return
-1 and set errno to the corresponding value:
[EPERM] The effective user ID is not the
superuser, and uid (gid) does not match
the read uid (gid) or the saved set-user
(group) ID.
SEE ALSO
getuid(2), intro(2).
Printed 1/15/91 Page 1