Bug 1016516

Summary: usermod exits with exit status 0 even when it fails.
Product: Red Hat Enterprise Linux 6 Reporter: Christos Triantafyllidis <ctrianta>
Component: shadow-utilsAssignee: Tomas Mraz <tmraz>
Status: CLOSED ERRATA QA Contact: Dalibor Pospíšil <dapospis>
Severity: high Docs Contact:
Priority: high    
Version: 6.4CC: dapospis, jbuchta, jon.fautley, kabbott
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: shadow-utils-4.1.4.2-14.el6 Doc Type: Bug Fix
Doc Text:
Cause: The usermod code did not properly handle creation of new entry in /etc/shadow. Consequence: The usermod -p command failed to set the new password if the entry in /etc/shadow file was missing. Fix: The usermod code now properly creates new entry in /etc/shadow if it is missing. Result: The usermod -p command sets the new password correctly even if the user's entry in /etc/shadow is missing.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-14 07:17:20 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 994246, 1056252    

Description Christos Triantafyllidis 2013-10-08 10:05:24 UTC
Description of problem:
When the usermod is requested to change the password of a user that is not listed in /etc/shadow it returns exit code 0 although it fails.

Version-Release number of selected component (if applicable):
shadow-utils-4.1.4.2-13.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Create a local user:
# useradd -M -u 99999 -g 99 -c 'Test Local User' testluser
[root@jumphost ~]# id testluser
uid=99999(testluser) gid=99(nobody) groups=99(nobody)
2. Set a password (optional):
# echo "pass" | passwd --stdin testluser
Changing password for user testluser.
passwd: all authentication tokens updated successfully.

3. Verify: 
# grep testluser /etc/shadow
testluser:$6$z4ZsFGEN$Tlp8Nrhe53RIp8XdgiNBSb0g1o./4kXh7vWgCH2Bn1Pc/7sNJ8/hE9KbNUBbUz3L/rmGNry8Ma4JewvwzSX1F.:15978:0:99999:7:::
# grep testluser /etc/passwd
testluser:x:99999:99:Test Local User:/home/testluser:/bin/bash

4. Remove user's entry from /etc/shadow:
# sed -i -e '/^testluser:/d' /etc/shadow
# grep testluser /etc/shadow

5. Attempt to set user password with usermod:
# usermod -p 'XinvalidX' testluser
# echo $?
0

6. Check the shadow file:
# grep testluser /etc/shadow

Actual results:
No entries returned in /etc/shadow and no error code in usermod

Expected results:
Either an error message in usermod or a new entry in /etc/shadow

Additional info:

Comment 1 RHEL Program Management 2013-10-13 23:02:25 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 5 Tomas Mraz 2014-06-05 13:21:20 UTC
The backported fix causes usermod to create new shadow entry if it is missing if the contents of the passwd entry indicates that the user has shadow password. Otherwise the passwd entry is modified with the new password.

Comment 8 errata-xmlrpc 2014-10-14 07:17:20 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHBA-2014-1522.html