]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu) |
40593072 | 2 | .\" and Copyright (C) 2008, 2010, 2015, Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 3 | .\" |
93015253 | 4 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
5 | .\" Permission is granted to make and distribute verbatim copies of this |
6 | .\" manual provided the copyright notice and this permission notice are | |
7 | .\" preserved on all copies. | |
8 | .\" | |
9 | .\" Permission is granted to copy and distribute modified versions of this | |
10 | .\" manual under the conditions for verbatim copying, provided that the | |
11 | .\" entire resulting derived work is distributed under the terms of a | |
12 | .\" permission notice identical to this one. | |
c13182ef | 13 | .\" |
fea681da MK |
14 | .\" Since the Linux kernel and libraries are constantly changing, this |
15 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
16 | .\" responsibility for errors or omissions, or for damages resulting from | |
17 | .\" the use of the information contained herein. The author(s) may not | |
18 | .\" have taken the same level of care in the production of this manual, | |
19 | .\" which is licensed free of charge, as they might when working | |
20 | .\" professionally. | |
c13182ef | 21 | .\" |
fea681da MK |
22 | .\" Formatted or processed versions of this manual, if unaccompanied by |
23 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 24 | .\" %%%LICENSE_END |
fea681da MK |
25 | .\" |
26 | .\" Modified Thu Oct 31 12:04:29 1996 by Eric S. Raymond <esr@thyrsus.com> | |
c11b1abf | 27 | .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 28 | .\" Added notes on capability requirements |
f95ef6d5 MK |
29 | .\" 2008-05-03, mtk, expanded and rewrote parts of DESCRIPTION and RETURN |
30 | .\" VALUE, made style of page more consistent with man-pages style. | |
fea681da | 31 | .\" |
9ba01802 | 32 | .TH GETGROUPS 2 2019-03-06 "Linux" "Linux Programmer's Manual" |
fea681da MK |
33 | .SH NAME |
34 | getgroups, setgroups \- get/set list of supplementary group IDs | |
35 | .SH SYNOPSIS | |
36 | .B #include <sys/types.h> | |
37 | .br | |
38 | .B #include <unistd.h> | |
68e4db0a | 39 | .PP |
fea681da | 40 | .BI "int getgroups(int " size ", gid_t " list []); |
f90f031e | 41 | |
fea681da | 42 | .B #include <grp.h> |
68e4db0a | 43 | .PP |
fea681da | 44 | .BI "int setgroups(size_t " size ", const gid_t *" list ); |
68e4db0a | 45 | .PP |
cc4615cc MK |
46 | .in -4n |
47 | Feature Test Macro Requirements for glibc (see | |
48 | .BR feature_test_macros (7)): | |
49 | .in | |
68e4db0a | 50 | .PP |
cc4615cc | 51 | .BR setgroups (): |
51c612fb MK |
52 | Since glibc 2.19: |
53 | _DEFAULT_SOURCE | |
54 | Glibc 2.19 and earlier: | |
c1bda2c8 | 55 | _BSD_SOURCE |
fea681da | 56 | .SH DESCRIPTION |
f95ef6d5 | 57 | .PP |
e511ffb6 | 58 | .BR getgroups () |
f95ef6d5 MK |
59 | returns the supplementary group IDs of the calling process in |
60 | .IR list . | |
61 | The argument | |
fea681da | 62 | .I size |
f95ef6d5 MK |
63 | should be set to the maximum number of items that can be stored in the |
64 | buffer pointed to by | |
fea681da | 65 | .IR list . |
f95ef6d5 MK |
66 | If the calling process is a member of more than |
67 | .I size | |
68 | supplementary groups, then an error results. | |
fea681da | 69 | It is unspecified whether the effective group ID of the calling process |
c13182ef MK |
70 | is included in the returned list. |
71 | (Thus, an application should also call | |
fea681da MK |
72 | .BR getegid (2) |
73 | and add or remove the resulting value.) | |
efeece04 | 74 | .PP |
fea681da MK |
75 | If |
76 | .I size | |
77 | is zero, | |
78 | .I list | |
79 | is not modified, but the total number of supplementary group IDs for the | |
80 | process is returned. | |
f95ef6d5 MK |
81 | This allows the caller to determine the size of a dynamically allocated |
82 | .I list | |
83 | to be used in a further call to | |
84 | .BR getgroups (). | |
85 | .PP | |
e511ffb6 | 86 | .BR setgroups () |
f95ef6d5 | 87 | sets the supplementary group IDs for the calling process. |
e31d1beb MK |
88 | Appropriate privileges are required (see the description of the |
89 | .BR EPERM | |
90 | error, below). | |
f95ef6d5 MK |
91 | The |
92 | .I size | |
93 | argument specifies the number of supplementary group IDs | |
94 | in the buffer pointed to by | |
95 | .IR list . | |
44645ac4 MK |
96 | A process can drop all of its supplementary groups with the call: |
97 | .PP | |
98 | .in +4n | |
99 | .EX | |
100 | setgroups(0, NULL); | |
101 | .EE | |
102 | .in | |
47297adb | 103 | .SH RETURN VALUE |
f95ef6d5 | 104 | On success, |
e511ffb6 | 105 | .BR getgroups () |