1getgroups(2) System Calls getgroups(2)
2
3
4
6 getgroups, setgroups - get or set supplementary group access list IDs
7
9 #include <unistd.h>
10
11 int getgroups(int gidsetsize, gid_t *grouplist);
12
13
14 int setgroups(int ngroups, const gid_t *grouplist);
15
16
18 The getgroups() function gets the current supplemental group access
19 list of the calling process and stores the result in the array of group
20 IDs specified by grouplist. This array has gidsetsize entries and must
21 be large enough to contain the entire list. This list cannot be larger
22 than NGROUPS_UMAX. If gidsetsize equals 0, getgroups() will return the
23 number of groups to which the calling process belongs without modifying
24 the array pointed to by grouplist.
25
26
27 The setgroups() function sets the supplementary group access list of
28 the calling process from the array of group IDs specified by grouplist.
29 The number of entries is specified by ngroups and can not be greater
30 than NGROUPS_MAX.
31
33 Upon successful completion, getgroups() returns the number of supple‐
34 mentary group IDs set for the calling process and setgroups() returns
35 0. Otherwise, −1 is returned and errno is set to indicate the error.
36
38 The getgroups() and setgroups() functions will fail if:
39
40 EFAULT A referenced part of the array pointed to by grouplist is an
41 illegal address.
42
43
44
45 The getgroups() function will fail if:
46
47 EINVAL The value of gidsetsize is non-zero and less than the number
48 of supplementary group IDs set for the calling process.
49
50
51
52 The setgroups() function will fail if:
53
54 EINVAL The value of ngroups is greater than {NGROUPS_MAX}.
55
56
57 EPERM The {PRIV_PROC_SETID} privilege is not asserted in the effec‐
58 tive set of the calling process.
59
60
62 Use of the setgroups() function requires the {PRIV_PROC_SETID} privi‐
63 lege.
64
66 See attributes(5) for descriptions of the following attributes:
67
68
69
70
71 ┌─────────────────────────────┬─────────────────────────────┐
72 │ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
73 ├─────────────────────────────┼─────────────────────────────┤
74 │Interface Stability │getgroups() is Standard. │
75 ├─────────────────────────────┼─────────────────────────────┤
76 │MT-Level │Async-Signal-Safe │
77 └─────────────────────────────┴─────────────────────────────┘
78
80 groups(1), chown(2), getuid(2), setuid(2), getgrnam(3C), init‐
81 groups(3C), attributes(5), privileges(5), standards(5)
82
83
84
85SunOS 5.11 8 Sep 2006 getgroups(2)