xref: /freebsd/usr.sbin/pwd_mkdb/pwd_mkdb.8 (revision 715d1396d6233158b94e85414b57520ee3e536cc)
1.\" Copyright (c) 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. Neither the name of the University nor the names of its contributors
13.\"    may be used to endorse or promote products derived from this software
14.\"    without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.\"	@(#)pwd_mkdb.8	8.1 (Berkeley) 6/6/93
29.\" $FreeBSD$
30.\"
31.Dd April 22, 2018
32.Dt PWD_MKDB 8
33.Os
34.Sh NAME
35.Nm pwd_mkdb
36.Nd "generate the password databases"
37.Sh SYNOPSIS
38.Nm
39.Op Fl BCilLNp
40.Op Fl d Ar directory
41.Op Fl s Ar cachesize
42.Op Fl u Ar username
43.Ar file
44.Sh DESCRIPTION
45The
46.Nm
47utility creates
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 flag
64.It Fl C
65Check if the password file is in the correct format.
66Do not
67change, add, or remove any files.
68.It Fl N
69Tell
70.Nm
71to exit with an error if it cannot obtain a lock on the file.
72By default,
73we block waiting for a lock on the source file.
74The lock is held through
75the rebuilding of the database.
76.It Fl p
77Create a Version 7 style password file and install it into
78.Pa /etc/passwd .
79.It Fl i
80Ignore locking failure of the
81.Pa master.passwd
82file.
83This option is intended to be used to build password files in
84the release process over NFS where no contention can happen.
85A non-default directory must also be specified with the
86.Fl d
87option for locking to be ignored.
88Other use of this option is strongly discouraged.
89.It Fl d Ar directory
90Store databases into specified destination directory instead of
91.Pa /etc .
92.It Fl u Ar username
93Only update the record for the specified user.
94Utilities that
95operate on a single user can use this option to avoid the
96overhead of rebuilding the entire database.
97.It Fl s Ar cachesize
98Specify in megabytes the size of the memory cache used by the
99hashing library.
100On systems with a large user base, a small cache
101size can lead to prohibitively long database file rebuild times.
102As a rough guide, the memory usage of
103.Nm
104in megabytes will be a little bit more than twice the figure
105specified here.
106The default is 2 megabytes.
107.El
108.Pp
109The two databases differ in that the secure version contains the user's
110encrypted password and the insecure version has an asterisk (``*'')
111.Pp
112The databases are used by the C library password routines (see
113.Xr getpwent 3 ) .
114.Pp
115By default,
116the
117.Nm
118utility generates new,
119machine independent format
120.Pq v4
121entries only.
122For compatibility with
123.Fx 5.0
124and earlier releases,
125the
126.Fl l
127option may be specified,
128which enables generation of legacy format
129.Pq v3
130entries.
131The legacy format entries are endianness dependent.
132The
133.Fl l
134option is deprecated and is not present in
135.Fx 12.0
136and later.
137.Pp
138The following options may be specified and will affect the
139generation of legacy entries.
140.Bl -tag -width flag
141.It Fl B
142Store data in big-endian format.
143.It Fl L
144Store data in little-endian format.
145.El
146.Pp
147The
148.Nm
149utility exits zero on success, non-zero on failure.
150.Sh ENVIRONMENT
151If the
152.Ev PW_SCAN_BIG_IDS
153environment variable is set,
154.Nm
155will suppress the warning messages that are
156normally generated for large user and group IDs.
157Such IDs can cause serious problems with software
158that makes assumptions about the values of IDs.
159.Sh FILES
160.Bl -tag -width Pa -compact
161.It Pa /etc/pwd.db
162The insecure password database file.
163.It Pa /etc/pwd.db.tmp
164A temporary file.
165.It Pa /etc/spwd.db
166The secure password database file.
167.It Pa /etc/spwd.db.tmp
168A temporary file.
169.It Pa /etc/master.passwd
170The current password file.
171.It Pa /etc/passwd
172A Version 7 format password file.
173.El
174.Sh EXAMPLES
175Regenerate the password database after manually editing or replacing
176the password file:
177.Bd -literal -offset -indent
178/usr/sbin/pwd_mkdb -p /etc/master.passwd
179.Ed
180.Sh COMPATIBILITY
181Previous versions of the system had a program similar to
182.Nm ,
183.Xr mkpasswd 8 ,
184which built
185.Xr dbm 3
186style databases for the password file but depended on the calling programs
187to install them.
188The program was renamed in order that previous users of the program
189not be surprised by the changes in functionality.
190.Sh SEE ALSO
191.Xr chpass 1 ,
192.Xr passwd 1 ,
193.Xr db 3 ,
194.Xr getpwent 3 ,
195.Xr passwd 5 ,
196.Xr vipw 8
197.Sh BUGS
198Because of the necessity for atomic update of the password files,
199.Nm
200uses
201.Xr rename 2
202to install them.
203This, however, requires that the file specified on the command line live
204on the same file system as the
205.Pa /etc
206directory.
207.Pp
208There are the obvious races with multiple people running
209.Nm
210on different password files at the same time.
211The front-ends to
212.Nm ,
213.Xr chpass 1 ,
214.Xr passwd 1
215and
216.Xr vipw 8 ,
217handle the locking necessary to avoid this problem.
218