Bug 853153 - passwd -l prepends '!!' to password hash where usermod -L prepends just '!'
Summary: passwd -l prepends '!!' to password hash where usermod -L prepends just '!'
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: libuser
Version: 39
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: ---
Assignee: Jakub Hrozek
QA Contact: BaseOS QE Security Team
URL:
Whiteboard:
: 1336663 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-08-30 15:39 UTC by Robert Menotte
Modified: 2024-11-11 05:42 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-11-11 05:42:00 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Robert Menotte 2012-08-30 15:39:54 UTC
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.

Comment 2 Tomas Mraz 2012-09-03 13:05:25 UTC
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.

Comment 3 Miloslav Trmač 2012-09-03 14:01:54 UTC
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).

Comment 4 Robert Menotte 2012-09-03 19:03:10 UTC
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.

Comment 5 Miloslav Trmač 2013-04-13 00:00:15 UTC
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?

Comment 6 Tomas Mraz 2013-04-15 06:53:15 UTC
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.

Comment 7 Miloslav Trmač 2013-04-15 14:34:34 UTC
(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.

Comment 8 RHEL Program Management 2013-10-14 00:29:34 UTC
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.

Comment 9 Stef Walter 2016-06-24 07:36:22 UTC
*** Bug 1336663 has been marked as a duplicate of this bug. ***

Comment 10 Tomas Mraz 2016-06-24 09:50:48 UTC
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'.

Comment 11 Tomas Mraz 2016-06-24 09:53:09 UTC
Let's move it to Fedora.

Comment 12 Jan Kurik 2016-07-26 04:46:03 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 25 development cycle.
Changing version to '25'.

Comment 13 Fedora End Of Life 2017-11-16 18:52:30 UTC
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.

Comment 14 Ben Cotton 2018-11-27 17:30:28 UTC
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.

Comment 15 Ben Cotton 2019-02-19 17:12:21 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 30 development cycle.
Changing version to '30.

Comment 16 Ben Cotton 2020-04-30 22:16:21 UTC
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.

Comment 17 Ben Cotton 2020-05-26 14:42:46 UTC
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.

Comment 18 Martin Pitt 2023-12-15 09:59:27 UTC
After 11 years this bug is still happening in current Fedora 39.

Comment 19 Aoife Moloney 2024-11-08 10:38:58 UTC
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.

Comment 20 Martin Pitt 2024-11-11 05:42:00 UTC
I just re-tested that on Fedora 41, and this is finally fixed \o/


Note You need to log in before you can comment on or make changes to this bug.