...
Code Block | ||||
---|---|---|---|---|
| ||||
my $host = `hostname`; chop($host); my $prompt = "$ENV{USER}\@$host"; sub validate_password { my ($prompt, $password) = @_; my $is_ok = ($password eq "goodpass"); printf "$prompt: Password ok? %d\n", $is_ok; return $is_ok; }; my $host = `hostname`; chop($host); my $prompt = "$ENV{USER}\@$host"; if (validate_password( $prompt, $ARGV[0])) { print "$prompt: access granted\n"; } else { print "$prompt: access denied\n"; }; |
The program works as expected as long as the user name and host name are benign:
...
Code Block | ||||
---|---|---|---|---|
| ||||
sub validate_password {
my ($prompt, $password) = @_;
my $is_ok = ($password eq "goodpass");
print "$prompt: Password ok? $is_ok\n";
return $is_ok;
};
# ...
|
...