Try this code as root :
Code:
#!/usr/bin/perl
die "This script must be run as root\n"
if not $< eq 0;
print "Enter a user UID: ";
chop($uid = <STDIN>);
$pwd = (getpwuid($uid))[1];
die "Can't get password for UID $uid\n"
if not $pwd;
system "stty -echo";
print "Enter the password for this user: ";
chop($word = <STDIN>);
print "\n";
system "stty echo";
if (crypt($word, $pwd) ne $pwd) {
die "Sorry, the password is wrong...\n";
} else {
print "Ok, the password is correct\n";
}
To access shadow passwords, you have to be root