From owner-freebsd-questions Wed Oct 16 20:14:53 1996 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id UAA28006 for questions-outgoing; Wed, 16 Oct 1996 20:14:53 -0700 (PDT) Received: from lserver.infoworld.com (lserver.infoworld.com [192.216.48.4]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id UAA27999 for ; Wed, 16 Oct 1996 20:14:50 -0700 (PDT) From: BRETT_GLASS@infoworld.com Received: from ccgate.infoworld.com (ccgate.infoworld.com [192.216.49.101]) by lserver.infoworld.com (8.7.5/8.7.3/GNAC-GW-1.2) with SMTP id UAA03244 for ; Wed, 16 Oct 1996 20:14:43 -0700 (PDT) Received: from ccMail by ccgate.infoworld.com (SMTPLINK V2.11) id AA845521883; Wed, 16 Oct 96 20:20:40 PST Date: Wed, 16 Oct 96 20:20:40 PST Message-Id: <9609168455.AA845521883@ccgate.infoworld.com> To: questions@freebsd.org Subject: Programming question: How to identify owner of a socket? Sender: owner-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk 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