diff options
author | Stuart Henderson <stu@spacehopper.org> | 2017-01-27 12:56:11 (GMT) |
---|---|---|
committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-06 09:15:35 (GMT) |
commit | c2f20fdd94feb06e815a891b22f25fac10c2cc13 (patch) | |
tree | af4674cd3b4c85c93867aec12c00389d1979e245 /plugins-scripts | |
parent | be0e475339346907c86de5d797f0fab1e071f75c (diff) | |
download | monitoring-plugins-c2f20fdd94feb06e815a891b22f25fac10c2cc13.tar.gz |
use pack_sockaddr_in rather than hand-rolledrefs/pull/1932/head
On some OS, sockaddr structs include a length field. Perl's pack_sockaddr_in
takes this into account; the hand-rolled "pack('S n a4 x8'..." doesn't do so,
resulting in connection failures.
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-x | plugins-scripts/check_ircd.pl | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl index 84f2022..4822fe6 100755 --- a/plugins-scripts/check_ircd.pl +++ b/plugins-scripts/check_ircd.pl | |||
@@ -146,7 +146,6 @@ sub bindRemote ($$) | |||
146 | { | 146 | { |
147 | my ($in_remotehost, $in_remoteport) = @_; | 147 | my ($in_remotehost, $in_remoteport) = @_; |
148 | my $proto = getprotobyname('tcp'); | 148 | my $proto = getprotobyname('tcp'); |
149 | my $sockaddr; | ||
150 | my $that; | 149 | my $that; |
151 | my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); | 150 | my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); |
152 | 151 | ||
@@ -154,8 +153,7 @@ sub bindRemote ($$) | |||
154 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; | 153 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; |
155 | exit $ERRORS{"UNKNOWN"}; | 154 | exit $ERRORS{"UNKNOWN"}; |
156 | } | 155 | } |
157 | $sockaddr = 'S n a4 x8'; | 156 | $that = pack_sockaddr_in ($in_remoteport, $thataddr); |
158 | $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); | ||
159 | if (!connect(ClientSocket, $that)) { | 157 | if (!connect(ClientSocket, $that)) { |
160 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; | 158 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; |
161 | exit $ERRORS{"UNKNOWN"}; | 159 | exit $ERRORS{"UNKNOWN"}; |