1.\" $OpenBSD: pwd_mkdb.8,v 1.29 2022/03/31 17:27:31 naddy 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 $Mdocdate: March 31 2022 $ 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 | s 42.Op Fl d Ar directory 43.Op Fl u Ar username 44.Ar file 45.Sh DESCRIPTION 46.Nm 47creates a pair of Berkeley databases from 48.Ar file 49and installs them into 50.Pa /etc/spwd.db 51and 52.Pa /etc/pwd.db . 53The 54.Ar file 55argument is renamed to 56.Pa /etc/master.passwd . 57.Pp 58The options are as follows: 59.Bl -tag -width Ds 60.It Fl c 61Check whether 62.Ar file 63is in the correct format. 64Do not change, add, or remove any files. 65.It Fl d Ar directory 66Operate in a base directory other than the default of 67.Pa /etc . 68All absolute paths (including 69.Ar file ) 70will be made relative to 71.Ar directory . 72Any directories specified as a part of 73.Ar file 74will be stripped off. 75This option is used to create password databases in directories 76other than 77.Pa /etc ; 78for instance in a 79.Xr chroot 8 80jail. 81.It Fl p 82Also create a legacy password file and install it into 83.Pa /etc/passwd . 84.It Fl s 85Only update the secure version of the database. 86This is most commonly used in conjunction with the 87.Fl u 88flag during a password change. 89Because the insecure database doesn't contain the password, there 90is no reason to update it if the only change is in the password field. 91Cannot be used in conjunction with the 92.Fl p 93flag. 94.It Fl u Ar username 95Only update the record for the specified user. 96Utilities that operate on a single user can use this option to avoid the 97overhead of rebuilding the entire database. 98This option must never be used if the line number of the user's record in 99.Pa /etc/master.passwd 100has changed. 101.It Ar file 102The absolute path to a file in 103.Xr master.passwd 5 104format. 105.El 106.Pp 107The two databases differ in that the secure version contains the user's 108encrypted password and the insecure version has an asterisk 109.Pq Sq \&* . 110.Pp 111The databases are used by the C library password routines (see 112.Xr getpwent 3 ) . 113.Sh FILES 114.Bl -tag -width /etc/master.passwd -compact 115.It Pa /etc/master.passwd 116current password file 117.It Pa /etc/passwd 118legacy password file 119.It Pa /etc/pwd.db 120insecure password database file 121.It Pa /etc/pwd.db.tmp 122temporary file 123.It Pa /etc/spwd.db 124secure password database file 125.It Pa /etc/spwd.db.tmp 126temporary file 127.El 128.Sh EXIT STATUS 129.Ex -std 130.Sh SEE ALSO 131.Xr chpass 1 , 132.Xr passwd 1 , 133.Xr dbopen 3 , 134.Xr getpwent 3 , 135.Xr passwd 5 , 136.Xr vipw 8 137.Sh HISTORY 138The 139.Nm 140utility first appeared in 141.Bx 4.3 Net/2 . 142.Sh AUTHORS 143.An Keith Bostic 144.Sh BUGS 145Because of the necessity for atomic update of the password files, 146.Nm 147uses 148.Xr rename 2 149to install them. 150This, however, requires that the file specified on the command line live 151on the same file system as the 152.Pa /etc 153directory. 154.Pp 155There are the obvious races with multiple people running 156.Nm 157on different password files at the same time. 158The front-ends to 159.Nm pwd_mkdb , 160.Xr chpass 1 , 161.Xr passwd 1 , 162and 163.Xr vipw 8 164handle the locking necessary to avoid this problem. 165