[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Remote IP for inetd "daemon"

On Tue, 18 Sep 2001 09:55:06 PDT, "Jeremy C. Reed" writes:
>On Tue, 18 Sep 2001, Marcel Hicking wrote:
>> I have a script invoked via inetd.
>> How can I let the script know of the IP of the client
>> connecting (remote IP)?
>> I need to do some additional security checks not
>> possible with hosts.access|deny
>> Any hints?
>getpeername(2) is the C library function to get the remote IP. This works
>for me:
>Then compile it with "gcc -o getpeername getpeername.c". Then use the
>getpeername executable in your script.

Hmm, this doesn´t work for me. If I invoke it via
sunrpc stream tcp nowait nobody /usr/local/bin/test.sh test.sh

/usr/local/bin/getpeername >>/tmp/peer.ip

only a \n is logged to the file (so permissions et al are ok ;-) ).

However, if I do
sunrpc stream tcp nowait nobody /usr/local/bin/getpeername getpeername

waldner@st:~$ telnet ka 111
Connected to ka.
Escape character is '^]'. closed by foreign host.

(IPs obfuscated)

What am I doing wrong?

/ Ing. Robert Waldner |  <r.waldner@xsoft.at>  \
\     Xsoft GmbH      | T: +43 1 796 36 36 692 /

Attachment: pgpbRFh0Q1ehx.pgp
Description: PGP signature

Reply to: