2

I'm having a weird problem, and I don't know if I've screwed something up or this is the way it's supposed to be and I never noticed..

Using passwd and chpasswd to change a users password works as expected, /etc/passwd is ignored and /etc/shadow is updated.

Using passwd and chpasswd to change the root users password does the opposite; /etc/passwd is updated and /etc/shadow is ignored.

I checked permissions on /etc/shadow, it is 0644, same as /etc/passwd.

This is a CentOS 5.9 system, updated in the last few months, yum update shadow-utils show no updates and rpm -q shadow-utils shows shadow-utils-4.0.17-21.el5.

What the heck is going on?

harleypig
  • 121

2 Answers2

0

I know that this is an old question but I just ran into this problem and I think I figured out what was going on for me.

My implementation of chpasswd (busybox 1.35) is written such that if the user is not found in the /etc/shadow file then the password is written to the /etc/passwd file. Upon inspecting the /etc/shadow file, sure enough the root user line was missing, I added it back and all is right with the world.

I still don't know how the root user got removed from the shadow file on my system (it's an embedded system so it should have been there).

-1

You might try the Methods in this other answer from Rahul Patil, it worked for me.

the one I used was echo "root:" | chpasswd

that updates the encrypted password in the second field of /etc/shadow

the other fields in shadow are the ones affected by the command chage

Here is the man of shadow, but see the primary command related to that file is chage, so try to use chage first for the other fields in shadow that is not the user and encrypted password