1 .\" Copyright (c) 1988, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" From: @(#)getpwent.3 8.2 (Berkeley) 12/11/93
33 .\" $FreeBSD: src/lib/libc/gen/getpwent.3,v 1.11.2.5 2002/02/01 15:51:16 ru Exp $
34 .\" $DragonFly: src/lib/libc/gen/getpwent.3,v 1.5 2006/05/26 19:39:36 swildner Exp $
36 .Dd September 20, 1994
46 .Nd password database operations
55 .Fn getpwnam "const char *login"
57 .Fn getpwuid "uid_t uid"
59 .Fn setpassent "int stayopen"
66 operate on the password database file
70 Each entry in the database is defined by the structure
75 .Bd -literal -offset indent
77 char *pw_name; /* user name */
78 char *pw_passwd; /* encrypted password */
79 uid_t pw_uid; /* user uid */
80 gid_t pw_gid; /* user gid */
81 time_t pw_change; /* password change time */
82 char *pw_class; /* user access class */
83 char *pw_gecos; /* Honeywell login info */
84 char *pw_dir; /* home directory */
85 char *pw_shell; /* default shell */
86 time_t pw_expire; /* account expiration */
87 int pw_fields; /* internal: fields filled in */
95 search the password database for the given login name or user uid,
96 respectively, always returning the first one encountered.
101 sequentially reads the password database and is intended for programs
102 that wish to process the complete list of users.
107 accomplishes two purposes.
110 to ``rewind'' to the beginning of the database.
113 is non-zero, file descriptors are left open, significantly speeding
114 up subsequent accesses for all of the routines.
115 (This latter functionality is unnecessary for
117 as it doesn't close its file descriptors by default.)
119 It is dangerous for long-running programs to keep the file descriptors
120 open as the database will become out of date if it is updated while the
128 with an argument of zero.
133 closes any open files.
135 These routines have been written to ``shadow'' the password file, e.g.\&
136 allow only certain programs to have access to the encrypted password.
137 If the process which calls them has an effective uid of 0, the encrypted
138 password will be returned, otherwise, the password field of the returned
139 structure will point to the string
141 .Sh YP/NIS INTERACTION
144 password database is enabled, the
148 functions use the YP maps
151 .Dq Li passwd.byuid ,
152 respectively, if the requested password entry is not found in the
155 function will step through the YP map
157 if the entire map is enabled as described in
165 return a valid pointer to a passwd structure on success
166 and a null pointer if end-of-file is reached or an error occurs.
169 function returns 0 on failure and 1 on success.
175 have no return value.
177 .Bl -tag -width /etc/master.passwd -compact
179 The insecure password database file
181 The secure password database file
182 .It Pa /etc/master.passwd
183 The current password file
185 A Version 7 format password file
188 The historic function
190 which allowed the specification of alternate password databases,
191 has been deprecated and is no longer available.
207 functions appeared in
219 leave their results in an internal static object and return
220 a pointer to that object.
223 will modify the same object.