1 .\" $NetBSD: pw_init.3,v 1.13 2004/08/03 23:29:05 thorpej 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
94 will set the effective user and group ID to the real user and group ID
95 before running the editor.
99 function asks the user whether he or she wants to re-edit the password
100 file; if the answer is no,
102 deletes the lock file and exits the process.
106 function reads a passwd file from
110 updating the entry corresponding to pw-\*[Gt]pw_name with the information
115 is not NULL, it checks to make sure the old entry is the same as
118 or the process is aborted.
119 If an entry is not found to match
121 a new entry is appended to the passwd file only if the real user
125 will display a message on
132 function performs the same operation as
134 with the exception of error handling.
137 will write an error message into the buffer pointed to by
146 a passwd entry as it would be represented in
147 .Pa /etc/master.passwd
150 with corresponding values; string fields in
152 will be pointers into
156 will be overwritten with 0s in order to terminate the strings pointed
161 is non-null, it should be cleared and the following options
163 .Bl -tag -offset indent -width _PASSWORD_OLDFMT
164 .It Dv _PASSWORD_NOWARN
165 Don't print warnings.
166 .It Dv _PASSWORD_OLDFMT
169 as an old format entry as found in
173 Upon return it is cleared, and filled in with the following flags:
174 .Bl -tag -offset indent -width _PASSWORD_NOGID
175 .It Dv _PASSWORD_NOUID
179 .It Dv _PASSWORD_NOGID
183 .It Dv _PASSWORD_NOCHG
187 .It Dv _PASSWORD_NOEXP
195 function displays an error message, aborts the current passwd update,
196 and exits the current process.
199 is non-zero, a warning message beginning with
201 is printed for the current value of
203 The process exits with status
208 function returns 1 if the new password entry was successfully written
209 to the destination file, and 0 otherwise.
213 function prints a warning message and returns 0 if the string in the
215 argument is not a valid passwd string.
220 .Bl -tag -width /etc/master.passwd -compact
221 .It Pa /etc/master.passwd