1SETGID(2)                  Linux Programmer's Manual                 SETGID(2)
2
3
4

NAME

6       setgid - set group identity
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <unistd.h>
11
12       int setgid(gid_t gid);
13

DESCRIPTION

15       setgid()  sets  the  effective group ID of the calling process.  If the
16       caller is the superuser, the real GID and saved set-group-ID  are  also
17       set.
18
19       Under  Linux,  setgid()  is implemented like the POSIX version with the
20       _POSIX_SAVED_IDS feature.  This allows a set-group-ID program  that  is
21       not  set-user-ID-root  to drop all of its group privileges, do some un-
22       privileged work, and then reengage the original effective group ID in a
23       secure manner.
24

RETURN VALUE

26       On  success,  zero is returned.  On error, -1 is returned, and errno is
27       set appropriately.
28

ERRORS

30       EPERM  The calling  process  is  not  privileged  (does  not  have  the
31              CAP_SETGID capability), and gid does not match the real group ID
32              or saved set-group-ID of the calling process.
33

CONFORMING TO

35       SVr4, POSIX.1-2001.
36

NOTES

38       The original Linux setgid() system call  supported  only  16-bit  group
39       IDs.   Subsequently,  Linux 2.4 added setgid32() supporting 32-bit IDs.
40       The glibc setgid() wrapper function transparently deals with the varia‐
41       tion across kernel versions.
42

SEE ALSO

44       getgid(2), setegid(2), setregid(2), capabilities(7), credentials(7)
45

COLOPHON

47       This  page  is  part of release 3.53 of the Linux man-pages project.  A
48       description of the project, and information about reporting  bugs,  can
49       be found at http://www.kernel.org/doc/man-pages/.
50
51
52
53Linux                             2010-11-22                         SETGID(2)
Impressum