Given a filedescriptor, how can I find source IP??

Joe Porkka jap at convex.cl.msu.edu
Wed Mar 27 03:08:37 AEST 1991


ed at mtxinu.COM (Ed Gould) writes:

>>Remember boys and girls, "getpeername()" only works on sockets.
>>I guess I was not clear - the program does not open a socket -
>>it inherits some filedescriptors (0 1 and 2).

>A program can inherit sockets, just as it can inherit files.  "File"
>descriptors can refer to either.  If you're asking about the child
>of a telnet session - which has pseudo-terminals connected to 0,
>1, and 2 - then you are out of luck.  In general, there is no way
Yes, it would seem to not be possible. It *oughta* be!

Well, we have come to a pretty workable solution to the problem.

It turns out that in SunOS3.x, inetd by default passed the ip address
as a command line arg to in.telnetd. 

In SunOS4.1 they "fixed" it so that it does not. However, you can
turn that feature back on by editing inetd.conf

So, with that feature back on, I just gotta look at my parents (in.telnetd)
command line args to get the IP address.



More information about the Comp.unix.wizards mailing list