Description of problem: When using passwd and usermod to lock\unlock account passwords interchangeably may end with conflict. ###usermod### usermod -L <username> will place a single exclamation mark at the beginning of the encrypted password field. This is expected normal behavior as described in the man page. usermod -U <username> will remove a single exclamation mark from the beginning of the encrypted password field. Again, this is expected behavior. ###passwd### passwd -l <username> will place two exclamation marks at the beginning of the encrypted password field. This is contrary to the man page which states, "The locking is performed by rendering the encrypted password into an invalid string (by prefixing the encrypted string with an !)." passwd -u <username> will remove all exclamation marks from the beginning of the encrypted password field as long as the password field itself does not consist of a single exclamation mark. This is contrary to the man page which implies a single exclamation mark will be removed. By using both passwd and usermod interchangeably (e.g. by different users administering the host), it may be possible to not completely unlock an account on the first attempt. The issue may present itself more severe if scripting is involved. Locking a user with passwd -l will require two invocations of usermod -U to completely unlock. Version-Release number of selected component (if applicable): ALL How reproducible: Always Steps to Reproduce: 1. passwd -l userid 2. usermod -U userid 3. attempt login by userid Actual results: User will be unable to log in as their password is still considered locked. This is due to passwd supplying two exclamation marks at the beginning of the encrypted password and usermod only removing one. Expected results: The user would be able to log in successfully as the account was intended to be unlocked. Additional info: I felt this functionality may have been intentional, but I fail to see any practical reason this should work this way. The actions taken by passwd are are at least contrary to the documentation.
The lock/unlock feature of passwd is done by libuser. CCing owner of libuser for comments. I suppose changing the functionality would have unwanted side effects so I'd really prefer changing the documentation to reflect the current situation.
The libuser behavior does contradict the documentation, and the commit logs do not indicate any reason for this behavior. There is also http://lists.opensuse.org/opensuse-bugs/2010-08/msg02301.html discussing this difference. http://en.wikipedia.org/wiki/Shadow_password suggests something else entirely. We will probably need to review all applications that use the shadow information, make sure the documentation is correct, update programs as necessary to match it (... and perhaps update usermod to handle the "!!" prefix as well).
When I posted this bug, I was unsure if there was to be a functional difference between a single and double "!" prefix. Assuming the Wikipedia entry is more or less up to date, I think a relatively quick and sufficient fix would be to update the documentation for each respective command and have usermod utilize "!!" instead of "!" for all locking actions. "NP", "!", or null signify no password is set on the account. As usermod doesn't provide a way to delete a password, I think it makes sense for it to utilize "!!". But you're right Miloslav, it will require going through every utility to make sure that those that use /etc/shadow are utilizing the lock prefix correctly.
I have filed #951743 for the usermod compatibility update; reassigning this to libuser because there's nothing to fix in passwd. I'm inclined to block the libuser change on review of other users (changing libuser might in turn break something else that expects "!!"); Tomáš, what do you think?
I do not know of anything that would expect "!!" for password locking. I'd prefer to keep the usermod -L behavior as is. For the usermod -U I would accept changing the behavior so one or two '!' are removed if the resulting password hash is not empty string.
(In reply to comment #6) > I'd prefer to keep the usermod -L behavior as is. Of course, there's no reason to change usermod -L. > For the usermod -U I would accept changing the behavior so one or two '!' > are removed if the resulting password hash is not empty string. ... it's only -U for interoperability with the (as far as we know) incorrect libuser.
This request was evaluated by Red Hat Product Management for inclusion in the current release of Red Hat Enterprise Linux. Because the affected component is not scheduled to be updated in the current release, Red Hat is unable to address this request at this time. Red Hat invites you to ask your support representative to propose this request, if appropriate, in the next release of Red Hat Enterprise Linux.
*** Bug 1336663 has been marked as a duplicate of this bug. ***
Note that usermod -U was already fixed to unlock properly accounts locked by both usermod -L and passwd -l. I am not sure whether modifying libuser is needed - it might be good for consistency in /etc/{shadow,passwd} but it will not fix anything 'user visible'.
Let's move it to Fedora.
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle. Changing version to '25'.
This message is a reminder that Fedora 25 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 25. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '25'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 25 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
This message is a reminder that Fedora 27 is nearing its end of life. On 2018-Nov-30 Fedora will stop maintaining and issuing updates for Fedora 27. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '27'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 27 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
This bug appears to have been reported against 'rawhide' during the Fedora 30 development cycle. Changing version to '30.
This message is a reminder that Fedora 30 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora 30 on 2020-05-26. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '30'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 30 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Fedora 30 changed to end-of-life (EOL) status on 2020-05-26. Fedora 30 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.
After 11 years this bug is still happening in current Fedora 39.
This message is a reminder that Fedora Linux 39 is nearing its end of life. Fedora will stop maintaining and issuing updates for Fedora Linux 39 on 2024-11-26. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a 'version' of '39'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, change the 'version' to a later Fedora Linux version. Note that the version field may be hidden. Click the "Show advanced fields" button if you do not see it. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora Linux 39 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora Linux, you are encouraged to change the 'version' to a later version prior to this bug being closed.
I just re-tested that on Fedora 41, and this is finally fixed \o/