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