Gah. I always get those backwards. I actually typed "SCM_RIGHTS" and then changed it to "SCM_CREDENTIALS". I still don't understand why fd passing is called "rights".On Tue, Jan 27, 2015 at 11:25 AM, Simon McVittie <simon mcvittie collabora co uk> wrote:On 27/01/15 15:55, Jasper St. Pierre wrote:
> Wayland requires two features that would perhaps make it unportable: FD
> passing (SCM_CREDENTIALS), and shared memory (allocate a temporary
> files, ftruncate it, mmap it, unlink it and then send the fd across the
> wire). Everything else is just a simple Unix domain socket. Does OS X
> support those two features?
I think you mean SCM_RIGHTS?
SCM_RIGHTS is "here's a message with an open fd attached". It's how
D-Bus does fd-passing, so if D-Bus fd-passing works on your favourite
platform, Wayland fd-passing should too.
SCM_CREDENTIALS is "here's a message with my uid, gid and pid[1]
attached, the kernel will check that I haven't lied to you" (also called
SCM_CREDS on e.g. FreeBSD). Basically every Unix has either this or a
syscall to query those things or both, but most Unixes also have their
own unique spelling for the API, because standards are hard.[2]
S
[1] Strictly speaking "the uid, gid and pid I had at the time I opened
this socket"
[2] Except that FreeBSD, Dragonfly BSD and Hurd share SCM_CREDS, and
several platforms (sadly not including Linux) share getpeereid(). For
the gory details see libdbus source code.