Unix domain sockets / IPC - how to get remote process/user id?

Fossie gogr at fossie.net
Mon Feb 9 18:39:34 EST 2004


Hi folks,

I am unable to solve the following problem, which should not be new,
but I cannot find an appropriate solution anywhere:

One python process ("daemon") waits for messages. Another python
program ("client"), which is NOT forked off the daemon (but is on the
same Linux machine), sends that message to the daemon.

This of course can be nicely done with Unix domain sockets (AF_UNIX),
but additionally I want the daemon to know the process or user id of
the client. The client could of course include this info in the
message, but then it also could fake it, which I want to prevent.
Therefore it must come somewhere from the kernel.

My hope was that the address returned from socket.recvfrom would help,
but with python 2.3.3 on Debian, the returned address is always None
(a bit odd, python 2.1? at least returned a (meaningless?)
int,emptystring-tupel). I know that Unix domain sockets can return
those info (in structure called credentials), but obviously python
does not handle them?

So, for my question: What are my options? I cannot believe I am the
first with this problem. Preferable, only standard python packages
should be used.

Thanks in advance, Fossie



More information about the Python-list mailing list