1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\" References consulted:
6 .\" Linux libc source code
7 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified Sat Jul 24 19:22:14 1993 by Rik Faith (faith@cs.unc.edu)
11 .\" Modified Mon May 27 21:37:47 1996 by Martin Schulze (joey@linux.de)
13 .TH GETPWENT 3 2021-03-22 "Linux man-pages (unreleased)"
15 getpwent, setpwent, endpwent \- get password file entry
18 .RI ( libc ", " \-lc )
21 .B #include <sys/types.h>
24 .B struct passwd *getpwent(void);
25 .B void setpwent(void);
26 .B void endpwent(void);
30 Feature Test Macro Requirements for glibc (see
31 .BR feature_test_macros (7)):
39 .\" || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
40 || /* Glibc since 2.19: */ _DEFAULT_SOURCE
41 || /* Glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE
46 function returns a pointer to a structure containing
47 the broken-out fields of a record from the password database
48 (e.g., the local password file
53 is called, it returns the first entry; thereafter, it returns successive
58 function rewinds to the beginning
59 of the password database.
63 function is used to close the password database
64 after all processing has been performed.
66 The \fIpasswd\fP structure is defined in \fI<pwd.h>\fP as follows:
71 char *pw_name; /* username */
72 char *pw_passwd; /* user password */
73 uid_t pw_uid; /* user ID */
74 gid_t pw_gid; /* group ID */
75 char *pw_gecos; /* user information */
76 char *pw_dir; /* home directory */
77 char *pw_shell; /* shell program */
82 For more information about the fields of this structure, see
87 function returns a pointer to a
90 there are no more entries or an error occurred.
93 is set to indicate the error.
96 after the call, it should be set to zero before the call.
98 The return value may point to a static area, and may be overwritten
99 by subsequent calls to
104 (Do not pass the returned pointer to
109 A signal was caught; see
116 The per-process limit on the number of open file descriptors has been reached.
119 The system-wide limit on the total number of open files has been reached.
123 Insufficient memory to allocate
126 .\" to allocate the passwd structure, or to allocate buffers
129 Insufficient buffer space supplied.
133 local password database file
135 For an explanation of the terms used in this section, see
143 Interface Attribute Value
154 MT-Unsafe race:pwent locale
164 signifies that if any of the functions
169 are used in parallel in different threads of a program,
170 then data races could occur.
172 POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD.
175 field is not specified in POSIX, but is present on most implementations.