xref: /openbsd/usr.sbin/pwd_mkdb/pwd_mkdb.8 (revision db3296cf)
1.\"	$OpenBSD: pwd_mkdb.8,v 1.17 2003/06/12 12:59:52 jmc Exp $
2.\"
3.\" Copyright (c) 1991, 1993
4.\"	The Regents of the University of California.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. Neither the name of the University nor the names of its contributors
15.\"    may be used to endorse or promote products derived from this software
16.\"    without specific prior written permission.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28.\" SUCH DAMAGE.
29.\"
30.\"	from: @(#)pwd_mkdb.8	8.1 (Berkeley) 6/6/93
31.\"
32.Dd June 6, 1993
33.Dt PWD_MKDB 8
34.Os
35.Sh NAME
36.Nm pwd_mkdb
37.Nd generate the password databases
38.Sh SYNOPSIS
39.Nm pwd_mkdb
40.Op Fl c
41.Op Fl p | Fl s
42.Op Fl d Ar directory
43.Op Fl u Ar username
44.Ar file
45.Sh DESCRIPTION
46.Nm
47creates
48.Xr db 3
49style secure and insecure databases for the specified file.
50These databases are then installed into
51.Pa /etc/spwd.db
52and
53.Pa /etc/pwd.db ,
54respectively.
55The file is installed into
56.Pa /etc/master.passwd .
57The file must be in the correct format (see
58.Xr passwd 5 ) .
59It is important to note that the format used in this system is
60different from the historic Version 7 style format.
61.Pp
62The options are as follows:
63.Bl -tag -width Ds
64.It Fl c
65Check if the password file is in the correct format.
66Do not change, add, or remove any files.
67.It Fl p
68Create a Version 7 style password file and install it into
69.Pa /etc/passwd .
70.It Fl s
71Only update the secure version of the database.
72This is most commonly used in conjunction with the
73.Fl u
74flag during a password change.
75Because the insecure database doesn't contain the password there
76is no reason to update it if the only change is in the password field.
77Cannot be used in conjunction with the
78.Fl p
79flag.
80.It Fl d Ar directory
81Operate in a base directory other than the default of
82.Pa /etc .
83All absolute paths (including
84.Ar file )
85will be made relative to
86.Ar directory .
87Any directories specified as a part of
88.Ar file
89will be stripped off.
90This option is used to create password databases in directories
91other than
92.Pa etc ;
93for instance in a
94.Xr chroot 8
95jail.
96.It Fl u Ar username
97Only update the record for the specified user.
98Utilities that operate on a single user can use this option to avoid the
99overhead of rebuilding the entire database.
100This option must never be used if the line number of the user's record in
101.Pa /etc/master.passwd
102has changed.
103.It Ar file
104The absolute path to a file in
105.Ar master.passwd
106format, as described in
107.Xr passwd 5 .
108.El
109.Pp
110The two databases differ in that the secure version contains the user's
111encrypted password and the insecure version has an asterisk
112.Pq Sq \&* .
113.Pp
114The databases are used by the C library password routines (see
115.Xr getpwent 3 ) .
116.Pp
117.Nm
118exits zero on success, non-zero on failure.
119.Sh FILES
120.Bl -tag -width /etc/master.passwd -compact
121.It Pa /etc/master.passwd
122current password file
123.It Pa /etc/passwd
124a Version 7 format password file
125.It Pa /etc/pwd.db
126insecure password database file
127.It Pa /etc/pwd.db.tmp
128temporary file
129.It Pa /etc/spwd.db
130secure password database file
131.It Pa /etc/spwd.db.tmp
132temporary file
133.El
134.Sh SEE ALSO
135.Xr chpass 1 ,
136.Xr passwd 1 ,
137.Xr db 3 ,
138.Xr getpwent 3 ,
139.Xr passwd 5 ,
140.Xr vipw 8
141.Sh STANDARDS
142Previous versions of the system had a program similar to
143.Nm pwd_mkdb ,
144.Xr mkpasswd ,
145which built
146.Xr dbm 3
147style databases for the password file but depended on the calling programs
148to install them.
149The program was renamed in order that previous users of the program
150not be surprised by the changes in functionality.
151.Sh BUGS
152Because of the necessity for atomic update of the password files,
153.Nm
154uses
155.Xr rename 2
156to install them.
157This, however, requires that the file specified on the command line live
158on the same file system as the
159.Pa /etc
160directory.
161.Pp
162There are the obvious races with multiple people running
163.Nm
164on different password files at the same time.
165The front-ends to
166.Nm pwd_mkdb ,
167.Xr chpass 1 ,
168.Xr passwd 1 ,
169and
170.Xr vipw 8
171handle the locking necessary to avoid this problem.
172