-   Slackware (
-   -   password hashes are (wrongly) stored in /etc/passwd (

NoStressHQ 06-27-2012 05:38 AM

password hashes are (wrongly) stored in /etc/passwd
Hi all,

I just realized than our /etc/passwd file holds the hash of passwords of freshly changed password users.

What I mean is usually the /etc/passwd file holds lines like:

But now I have some users having:

... It's the first time that I see the password in this place. Since 94 I've always been told that "now" passwords where stored in the '/etc/shadow' file, and that's what I've always observed since then.

We checked /etc/login.defs but couldn't find anything pointing us to an explaination.

So does anybody knows how to change this behavior ? (And so set back to the normal 'password shadowing')..



Edit: sorry, it's obvious and doesn't change the problem but I'm running Slack64 13.37 (up to date)...

tronayne 06-27-2012 08:23 AM

I had this happen some time ago (like, years).

What I was doing was copying user home directories from another machine and made a mess of it.

If I remember correctly, I was fooling around and added two user accounts to /etc/passwd manually (with vi); i.e., I copy-pasted a line from the file, changed the login name, changed the UID and saved it. I did this manually rather than using passwd as root so there was no entry in /etc/shadow and, when I did use passwd, the hashed password was written into /etc/passwd (and still no entry in /etc/shadow if I remember right.

I think -- think! -- the fix was to remove both lines from /etc/passwd then create them again with passwd; first renaming the home directories to user.bak (because passwd wants to create the home directory). When the /etc/passwd and /etc/shadow entries had been created I simply removed the new home directory and renames the "bak" directory to the proper user name, and did

chown -R /home/user
for each user name and all was well that ended.

I seem to remember that I tried manually adding entries to /etc/shadow that didn't help but I can't be sure about that.

And I never did that dumbass thing again -- whatever you did and however you did it may vary, eh?

Hope this helps some.

NoStressHQ 06-27-2012 08:46 AM


Originally Posted by tronayne (Post 4713261)
I had this happen some time ago (like, years).

What I was doing was copying user home directories from another machine and made a mess of it.

Hi tronayne,

Many thanx ! I haven't checked yet but it might be that I did the changes myself, that makes a lot of sense :).
I'm impressed how you remember the issue and solution from a problem so improbable !
I'll try to see if I can (pre-)modify the /etc/shadow file myself before overriding the password again with a final 'passwd'...
And that reminds me that on debian or so, you can't modify those files by hand without a warning and you need to use a special "vi-based" script that does all those things safely.
Anyway, I should have use the 'useradd' script, but I wanted "non interactive" user addition.

Thanks again!



GazL 06-27-2012 08:59 AM

Really have no idea how you've ended up in this situation but pwck, pwconv commands might help you clean things up (remember to take a backup of your passwd and shadow files though just in case something goes wrong).

Also, you may find the newusers command of interest.

NoStressHQ 06-27-2012 09:03 AM

Yeah I knew for the 'useradd' (or 'adduser' I never remember which way it is :) ).
I end up there because I need to know the internals in order to develop tools for easy deployment and team installs... Yeah hacking time... Isn't it one of the reason why Slackware is THE distro of (our) choice ? :)


jamesf 06-27-2012 09:13 AM

Actually, there's both useradd and adduser. IIRC, using useradd you can give options for everything from the command line, making it totally scriptable.

They're both installed by the 'shadow' package, BTW.

NoStressHQ 06-27-2012 10:48 AM


Originally Posted by jamesf (Post 4713304)
They're both installed by the 'shadow' package, BTW.

Thank you for this information.


All times are GMT -5. The time now is 03:56 PM.