]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
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. | |
c13182ef | 12 | .\" |
fea681da MK |
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. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
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 | .\" | |
30 | .\" Modified Sat Jul 24 19:22:14 1993 by Rik Faith (faith@cs.unc.edu) | |
31 | .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de) | |
32 | .\" | |
4b8c67d9 | 33 | .TH GETPWENT 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da MK |
34 | .SH NAME |
35 | getpwent, setpwent, endpwent \- get password file entry | |
36 | .SH SYNOPSIS | |
37 | .nf | |
38 | .B #include <sys/types.h> | |
39 | .B #include <pwd.h> | |
68e4db0a | 40 | .PP |
fea681da | 41 | .B struct passwd *getpwent(void); |
68e4db0a | 42 | .PP |
fea681da | 43 | .B void setpwent(void); |
68e4db0a | 44 | .PP |
fea681da MK |
45 | .B void endpwent(void); |
46 | .fi | |
68e4db0a | 47 | .PP |
cc4615cc MK |
48 | .in -4n |
49 | Feature Test Macro Requirements for glibc (see | |
50 | .BR feature_test_macros (7)): | |
51 | .in | |
68e4db0a | 52 | .PP |
cc4615cc MK |
53 | .ad l |
54 | .BR getpwent (), | |
55 | .BR setpwent (), | |
56 | .BR endpwent (): | |
515334d6 | 57 | .RS 4 |
9db90c7c | 58 | _XOPEN_SOURCE\ >=\ 500 |
cf7fa0a1 | 59 | .\" || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED |
9db90c7c MK |
60 | || /* Glibc since 2.19: */ _DEFAULT_SOURCE |
61 | || /* Glibc versions <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
515334d6 | 62 | .RE |
cc4615cc | 63 | .ad b |
fea681da | 64 | .SH DESCRIPTION |
60a90ecd MK |
65 | The |
66 | .BR getpwent () | |
67 | function returns a pointer to a structure containing | |
f2738b39 | 68 | the broken-out fields of a record from the password database |
c13182ef | 69 | (e.g., the local password file |
f2738b39 MK |
70 | .IR /etc/passwd , |
71 | NIS, and LDAP). | |
1e82fbcf MK |
72 | The first time |
73 | .BR getpwent () | |
74 | is called, it returns the first entry; thereafter, it returns successive | |
fea681da MK |
75 | entries. |
76 | .PP | |
60a90ecd MK |
77 | The |
78 | .BR setpwent () | |
79 | function rewinds to the beginning | |
f2738b39 | 80 | of the password database. |
fea681da | 81 | .PP |
60a90ecd MK |
82 | The |
83 | .BR endpwent () | |
84 | function is used to close the password database | |
f2738b39 | 85 | after all processing has been performed. |
fea681da MK |
86 | .PP |
87 | The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows: | |
51f5698d | 88 | .PP |
bd191423 | 89 | .in +4n |
b8302363 | 90 | .EX |
fea681da | 91 | struct passwd { |
18701562 | 92 | char *pw_name; /* username */ |
f2738b39 | 93 | char *pw_passwd; /* user password */ |
34c97781 MK |
94 | uid_t pw_uid; /* user ID */ |
95 | gid_t pw_gid; /* group ID */ | |
958680cd | 96 | char *pw_gecos; /* user information */ |
f2738b39 MK |
97 | char *pw_dir; /* home directory */ |
98 | char *pw_shell; /* shell program */ | |
fea681da | 99 | }; |
b8302363 | 100 | .EE |
bd191423 | 101 | .in |
7f12f117 MK |
102 | .PP |
103 | For more information about the fields of this structure, see | |
104 | .BR passwd (5). | |
47297adb | 105 | .SH RETURN VALUE |
60a90ecd MK |
106 | The |
107 | .BR getpwent () | |
108 | function returns a pointer to a | |
f2738b39 | 109 | .I passwd |
c13182ef | 110 | structure, or NULL if |
890968b1 | 111 | there are no more entries or an error occurred. |
f2738b39 MK |
112 | If an error occurs, |
113 | .I errno | |
114 | is set appropriately. | |
115 | If one wants to check | |
116 | .I errno | |
117 | after the call, it should be set to zero before the call. | |
847e0d88 | 118 | .PP |
f2ac73c7 MK |
119 | The return value may point to a static area, and may be overwritten |
120 | by subsequent calls to | |
121 | .BR getpwent (), | |
122 | .BR getpwnam (3), | |
123 | or | |
124 | .BR getpwuid (3). | |
48e4cfa0 MK |
125 | (Do not pass the returned pointer to |
126 | .BR free (3).) | |
fea681da MK |
127 | .SH ERRORS |
128 | .TP | |
f2738b39 | 129 | .B EINTR |
bb14af39 MK |
130 | A signal was caught; see |
131 | .BR signal (7). | |
f2738b39 MK |
132 | .TP |
133 | .B EIO | |
134 | I/O error. | |
135 | .TP | |
136 | .B EMFILE | |
26c32fab | 137 | The per-process limit on the number of open file descriptors has been reached. |
f2738b39 MK |
138 | .TP |
139 | .B ENFILE | |
e258766b | 140 | The system-wide limit on the total number of open files has been reached. |
f2738b39 | 141 | .TP |
fea681da | 142 | .B ENOMEM |
f2738b39 | 143 | .\" not in POSIX |
d9a10d9d MK |
144 | Insufficient memory to allocate |
145 | .I passwd | |
146 | structure. | |
f2738b39 MK |
147 | .\" to allocate the passwd structure, or to allocate buffers |
148 | .TP | |
149 | .B ERANGE | |
150 | Insufficient buffer space supplied. | |
fea681da MK |
151 | .SH FILES |
152 | .TP | |
153 | .I /etc/passwd | |
f2738b39 | 154 | local password database file |
8bce3424 | 155 | .SH ATTRIBUTES |
ec22aefa MK |
156 | For an explanation of the terms used in this section, see |
157 | .BR attributes (7). | |
158 | .TS | |
159 | allbox; | |
6f0a3033 | 160 | lbw11 lb lb |
ec22aefa MK |
161 | l l l. |
162 | Interface Attribute Value | |
163 | T{ | |
7f4cd55d | 164 | .BR getpwent () |
6f0a3033 MK |
165 | T} Thread safety T{ |
166 | MT-Unsafe race:pwent | |
167 | .br | |
168 | race:pwentbuf locale | |
169 | T} | |
ec22aefa MK |
170 | T{ |
171 | .BR setpwent (), | |
4e1ec7cb | 172 | .br |
7f4cd55d | 173 | .BR endpwent () |
4e1ec7cb | 174 | T} Thread safety MT-Unsafe race:pwent locale |
ec22aefa | 175 | .TE |
847e0d88 | 176 | .sp 1 |
0970ab3f MS |
177 | In the above table, |
178 | .I pwent | |
179 | in | |
180 | .I race:pwent | |
181 | signifies that if any of the functions | |
182 | .BR setpwent (), | |
183 | .BR getpwent (), | |
184 | or | |
185 | .BR endpwent () | |
f038f4f1 MK |
186 | are used in parallel in different threads of a program, |
187 | then data races could occur. | |
47297adb | 188 | .SH CONFORMING TO |
5677ac3a | 189 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. |
958680cd MK |
190 | The |
191 | .I pw_gecos | |
192 | field is not specified in POSIX, but is present on most implementations. | |
47297adb | 193 | .SH SEE ALSO |
fea681da MK |
194 | .BR fgetpwent (3), |
195 | .BR getpw (3), | |
196 | .BR getpwent_r (3), | |
197 | .BR getpwnam (3), | |
198 | .BR getpwuid (3), | |
199 | .BR putpwent (3), | |
200 | .BR passwd (5) |