Cannot Add User

Lowell Gilbert freebsd-questions-local at
Wed Feb 4 14:52:35 PST 2004

Vince Sabio <vince at> writes:

> ** Sometime around 09:21 -0500 02/04/2004, Lowell Gilbert sent everyone:
> >Vince Sabio <vince at> writes:
> >
> >[...]
> >  > I'm now trying to install Postfix, and the problem I'm running into is
> >>  that I cannot create new user accounts. I created several user
> >>  accounts during installation, and they seem to be fine. But when I
> >>  [manually] create entries in /etc/passwd, master.passwd, and group,
> >>  the entries are 'ignored' -- e.g., a "chown [newuser] [filename]"
> >>  command fails, attempts to su from root into the user account fail,
> >>  etc. When I try to create the user via adduser (using the standard
> >>  defaults), the account creation step fails with the following error:
> >>
> >  > pw: user '[newuser]' disappeared during update
> >
> >It sounds like you've messed up your user database.  Try running
> >pwd_mkdb(8) by hand to get it straightened out.  In future, remember
> >not to edit passwd and so forth by hand; stick with adduser(8) and/or
> >vipw(8) to avoid shooting yourself in the foot like this.
> I have to wonder if this is unique to the BSDs; I've been using
> Solaris for nearly a decade now, and the _only_ way I've ever created
> user accounts is manually -- by editing /etc/passwd, shadow, and group
> files, creating user directories, etc. I've never had a problem with
> it before. (I'm pretty sure I've done the same under Linux, too.)

Right.  By default, FreeBSD uses databases to hold account
information; the "passwd" file is present only for backward
compatibility, and the "master.passwd" is used only as an *input* 
from which the databases are created.

> Running adduser is fine for simple user accounts -- but there are few
> user accounts on a typical server. The problem with adduser is that it
> isn't well suited to things like accounts with no home directories or
> login shells, disabled passwords (not the same as a locked account),
> etc.

Normally I do those directly with vipw(8).  If I were automating
those, I'd use pw(8).

> Either way, I tried running pwd_mkdb -C /etc/passwd, and it reported a
> format error on line 3 -- which happens to be the root account, and is
> the first real data line in the file.

That file has a slightly different format:  
you wanted "pwd_mkdb /etc/master.passwd"

>                                       Moreover, it's a line that I
> didn't modify. It reported no errors on /etc/master.passwd, so I
> copied and modified it into a passwd file -- and pwd_mkdb then
> reported no errors on the new passwd file. However, that action also
> prevented any new logins, and running passwd didn't fix the problem.

Here we've got an actual problem.  There were a number of chances for
bogus data to creep into the file, but in case of future problems,
note that master.passwd is among the things that gets automatically
backed up into /var/backups.

> So, after mucking around with pwd_mkdb for a while, I opted to simply
> reinstall the OS -- it was still a rather new installation, and I
> wanted to increase the /usr partition, anyway. After completing the
> new FreeBSD installation, the first thing I did upon logging in was
> run pwd_mkdb on /etc/passwd, and it still reported a format error on
> line 3. I then manually added the necessary users, and this time the
> postfix installation ran to completion.

The postfix port adds all the necessary users for you, and does it
correctly.  [The next time you add a *real* new user, your postfix
changes will be wiped out by pwd_mkdb.]

> While it's possible that I messed up the format on the original try,
> it's unlikely -- I checked it over a dozen times before going in
> search of a FreeBSD list on which to ask the question. I'm thinking
> that there might have been something else in the mix. But either way,
> the clean install fixed it (though admittedly it was a rather
> Draconian fix).

Just use vipw(8) to make your changes to the password database, and
all the tricky bits will be handled for you. 

More information about the freebsd-questions mailing list