Subject: Re: getpeereid() or equivalent
To: Arne H.Juul <firstname.lastname@example.org>
From: Jason Thorpe <email@example.com>
Date: 08/01/2007 10:56:11
On Aug 1, 2007, at 2:27 AM, Arne H. Juul wrote:
>> On Jul 31, 2007, at 4:59 PM, Daniel Carosone wrote:
>>> 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
> On Tue, 31 Jul 2007, Jason Thorpe wrote:
>> The latter, I believe. If we have the sockopt, might as well have
>> the API call as well.
> you're both right in that - the FreeBSD getpeereid() is just a wrapper
> around getsockopt with their LOCAL_PEERCRED option. But my NetBSD
> -current machine has neither SO_PEERCRED nor LOCAL_PEERCRED defined
Right, we don't implement that socket option yet. We'd need to do
> blackbox:~:$ uname -s -r
> NetBSD 4.99.25
> blackbox:~:$ grep -r SO_PEERCRED /usr/include/
> blackbox:~:$ grep -r LOCAL_PEERCRED /usr/include/
> blackbox:~:$ grep -r LOCAL_CREDS /usr/include/
> /usr/include/sys/un.h:#define LOCAL_CREDS 0x0001 /*
> credentials to receiver */
> only the LOCAL_CREDS that I mentioned in my first mail is defined.
>>> For usage examples, see postgresql or ssh code.
> the ssh code looks really bad to me when SO_PEERCRED is undefined.
> - Arne H. J.