Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Oct 96 20:20:40 PST
From:      BRETT_GLASS@infoworld.com
To:        questions@freebsd.org
Subject:   Programming question: How to identify owner of a socket?
Message-ID:  <9609168455.AA845521883@ccgate.infoworld.com>

next in thread | raw e-mail | index | archive | help
I'm writing a TCP/IP daemon (initially in Perl; probably in C
eventually) to run on a FreeBSD machine which functions as a terminal
server.  The users who dial in on the modems use SLiRP to connect via
PPP or SLIP. (This means that they will all appear to have the same IP
address: the IP address of the local host.)

For security reasons, I'd like the daemon to accept requests from
users on the modems only -- not from across the Net. I'd also like it to be
able to identify the user making each request.

To do this, the daemon has to verify that the client's IP address
matches that of the local host. It should then verify that the client's IP
port number belongs to a local instance of SLiRP.  Finally, it should
identify the user by looking up the owner of the SLiRP process.

I'm sure all of this is possible. However, since I'm not experienced at
building IP daemons under UNIX, I don't know quite how to do it. What are
the system calls that:

Let a daemon find the IP address of the connecting client?

Let it find the IP port number of the connecting client?

Map the IP port number to a process and user on the local machine?

And can these all be called from Perl, so I can do the first draft of the
daemon without coding it in C?

Any help will be much appreciated.

--Brett Glass




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9609168455.AA845521883>