RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2094216 - lslogins reports incorrect "Password is locked" status
Summary: lslogins reports incorrect "Password is locked" status
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: util-linux
Version: 9.0
Hardware: All
OS: Linux
unspecified
low
Target Milestone: rc
: ---
Assignee: Karel Zak
QA Contact: Radka Brychtova
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-06-07 07:21 UTC by Karel Zak
Modified: 2022-11-15 13:22 UTC (History)
2 users (show)

Fixed In Version: util-linux-2.37.4-6.el9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2093166
Environment:
Last Closed: 2022-11-15 11:23:24 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker RHELPLAN-124429 0 None None None 2022-06-07 07:36:42 UTC
Red Hat Product Errata RHBA-2022:8404 0 None None None 2022-11-15 11:23:32 UTC

Description Karel Zak 2022-06-07 07:21:30 UTC
+++ This bug was initially created as a clone of Bug #2093166 +++

Description of problem:

lslogins reports incorrect "Password is locked" status

After an account is locked, `lslogins` reports incorrect "Password is locked" status. `passwd -S` reports status correctly.

~~~
# passwd -l bob
Locking password for user bob.
passwd: Success

# passwd -S bob
bob LK 2022-06-02 0 99999 7 -1 (Password locked.)

# lslogins bob
Username:                           bob                                 
UID:                                1002                                
Gecos field:                                                            
Home directory:                     /home/bob                           
Shell:                              /bin/bash                           
No login:                           no                                  
Password is locked:                 no             <<<<<=====
Password not required:              no                                  
Login by password disabled:         yes                                 
Primary group:                      bob                                 
GID:                                1002                                
Hushed:                             no                                  
Password expiration warn interval:  7                                   
Password changed:                   20:00                               
Maximum change time:                99999                               
Running processes:                  0   
~~~

I think the logic in lslogin.c is incorrect. When account is locked by `passwd -l`, two exclamation marks ("!!") are inserted in front of a password hash. The source code checks for the presence of one exclamation marks ("!").

~~~
lslogins.c

case COL_PWDLOCK:
        if (shadow) {
                if (*shadow->sp_pwdp == '!' && valid_pwd(shadow->sp_pwdp + 1))
                        user->pwd_lock = STATUS_TRUE;
        } else
                user->pwd_lock = STATUS_UNKNOWN;
        break;
~~~

Version-Release number of selected component (if applicable):
util-linux-2.32.1-35.el8.x86_64

How reproducible:
100%

Steps to Reproduce:
~~~
# useradd bob

# passwd bob
Changing password for user bob.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

# passwd -S bob
bob PS 2022-06-02 0 99999 7 -1 (Password set, SHA512 crypt.)

# lslogins bob
Username:                           bob                                 
UID:                                1002                                
Gecos field:                                                            
Home directory:                     /home/bob                           
Shell:                              /bin/bash                           
No login:                           no                                  
Password is locked:                 no                                  
Password not required:              no                                  
Login by password disabled:         no                                  
Primary group:                      bob                                 
GID:                                1002                                
Hushed:                             no                                  
Password expiration warn interval:  7                                   
Password changed:                   20:00                               
Maximum change time:                99999                               
Running processes:                  0                                   

Last logs:

# passwd -l bob
Locking password for user bob.
passwd: Success

# passwd -S bob
bob LK 2022-06-02 0 99999 7 -1 (Password locked.)

# lslogins bob
Username:                           bob                                 
UID:                                1002                                
Gecos field:                                                            
Home directory:                     /home/bob                           
Shell:                              /bin/bash                           
No login:                           no                                  
Password is locked:                 no             <<<<<=====
Password not required:              no                                  
Login by password disabled:         yes            <<<<<=====
Primary group:                      bob                                 
GID:                                1002                                
Hushed:                             no                                  
Password expiration warn interval:  7                                   
Password changed:                   20:00                               
Maximum change time:                99999                               
Running processes:                  0                                   

Last logs:

# cat /etc/passwd | grep bob
bob:x:1002:1002::/home/bob:/bin/bash

# cat /etc/shadow | grep bob
bob:!!$6$.18513c.OKQEXCS/$PcBAvB<...>:19146:0:99999:7:::

# vi /etc/shadow

# cat /etc/shadow | grep bob
bob:!$6$.18513c.OKQEXCS/$PcBAvB<...>:19146:0:99999:7:::

# passwd -S bob
bob LK 2022-06-02 0 99999 7 -1 (Password locked.)

# lslogins bob
Username:                           bob                                 
UID:                                1002                                
Gecos field:                                                            
Home directory:                     /home/bob                           
Shell:                              /bin/bash                           
No login:                           no                                  
Password is locked:                 yes            <<<<<=====
Password not required:              no                                  
Login by password disabled:         no             <<<<<=====
Primary group:                      bob                                 
GID:                                1002                                
Hushed:                             no                                  
Password expiration warn interval:  7                                   
Password changed:                   20:00                               
Maximum change time:                99999                               
Running processes:                  0                                   

Last logs:
~~~

Actual results:
"Password is locked" shows "no" when account is locked.

Expected results:
"Password is locked" shows "yes" when account is locked.

Additional info:

--- Additional comment from Karel Zak on 2022-06-07 07:20:11 UTC ---

Good catch. It seems the lslogins code follows shadow(5) documentation rather than a real way of how passed(1) works.

Fixed in upstream repository:
https://github.com/util-linux/util-linux/commit/c51cba1e838ae7e36a843ec785543492bb8737cd

Comment 13 errata-xmlrpc 2022-11-15 11:23:24 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (util-linux bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:8404


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