setregid(3C)
setregid --
set real and effective group IDs
Synopsis
#include <unistd.h>
int setregid(gid_t rgid, gid_t egid);
Description
setregid
is used to set the real and effective group
IDs
of the calling process.
If
rgid
is -1, the real
GID
is not changed; if
egid
is -1, the effective
GID
is not changed.
The real and effective
GIDs
may be set to different values in the same call.
If the effective user
ID
of the calling process is super-user,
the real
GID
and the effective
GID
can be set to any valid value.
If the effective user
ID
of the calling process is not super-user,
either the real
GID
can be set to the saved setGID
from
execv,
or the effective
GID
can either be set to the saved setGID
or the real
GID.
Note: if a setGID process sets its effective
GID
to its real
GID,
it can still set its effective
GID
back to the saved setGID.
<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
setregid
will fail and neither of the group
IDs
will be changed if:
- EINVAL
-
The value of rgid or egid is invalid or out of range.
- EPERM
-
The calling process's effective
UID
is not the super-user and a change
other than changing the real
GID
to the saved setGID,
or changing the effective
GID
to the real
GID
or the saved
GID,
was specified.
References
exec(2),
getuid(2),
setreuid(3C),
setuid(2)
30 January 1998
© 1998 The Santa Cruz Operation, Inc. All rights reserved.