how to discover starter bus w/systemd

Jeremy Audet jerebear at protonmail.com
Wed Aug 14 03:08:18 UTC 2019


I'm writing an application that's split into a sender and several receivers, and which communicate over D-Bus. The receivers make use of D-Bus' service activation [1] feature: they are started only when a message is sent to them, and they quit shortly after consuming all buffered messages.

Some of the receivers are designed to consume messages from whichever message bus woke them up, regardless of whether it's a system bus, a session bus, or a custom bus. (Consuming messages from a custom bus could be especially useful for integration testing. We'll see.) Which message bus should a receiver connect to and consume messages from? The message bus at DBUS_STARTER_ADDRESS, natch.

Here's the catch: this only works when a process is started directly by a message bus. If a message bus delegates to systemd, like so:

    [D-BUS Service]
    Name=name.jerebear.MyService1
    Exec=/usr/bin/my-service
    # Delegate to systemd.
    SystemdService=my-service.service

...then the DBUS_STARTER_* environment variables aren't set. This is unfortunate, because systemd is far better equipped to manage processes than a message bus. (I'm especially fond of the hardening directives like NoNewPrivileges=.) This is doubly unfortunate because I'd like to support just one technique for starting the receivers, and since my app depends on systemd anyway, it's the obvious choice.

Have any of y'all heard of this issue before? Is this a question that I should take somewhere else, like the systemd mailing list? How has this issue been resolved elsewhere, if at all? The closest I've found is a bug on the systemd bug tracker. [2]

I've put together a reproducer. [3] You might need to log out and in again between invocations of dbus-send. If you're feeling fancy, fiddle with `files/name.jerebear.MyService1.service` as described in that file.

FWIW, I'm running on up-to-date Arch Linux installs. Nothing fancy. I've not replaced dbus-daemon with dbus-broker, I'm not running a custom kernel, etc.

Thanks for your time,
—Jeremy

p.s. I'm not subscribed to this mailing list. Please include me in your responses.

p.p.s. Please don't tell me that "having [an app] work on either system, session or a custom bus simply isn't done." [4] Some of the receivers most definitely are designed to consume messages from whichever bus started them.

[1] https://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-starting-services
[2] https://bugs.freedesktop.org/show_bug.cgi?id=55288
[3] https://github.com/Ichimonji10/impedimenta/tree/master/bash/dbus-starter-address
[4] https://lists.freedesktop.org/archives/dbus/2016-September/017029.html




More information about the dbus mailing list