Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

setregid - set real and effective group IDs

&pagelevel(4)&pagelevel

Syntax

#include <unistd.h>

int setregid(gid_t rgid, grid_t egid); 

Description

setregid() is used to set the real and the effective group IDs of the calling process. If rgid is -1, the real group ID (GID) is not changed; if egid is -1, the effective GID is not changed. The real and effective GIDs can be set to different values in the same call.

If the effective user ID of the calling process matches the superuser, the real GID and the effective GID can be set to any permissible value.

If the effective user ID of the calling process does not match the superuser, either the real GID can be set to the saved “set-GID“ from execv(), or the effective GID can be set to either the saved “set-GID“ or the real GID.

If a process for setting the GID sets its effective GID to its real GID, it can still reset its effective GID to the saved “set-GID“.

Both when the real GID is changed (i.e. if rgid is not -1) and when the effective GID is changed into a value that does not match the real GID, the saved “set-GID“ is set to the same as the new effective GID.

If the current value of the real GID is changed, the old value from the group access list is deleted (see getgroups()), if it is entered in the list, and the new value is added to the group access list if it does not already exist and as long as this does not cause the number of groups in this NGROUPS list to be exceeded, as defined in the /usr/include/sys/param.h file.

Return val.

0

-1

if executed successfully

if an error occurs. errno is set to indicate the error

Errors

setregid() will fail if:

 

EINVAL

The value of rgid or egid is invalid or outside the permitted value range.

 

EPERM

The effective user ID of the calling process does not match the superuser, and a different modification was specified, i.e. something other than changing the real GID into the saved “set-GID“ or the effective GID into the real or saved GID.

See also

exec(), getuid(), setuid(), setreuid(), unistd.h.