summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bus/at-spi-bus-launcher.c18
-rw-r--r--bus/meson.build11
2 files changed, 28 insertions, 1 deletions
diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c
index 362fd05f..d7c66900 100644
--- a/bus/at-spi-bus-launcher.c
+++ b/bus/at-spi-bus-launcher.c
@@ -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));
diff --git a/bus/meson.build b/bus/meson.build
index 0fff5a89..f6c32c99 100644
--- a/bus/meson.build
+++ b/bus/meson.build
@@ -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)