2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 19:29:54 1993 by Rik Faith (faith@cs.unc.edu)
11 .TH getgrent 3 (date) "Linux man-pages (unreleased)"
13 getgrent, setgrent, endgrent \- get group file entry
16 .RI ( libc ", " \-lc )
19 .B #include <sys/types.h>
22 .B struct group *getgrent(void);
24 .B void setgrent(void);
25 .B void endgrent(void);
29 Feature Test Macro Requirements for glibc (see
30 .BR feature_test_macros (7)):
36 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
37 || /* glibc >= 2.19: */ _DEFAULT_SOURCE
38 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
45 _XOPEN_SOURCE >= 500 || _DEFAULT_SOURCE
46 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
47 glibc 2.21 and earlier
49 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
50 || /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
51 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
56 function returns a pointer to a structure containing
57 the broken-out fields of a record in the group database
58 (e.g., the local group file
64 it returns the first entry; thereafter, it returns successive entries.
68 function rewinds to the beginning
69 of the group database, to allow repeated scans.
73 function is used to close the group database
74 after all processing has been performed.
76 The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
81 char *gr_name; /* group name */
82 char *gr_passwd; /* group password */
83 gid_t gr_gid; /* group ID */
84 char **gr_mem; /* NULL\-terminated array of pointers
85 to names of group members */
90 For more information about the fields of this structure, see
95 function returns a pointer to a
98 or NULL if there are no more entries or an error occurs.
103 If one wants to check
105 after the call, it should be set to zero before the call.
107 The return value may point to a static area, and may be overwritten
108 by subsequent calls to
113 (Do not pass the returned pointer to
118 The service was temporarily unavailable; try again later.
119 For NSS backends in glibc
120 this indicates a temporary error talking to the backend.
121 The error may correct itself, retrying later is suggested.
124 A signal was caught; see
131 The per-process limit on the number of open file descriptors has been reached.
134 The system-wide limit on the total number of open files has been reached.
138 A necessary input file cannot be found.
139 For NSS backends in glibc
140 this indicates the backend is not correctly configured.
144 Insufficient memory to allocate
149 Insufficient buffer space supplied.
153 local group database file
155 For an explanation of the terms used in this section, see
161 Interface Attribute Value
180 MT-Unsafe race:grent locale
189 signifies that if any of the functions
194 are used in parallel in different threads of a program,
195 then data races could occur.
199 POSIX.1-2001, SVr4, 4.3BSD.
205 .BR getgrouplist (3),