]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/getgroups.2
on_exit.3: Atack variables may be out of scope when exit handler is invoked
[thirdparty/man-pages.git] / man2 / getgroups.2
CommitLineData
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
34getgroups, 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
47Feature 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
59returns the supplementary group IDs of the calling process in
60.IR list .
61The argument
fea681da 62.I size
f95ef6d5
MK
63should be set to the maximum number of items that can be stored in the
64buffer pointed to by
fea681da 65.IR list .
f95ef6d5
MK
66If the calling process is a member of more than
67.I size
68supplementary groups, then an error results.
fea681da 69It is unspecified whether the effective group ID of the calling process
c13182ef
MK
70is included in the returned list.
71(Thus, an application should also call
fea681da
MK
72.BR getegid (2)
73and add or remove the resulting value.)
efeece04 74.PP
fea681da
MK
75If
76.I size
77is zero,
78.I list
79is not modified, but the total number of supplementary group IDs for the
80process is returned.
f95ef6d5
MK
81This allows the caller to determine the size of a dynamically allocated
82.I list
83to be used in a further call to
84.BR getgroups ().
85.PP
e511ffb6 86.BR setgroups ()
f95ef6d5 87sets the supplementary group IDs for the calling process.
e31d1beb
MK
88Appropriate privileges are required (see the description of the
89.BR EPERM
90error, below).
f95ef6d5
MK
91The
92.I size
93argument specifies the number of supplementary group IDs
94in the buffer pointed to by
95.IR list .
44645ac4
MK
96A process can drop all of its supplementary groups with the call:
97.PP
98.in +4n
99.EX
100setgroups(0, NULL);
101.EE
102.in
47297adb 103.SH RETURN VALUE
f95ef6d5 104On success,
e511ffb6 105.BR getgroups ()