Passing pwd_mkdb args to pw command

Sven Willenberger sven at
Sat Jun 12 16:46:16 PDT 2004

Is there any way to pass an argument to the pw command that could be 
passed to it when it invokes pwd_mkdb to rebuild the password database. 
On a system with about 25k users, it takes an inordinate amount of time 
to rebuild the database using the pw command. Invoking the pwd_mkdb on 
the master.passwd file using the -s flag (-s 96) speeds up this process 
immensely (FreeBSD 5.2.1-Release-P8). By "immensely" I mean from nearly 
30 seconds to just under 5 seconds. The following scenario is why I ask:

Have a perl script that adds a user to the master.passwd file (yeah I 
know, dangerous, but it's only bit me twice in as many years and could 
recover with the backup the script makes).

Part of the script involves invoking system commands to make the home 
directory and change permissions on it. Unfortunately, even though 
testing for the return status, I still find that that often the chown 
system call fails with "directory not found". It would seem that the 
mkdir command returns a status of success before the directory tables 
are actually updated and/or the changes written to disk. (This happens 
regardless of whether I use the perl builtins or system() calls).

So the idea would be to invoke the pw command instead, but having a 30 
second rebuild for every user added, deleted, password changed, etc is 
kind of a show stopper here.

Has anyone patched or found a way to make this happen? If not, has 
anyone done similar to what I am trying to do or found other workarounds?



More information about the freebsd-questions mailing list