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 .\" 4. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" From: @(#)getpwent.3 8.2 (Berkeley) 12/11/93
44 .Nd password database operations
53 .Fn getpwent_r "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result"
55 .Fn getpwnam "const char *login"
57 .Fn getpwnam_r "const char *name" "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result"
59 .Fn getpwuid "uid_t uid"
61 .Fn getpwuid_r "uid_t uid" "struct passwd *pwd" "char *buffer" "size_t bufsize" "struct passwd **result"
63 .Fn setpassent "int stayopen"
70 operate on the password database file
74 Each entry in the database is defined by the structure
79 .Bd -literal -offset indent
81 char *pw_name; /* user name */
82 char *pw_passwd; /* encrypted password */
83 uid_t pw_uid; /* user uid */
84 gid_t pw_gid; /* user gid */
85 time_t pw_change; /* password change time */
86 char *pw_class; /* user access class */
87 char *pw_gecos; /* Honeywell login info */
88 char *pw_dir; /* home directory */
89 char *pw_shell; /* default shell */
90 time_t pw_expire; /* account expiration */
91 int pw_fields; /* internal: fields filled in */
99 search the password database for the given login name or user uid,
100 respectively, always returning the first one encountered.
105 sequentially reads the password database and is intended for programs
106 that wish to process the complete list of users.
113 are thread-safe versions of
119 The caller must provide storage for the results of the search in
127 When these functions are successful, the
129 argument will be filled-in, and a pointer to that argument will be
132 If an entry is not found or an error occurs,
140 accomplishes two purposes.
143 to ``rewind'' to the beginning of the database.
146 is non-zero, file descriptors are left open, significantly speeding
147 up subsequent accesses for all of the routines.
148 (This latter functionality is unnecessary for
150 as it does not close its file descriptors by default.)
152 It is dangerous for long-running programs to keep the file descriptors
153 open as the database will become out of date if it is updated while the
161 with an argument of zero.
166 closes any open files.
168 These routines have been written to ``shadow'' the password file, e.g.\&
169 allow only certain programs to have access to the encrypted password.
170 If the process which calls them has an effective uid of 0, the encrypted
171 password will be returned, otherwise, the password field of the returned
172 structure will point to the string
180 return a valid pointer to a passwd structure on success
183 if the entry is not found or if an error occurs.
184 If an error does occur,
187 Note that programs must explicitly set
189 to zero before calling any of these functions if they need to
190 distinguish between a non-existent entry and an error.
196 return 0 if no error occurred, or an error number to indicate failure.
197 It is not an error if a matching entry is not found.
202 and the return value is 0, no matching entry exists.)
206 function returns 0 on failure and 1 on success.
212 have no return value.
214 .Bl -tag -width /etc/master.passwd -compact
216 The insecure password database file
218 The secure password database file
219 .It Pa /etc/master.passwd
220 The current password file
222 A Version 7 format password file
225 The historic function
227 which allowed the specification of alternate password databases,
228 has been deprecated and is no longer available.
230 These routines may fail for any of the errors specified in
236 in addition to the following:
239 The buffer specified by the
243 arguments was insufficiently sized to store the result.
244 The caller should retry with a larger buffer.
249 .Xr nsswitch.conf 5 ,
274 functions appeared in
285 functions appeared in
293 leave their results in an internal static object and return
294 a pointer to that object.
297 will modify the same object.
306 are fairly useless in a networked environment and should be
307 avoided, if possible.
313 make no attempt to suppress duplicate information if multiple
314 sources are specified in
315 .Xr nsswitch.conf 5 .