[lkml]   [2001]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: getpeereid() for Linux
> Would anyone like to give me a helping hand in implementing the
> getpeereid() syscall for Linux? See the following page for the
> documentation of the OpenBSD implementation:
> I think I could work out the kernel data structures to gather the
> relevant data from, however, I won't get all the locking stuff right.
> OTOH, is there any chance that the addition of such a syscall would be
> accepted?

There's no need. The equivalent functionality can already be
implemented in userspace.


#include <sys/socket.h>

uid_t getpeereuid(int sd)
struct ucred cred;
int len = sizeof (cred);

if (getsockopt(sd,SOL_SOCKET,SO_PEERCRED,&cred,&len))
return -1;

return cred.uid;


The same can be done for gid, and even pid.

Yes, Linux rules.

Michael Bacarella <>
Technical Staff / System Development,
New York Connect.Net, Ltd.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:02    [W:0.228 / U:22.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site