summaryrefslogtreecommitdiffstats
path: root/web/attachments/50702-check_pop3.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/50702-check_pop3.patch')
-rw-r--r--web/attachments/50702-check_pop3.patch213
1 files changed, 213 insertions, 0 deletions
diff --git a/web/attachments/50702-check_pop3.patch b/web/attachments/50702-check_pop3.patch
new file mode 100644
index 0000000..2c897e3
--- /dev/null
+++ b/web/attachments/50702-check_pop3.patch
@@ -0,0 +1,213 @@
1*** check_pop3.pl.orig 2002-02-27 22:42:53.000000000 -0800
2--- check_pop3.pl 2003-05-19 14:57:06.000000000 -0700
3***************
4*** 23,32 ****
5 # with perl -wT and 'use strict'
6 # 2000/01/20 RM Corrected POP3 Exit State.
7 # 2000/01/21 RM Fix Exit Codes Again!!
8 # ------------------------------------------------------------------------------
9
10 # -----------------------------------------------------------------[ Require ]--
11! require 5.004;
12
13 # --------------------------------------------------------------------[ Uses ]--
14 use Socket;
15--- 23,34 ----
16 # with perl -wT and 'use strict'
17 # 2000/01/20 RM Corrected POP3 Exit State.
18 # 2000/01/21 RM Fix Exit Codes Again!!
19+ # 2003/05/17 CS Cleaned up little, simplifed logic flow, better
20+ # checking of return status from server.
21 # ------------------------------------------------------------------------------
22
23 # -----------------------------------------------------------------[ Require ]--
24! use 5.004;
25
26 # --------------------------------------------------------------------[ Uses ]--
27 use Socket;
28***************
29*** 37,43 ****
30 $ENV{BASH_ENV} = "";
31 $|=1;
32 # ------------------------------------------------------------------[ Global ]--
33! my $TIMEOUT = 60;
34
35 # -------------------------------------------------------------------[ usage ]--
36 sub usage
37--- 39,46 ----
38 $ENV{BASH_ENV} = "";
39 $|=1;
40 # ------------------------------------------------------------------[ Global ]--
41! my $TIMEOUT = 30;
42! my $DEBUG = 0;
43
44 # -------------------------------------------------------------------[ usage ]--
45 sub usage
46***************
47*** 65,78 ****
48 my $that;
49 my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost);
50
51! if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { die $!; }
52 $sockaddr = 'S n a4 x8';
53 $this = pack($sockaddr, AF_INET, 0, $thisaddr);
54 $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr);
55! if (!bind(ClientSocket, $this)) { print "Connection Refused"; exit 2; }
56! if (!connect(ClientSocket, $that)) { print "Connection Refused"; exit 2; }
57! select(ClientSocket); $| = 1; select(STDOUT);
58! return \*ClientSocket;
59 }
60
61 # ====================================================================[ MAIN ]==
62--- 68,88 ----
63 my $that;
64 my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost);
65
66! if (!socket(POPS,AF_INET, SOCK_STREAM, $proto)) {
67! err("$!");
68! }
69 $sockaddr = 'S n a4 x8';
70 $this = pack($sockaddr, AF_INET, 0, $thisaddr);
71 $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr);
72! if (!bind(POPS, $this)) {
73! err("$!");
74! }
75! if (!connect(POPS, $that)) {
76! err("$!");
77! }
78! select(POPS); $|=1;
79! select(STDOUT); $|=1;
80! return \*POPS;
81 }
82
83 # ====================================================================[ MAIN ]==
84***************
85*** 86,92 ****
86
87 # Just in case of problems, let's not hang Nagios
88 $SIG{'ALRM'} = sub {
89! print "Something is Taking a Long Time, Increase Your TIMEOUT (Currently Set At $TIMEOUT Seconds)\n";
90 exit -1;
91 };
92
93--- 96,102 ----
94
95 # Just in case of problems, let's not hang Nagios
96 $SIG{'ALRM'} = sub {
97! print "POP3 Error: Timeout after $TIMEOUT seconds\n";
98 exit -1;
99 };
100
101***************
102*** 94,144 ****
103
104 chop($hostname = `hostname`);
105 my ($name, $alias, $proto) = getprotobyname('tcp');
106! my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname);
107!
108!
109! print ClientSocket "user $username\n";
110!
111! #Debug Server
112! #print "user $username\n";
113!
114! #Sleep or 3 secs, incase server is slow.
115! sleep 3;
116
117! print ClientSocket "pass $password\n";
118!
119! #Debug Server
120! #print "pass $password\n";
121!
122! while (<ClientSocket>) {
123
124! print ClientSocket "pass $password\n";
125
126! #Debug Server
127! #print $_;
128
129! err($_) if (m/\-ERR\s+(.*)\s+.*/);
130! message($_) if (m/\+OK Mailbox open,\s+(.*\d)\s+messages.*/);
131! }
132 }
133
134! sub message
135 {
136! my $answer = "UNKNOWN";
137! $answer = "Pop3 OK - Total Messages On Server :- $1";
138! alarm(0);
139! print ClientSocket "quit\n";
140! print "$answer";
141! exit 0;
142 }
143
144 sub err
145 {
146! my $answer = "UNKNOWN";
147! $answer = "Pop3 Error :- $1";
148 alarm(0);
149! print ClientSocket "quit\n";
150! print "$answer";
151 exit 2;
152 }
153
154--- 104,162 ----
155
156 chop($hostname = `hostname`);
157 my ($name, $alias, $proto) = getprotobyname('tcp');
158! my $POPS = &bindRemote($remotehost,$remoteport,$hostname);
159
160! # Wait for server to come ready
161! alarm($TIMEOUT);
162! $_ = <POPS>;
163! if (! /^.OK/) { err($_, *POPS); }
164! print STDERR "<< $_" if $DEBUG;
165
166! # Send login name
167! alarm($TIMEOUT);
168! print STDERR ">> user $username\n" if $DEBUG;
169! print POPS "user $username\n";
170! $_ = <POPS>;
171! if (! /^.OK/) { err($_, *POPS); }
172! print STDERR "<< $_" if $DEBUG;
173
174! # Send login password
175! alarm($TIMEOUT);
176! print STDERR ">> pass $password\n" if $DEBUG;
177! print POPS "pass $password\n";
178! $_ = <POPS>;
179! if (! /^.OK/) { err($_, *POPS); }
180! print STDERR "<< $_" if $DEBUG;
181!
182! # Return the good news
183! print "POP3 OK - $_";
184
185! logout(*POPS);
186 }
187
188! sub logout
189 {
190! my $pops = shift;
191!
192! print STDERR ">> quit\n" if $DEBUG;
193! print $pops "quit\n";
194! $_ = <$$pops>;
195! print STDERR "<< $_" if $DEBUG;
196! close($pops);
197! print STDERR "\nClosed socket\n" if $DEBUG;
198!
199 }
200
201 sub err
202 {
203! my ($msg, $pops) = @_;
204!
205 alarm(0);
206! print "POP3 Error: $msg";
207!
208! if (defined($pops)) {
209! logout($pops);
210! }
211 exit 2;
212 }
213