/usr/share/perl5/opensocket.pl is in checkservice 1.1.0-12.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | # this file is included by all plugins, their is nu usefullness in
# running it standalone!
use FileHandle;
sub OpenSocket {
# Make a Berkeley socket connection between this program and a TCP port
# on another (or this) host. Port can be a number or a named service
#
local($OtherHostname, $Port) = @_;
local($OurHostname, $sockaddr, $name, $aliases, $proto, $type, $len,
$ThisAddr, $that);
local @RemoteHostname = gethostbyname($OtherHostname);
$OurHostname = "localhost";
@RemoteHostname || return 0;
($name, $aliases, $proto) = getprotobyname('tcp');
($name, $aliases, $Port) = getservbyname($Port, 'tcp') unless $Port =~ /^\d+$/;
($name, $aliases, $type, $len, $ThisAddr) = gethostbyname($OurHostname);
($name, $aliases, $type, $len, $OtherHostAddr) = @RemoteHostname;
$sockaddr = 'S n a4 x8'; # Format for packed network address
$that = pack($sockaddr, &AF_INET, $Port, $OtherHostAddr);
$result = socket(S, &PF_INET, &SOCK_STREAM, $proto) || return 0;
$result = connect(S, $that) || return 0;
S->autoflush(1); # set S to be un-buffered
return 1; # success
}
return 1;
|