chsh corrupts /etc/pwd.db

Miroslav Lachman 000.fbsd at quip.cz
Thu Aug 22 10:43:24 UTC 2019


Miroslav Lachman wrote on 2019/08/22 11:21:
> Alan Somers wrote on 2019/08/22 04:07:

>>> Unless, of course your master.passwd file was damaged.  But the *.db 
>>> files are really just caches for faster access to user data.  The 
>>> real master file is master.passwd.
>>>
>>>
>>> The ch* tools typically just change master.passwd, and then call 
>>> pwd_mkdb to rebuild the *.db files.
>>
>> The pwd.db file from before the snapshot only has three entries.  From
>> after, it has four, and one of them has the wrong shell.  So it does
>> seem that chsh is corrupting the file.  And fortunately the problem is
>> repeatable.  Any ideas about how to debug it?
>>
>> -Alan
>>
>> P.S. I failed to mention earlier that this is happening on 
>> 12.0-RELEASE-p10
> 
> I run in to something similar from time to time from about 10.x or 8.x 
> (i skipped 9.x)
> I do not remember exactly what command did the corruption, if it was 
> vipw or chsh or something else to manipulate user database. The fix was 
> easy - run it again or use pwd_mkdb

I searched our archive of issues and found it. It was error with "pw" 
command which sometimes failed in very weird way:

# pw useradd -n user1 -u 1003 -G wheel -s /bin/tcsh -m -M 0700 -c "User One"

pw: user 'user1' disappeared during update

It was on FreeBSD 8.x. So it is different error than yours.

Miroslav Lachman


More information about the freebsd-stable mailing list