xref: /386bsd/usr/share/man/cat3/getpwent.0 (revision a2142627)
1GETPWENT(3)               386BSD Programmer's Manual               GETPWENT(3)
2
3NNAAMMEE
4     ggeettppwweenntt, ggeettppwwnnaamm, ggeettppwwuuiidd, sseettppaasssseenntt, sseettppwweenntt, eennddppwweenntt - password
5     database operations
6
7SSYYNNOOPPSSIISS
8     ##iinncclluuddee <<ssyyss//ttyyppeess..hh>>
9     ##iinncclluuddee <<ppwwdd..hh>>
10
11     _s_t_r_u_c_t _p_a_s_s_w_d *
12     ggeettppwweenntt(_v_o_i_d)
13
14     _s_t_r_u_c_t _p_a_s_s_w_d *
15     ggeettppwwnnaamm(_c_o_n_s_t _c_h_a_r *_l_o_g_i_n)
16
17     _s_t_r_u_c_t _p_a_s_s_w_d *
18     ggeettppwwuuiidd(_u_i_d__t _u_i_d)
19
20     _i_n_t
21     sseettppaasssseenntt(_i_n_t _s_t_a_y_o_p_e_n)
22
23     _i_n_t
24     sseettppwweenntt(_v_o_i_d)
25
26     _v_o_i_d
27     eennddppwweenntt(_v_o_i_d)
28
29DDEESSCCRRIIPPTTIIOONN
30     These functions operate on the password database file which is described
31     in passwd(5).  Each entry in the database is defined by the structure
32     _p_a_s_s_w_d found in the include file <_p_w_d._h>:
33
34           struct passwd {
35                   char    *pw_name;       /* user name */
36                   char    *pw_passwd;     /* encrypted password */
37                   uid_t   pw_uid;         /* user uid */
38                   gid_t   pw_gid;         /* user gid */
39                   time_t  pw_change;      /* password change time */
40                   char    *pw_class;      /* user access class */
41                   char    *pw_gecos;      /* Honeywell login info */
42                   char    *pw_dir;        /* home directory */
43                   char    *pw_shell;      /* default shell */
44                   time_t  pw_expire;      /* account expiration */
45           };
46
47     The functions ggeettppwwnnaamm() and ggeettppwwuuiidd() search the password database for
48     the given login name or user uid, respectively, always returning the
49     first one encountered.
50
51     The ggeettppwweenntt() function sequentially reads the password database and is
52     intended for programs that wish to process the complete list of users.
53
54     The sseettppaasssseenntt() function accomplishes two purposes.  First, it causes
55     ggeettppwweenntt() to ``rewind'' to the beginning of the database.  Additionally,
56     if _s_t_a_y_o_p_e_n is non-zero, file descriptors are left open, significantly
57     speeding up subsequent accesses for all of the routines.  (This latter
58     functionality is unnecessary for ggeettppwweenntt() as it doesn't close its file
59     descriptors by default.)
60
61     It is dangerous for long-running programs to keep the file descriptors
62     open the database will become out of date if it is updated while the
63     program is running.
64
65
66     The sseettppwweenntt() function is identical to sseettppaasssseenntt() with an argument of
67     zero.
68
69     The eennddppwweenntt() function closes any open files.
70
71     These routines have been written to ``shadow'' the password file, e.g.
72     allow only certain programs to have access to the encrypted password.  If
73     the process which calls them has an effective uid of 0, the encrypted
74     password will be returned, otherwise, the password field of the retuned
75     structure will point to the string `*'.
76
77RREETTUURRNN VVAALLUUEESS
78     The functions ggeettppwweenntt(), ggeettppwwnnaamm(), and ggeettppwwuuiidd(), return a valid
79     pointer to a passwd structure on success and a null pointer if end-of-
80     file is reached or an error occurs.  The functions sseettppaasssseenntt() and
81     sseettppwweenntt() return 0 on failure and 1 on success.  The eennddppwweenntt() function
82     has no return value.
83
84FFIILLEESS
85     /var/db/pwd.db      The insecure password database file
86     /var/db/spwd.db     The secure password database file
87     /etc/master.passwd  The current password file
88     /etc/passwd         A Version 7 format password file
89
90SSEEEE AALLSSOO
91     getlogin(3),  getgrent(3),  passwd(5),  pwd_mkdb(8),  vipw(8)
92
93HHIISSTTOORRYY
94     The ggeettppwweenntt, ggeettppwwnnaamm, ggeettppwwuuiidd, sseettppwweenntt,, and eennddppwweenntt functions
95     appeared in Version 7 AT&T UNIX.  The sseettppaasssseenntt function appeared in
96     4.3BSD-Reno.
97
98BBUUGGSS
99     The functions ggeettppwweenntt(), ggeettppwwnnaamm(), and ggeettppwwuuiidd(), leave their results
100     in an internal static object and return a pointer to that object.
101     Subsequent calls to the same function will modify the same object.
102
103     The routines ggeettppwweenntt(), eennddppwweenntt(), sseettppaasssseenntt(), and sseettppwweenntt() are
104     fairly useless in a networked environment and should be avoided, if
105     possible.
106
107CCOOMMPPAATTIIBBIILLIITTYY
108     The historic function setpwfile(3),  which allowed the specification of
109     alternate password databases, has been deprecated and is no longer
110     available.
111
112BSD Experimental                April 19, 1991                               2
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133