This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
sun_path for accept()'ed sockets
- To: glibc-linux at ricardo dot ecn dot wfu dot edu
- Subject: sun_path for accept()'ed sockets
- From: Wolfgang Sourdeau <wolfgang at iNsu dot com>
- Date: Tue, 9 May 2000 15:04:50 -0400 (EDT)
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
I am currently writing a client/server utility based on UNIX sockets
for GNU/Linux. The reference book I have (Advanced Programming in the
UNIX Environment, W. Richard Stevens, Add.-Wesley) doesn't provide any accurate
answer to my problem.
I would like to get the user id of the client connecting to my socket,
this from the server.
The technique mentioned in the book is to stat the socket returned by
the accept function. For whatever reason, it doesn't work.
I found out however that this resulting socket file name
(sockaddr.sun_path) begins by a '\0' and continues with some kind of
an identification which can be found with the netstat command as well.
This id seems to represent a name in a virtual table of the kernel,
but this interface is incompatible with stat.
So my questions are:
- how can you find out the UID of the client-process with the GNU C
Library?
- is there a way to find out the PID as well in a portable way ?
Wolfgang