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)
11 .\" Modified Sat Jul 24 19:22:14 1993 by Rik Faith (faith@cs.unc.edu)
12 .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de)
14 .TH getpwent 3 (date) "Linux man-pages (unreleased)"
16 getpwent, setpwent, endpwent \- get password file entry
19 .RI ( libc ", " \-lc )
22 .B #include <sys/types.h>
25 .B struct passwd *getpwent(void);
26 .B void setpwent(void);
27 .B void endpwent(void);
31 Feature Test Macro Requirements for glibc (see
32 .BR feature_test_macros (7)):
40 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
41 || /* glibc >= 2.19: */ _DEFAULT_SOURCE
42 || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
47 function returns a pointer to a structure containing
48 the broken-out fields of a record from the password database
49 (e.g., the local password file
54 is called, it returns the first entry; thereafter, it returns successive
59 function rewinds to the beginning
60 of the password database.
64 function is used to close the password database
65 after all processing has been performed.
67 The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
72 char *pw_name; /* username */
73 char *pw_passwd; /* user password */
74 uid_t pw_uid; /* user ID */
75 gid_t pw_gid; /* group ID */
76 char *pw_gecos; /* user information */
77 char *pw_dir; /* home directory */
78 char *pw_shell; /* shell program */
83 For more information about the fields of this structure, see
88 function returns a pointer to a
91 there are no more entries or an error occurred.
94 is set to indicate the error.
97 after the call, it should be set to zero before the call.
99 The return value may point to a static area, and may be overwritten
100 by subsequent calls to
105 (Do not pass the returned pointer to
110 A signal was caught; see
117 The per-process limit on the number of open file descriptors has been reached.
120 The system-wide limit on the total number of open files has been reached.
124 Insufficient memory to allocate
127 .\" to allocate the passwd structure, or to allocate buffers
130 Insufficient buffer space supplied.
134 local password database file
136 For an explanation of the terms used in this section, see
142 Interface Attribute Value
161 MT-Unsafe race:pwent locale
169 signifies that if any of the functions
174 are used in parallel in different threads of a program,
175 then data races could occur.
179 field is not specified in POSIX, but is present on most implementations.
183 POSIX.1-2001, SVr4, 4.3BSD.