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
25 .\" $FreeBSD: head/lib/libutil/pw_util.3 242503 2012-11-03 00:30:22Z bapt $
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_make "const struct passwd *pw"
65 .Fn pw_make_v7 "const struct passwd *pw"
67 .Fn pw_mkdb "const char *user"
71 .Fn pw_scan "const char *line" "int flags"
73 .Fn pw_tempname "void"
79 function reads a password file from
81 and writes it back out to
83 possibly with modifications:
94 then the record represented by
96 will not be copied (corresponding to user deletion).
104 then the record corresponding to
106 will be replaced by the record corresponding to
115 then the record corresponding to
117 will be appended (corresponding to user addition).
122 function returns -1 in case of failure otherwise 0.
126 function duplicates the
130 and returns a pointer to the copy, or
137 and it is the caller's responsibility to free it with
142 function invokes the command specified by the
144 environment variable (or
149 on a temporary copy of the master password file created by
151 If the file was modified,
153 installs it and regenerates the password database.
156 function returns -1 in case of failure, 0 if the file was not modified,
157 and a non-zero positive number if the file was modified and successfully
162 function compares two
164 and returns 0 if they are equal.
168 function destroy the temporary file created by
171 kills any running instance of
176 and closes the lock created by
182 initialize the static variable representing the path a password file.
184 is the directory where the password file is located.
190 is the name of the password file.
198 function creates a properly formatted
203 and returns a pointer to the resulting string.
204 The string is allocated with
206 and it is the caller's responsibility to free it with
211 function creates a properly formatted
216 and returns a pointer to the resulting string.
217 The string is allocated with
219 and it is the caller's responsibility to free it with
224 function regenerates the password database by running
228 only the record corresponding to that user will be updated.
231 function returns 0 in case of success and -1 in case of failure.
235 function locks the master password file.
236 It returns 0 in case of success and -1 in case of failure.
240 function is a wrapper around the internal libc function
242 It scans the master password file for a line corresponding to the
244 provided and return a
246 if it matched an existing record.
247 In case of failure, it returns
249 Otherwise, it returns a pointer to a
251 containing the matching record.
256 and it is the caller's responsibility to free it with
261 function returns the temporary name of the masterfile created via
266 creates and opens a presumably safe temporary password file.
269 is a file descriptor to an open password file, it will be read and
270 written back to the temporary password file.
271 Otherwise if should be set -1.
274 returns an open file descriptor to the temporary password file or -1 in case of
277 Portions of this software were developed for the
279 Project by ThinkSec AS and Network Associates Laboratories, the
280 Security Research Division of Network Associates, Inc.\& under
281 DARPA/SPAWAR contract N66001-01-C-8035
283 as part of the DARPA CHATS research program.
285 This manual page was written by
286 .An Baptiste Daroussin Aq Mt bapt@FreeBSD.org .