DBus on "other" platforms
simon.mcvittie at collabora.co.uk
Thu May 12 17:18:10 UTC 2016
On 12/05/16 14:59, René J.V. Bertin wrote:
> On Thursday May 12 2016 13:47:25 Simon McVittie wrote:
>> If OS X can do credentials-passing across AF_UNIX sockets, then the
>> correct long-term solution is to get that implemented compatibly in
>> libdbus and GDBus, and then MacPorts can stop patching libdbus to be
> So we'd be looking at patching GLib and libdbus?
You'd be looking at making changes to GLib and maybe libdbus that,
unlike disabling EXTERNAL authentication, are of a quality that can go
upstream, at which point you no longer need to carry a patch that
reduces security, and everyone wins.
It's possible that libdbus already knows how to do credentials-passing
on OS X. Try running "test/test-dbus-daemon --tap" (to get this
compiled, you have to build dbus with --enable-modular-tests, which
requires GLib). If you see something like
# ProcessID of this process is 12345
# UnixUserID of this process is 678
among the output, then it's working, and it's only GLib that you'd need
>> Setting that variable makes libdbus ignore the platform's poll()
>> implementation, and emulate it inefficiently using select() instead.
>> Does Darwin/OS X in fact have a broken poll() implementation, or is this
>> a workaround for something?
> I have no idea, the manpage just states that poll() doesn't support
> devices. It could well be that it's a remnant of an old patch from
> a previous OS that was never discarded because it still applies.
It looks as though this may still be a real issue: poll() on Darwin/OS X
seems to just be very poorly implemented, unless something has changed
in the last few years. I'm surprised by this, because surely it works
fine on the *BSD from which Darwin was forked...
Unfortunately, the check in configure.ac to determine whether poll() is
broken needs to run code on the host (machine where D-Bus will be run),
so it can't work when cross-compiling. Maybe the cross-compiling case
should assume poll() is broken on a Darwin host and non-broken
elsewhere; or maybe we should just assume that Darwin poll() will never
be fixed while everyone else's poll() is probably fine, and replace
tests for defined(BROKEN_POLL) with some sort of test for the system
This sort of thing is the reason D-Bus doesn't always work on "other
platforms" - sometimes those "other platforms" are just not very good at
being a Unix operating system. Windows at least has the excuse that it
doesn't claim to be one.
In practice D-Bus actually only polls sockets, pipes, inotify
descriptors (Linux and anything that copied the API, like QNX) and
kqueue descriptors (FreeBSD and anything that copied that API), so we
might even be able to get away with using Darwin's broken poll(). On the
other hand, the typical symptom of it not working would be a busy-loop,
which is not what we want.
The relevant commit:
Author: John (J5) Palmieri <johnp at redhat.com>
Date: 2008-03-04 13:21:05 -0500
fix broken poll on Mac OSX - build patch by Benjamin Reed
* configure.in: check for OSX's deadlocking poll
* dbus/dbus-sysdeps-unix.c (_dbus_poll): if we have a broken poll
don't use poll
mimicking a change in GLib a couple of years earlier:
Collabora Ltd. <http://www.collabora.com/>
More information about the dbus