Bug 1016516 - usermod exits with exit status 0 even when it fails.
usermod exits with exit status 0 even when it fails.
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: shadow-utils (Show other bugs)
Unspecified Unspecified
high Severity high
: rc
: ---
Assigned To: Tomas Mraz
Dalibor Pospíšil
Depends On:
Blocks: 994246 1056252
  Show dependency treegraph
Reported: 2013-10-08 06:05 EDT by Christos Triantafyllidis
Modified: 2015-02-01 18:11 EST (History)
4 users (show)

See Also:
Fixed In Version: shadow-utils-
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:
Last Closed: 2014-10-14 03:17:20 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Christos Triantafyllidis 2013-10-08 06:05:24 EDT
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):

How reproducible:

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
# 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 $?

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 Product and Program Management 2013-10-13 19:02:25 EDT
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 09:21:20 EDT
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 03:17:20 EDT
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.


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