]>
Commit | Line | Data |
---|---|---|
c2cf387f | 1 | #!@PERL@ |
5b95b903 AJ |
2 | ## |
3 | ## Copyright (C) 1996-2014 The Squid Software Foundation and contributors | |
4 | ## | |
5 | ## Squid software is distributed under GPLv2+ license and includes | |
6 | ## contributions from numerous individuals and organizations. | |
7 | ## Please see the COPYING and CONTRIBUTORS files for details. | |
8 | ## | |
9 | ||
e0301d3c | 10 | # POP3 authenticator for Squid |
ca02e0ec AJ |
11 | # Copyright (C) 2006 Henrik Nordstrom <henrik@henriknordstrom.net> |
12 | # | |
13 | # This program is free software; you can redistribute it and/or modify | |
14 | # it under the terms of the GNU General Public License as published by | |
15 | # the Free Software Foundation; either version 2 of the License, or | |
16 | # (at your option) any later version. | |
17 | # | |
18 | # This program is distributed in the hope that it will be useful, | |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | # GNU General Public License for more details. | |
22 | # | |
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program; if not, write to the Free Software | |
25 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. | |
e0301d3c | 26 | # |
27 | # Change log: | |
28 | # 2006-12-10 henrik Initial revision | |
29 | # | |
30 | ||
e0301d3c | 31 | use Net::POP3; |
32 | $|=1; | |
33 | ||
34 | if ( @ARGV != 1 ) { | |
35 | print STDERR "Usage: $0 popserver\n"; | |
36 | exit 1 | |
37 | } | |
38 | ||
39 | $server = shift @ARGV; | |
40 | ||
41 | while(<>) { | |
42 | my ($username, $password) = split(/\s+/); | |
43 | $username =~ s/%([0-9a-f][0-9a-f])/pack("H2",$1)/gie; | |
44 | $password =~ s/%([0-9a-f][0-9a-f])/pack("H2",$1)/gie; | |
45 | ||
46 | $pop = Net::POP3->new($server); | |
47 | if (!$pop) { | |
48 | print "ERR Server not responding\n"; | |
49 | next; | |
50 | } | |
51 | ||
52 | # Here apop could be used instead for MD5 support | |
53 | if ($pop->login($username, $password)) { | |
54 | print "OK\n"; | |
55 | } else { | |
56 | print "ERR\n"; | |
57 | } | |
58 | $pop->quit; | |
59 | undef $pop; | |
60 | } |