Libinfo-538.tar.gz
[apple/libinfo.git] / lookup.subproj / initgroups.3
1 .\" Copyright (c) 1983, 1991, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\"    must display the following acknowledgement:
14 .\"     This product includes software developed by the University of
15 .\"     California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\"    may be used to endorse or promote products derived from this software
18 .\"    without specific prior written permission.
19 .\"
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" SUCH DAMAGE.
31 .\"
32 .\"     @(#)initgroups.3        8.1 (Berkeley) 6/4/93
33 .\" $FreeBSD: src/lib/libc/gen/initgroups.3,v 1.10 2001/10/01 16:08:51 ru Exp $
34 .\"
35 .\" @APPLE_LICENSE_HEADER_START@
36 .\"
37 .\" Portions Copyright (c) 2003-2013 Apple Inc.  All Rights Reserved.
38 .\"
39 .\" This file contains Original Code and/or Modifications of Original Code
40 .\" as defined in and that are subject to the Apple Public Source License
41 .\" Version 2.0 (the 'License'). You may not use this file except in
42 .\" compliance with the License. Please obtain a copy of the License at
43 .\" http://www.opensource.apple.com/apsl/ and read it before using this
44 .\" file.
45 .\"
46 .\" The Original Code and all software distributed under the License are
47 .\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
48 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
49 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
50 .\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
51 .\" Please see the License for the specific language governing rights and
52 .\" limitations under the License.
53 .\"
54 .\" @APPLE_LICENSE_HEADER_END@
55 .\"
56 .Dd June 4, 1993
57 .Dt INITGROUPS 3
58 .Os
59 .Sh NAME
60 .Nm initgroups
61 .Nd initialize group access list
62 .Sh LIBRARY
63 Standard system libraries.
64 .Sh SYNOPSIS
65 .In unistd.h
66 .Ft int
67 .Fn initgroups "const char *name" "int basegid"
68 .Sh DESCRIPTION
69 The
70 .Fn initgroups
71 function calculates a group access list for the user
72 specified in
73 .Fa name .
74 This group list is then saved in the kernel credentials for the current process.
75 The
76 .Fa basegid
77 is included in the groups list.
78 Typically this value is given as
79 the default group associated with the user's account record.
80 .Pp
81 This function sets at most 16 group IDs in the process credentials.
82 This list can be retrieved using the
83 .Xr getgroups 2
84 function.
85 Note that OS X supports group membership in an unlimited number of groups.
86 The OS X kernel uses the group list stored in the process credentials only
87 as an initial cache.
88 Additional group memberships are determined by communication between the operating system and the
89 .Nm opendirectoryd
90 daemon.
91 .Pp
92 Processes should not use the group ID numbers from
93 .Xr getgroups 2
94 to determine a user's group membership.
95 The list obtained from
96 .Fn getgroups
97 may only be a partial list of a user's group membership.
98 Membership checks should use the
99 .Xr mbr_gid_to_uuid 3 ,
100 .Xr mbr_uid_to_uuid 3 ,
101 and
102 .Xr mbr_check_membership 3
103 functions.
104 .Sh RETURN VALUES
105 The
106 .Fn initgroups
107 function
108 returns 0 on success.
109 On failure, this function will return -1 and set
110 .Va errno 
111 to one of the following values:
112 .Bl -tag -width ".Bq Er EFAULT"
113 .It Bq Er EPERM
114 The caller's effictive UID is not zero.
115 .It Bq Er EINVAL
116 Internal error, an invalid array size was supplied to the kernel.
117 .It Bq Er EFAULT
118 Internal error, invalid data was supplied to the kernel.
119 .El
120 .Sh SEE ALSO
121 .Xr getgroups 2 ,
122 .Xr getgrouplist 3 ,
123 .Xr mbr_gid_to_uuid 3 ,
124 .Xr mbr_uid_to_uuid 3 ,
125 .Xr mbr_check_membership 3 .
126 .Sh HISTORY
127 The
128 .Fn initgroups
129 function appeared in
130 .Bx 4.2 .