]> git.ipfire.org Git - thirdparty/squid.git/blob - src/auth/basic/POP3/basic_pop3_auth.pl.in
Source Format Enforcement (#1234)
[thirdparty/squid.git] / src / auth / basic / POP3 / basic_pop3_auth.pl.in
1 #!@PERL@
2
3 use strict;
4 use Pod::Usage;
5 use Getopt::Long;
6
7 =pod
8
9 =head1 NAME
10
11 basic_pop3_auth - POP3 authenticator for Squid
12
13 =head1 SYNOPSIS
14
15 basic_pop3_auth server
16
17 =head1 DESCRIPTION
18
19 B<basic_pop3_auth> authenticates user credentials against a POP3 server.
20
21 =head1 OPTIONS
22
23 The only option this helper takes is the name of the POP3 server to validate against.
24
25 =head1 AUTHOR
26
27 This program was written by I<Henrik Nordstrom <henrik@henriknordstrom.net>>
28
29 This manual was written by I<Amos Jeffries <squid3@treenet.co.nz>>
30
31 =head1 COPYRIGHT
32
33 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
34 *
35 * Squid software is distributed under GPLv2+ license and includes
36 * contributions from numerous individuals and organizations.
37 * Please see the COPYING and CONTRIBUTORS files for details.
38
39 # Copyright (C) 2006 Henrik Nordstrom <henrik@henriknordstrom.net>
40 #
41 # This program is free software; you can redistribute it and/or modify
42 # it under the terms of the GNU General Public License as published by
43 # the Free Software Foundation; either version 2 of the License, or
44 # (at your option) any later version.
45 #
46 # This program is distributed in the hope that it will be useful,
47 # but WITHOUT ANY WARRANTY; without even the implied warranty of
48 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 # GNU General Public License for more details.
50 #
51 # You should have received a copy of the GNU General Public License
52 # along with this program; if not, write to the Free Software
53 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
54 #
55 # Change log:
56 # 2006-12-10 henrik Initial revision
57 #
58
59 =head1 QUESTIONS
60
61 Questions on the usage of this program can be sent to the I<Squid Users mailing list <squid-users@lists.squid-cache.org>>
62
63 =head1 REPORTING BUGS
64
65 Bug reports need to be made in English.
66 See http://wiki.squid-cache.org/SquidFaq/BugReporting for details of what you need to include with your bug report.
67
68 Report bugs or bug fixes using http://bugs.squid-cache.org/
69
70 Report serious security bugs to I<Squid Bugs <squid-bugs@lists.squid-cache.org>>
71
72 Report ideas for new improvements to the I<Squid Developers mailing list <squid-dev@lists.squid-cache.org>>
73
74 =head1 SEE ALSO
75
76 squid (8), GPL (7),
77
78 The Squid FAQ wiki http://wiki.squid-cache.org/SquidFaq
79
80 The Squid Configuration Manual http://www.squid-cache.org/Doc/config/
81
82 =cut
83
84 use Net::POP3;
85 $|=1;
86
87 if ( @ARGV != 1 ) {
88 print STDERR "Usage: $0 popserver\n";
89 exit 1
90 }
91
92 my $server = shift @ARGV;
93
94 while(<>) {
95 my ($username, $password) = split(/\s+/);
96 $username =~ s/%([0-9a-f][0-9a-f])/pack("H2",$1)/gie;
97 $password =~ s/%([0-9a-f][0-9a-f])/pack("H2",$1)/gie;
98
99 my $pop = Net::POP3->new($server);
100 if (!$pop) {
101 print "ERR Server not responding\n";
102 next;
103 }
104
105 # Here apop could be used instead for MD5 support
106 if ($pop->login($username, $password)) {
107 print "OK\n";
108 } else {
109 print "ERR\n";
110 }
111 $pop->quit;
112 undef $pop;
113 }