mirror of
https://github.com/webmin/webmin.git
synced 2025-07-23 00:30:33 +00:00
29 lines
452 B
Perl
Executable File
29 lines
452 B
Perl
Executable File
#!/usr/local/bin/perl
|
|
# squid-auth.pl
|
|
# A basic squid authentication program
|
|
|
|
use strict;
|
|
use warnings;
|
|
no warnings 'redefine';
|
|
no warnings 'uninitialized';
|
|
|
|
my %auth;
|
|
open(my $fh, "<".$ARGV[0]);
|
|
while(<$fh>) {
|
|
s/\r|\n//g;
|
|
s/#.*$//;
|
|
if (/^(\S+):(\S+)/) {
|
|
$auth{$1} = $2;
|
|
}
|
|
}
|
|
close($fh);
|
|
|
|
$| = 1;
|
|
while(<STDIN>) {
|
|
s/\r|\n//g;
|
|
my ($u, $p) = split(/\s+/, $_);
|
|
print $auth{$u} &&
|
|
$auth{$u} eq crypt($p, $auth{$u}) ? "OK\n" : "ERR\n";
|
|
}
|
|
|