diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-09-19 05:44:10 (GMT) |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-09-19 06:08:51 (GMT) |
commit | bc3c8c7cfbdbce716e8987bee211f69911ea8db2 (patch) | |
tree | d8a4c258be08fed8ac64346506683ca22641f007 | |
parent | e82b6118400d9cfa76412f562f4b4b9b7262fdcd (diff) | |
download | monitoring-plugins-bc3c8c7cfbdbce716e8987bee211f69911ea8db2.tar.gz |
Fix check_ircd binding to wrong interface (#668778)
-rw-r--r-- | NEWS | 3 | ||||
-rwxr-xr-x | plugins-scripts/check_ircd.pl | 21 |
2 files changed, 8 insertions, 16 deletions
@@ -1,5 +1,8 @@ | |||
1 | This file documents the major additions and syntax changes between releases. | 1 | This file documents the major additions and syntax changes between releases. |
2 | 2 | ||
3 | 1.4.15 ... | ||
4 | Fix check_ircd binding to wrong interface (#668778) | ||
5 | |||
3 | 1.4.14 16th September 2009 | 6 | 1.4.14 16th September 2009 |
4 | check_http has options to specify the HTTP method (#2155152) | 7 | check_http has options to specify the HTTP method (#2155152) |
5 | check_users thresholds were not working exactly as documented (>= rather than >) | 8 | check_users thresholds were not working exactly as documented (>= rather than >) |
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index cc730cf..3fbce2e 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl | |||
@@ -59,7 +59,7 @@ use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | |||
59 | sub print_help (); | 59 | sub print_help (); |
60 | sub print_usage (); | 60 | sub print_usage (); |
61 | sub connection ($$$$); | 61 | sub connection ($$$$); |
62 | sub bindRemote ($$$); | 62 | sub bindRemote ($$); |
63 | 63 | ||
64 | # -------------------------------------------------------------[ Enviroment ]-- | 64 | # -------------------------------------------------------------[ Enviroment ]-- |
65 | 65 | ||
@@ -141,28 +141,20 @@ Perl Check IRCD plugin for Nagios | |||
141 | 141 | ||
142 | # -------------------------------------------------------------[ bindRemote ]-- | 142 | # -------------------------------------------------------------[ bindRemote ]-- |
143 | 143 | ||
144 | sub bindRemote ($$$) | 144 | sub bindRemote ($$) |
145 | { | 145 | { |
146 | my ($in_remotehost, $in_remoteport, $in_hostname) = @_; | 146 | my ($in_remotehost, $in_remoteport) = @_; |
147 | my $proto = getprotobyname('tcp'); | 147 | my $proto = getprotobyname('tcp'); |
148 | my $sockaddr; | 148 | my $sockaddr; |
149 | my $this; | ||
150 | my $thisaddr = gethostbyname($in_hostname); | ||
151 | my $that; | 149 | my $that; |
152 | my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); | 150 | my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); |
153 | # ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($in_hostname); | ||
154 | 151 | ||
155 | if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { | 152 | if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { |
156 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; | 153 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; |
157 | exit $ERRORS{"UNKNOWN"}; | 154 | exit $ERRORS{"UNKNOWN"}; |
158 | } | 155 | } |
159 | $sockaddr = 'S n a4 x8'; | 156 | $sockaddr = 'S n a4 x8'; |
160 | $this = pack($sockaddr, AF_INET, 0, $thisaddr); | ||
161 | $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); | 157 | $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); |
162 | if (!bind(ClientSocket, $this)) { | ||
163 | print "IRCD UNKNOWN: Could not bind socket ($!)\n"; | ||
164 | exit $ERRORS{"UNKNOWN"}; | ||
165 | } | ||
166 | if (!connect(ClientSocket, $that)) { | 158 | if (!connect(ClientSocket, $that)) { |
167 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; | 159 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; |
168 | exit $ERRORS{"UNKNOWN"}; | 160 | exit $ERRORS{"UNKNOWN"}; |
@@ -221,13 +213,10 @@ MAIN: | |||
221 | 213 | ||
222 | alarm($TIMEOUT); | 214 | alarm($TIMEOUT); |
223 | 215 | ||
224 | chomp($hostname = `/bin/hostname`); | ||
225 | $hostname = $1 if ($hostname =~ /([-.a-zA-Z0-9]+)/); | ||
226 | my ($name, $alias, $proto) = getprotobyname('tcp'); | 216 | my ($name, $alias, $proto) = getprotobyname('tcp'); |
227 | print "MAIN(debug): hostname = $hostname\n" if $verbose; | ||
228 | 217 | ||
229 | print "MAIN(debug): binding to remote host: $remotehost -> $remoteport -> $hostname\n" if $verbose; | 218 | print "MAIN(debug): binding to remote host: $remotehost -> $remoteport\n" if $verbose; |
230 | my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname); | 219 | my $ClientSocket = &bindRemote($remotehost,$remoteport); |
231 | 220 | ||
232 | print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; | 221 | print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; |
233 | 222 | ||