OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / getgrent.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sat Jul 24 19:29:54 1993 by Rik Faith (faith@cs.unc.edu)
30 .TH GETGRENT 3  2014-10-02 "" "Linux Programmer's Manual"
31 .SH NAME
32 getgrent, setgrent, endgrent \- get group file entry
33 .SH SYNOPSIS
34 .nf
35 .B #include <sys/types.h>
36 .B #include <grp.h>
37 .sp
38 .B struct group *getgrent(void);
39 .sp
40 .B void setgrent(void);
41 .sp
42 .B void endgrent(void);
43 .fi
44 .sp
45 .in -4n
46 Feature Test Macro Requirements for glibc (see
47 .BR feature_test_macros (7)):
48 .in
49 .sp
50 .PD 0
51 .ad l
52 .BR setgrent ():
53 .RS 4
54 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
55 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED ||
56 .br
57 /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
58 .RE
59 .sp
60 .BR getgrent (),
61 .BR endgrent ():
62 .RS 4
63 _SVID_SOURCE || _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
64 _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
65 .RE
66 .PD
67 .ad b
68 .SH DESCRIPTION
69 The
70 .BR getgrent ()
71 function returns a pointer to a structure containing
72 the broken-out fields of a record in the group database
73 (e.g., the local group file
74 .IR /etc/group ,
75 NIS, and LDAP).
76 The first time
77 .BR getgrent ()
78 is called,
79 it returns the first entry; thereafter, it returns successive entries.
80 .PP
81 The
82 .BR setgrent ()
83 function rewinds to the beginning
84 of the group database, to allow repeated scans.
85 .PP
86 The
87 .BR endgrent ()
88 function is used to close the group database
89 after all processing has been performed.
90 .PP
91 The \fIgroup\fP structure is defined in \fI<grp.h>\fP as follows:
92 .sp
93 .in +4n
94 .nf
95 struct group {
96     char   *gr_name;        /* group name */
97     char   *gr_passwd;      /* group password */
98     gid_t   gr_gid;         /* group ID */
99     char  **gr_mem;         /* NULL-terminated array of pointers
100                                to names of group members */
101 };
102 .fi
103 .in
104 .PP
105 For more information about the fields of this structure, see
106 .BR group (5).
107 .SH RETURN VALUE
108 The
109 .BR getgrent ()
110 function returns a pointer to a
111 .I group
112 structure,
113 or NULL if there are no more entries or an error occurs.
114 .LP
115 Upon error,
116 .I errno
117 may be set.
118 If one wants to check
119 .I errno
120 after the call, it should be set to zero before the call.
121
122 The return value may point to a static area, and may be overwritten
123 by subsequent calls to
124 .BR getgrent (),
125 .BR getgrgid (3),
126 or
127 .BR getgrnam (3).
128 (Do not pass the returned pointer to
129 .BR free (3).)
130 .SH ERRORS
131 .TP
132 .B EAGAIN
133 The service was temporarily unavailable; try again later.
134 For NSS backends in glibc this indicates a temporary error talking to the backend.
135 The error may correct itself, retrying later is suggested.
136 .TP
137 .B EINTR
138 A signal was caught.
139 .TP
140 .B EIO
141 I/O error.
142 .TP
143 .B EMFILE
144 The calling process already has too many open files.
145 .TP
146 .B ENFILE
147 Too many open files in the system.
148 .TP
149 .\" not in POSIX
150 .B ENOENT
151 A necessary input file cannot be found.
152 For NSS backends in glibc this indicates the backend is not correctly configured.
153 .TP
154 .B ENOMEM
155 .\" not in POSIX
156 Insufficient memory to allocate
157 .I group
158 structure.
159 .TP
160 .B ERANGE
161 Insufficient buffer space supplied.
162 .SH FILES
163 .TP
164 .I /etc/group
165 local group database file
166 .SH ATTRIBUTES
167 .SS Multithreading (see pthreads(7))
168 The
169 .BR getgrent ()
170 function is not thread-safe.
171 .LP
172 The
173 .BR setgrent ()
174 and
175 .BR endgrent ()
176 functions are thread-safe.
177 .SH CONFORMING TO
178 SVr4, 4.3BSD, POSIX.1-2001.
179 .SH SEE ALSO
180 .BR fgetgrent (3),
181 .BR getgrent_r (3),
182 .BR getgrgid (3),
183 .BR getgrnam (3),
184 .BR getgrouplist (3),
185 .BR putgrent (3),
186 .BR group (5)
187 .SH COLOPHON
188 This page is part of release 3.79 of the Linux
189 .I man-pages
190 project.
191 A description of the project,
192 information about reporting bugs,
193 and the latest version of this page,
194 can be found at
195 \%http://www.kernel.org/doc/man\-pages/.