Merge commit 'b31320a79e2054c6739b5229259dbf98f3afc547' into merges
[unleashed.git] / share / man / man2 / getgroups.2
blob4b871aa6232545fa0560b69a964f939e77effb7b
1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH GETGROUPS 2 "Sep 8, 2006"
8 .SH NAME
9 getgroups, setgroups \- get or set supplementary group access list IDs
10 .SH SYNOPSIS
11 .LP
12 .nf
13 #include <unistd.h>
15 \fBint\fR \fBgetgroups\fR(\fBint\fR \fIgidsetsize\fR, \fBgid_t *\fR\fIgrouplist\fR);
16 .fi
18 .LP
19 .nf
20 \fBint\fR \fBsetgroups\fR(\fBint\fR \fIngroups\fR, \fBconst gid_t *\fR\fIgrouplist\fR);
21 .fi
23 .SH DESCRIPTION
24 .sp
25 .LP
26 The \fBgetgroups()\fR function gets the current supplemental group access list
27 of the calling process and stores the result in the array of group IDs
28 specified by \fIgrouplist\fR. This array has \fIgidsetsize\fR entries and must
29 be large enough to contain the entire list. This list cannot be larger than
30 \fBNGROUPS_UMAX\fR. If \fIgidsetsize\fR equals 0, \fBgetgroups()\fR will return
31 the number of groups to which the calling process belongs without modifying the
32 array pointed to by \fIgrouplist\fR.
33 .sp
34 .LP
35 The \fBsetgroups()\fR function sets the supplementary group access list of the
36 calling process from the array of group IDs specified by \fIgrouplist\fR. The
37 number of entries is specified by \fIngroups\fR and can not be greater than
38 \fBNGROUPS_MAX\fR.
39 .SH RETURN VALUES
40 .sp
41 .LP
42 Upon successful completion, \fBgetgroups()\fR returns the number of
43 supplementary group IDs set for the calling process and \fBsetgroups()\fR
44 returns \fB0\fR. Otherwise, \fB\(mi1\fR is returned and \fBerrno\fR is set to
45 indicate the error.
46 .SH ERRORS
47 .sp
48 .LP
49 The \fBgetgroups()\fR and \fBsetgroups()\fR functions will fail if:
50 .sp
51 .ne 2
52 .na
53 \fB\fBEFAULT\fR\fR
54 .ad
55 .RS 10n
56 A referenced part of the array pointed to by \fIgrouplist\fR is an illegal
57 address.
58 .RE
60 .sp
61 .LP
62 The \fBgetgroups()\fR function will fail if:
63 .sp
64 .ne 2
65 .na
66 \fB\fBEINVAL\fR\fR
67 .ad
68 .RS 10n
69 The value of \fIgidsetsize\fR is non-zero and less than the number of
70 supplementary group IDs set for the calling process.
71 .RE
73 .sp
74 .LP
75 The \fBsetgroups()\fR function will fail if:
76 .sp
77 .ne 2
78 .na
79 \fB\fBEINVAL\fR\fR
80 .ad
81 .RS 10n
82 The value of \fIngroups\fR is greater than {\fBNGROUPS_MAX\fR}.
83 .RE
85 .sp
86 .ne 2
87 .na
88 \fB\fBEPERM\fR\fR
89 .ad
90 .RS 10n
91 The {\fBPRIV_PROC_SETID\fR} privilege is not asserted in the effective set of
92 the calling process.
93 .RE
95 .SH USAGE
96 .sp
97 .LP
98 Use of the \fBsetgroups()\fR function requires the {\fBPRIV_PROC_SETID\fR}
99 privilege.
100 .SH ATTRIBUTES
103 See \fBattributes\fR(5) for descriptions of the following attributes:
108 box;
109 c | c
110 l | l .
111 ATTRIBUTE TYPE  ATTRIBUTE VALUE
113 Interface Stability     \fBgetgroups()\fR is Standard.
115 MT-Level        Async-Signal-Safe
118 .SH SEE ALSO
121 \fBgroups\fR(1), \fBchown\fR(2), \fBgetuid\fR(2), \fBsetuid\fR(2),
122 \fBgetgrnam\fR(3C), \fBinitgroups\fR(3C), \fBattributes\fR(5),
123 \fBprivileges\fR(5), \fBstandards\fR(5)