PWD_MKDB(8)

๐Ÿ“ฆ
version 1042.100.6.0.1 ยท 3 versions
, in nixpkgs unstable

๐ŸŽ€ PWD_MKDB(8) ๐ŸŽ€

okay bestie, welcome to pwd_mkdb โ€” the password-database generator that is, and I cannot stress this enough, living its best retired life on macOS. Buckle in, this one's got lore. ๐Ÿ’…


โœจ NAME โœจ

pwd_mkdb โ€” generate the password databases ๐Ÿซถ


โœจ SYNOPSIS โœจ

pwd_mkdb [-ciN] [-p | -s] [-d directory] [-S cachesize] [-u username]
         file

like, that's the whole vibe. one file, a handful of flags, zero chill. ๐ŸŒธ


โœจ DESCRIPTION โœจ

so here's the tea: the pwd_mkdb utility serves no purpose in macOS and is included solely for backward compatibility. it's basically the group chat member who's still here from 2011 and we keep them around out of love. ๐Ÿ˜ญ

the -c and -p flags โ€” plus any options that modify the behavior of those flags โ€” still work. the -s flag has no effect. like, none. it's giving decorative. ๐Ÿ’€

see DirectoryService(8) for information on identity management in macOS. that's where the real main character energy lives now. ๐Ÿ‘‘


โœจ LEGACY DESCRIPTION โœจ

okay so back in the day (and this is the part that still technically runs), the pwd_mkdb utility creates db(3) style secure and insecure databases for the specified file. those databases then get installed into /etc/spwd.db and /etc/pwd.db respectively, and the file itself gets installed into /etc/master.passwd. no cap. ๐Ÿฆ‹

the file must be in the correct format (see passwd(5)). and it is important to note that the format used in this system is different from the historic Version 7 style format. like, do not mix them up, i'm begging. ๐Ÿ™ˆ

the options are as follows:

  • -c โ€” check if the password file is in the correct format. that's it. do not change, add, or remove any files. purely a vibe check, no edits. โœ…
  • -d directory โ€” store databases into the specified destination directory instead of /etc. pick your own home, icon behavior. ๐Ÿ 
  • -i โ€” ignore locking failure of the master.passwd file. this option is intended to be used to build password files in the release process over NFS where no contention can happen. heads up: a non-default directory must also be specified with the -d option for locking to be ignored, and other use of this option is strongly discouraged. like, i said what i said. โš ๏ธ
  • -N โ€” tell pwd_mkdb to exit with an error if it cannot obtain a lock on the file. by default, we block waiting for a lock on the source file โ€” and the lock is held through the rebuilding of the database. so -N is the "no, i'm not waiting, bye" flag. ๐Ÿšช๐Ÿ’จ
  • -p โ€” create a Version 7 style password file and install it into /etc/passwd. cannot be used in conjunction with the -s flag. they are literally not friends. ๐Ÿ™…โ€โ™€๏ธ
  • -S cachesize โ€” specify in megabytes the size of the memory cache used by the hashing library. on systems with a large user base, a small cache size can lead to prohibitively long database file rebuild times. as a rough guide, the memory usage of pwd_mkdb in megabytes will be a little bit more than twice the figure specified here. the default is 2 megabytes. so like, do the math bestie. ๐Ÿงฎ
  • -s โ€” only update the secure version of the database. most commonly used in conjunction with the -u flag during a password change. because the insecure database doesn't contain the password, there's no reason to update it if the only change is in the password field. cannot be used in conjunction with the -p flag. again: not friends. ๐Ÿ’”
  • -u username โ€” only update the record for the specified user. utilities that operate on a single user can use this option to avoid the overhead of rebuilding the entire database. it's giving targeted, efficient, slay. ๐ŸŽฏ

the two databases differ in that the secure version contains the user's encrypted password and the insecure version has an asterisk (''*'')

okay so the original sentence literally cuts off right there โ€” that's not me being mysterious, that's the manpage being mysterious. the asterisk is the whole story and then it justโ€ฆ stops. ๐Ÿ™ˆ

the databases are used by the C library password routines (see getpwent(3)). ๐Ÿ”ฅ

the pwd_mkdb utility exits zero on success, non-zero on failure. classic.


โœจ ENVIRONMENT โœจ

  • PW_SCAN_BIG_IDS โ€” if this environment variable is set, pwd_mkdb will suppress the warning messages that are normally generated for large user and group IDs. such IDs can cause serious problems with software that makes assumptions about the values of IDs. so like, suppressing the warning doesn't fix the problem, bestie, it just mutes the notification. ๐Ÿซฃ

โœจ FILES โœจ

  • /etc/pwd.db โ€” the insecure password database file.
  • /etc/pwd.db.tmp โ€” a temporary file.
  • /etc/spwd.db โ€” the secure password database file.
  • /etc/spwd.db.tmp โ€” a temporary file.
  • /etc/master.passwd โ€” the current password file.
  • /etc/passwd โ€” a Version 7 format password file.

look at all these little files living their truth. ๐Ÿ“


โœจ EXAMPLES โœจ

regenerate the password database after manually editing or replacing the password file:

/usr/sbin/pwd_mkdb -p /etc/master.passwd

that's it. that's the example. iconic. ๐Ÿ‘‘


โœจ COMPATIBILITY โœจ

previous versions of the system had a program similar to pwd_mkdb called mkpasswd(8), which built dbm(3) style databases for the password file but depended on the calling programs to install them. the program was renamed in order that previous users of the program not be surprised by the changes in functionality. basically they rebranded so nobody would be jumpscared. considerate fr fr. ๐Ÿงš


โœจ SEE ALSO โœจ

chpass(1), passwd(1), db(3), getpwent(3), passwd(5), vipw(8)

go read those, they're all lowkey connected. ๐ŸŒˆ


โœจ BUGS โœจ

  • because of the necessity for atomic update of the password files, pwd_mkdb uses rename(2) to install them. this, however, requires that the file specified on the command line live on the same file system as the /etc directory. cross-device? not happening. ๐Ÿšซ
  • there are the obvious races with multiple people running pwd_mkdb on different password files at the same time. the front-ends to pwd_mkdb โ€” chpass(1), passwd(1) and vipw(8) โ€” handle the locking necessary to avoid this problem. so like, use the front-ends, they're the responsible ones. ๐Ÿ’€

and that's the page!! written by the Debian crew, dated December 20, 2023, filed under PWD_MKDB(8) in the System Manager's Manual. mwah, drink water, back up your /etc. ๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from