SETREGID(2)

NAME
setregid - set real and effective group ID

SYNOPSIS
#include <unistd.h>

int setregid(gid_t rgid ,gid_t egid );

DESCRIPTION
The real and effective group ID's of the current process are set to the arguments. Unprivileged users may change the real group ID to the effective group ID and vice-versa; only the super-user may make other changes. Supplying a value of -1 for either the real or effective group ID forces the system to substitute the current ID in place of the -1 parameter.

NOTES FROM KERNEL SOURCE
setregid is done BSD-style, with no consideration of the saved gid, except that if you set the effective gid, it sets the saved gid too. This makes it possible for a setgid program to completely drop its privileges, which is often a useful assertion to make when you are doing a security audit over a program. The general idea is that a program which uses just setregid will be 100% compatible with BSD. A program which uses just setgid will be 100% compatible with POSIX w/ Saved ID's.

RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.

ERRORS

EPERM
    The current process is not the super-user and a change other than changing the effective group-id to the real group-id was specified.

HISTORY
The setregid function call appeared in BSD 4.2.

CONFORMING TO
BSD 4.3

SEE ALSO
getgid(2), setgid(2)