Handle hostnames with upper-case letters
[webmin.git] / squid / squid-auth.pl
1 #!/usr/local/bin/perl
2 # squid-auth.pl
3 # A basic squid authentication program
4
5 open(AUTH, $ARGV[0]);
6 while(<AUTH>) {
7         s/\r|\n//g;
8         s/#.*$//;
9         if (/^(\S+):(\S+)/) {
10                 $auth{$1} = $2;
11                 }
12         }
13 close(AUTH);
14
15 $| = 1;
16 while(<STDIN>) {
17         s/\r|\n//g;
18         local ($u, $p) = split(/\s+/, $_);
19         print $auth{$u} &&
20               $auth{$u} eq crypt($p, $auth{$u}) ? "OK\n" : "ERR\n";
21         }
22