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(): _BSD_SOURCE || _SVID_SOURCE ||
21       _XOPEN_SOURCE > = 500
22

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

FILES

73       /etc/passwd
74              local password database file
75

CONFORMING TO

77       SVr4, 4.3BSD, POSIX.1-2001.
78

SEE ALSO

80       fgetpwent(3), getpw(3), getpwent_r(3), getpwnam(3), getpwuid(3),  putp‐
81       went(3), passwd(5)
82

COLOPHON

84       This  page  is  part of release 3.25 of the Linux man-pages project.  A
85       description of the project, and information about reporting  bugs,  can
86       be found at http://www.kernel.org/doc/man-pages/.
87
88
89
90GNU                               2009-03-30                       GETPWENT(3)
Impressum