1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified Thu Oct 31 12:04:29 1996 by Eric S. Raymond <esr@thyrsus.com>
26 .\" Modified, 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\" Added notes on capability requirements
28 .\" 2008-05-03, mtk, expanded and rewrote parts of DESCRIPTION and RETURN
29 .\" VALUE, made style of page more consistent with man-pages style.
31 .TH GETGROUPS 2 2008-06-03 "Linux" "Linux Programmer's Manual"
33 getgroups, setgroups \- get/set list of supplementary group IDs
35 .B #include <sys/types.h>
37 .B #include <unistd.h>
39 .BI "int getgroups(int " size ", gid_t " list []);
43 .BI "int setgroups(size_t " size ", const gid_t *" list );
46 Feature Test Macro Requirements for glibc (see
47 .BR feature_test_macros (7)):
55 returns the supplementary group IDs of the calling process in
59 should be set to the maximum number of items that can be stored in the
62 If the calling process is a member of more than
64 supplementary groups, then an error results.
65 It is unspecified whether the effective group ID of the calling process
66 is included in the returned list.
67 (Thus, an application should also call
69 and add or remove the resulting value.)
75 is not modified, but the total number of supplementary group IDs for the
77 This allows the caller to determine the size of a dynamically allocated
79 to be used in a further call to
83 sets the supplementary group IDs for the calling process.
84 Appropriate privileges (Linux: the
86 capability) are required.
89 argument specifies the number of supplementary group IDs
90 in the buffer pointed to by
95 returns the number of supplementary group IDs.
96 On error, \-1 is returned, and
103 On error, \-1 is returned, and
105 is set appropriately.
110 has an invalid address.
113 can additionally fail with the following error:
117 is less than the number of supplementary group IDs, but is not zero.
120 can additionally fail with the following errors:
126 (32 before Linux 2.6.4; 65536 since Linux 2.6.4).
132 The calling process has insufficient privilege.
137 function is in POSIX.1-2001.
140 requires privilege, it is not covered by POSIX.1-2001.
142 A process can have up to
144 supplementary group IDs
145 in addition to the effective group ID.
146 The set of supplementary group IDs
147 is inherited from the parent process, and preserved across an
150 The maximum number of supplementary group IDs can be found using
155 ngroups_max = sysconf(_SC_NGROUPS_MAX);
158 The maximum return value of
160 cannot be larger than one more than this value.
164 .BR getgrouplist (3),
166 .BR capabilities (7),