[MUD-Dev] Re: Question for the list (Semi-OT)

Jon Leonard jleonard at divcom.slimy.com
Mon Aug 17 13:33:21 CEST 1998


On Sun, Aug 16, 1998 at 11:59:47AM +1200, Oliver Jowett wrote:
> On Sat, 15 Aug 1998, Nathan F Yospe wrote:
> 
> > What I'm looking for is a way, on a generalized unix platform, to track the
> > process that is currently binding a descriptor to a socket, and return that
> > process's pid, without su access...
> > 
> > For example, while on the host machine, I'd like to be able to make a call,
> > int p_id = get_owner(short portnum); Where I say p_id = get_owner(5000). It
> > seems like there should be some way to recover this, but... *shrug*
> 
> Without su access could be hairy.
> 
> lsof (ftp://vic.cc.purdue.edu/pub/tools/unix/lsof) will do it, but it
> needs access to kernel memory on most systems. I think that it can work
> entirely from /proc under recent linux kernels, although you need read
> access to the appropriate /proc/nnn/* entries.

Identd is another tool to look at for example source code..

> I suspect the answer is "no" for a generic solution, and "probably no" for
> most system-specific solutions.

The answer isn't necessarily unique, either.  Fork can let the same socket
be owned by multiple processes, and games with setUID stuff can even make
them be different users.

> If you're writing code for the process in question, of course, you could
> maintain a database of port information somewhere yourself.

This is by far the best solution, of course.

Jon




More information about the mud-dev-archive mailing list