1 .\" $NetBSD: pw_init.3,v 1.15 2010/05/05 22:05:31 wiz Exp $
4 .\" The Regents of the University of California. All rights reserved.
6 .\" This code is derived from software developed by the Computer Systems
7 .\" Engineering group at Lawrence Berkeley Laboratory under DARPA contract
8 .\" BG 91-66 and contributed to Berkeley.
10 .\" Redistribution and use in source and binary forms, with or without
11 .\" modification, are permitted provided that the following conditions
13 .\" 1. Redistributions of source code must retain the above copyright
14 .\" notice, this list of conditions and the following disclaimer.
15 .\" 2. Redistributions in binary form must reproduce the above copyright
16 .\" notice, this list of conditions and the following disclaimer in the
17 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
45 .Nd utility functions for interactive passwd file updates
54 .Fn pw_edit "int notsetuid" "const char *filename"
58 .Fn pw_copy "int ffd" "int tfd" "struct passwd *pw" "struct passwd *old_pw"
60 .Fn pw_copyx "int ffd" "int tfd" "struct passwd *pw" "struct passwd *old_pw" \
61 "char *errbuf" "size_t errbufsz"
63 .Fn pw_scan "char *bp" "struct passwd *pw" "int *flags"
65 .Fn pw_error "const char *name" "int err" "int eval"
67 These functions are designed as conveniences for interactive programs
68 which update the passwd file and do nothing else.
69 They generally handle errors by printing out a message to the standard error
70 stream and possibly aborting the process.
74 function prepares for a passwd update by unlimiting all resource
75 constraints, disabling core dumps (thus preventing dumping the
76 contents of the passwd database into a world-readable file), and
77 disabling most signals.
81 function runs an editor (named by the environment variable EDITOR, or
83 if EDITOR is not set) on the file
95 will set the effective user and group ID to the real user and group ID
96 before running the editor.
100 function asks the user whether he or she wants to re-edit the password
101 file; if the answer is no,
103 deletes the lock file and exits the process.
107 function reads a passwd file from
111 updating the entry corresponding to pw-\*[Gt]pw_name with the information
118 it checks to make sure the old entry is the same as
121 or the process is aborted.
122 If an entry is not found to match
124 a new entry is appended to the passwd file only if the real user
128 will display a message on
135 function performs the same operation as
137 with the exception of error handling.
140 will write an error message into the buffer pointed to by
149 a passwd entry as it would be represented in
150 .Pa /etc/master.passwd
153 with corresponding values; string fields in
155 will be pointers into
159 will be overwritten with 0s in order to terminate the strings pointed
164 is non-null, it should be cleared and the following options
166 .Bl -tag -offset indent -width _PASSWORD_OLDFMT
167 .It Dv _PASSWORD_NOWARN
168 Don't print warnings.
169 .It Dv _PASSWORD_OLDFMT
172 as an old format entry as found in
176 Upon return it is cleared, and filled in with the following flags:
177 .Bl -tag -offset indent -width _PASSWORD_NOGID
178 .It Dv _PASSWORD_NOUID
182 .It Dv _PASSWORD_NOGID
186 .It Dv _PASSWORD_NOCHG
190 .It Dv _PASSWORD_NOEXP
198 function displays an error message, aborts the current passwd update,
199 and exits the current process.
202 is non-zero, a warning message beginning with
204 is printed for the current value of
206 The process exits with status
211 function returns 1 if the new password entry was successfully written
212 to the destination file, and 0 otherwise.
216 function prints a warning message and returns 0 if the string in the
218 argument is not a valid passwd string.
223 .Bl -tag -width /etc/master.passwd -compact
224 .It Pa /etc/master.passwd