Commit 3faf8f76 authored by Mike Gorse's avatar Mike Gorse

Merge branch 'mcatanzaro#25' into 'master'

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

Closes #25

See merge request !48
parents 2650710c 260a4414
......@@ -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