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

DESCRIPTION

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

RETURN VALUE

44       The  getpwent()  function  returns  a pointer to a passwd structure, or
45       NULL if there are no more entries or an  error  occurs.   If  an  error
46       occurs,  errno is set appropriately.  If one wants to check errno after
47       the call, it should be set to zero before the call.
48

ERRORS

50       EINTR  A signal was caught.
51
52       EIO    I/O error.
53
54       EMFILE The maximum number (OPEN_MAX) of files was open already  in  the
55              calling process.
56
57       ENFILE The maximum number of files was open already in the system.
58
59       ENOMEM Insufficient memory to allocate passwd structure.
60
61       ERANGE Insufficient buffer space supplied.
62

FILES

64       /etc/passwd
65              local password database file
66

CONFORMING TO

68       SVr4, 4.3BSD, POSIX.1-2001.
69

SEE ALSO

71       fgetpwent(3),  getpw(3), getpwent_r(3), getpwnam(3), getpwuid(3), putp‐
72       went(3), passwd(5)
73
74
75
76GNU                               1996-05-27                       GETPWENT(3)
Impressum