Hi all,
I can't believe that I can't find the answer to this one. I have a perl script which is called by xinetd.
I want that perl script to be able to detect the remote IP address of the caller.
I presumed that it would be an environment variable but I could be wrong. I've found reference to the ENV and PASSENV arguments for xinetd.conf but no examples, and no indication of what auguments to use.
In my script I have the following code:
foreach (keys %ENV) { print "$_=$ENV{$_}\n";}
but the only line I get back is:
XINETD_LANG=en_US
On Thu, May 28, 2020 at 04:46:34PM +0100, Gary Stainburn wrote:
Hi all,
I can't believe that I can't find the answer to this one. I have a perl script which is called by xinetd.
I want that perl script to be able to detect the remote IP address of the caller.
I presumed that it would be an environment variable but I could be wrong. I've found reference to the ENV and PASSENV arguments for xinetd.conf but no examples, and no indication of what auguments to use.
In my script I have the following code:
foreach (keys %ENV) { print "$_=$ENV{$_}\n";}
but the only line I get back is:
XINETD_LANG=en_US
I don't believe that xinetd tells the underlying processes anything about IPs, since xinetd handles the network connection and as far as the process is concerned, it's just filehandles.
On 5/28/2020 8:55 AM, Jonathan Billings wrote:
I don't believe that xinetd tells the underlying processes anything about IPs, since xinetd handles the network connection and as far as the process is concerned, it's just filehandles.
Isn't the filehandle just a socket? So can't you use Perl's socket API to recover the connection information? So the next problem is to find something that wraps an existing filehandle in a Perl socket object.
Hi all,
I can't believe that I can't find the answer to this one. I have a perl script which is called by xinetd.
I want that perl script to be able to detect the remote IP address of the caller.
I presumed that it would be an environment variable but I could be wrong. I've found reference to the ENV and PASSENV arguments for xinetd.conf but no examples, and no indication of what auguments to use.
In my script I have the following code:
foreach (keys %ENV) { print "$_=$ENV{$_}\n";}
but the only line I get back is:
The variable you may want is REMOTE_HOST, at least that's what I see on a host of mine.
Regards, Simon
In article 202005281646.34790.gary.stainburn@ringways.co.uk, Gary Stainburn gary.stainburn@ringways.co.uk wrote:
Hi all,
I can't believe that I can't find the answer to this one. I have a perl script which is called by xinetd.
I want that perl script to be able to detect the remote IP address of the caller.
I presumed that it would be an environment variable but I could be wrong. I've found reference to the ENV and PASSENV arguments for xinetd.conf but no examples, and no indication of what auguments to use.
In my script I have the following code:
foreach (keys %ENV) { print "$_=$ENV{$_}\n";}
but the only line I get back is:
XINETD_LANG=en_US
Works for me. Here are my details:
1. /usr/local/bin/args:
#!/usr/bin/perl
$i=1; while(defined($_ = shift)) { printf "ARGV[%d]="%s"\n",$i++,$_; } foreach $env (keys %ENV) { printf "ENV{%s}="%s"\n",$env,$ENV{$env}; }
2. /etc/xinetd.d/args:
service args { disable = no port = 54321 type = UNLISTED socket_type = stream wait = no user = root server = /usr/local/bin/args server_args = --test log_on_failure += USERID }
3. Results of telnet 127.0.0.1 54321:
# telnet 127.0.0.1 54321 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. ARGV[1]="--test" ENV{CONSOLE}="/dev/console" ENV{PREVLEVEL}="N" ENV{SELINUX_INIT}="YES" ENV{LC_COLLATE}="en_US" ENV{RUNLEVEL}="3" ENV{LC_ALL}="en_US" ENV{previous}="N" ENV{LC_NUMERIC}="en_US" ENV{PWD}="/" ENV{LC_TIME}="en_US" ENV{LANG}="en_US" ENV{LC_MESSAGES}="en_US" ENV{runlevel}="3" ENV{INIT_VERSION}="sysvinit-2.86" ENV{SHLVL}="3" ENV{LC_MONETARY}="en_US" ENV{_}="/usr/sbin/xinetd" ENV{PATH}="/sbin:/usr/sbin:/bin:/usr/bin" ENV{vga}="773" ENV{REMOTE_HOST}="127.0.0.1" ENV{TERM}="linux" Connection closed by foreign host.
Notice the value of ENV{REMOTE_HOST}
Cheers Tony
On Thursday 28 May 2020 18:12:55 Tony Mountifield wrote:
In article 202005281646.34790.gary.stainburn@ringways.co.uk, Works for me. Here are my details:
Thanks for this Tony. This is exactly what I had expected to happen. I subsitiuted your server for mine and got exactly the same results.
The problem was not my server, but the client (Powershell on Win10) losing half of the data I returned.