


SETREGID(2)               SYSTEM CALLS                SETREGID(2)



NAME
     setregid - set real and effective group IDs

SYNOPSIS
     int setregid(rgid, egid)
     int rgid, egid;

DESCRIPTION
     setregid() is used to set the real and effective  group  IDs
     of  the calling process.  If _r_g_i_d is -1, the real GID is not
     changed; if _e_g_i_d 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
     legal value.

     If the effective user ID  of  the  calling  process  is  not
     super-user, either the real GID can be set to the saved set-
     GID from execve(2V), or the effective GID can either be  set
     to  the saved setGID or the real GID. Note: if a setGID pro-
     cess sets its effective GID to its real GID,  it  can  still
     set its effective GID back to the saved setGID.

     In either case, if the real GID is being changed  (that  is,
     if _r_g_i_d is not -1), or the effective GID is being changed to
     a value not equal to the real GID, the saved setGID  is  set
     equal to the new effective GID.

RETURN VALUES
     setregid() returns:

     0    on success.

     -1   on failure and sets errno to indicate the error.

ERRORS
     setregid() will fail and neither of the group  IDs  will  be
     changed if:

     EINVAL         The value of _r_g_i_d or _e_g_i_d is less than  0  or
                    greater    than    USHRT_MAX    (defined   in
                    <sys/limits.h>).

     EPERM          The calling process' 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.





Sun Release 4.1   Last change: 21 January 1990                  1






SETREGID(2)               SYSTEM CALLS                SETREGID(2)



SEE ALSO
     execve(2V), getgid(2V), setreuid(2), setuid(3V)





















































Sun Release 4.1   Last change: 21 January 1990                  2



