Subject: Re: getpeereid() or equivalent
To: Daniel Carosone <>
From: Jason Thorpe <>
List: tech-net
Date: 07/31/2007 21:21:28
On Jul 31, 2007, at 4:59 PM, Daniel Carosone wrote:

> On Mon, Jul 30, 2007 at 02:50:09PM +0200, Arne H. Juul wrote:
>> I'm trying to port some code that on FreeBSD uses the getpeereid()
>> system call, to get the user and group IDs of a peer connected on a
>> UNIX-domain socket.
> You want getsockopt and the SO_PEERCRED option.  AFAICT, this is the
> 'conventional' way of getting this functionality across (at least)
> Linux and *BSD - the FreeBSD syscall seems to be an extra.  (Is it
> really a syscall, or a convenient library wrapper around getsockopt?)

The latter, I believe.  If we have the sockopt, might as well have the  
API call as well.

> For usage examples, see postgresql or ssh code.
> --
> Dan.

-- thorpej