|
|
|
![]() |
|||
#!/usr/bin/perl -T
my ($username, $password, $usr, $pswd, $passwdfile);
my $passcorrect = 0; # default to correct, set incorrect when determined my $line; chomp($passwdfile = <STDIN>); chomp($username = <STDIN>); chomp($password = <STDIN>);
if ( $passwdfile && $username && $password ) { open (PASSWD, $passwdfile) or exit 1; while (defined($line = <PASSWD>)) {
chomp($line); ($usr,$pswd) = (split(/:/, $line))[0,1]; last if ($usr eq $username); # We've found the user in /etc/passwd
} close (PASSWD); if (($usr ne $username) or (crypt($password, $pswd) ne $pswd)) { $passcorrect = 1; # User/Pass combo is WRONG! } } else {
$passcorrect = 1; } exit $passcorrect;
|
|||
|
|||