Subject: Re: getpeereid() or equivalent
To: Arne H. Juul <arnej@pvv.ntnu.no>
From: Daniel Carosone <dan@geek.com.au>
List: tech-net
Date: 08/01/2007 09:59:36
--qicHaSekiYEWE95x
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

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?)

For usage examples, see postgresql or ssh code.

--
Dan.


--qicHaSekiYEWE95x
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (NetBSD)

iD8DBQFGr8znEAVxvV4N66cRAnptAKCwy7pL7aGbis8YL0OhcU3eU7lfEACcCDBf
QkV3wd3PEF0Xien78hjPrcg=
=oLNg
-----END PGP SIGNATURE-----

--qicHaSekiYEWE95x--