Bug 8646

Summary: Perl function getpwuid() for checking users password do not work in Red Hat 6.1 (with shadow password file).
Product: [Retired] Red Hat Linux Reporter: Atanas Kolev <atanas>
Component: perlAssignee: Crutcher Dunnavant <crutcher>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-03-22 06:19:23 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Atanas Kolev 2000-01-20 06:26:05 UTC
Perl function getpwuid() for checking users password do not work in Red Hat
6.1 (with shadow password file).

I am using perl script to check password entered by user against his
password in Linux system. Below you see the code.

#!/bin/perl -w

$pwd = (getpwuid($<))[1];
system "stty -echo";
print "Password: ";
chomp($word = <STDIN>);
print "\n";
system "stty echo";
print "Encripted   pass="; print crypt($word, $pwd); print "\n";
print "You entered pass=$pwd\n";
if (crypt($word, $pwd) ne $pwd) {
    die "Sorry...\n";
} else {
    print "ok\n";
}

It is working correctly in Red Hat 5.2 system, but in Red Hat 6.1 - not.

Below is output of the program:

[atanas@pcs2133 progs]$ perl check-passwd.pl
Password:
Encripted   pass=xxCAt9eiuvfl2
You entered pass=x
Sorry...

In perlfunc manual page is written:

	Shadow password
	files are only supported if your vendor has
	implemented them in the intuitive fashion that
        calling the regular C library routines gets the
        shadow versions if you're running under privilege.
        Those that incorrectly implement a separate
        library call are not supported.

What is you solution.

P.S. I have tried to run the program from privileged (root) account that is
supposed to work - the same result.

Comment 1 Atanas Kolev 2000-03-22 06:19:59 UTC
P.S. I have tried to run the program from privileged (root) account that is
supposed to work - the same result.

Note: a little correction in upper example - comments need to be switched,
instead of

print "Encripted   pass="; print crypt($word, $pwd); print "\n";
print "You entered pass=$pwd\n";

must be:

print "You entered pass="; print crypt($word, $pwd); print "\n";
print "Encrypted   pass=$pwd\n";

and according to this resulting output will be:

You entered pass=xxCAt9eiuvfl2
Encrypted   pass=x

I think it is a serious problem especially if you have perl written interface
for user logins/password checkers, and a reasonable time of response is
appropriate.

Thank You for "fast" answers.

Comment 2 Nalin Dahyabhai 2000-08-03 11:48:34 UTC
This is working correctly in the development tree.