Re: RFC: GtkPreview library



On Tue, Jan 27, 2015 at 8:49 AM, Jasper St. Pierre <jstpierre mecheye net> wrote:
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.

I put it to the test and tried to build Jasper's proof of concept (and therefore Wayland) on OSX. I didn't get very far. Wayland's configure.ac checks for SFD_CLOEXEC and TFD_CLOEXEC which implies that it uses signalfd() and timerfd(), not available on OSX. I guess the replacement would be something with kqueue though I really haven't the faintest idea what I'm talking about there.

Wayland also wants clock_gettime() - not insurmountable to provide on OSX but afaik uses a different API, quick googling showed up this: http://stackoverflow.com/a/6725161/172999

PS. Funny thing that this is one of the top results for googling SFD_CLOEXEC, even without adding "osx" or "wayland": http://stackoverflow.com/questions/27864027/sfd-cloexec-wayland

Best,
--
Philip


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]