1 .\" Copyright (c) 1989, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
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 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" From: @(#)getgrent.3 8.2 (Berkeley) 4/19/94
29 .\" $FreeBSD: src/lib/libc/gen/getgrent.3,v 1.28 2007/01/09 00:27:53 imp Exp $
31 .\" @APPLE_LICENSE_HEADER_START@
33 .\" Portions Copyright (c) 2003-2013 Apple Inc. All Rights Reserved.
35 .\" This file contains Original Code and/or Modifications of Original Code
36 .\" as defined in and that are subject to the Apple Public Source License
37 .\" Version 2.0 (the 'License'). You may not use this file except in
38 .\" compliance with the License. Please obtain a copy of the License at
39 .\" http://www.opensource.apple.com/apsl/ and read it before using this
42 .\" The Original Code and all software distributed under the License are
43 .\" distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
44 .\" EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
45 .\" INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
46 .\" FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
47 .\" Please see the License for the specific language governing rights and
48 .\" limitations under the License.
50 .\" @APPLE_LICENSE_HEADER_END@
67 .Nd group database operations
69 Standard system libraries.
76 .\".Fn getgrent_r "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
78 .Fn getgrnam "const char *name"
80 .Fn getgrnam_r "const char *name" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
82 .Fn getgrgid "gid_t gid"
84 .Fn getgrgid_r "gid_t gid" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
86 .Fn getgruuid "uuid_t uuid"
88 .Fn getgruuid_r "uuid_t uuid" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
90 .Fn setgroupent "int stayopen"
96 .\"These functions operate on the group database file
97 These functions obtain information from
98 .Xr opendirectoryd 8 ,
104 Each line of the database is defined by the structure
109 .Bd -literal -offset indent
111 char *gr_name; /* group name */
112 char *gr_passwd; /* group password */
113 gid_t gr_gid; /* group id */
114 char **gr_mem; /* group members */
123 search the group database for the given group name pointed to by
125 the group id given by
129 respectively, returning the first one encountered.
131 names, group gids, or uuids may result in undefined behavior.
133 Note that the groups file
135 does not contain group UUIDs.
136 The UUID for a group may be found using
137 .Fn mbr_gid_to_uuid .
139 On OS X, these routines are thread-safe and return a pointer to a
140 thread-specific data structure. The contents of this data
141 structure are automatically released by subsequent calls to
142 any of these routines on the same thread, or when the thread exits.
143 These routines are therefore unsuitable for use in libraries or frameworks,
144 from where they may overwrite the per-thread data that the calling
145 application expects to find as a result of its own calls to these
146 routines. Library and framework code should use the alternative reentrant
147 variants detailed below.
152 searches all available directory services on it's first invocation.
153 It caches the returned entries in a list
154 and returns group entries one at a time.
159 may cause a very lengthy search for group records by
161 and may result in a large number of group records being cached
162 by the calling process.
163 Use of this function is not advised.
170 are alternative versions of
176 The caller must provide storage for the results of the search in
184 When these functions are successful, the
186 argument will be filled-in, and a pointer to that argument will be
189 If an entry is not found or an error occurs,
194 These functions will open the group file for reading, if necessary.
200 to ``rewind'' to the beginning of the list of entries cached by a previous
203 The cache is not cleared.
206 parameter value is unused on OS X.
212 functions clear the cached results from a previous
221 return a pointer to a group structure on success or
223 if the entry is not found or if an error occurs.
224 If an error does occur,
227 Note that programs must explicitly set
229 to zero before calling any of these functions if they need to
230 distinguish between a non-existent entry and an error.
236 return 0 if no error occurred, or an error number to indicate failure.
237 It is not an error if a matching entry is not found.
242 and the return value is 0, no matching entry exists.)
245 returns the value 1 if successful, otherwise the value
252 have no return value.
254 .Bl -tag -width /etc/group -compact
259 The historic function
261 which allowed the specification of alternate group databases, has
262 been deprecated and is no longer available.
266 .Xr mbr_gid_to_uuid 3,
267 .Xr opendirectory 8 ,
282 function differs from that standard in that its return type is
314 appeared in Mac OS X 10.8.
324 leave their results in an internal thread-specific memory and return
325 a pointer to that object.
328 will modify the same object.