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 $
44 .Nd group database operations
52 .\".Fn getgrent_r "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
54 .Fn getgrnam "const char *name"
56 .Fn getgrnam_r "const char *name" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
58 .Fn getgrgid "gid_t gid"
60 .Fn getgrgid_r "gid_t gid" "struct group *grp" "char *buffer" "size_t bufsize" "struct group **result"
62 .Fn setgroupent "int stayopen"
68 .\"These functions operate on the group database file
69 These functions obtain information from
70 .Xr DirectoryService 8 ,
76 Each line of the database is defined by the structure
81 .Bd -literal -offset indent
83 char *gr_name; /* group name */
84 char *gr_passwd; /* group password */
85 gid_t gr_gid; /* group id */
86 char **gr_mem; /* group members */
94 search the group database for the given group name pointed to by
96 or the group id pointed to by
98 respectively, returning the first one encountered.
100 names or group gids may result in undefined behavior.
102 On Mac OS X, these routines are thread-safe and return a pointer to a
103 thread-specific data structure. The contents of this data
104 structure are automatically released by subsequent calls to
105 any of these routines on the same thread, or when the thread exits.
110 sequentially reads the group database and is intended for programs
111 that wish to step through the complete list of groups.
119 are thread-safe versions of
126 The caller must provide storage for the results of the search in
134 When these functions are successful, the
136 argument will be filled-in, and a pointer to that argument will be
139 If an entry is not found or an error occurs,
144 These functions will open the group file for reading, if necessary.
149 opens the file, or rewinds it if it is already open.
152 is non-zero, file descriptors are left open, significantly speeding
153 functions subsequent calls.
154 This functionality is unnecessary for
156 as it does not close its file descriptors by default.
158 be noted that it is dangerous for long-running programs to use this
159 functionality as the group file may be updated.
166 with an argument of zero.
171 closes any open files.
178 return a pointer to a group structure on success or
180 if the entry is not found or if an error occurs.
181 If an error does occur,
184 Note that programs must explicitly set
186 to zero before calling any of these functions if they need to
187 distinguish between a non-existent entry and an error.
194 return 0 if no error occurred, or an error number to indicate failure.
195 It is not an error if a matching entry is not found.
200 and the return value is 0, no matching entry exists.)
206 return the value 1 if successful, otherwise the value
212 have no return value.
214 .Bl -tag -width /etc/group -compact
219 The historic function
221 which allowed the specification of alternate password databases, has
222 been deprecated and is no longer available.
226 .\".Xr nsswitch.conf 5 ,
227 .Xr DirectoryService 8 ,
242 function differs from that standard in that its return type is
278 leave their results in an internal thread-specific memory and return
279 a pointer to that object.
282 will modify the same object.
291 .\"are fairly useless in a networked environment and should be
292 .\"avoided, if possible.
298 .\"make no attempt to suppress duplicate information if multiple
299 .\"sources are specified in
300 .\".Xr nsswitch.conf 5 .