The setregid() function is used to set the real and effective group IDs of the calling process. If rgid is -1, the real group ID is not changed; if egid is -1, the effective group ID is not changed. The real and effective group IDs may be set to different
values in the same call.
If the effective user ID of the calling process is super-user, the real group ID and the effective group ID can be set to any legal value.
If the effective user ID of the calling process is not super-user, either the real group ID can be set to the saved set-group-ID from execve(2), or the effective group ID can either be set to the
saved set-group-ID or the real group ID.
In either case, if the real group ID is being changed (that is, if rgid is not -1), or the effective group ID
is being changed to a value not equal to the real group ID, the saved set-group-ID is set equal to the new effective group ID.
|