1GETPWENT(3)                Linux Programmer's Manual               GETPWENT(3)
2
3
4

NAME

6       getpwent, setpwent, endpwent - get password file entry
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <pwd.h>
11
12       struct passwd *getpwent(void);
13
14       void setpwent(void);
15
16       void endpwent(void);
17
18   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
19
20       getpwent(), setpwent(), endpwent():
21           _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 ||
22           _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
23

DESCRIPTION

25       The getpwent() function returns a pointer to a structure containing the
26       broken-out  fields  of  a  record from the password database (e.g., the
27       local password file /etc/passwd, NIS, and LDAP).  The first time  getp‐
28       went()  is  called,  it returns the first entry; thereafter, it returns
29       successive entries.
30
31       The setpwent() function rewinds to the beginning of the password  data‐
32       base.
33
34       The  endpwent()  function  is used to close the password database after
35       all processing has been performed.
36
37       The passwd structure is defined in <pwd.h> as follows:
38
39           struct passwd {
40               char   *pw_name;       /* username */
41               char   *pw_passwd;     /* user password */
42               uid_t   pw_uid;        /* user ID */
43               gid_t   pw_gid;        /* group ID */
44               char   *pw_gecos;      /* user information */
45               char   *pw_dir;        /* home directory */
46               char   *pw_shell;      /* shell program */
47           };
48
49       For more information about the fields of this structure, see passwd(5).
50

RETURN VALUE

52       The getpwent() function returns a pointer to  a  passwd  structure,  or
53       NULL  if  there  are  no  more entries or an error occurs.  If an error
54       occurs, errno is set appropriately.  If one wants to check errno  after
55       the call, it should be set to zero before the call.
56
57       The  return value may point to a static area, and may be overwritten by
58       subsequent calls to getpwent(), getpwnam(3), or getpwuid(3).   (Do  not
59       pass the returned pointer to free(3).)
60

ERRORS

62       EINTR  A signal was caught.
63
64       EIO    I/O error.
65
66       EMFILE The  maximum  number (OPEN_MAX) of files was open already in the
67              calling process.
68
69       ENFILE The maximum number of files was open already in the system.
70
71       ENOMEM Insufficient memory to allocate passwd structure.
72
73       ERANGE Insufficient buffer space supplied.
74

FILES

76       /etc/passwd
77              local password database file
78

ATTRIBUTES

80   Multithreading (see pthreads(7))
81       The getpwent() function is not thread-safe.
82
83       The setpwent() and endpwent() functions are thread-safe.
84

CONFORMING TO

86       SVr4, 4.3BSD, POSIX.1-2001.  The pw_gecos field  is  not  specified  in
87       POSIX, but is present on most implementations.
88

SEE ALSO

90       fgetpwent(3),  getpw(3), getpwent_r(3), getpwnam(3), getpwuid(3), putp‐
91       went(3), passwd(5)
92

COLOPHON

94       This page is part of release 3.53 of the Linux  man-pages  project.   A
95       description  of  the project, and information about reporting bugs, can
96       be found at http://www.kernel.org/doc/man-pages/.
97
98
99
100GNU                               2013-06-21                       GETPWENT(3)
Impressum