1 .\" Copyright (c) 2012 Baptiste Daroussin <bapt@FreeBSD.org>
2 .\" 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.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
44 .Nd "functions for passwd file handling"
51 .Fn pw_copy "int ffd" "int tfd" "const struct passwd *pw" "struct passwd *oldpw"
53 .Fn pw_dup "const struct passwd *pw"
55 .Fn pw_edit "int nosetuid"
57 .Fn pw_equal "const struct passwd *pw1" "const struct passwd *pw2"
61 .Fn pw_init "const char *dir" "const char *master"
63 .Fn pw_initpwd "struct passwd *pw"
65 .Fn pw_make "const struct passwd *pw"
67 .Fn pw_make_v7 "const struct passwd *pw"
69 .Fn pw_mkdb "const char *user"
73 .Fn pw_scan "const char *line" "int flags"
75 .Fn pw_tempname "void"
81 function reads a password file from
83 and writes it back out to
85 possibly with modifications:
96 then the record represented by
98 will not be copied (corresponding to user deletion).
106 then the record corresponding to
108 will be replaced by the record corresponding to
117 then the record corresponding to
119 will be appended (corresponding to user addition).
124 function returns -1 in case of failure otherwise 0.
128 function duplicates the
132 and returns a pointer to the copy, or
139 and it is the caller's responsibility to free it with
144 function invokes the command specified by the
146 environment variable (or
151 on a temporary copy of the master password file created by
153 If the file was modified,
155 installs it and regenerates the password database.
158 function returns -1 in case of failure, 0 if the file was not modified,
159 and a non-zero positive number if the file was modified and successfully
164 function compares two
166 and returns 0 if they are equal.
170 function destroy the temporary file created by
173 kills any running instance of
178 and closes the lock created by
184 initializes the static variable representing the path to a password file.
186 is the directory where the password file is located.
192 is the name of the password file.
200 function initializes the
202 struct to canonical values.
203 The entire structure is zeroed, then
207 are set to -1, and all string pointers are set to point at
208 an internally-defined zero-length string.
212 function creates a properly formatted
217 and returns a pointer to the resulting string.
218 The string is allocated with
220 and it is the caller's responsibility to free it with
225 function creates a properly formatted
230 and returns a pointer to the resulting string.
231 The string is allocated with
233 and it is the caller's responsibility to free it with
238 function regenerates the password database by running
242 only the record corresponding to that user will be updated.
245 function returns 0 in case of success and -1 in case of failure.
249 function locks the master password file.
250 It returns a file descriptor to the master password file on success
255 function is a wrapper around the internal libc function
257 It scans the master password file for a line corresponding to the
259 provided and return a
261 if it matched an existing record.
262 In case of failure, it returns
264 Otherwise, it returns a pointer to a
266 containing the matching record.
271 and it is the caller's responsibility to free it with
276 function returns the temporary name of the masterfile created via
281 creates and opens a presumably safe temporary password file.
284 is a file descriptor to an open password file, it will be read and
285 written back to the temporary password file.
286 Otherwise if should be set -1.
289 returns an open file descriptor to the temporary password file or -1 in case of
292 The functions for passwd file handling first appeared in
295 Portions of this software were developed for the
297 Project by ThinkSec AS and Network Associates Laboratories, the
298 Security Research Division of Network Associates, Inc.\& under
299 DARPA/SPAWAR contract N66001-01-C-8035
301 as part of the DARPA CHATS research program.
303 This manual page was written by
304 .An Baptiste Daroussin Aq Mt bapt@FreeBSD.org .