Commit 260a4414 authored by Michael Catanzaro's avatar Michael Catanzaro

Don't use dbus-broker if not running under systemd

Since gdm@febeb9a9, gdm no longer runs a systemd user session, because
gdm supports multiseat but systemd only allows one graphical session per
user. Since gdm currently runs as the gdm user, that means we cannot use
systemd there. Benjamin Berg says we could fix that by changing gdm to
use temporary users for each seat, but that would be a lot of work.

Meanwhile, dbus-broker relies on systemd to autostart D-Bus services. So
if we are not running a systemd user session, nothing gets autostarted
in response to D-Bus calls. That means orca never gets any response to
its method calls to org.a11y.atspi.Registry, and we wind up with no
accessibility on the gnome-shell login screen.

Fix this by implementing Benjamin's suggested check to see if we are
running under systemd before using dbus-broker. So now we will use
dbus-daemon on the login screen, but we will still use dbus-broker for
the user session (except in distros that still prefer dbus-daemon...
which is actually the default configuration). libsystemd is added as a
build dependency whenever built with dbus-broker support, which should
be uncontroversial because it won't work without systemd.

I expect dbus-daemon is going to live alongside dbus-broker for a long
time, because it seems very hard for us to migrate fully.

Big thanks to Benjamin Berg for discovering the problem and suggesting
this solution.

Fixes #25
parent 2650710c
......@@ -39,6 +39,9 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#endif
#ifdef DBUS_BROKER
#include <systemd/sd-login.h>
#endif
typedef enum {
A11Y_BUS_STATE_IDLE = 0,
......@@ -392,11 +395,26 @@ static gboolean
ensure_a11y_bus_broker (A11yBusLauncher *app, char *config_path)
{
char *argv[] = { DBUS_BROKER, config_path, "--scope", "user", NULL };
char *unit;
struct sockaddr_un addr = { .sun_family = AF_UNIX };
socklen_t addr_len = sizeof(addr);
GPid pid;
GError *error = NULL;
/* This detects whether we are running under systemd. We only try to
* use dbus-broker if we are running under systemd because D-Bus
* service activation won't work otherwise.
*/
if (sd_pid_get_user_unit (getpid (), &unit) >= 0)
{
free (unit);
}
else
{
app->state = A11Y_BUS_STATE_ERROR;
return FALSE;
}
if ((app->listenfd = socket (PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) < 0)
g_error ("Failed to create listening socket: %s", strerror (errno));
......
......@@ -48,13 +48,16 @@ else
endif
endif
needs_systemd = false
if get_option('dbus_broker') != 'default'
launcher_args += '-DDBUS_BROKER="@0@"'.format(get_option('dbus_broker'))
needs_systemd = true
else
dbus_broker = find_program('dbus-broker-launch',
required: false)
if dbus_broker.found()
launcher_args += '-DDBUS_BROKER="@0@"'.format(dbus_broker.path())
needs_systemd = true
endif
endif
......@@ -62,9 +65,15 @@ if get_option('default_bus') == 'dbus-broker'
launcher_args += '-DWANT_DBUS_BROKER'
endif
if needs_systemd
systemd_dep = dependency('libsystemd')
else
systemd_dep = dependency('', required: false)
endif
executable('at-spi-bus-launcher', 'at-spi-bus-launcher.c',
include_directories: [ root_inc, include_directories('.') ],
dependencies: [ gio_dep, x11_deps ],
dependencies: [ gio_dep, systemd_dep, x11_deps ],
c_args: launcher_args,
install: true,
install_dir: atspi_libexecdir)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment