CentOS 6 Linux has two ways to lock a password:
passwd -l
usermod -L
Today I found out, that they do something different.
passwd
writes two exclamation marks into the shadow file.
# passwd -d test1 Removing password for user test1. passwd: Success # passwd -l test1 Locking password for user test1. passwd: Success # passwd -S test1 test1 LK 2014-01-14 0 99999 7 -1 (Password locked.) # grep test1 /etc/shadow test1:!!:16084:0:99999:7:::
But usermod
writes only one.
# passwd -d test1 Removing password for user test1. passwd: Success # usermod -L test1 # passwd -S test1 test1 LK 2014-01-14 0 99999 7 -1 (Password locked.) # grep test1 /etc/shadow test1:!:16084:0:99999:7:::
Is this only a cosmetic inconsistency or is there a meaning for the different lock indicators?
Funny things happen, if you mix the two commands:
Lock an account with passwd
:
# passwd -l test1
Locking password for user test1.
passwd: Success
Unlock it with usermod
:
# usermod -U test1
And surprise it is still locked:
# passwd -S test1
test1 LK 2014-01-14 0 99999 7 -1 (Password locked.)
Bug or feature?
passwd -l
to lock it, then can't you useusermod -U
twice to unlock it?