This is the mail archive of the glibc-linux@ricardo.ecn.wfu.edu mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

sun_path for accept()'ed sockets


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]