in reply to getpwnam() password

getpwnam() only returns the crypted password if you execute it as root.

[matt@resuna ~]$ perl -le 'print $passwd = (getpwnam("root"))[1]' * [matt@resuna ~]$ su Password: resuna# perl -le 'print $passwd = (getpwnam("root"))[1]' $2a$61$8DF//jVKvvTJ1zimSj82fdsFH/.z64H3vHlcp1FqhEOJ9HBBSiPq6
(root password changed to protect the innocent)

-Matt

Replies are listed 'Best First'.
RE: Re: getpwnam() password
by merlyn (Sage) on Aug 03, 2000 at 07:42 UTC
    Well, that's obviously true on your system. But not necessarily everywhere: getpwnam() returns whatever the underlying library call returns, so man getpwnam is your reference there.

    -- Randal L. Schwartz, Perl hacker

      Actually, on systems where the underlying getpwnam() never returns the crypted password but Perl knows how to get the crypted password, Perl's getpwnam() will return the crypted password when you are root. Some like this, some hate it. But you are right in that it doesn't work on all systems.