1.\" $NetBSD: pwd_mkdb.8,v 1.19 2002/01/19 11:44:59 wiz 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. All advertising materials mentioning features or use of this software 15.\" must display the following acknowledgement: 16.\" This product includes software developed by the University of 17.\" California, Berkeley and its contributors. 18.\" 4. 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. 21.\" 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 32.\" SUCH DAMAGE. 33.\" 34.\" from: @(#)pwd_mkdb.8 8.2 (Berkeley) 4/27/95 35.\" 36.Dd April 27, 1995 37.Dt PWD_MKDB 8 38.Os 39.Sh NAME 40.Nm pwd_mkdb 41.Nd "generate the password databases" 42.Sh SYNOPSIS 43.Nm 44.Op Fl BLps 45.Op Fl d Ar directory 46.Op Fl u Ar username 47.Ar file 48.Sh DESCRIPTION 49.Nm 50creates 51.Xr db 3 52style secure and insecure databases for the specified file. 53These databases are then installed into 54.Dq Pa /etc/spwd.db 55and 56.Dq Pa /etc/pwd.db 57respectively. 58The file is installed into 59.Dq Pa /etc/master.passwd . 60The file must be in the correct format (see 61.Xr passwd 5 ) . 62It is important to note that the format used in this system is 63different from the historic Version 7 style format. 64.Pp 65The options are as follows: 66.Bl -tag -width flag 67.It Fl B 68Store data in big-endian format. 69.It Fl L 70Store data in little-endian format. 71.It Fl d Ar directory 72Change the root directory of the generated files from 73.Dq Pa / 74to 75.Ar directory . 76.It Fl p 77Create a Version 7 style password file and install it into 78.Dq Pa /etc/passwd . 79.It Fl s 80Update the secure database only. This is useful when only encrypted 81passwords have changed. This option negates the effect of any 82.Fl p 83option. 84.It Fl u Ar name 85Don't re-build the database files, but instead modify or add entries for the 86specified user only. This option may only be used when the line number and 87user name in the password file have not changed, or when adding a new user 88from the last line in the password file. 89.El 90.Pp 91The two databases differ in that the secure version contains the user's 92encrypted password and the insecure version has an asterisk (``*''). 93.Pp 94The databases are used by the C library password routines (see 95.Xr getpwent 3 ) . 96.Pp 97.Nm 98exits zero on success, non-zero on failure. 99.Sh FILES 100.Bl -tag -width Pa -compact 101.It Pa /etc/master.passwd 102The current password file. 103.It Pa /etc/passwd 104A Version 7 format password file. 105.It Pa /etc/pwd.db 106The insecure password database file. 107.It Pa /etc/pwd.db.tmp 108A temporary file. 109.It Pa /etc/spwd.db 110The secure password database file. 111.It Pa /etc/spwd.db.tmp 112A temporary file. 113.El 114.Sh BUGS 115Because of the necessity for atomic update of the password files, 116.Nm 117uses 118.Xr rename 2 119to install them. 120This, however, requires that the file specified on the command line live 121on the same file system as the 122.Dq Pa /etc 123directory. 124.Pp 125There are the obvious races with multiple people running 126.Nm 127on different password files at the same time. 128The front-ends to 129.Xr chpass 1 , 130.Xr passwd 1 , 131.Xr useradd 8 , 132.Xr userdel 8 , 133.Xr usermod 8 , 134and 135.Xr vipw 8 136handle the locking necessary to avoid this problem. 137.Pp 138The database files are copied when the 139.Fl u 140option is used. Real locking would make this unnecessary. 141.Pp 142Although the DB format is endian-transparent, the data stored in the DB is 143not. Also, the format doesn't lend itself to insertion or removal of 144records from arbitrary locations in the password file. This is difficult to 145fix without breaking compatibility. 146.Pp 147Using the 148.Fl u 149option on a system where multiple users share the same UID can have 150unexpected results. 151.Sh COMPATIBILITY 152Previous versions of the system had a program similar to 153.Nm 154which built 155.Em dbm 156style databases for the password file but depended on the calling programs 157to install them. 158The program was renamed in order that previous users of the program 159not be surprised by the changes in functionality. 160.Sh SEE ALSO 161.Xr chpass 1 , 162.Xr passwd 1 , 163.Xr db 3 , 164.Xr getpwent 3 , 165.Xr pw_mkdb 3 , 166.Xr passwd 5 , 167.Xr useradd 8 , 168.Xr userdel 8 , 169.Xr usermod 8 , 170.Xr vipw 8 171