Update to newer version of dbus-broker support

Resolves: rhbz#1622545

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
This commit is contained in:
Stephen Gallagher 2018-08-28 08:07:26 -04:00
parent 3af57777ad
commit e128e1884b
No known key found for this signature in database
GPG Key ID: 7A25556236BAA3A3
3 changed files with 191 additions and 68 deletions

View File

@ -1,12 +1,16 @@
From 09e012860a6e1e074ac1950a4afc3d4131d046d9 Mon Sep 17 00:00:00 2001
From fd6e9787723c954bb4113f862d5ecd3a77ed633c Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Thu, 1 Mar 2018 12:00:09 +0100
Subject: [PATCH] bus-launch: add dbus-broker support
If dbus-broker is enabled at compile-time and found at run-time prefer that
over dbus-daemon.
Both dbus-daemon and dbus-broker are now optional at compile-time, though
at least one must be configured. A new configuration option is introduce in
order to select the default implementation attempted at runtime. The other
implementation will function as a fall-back (in case support for both are
compiled in). If no default is selected, dbus-daemon remains the default as
before.
Unlike with dbus-daemon, this means that at-spi-bus-launch must create the
Unlike dbus-daemon, dbus-broker requires at-spi-bus-launch to create the
listening socket and pass it in, rather than having the bus do that and send
back the address. For now we follow what dbus-daemon does, and create a socket
in the abstract namespace, though it might be more suitable to create a socket
@ -19,18 +23,23 @@ applies to `org.a11y.atspi.Registry`.
For non-linux and non-systemd systems, dbus-daemon should continue to be used.
[v2:
- drop the --verbose switch, which is no longer supported
- make dbus-daemon optional too
- allow the default implementation to be selected]
Signed-off-by: Tom Gundersen <teg@jklm.no>
---
bus/at-spi-bus-launcher.c | 145 ++++++++++++++++++++++++++++++++++++++--------
bus/meson.build | 27 +++++++--
meson_options.txt | 4 ++
3 files changed, 147 insertions(+), 29 deletions(-)
bus/at-spi-bus-launcher.c | 196 ++++++++++++++++++++++++++++++--------
bus/meson.build | 32 +++++--
meson_options.txt | 9 ++
3 files changed, 191 insertions(+), 46 deletions(-)
diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c
index eb2b8e3..8aeb490 100644
index eb2b8e33011c48e45774f07defbf46149a643bb9..354c04eec7ba1a1ee034a245ee25c0139c48a1e5 100644
--- a/bus/at-spi-bus-launcher.c
+++ b/bus/at-spi-bus-launcher.c
@@ -2,7 +2,7 @@
@@ -1,10 +1,10 @@
/* -*- mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
*
* at-spi-bus-launcher: Manage the a11y bus as a child process
*
@ -39,7 +48,11 @@ index eb2b8e3..8aeb490 100644
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,6 +25,11 @@
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
@@ -23,10 +23,15 @@
#include "config.h"
#include <unistd.h>
#include <string.h>
#include <signal.h>
@ -51,7 +64,11 @@ index eb2b8e3..8aeb490 100644
#include <sys/wait.h>
#include <errno.h>
#include <stdio.h>
@@ -58,6 +63,7 @@ typedef struct {
#include <gio/gio.h>
@@ -56,10 +61,11 @@ typedef struct {
A11yBusState state;
/* -1 == error, 0 == pending, > 0 == running */
int a11y_bus_pid;
char *a11y_bus_address;
int pipefd[2];
@ -59,26 +76,59 @@ index eb2b8e3..8aeb490 100644
char *a11y_launch_error_message;
} A11yBusLauncher;
@@ -216,7 +222,7 @@ name_appeared_handler (GDBusConnection *connection,
static A11yBusLauncher *_global_app = NULL;
@@ -213,27 +219,10 @@ name_appeared_handler (GDBusConnection *connection,
A11yBusLauncher *app = user_data;
register_client (app);
}
static void
-static void
-setup_bus_child (gpointer data)
+setup_bus_child_daemon (gpointer data)
{
A11yBusLauncher *app = data;
(void) app;
@@ -227,7 +233,6 @@ setup_bus_child (gpointer data)
/* On Linux, tell the bus process to exit if this process goes away */
#ifdef __linux
-{
- A11yBusLauncher *app = data;
- (void) app;
-
- close (app->pipefd[0]);
- dup2 (app->pipefd[1], 3);
- close (app->pipefd[1]);
-
- /* On Linux, tell the bus process to exit if this process goes away */
-#ifdef __linux
-#include <sys/prctl.h>
prctl (PR_SET_PDEATHSIG, 15);
#endif
}
@@ -277,23 +282,12 @@ on_bus_exited (GPid pid,
- prctl (PR_SET_PDEATHSIG, 15);
-#endif
-}
-
/**
* unix_read_all_fd_to_string:
*
* Read all data from a file descriptor to a C string buffer.
*/
@@ -274,37 +263,43 @@ on_bus_exited (GPid pid,
app->a11y_launch_error_message = g_strdup_printf ("Bus stopped by signal %d", WSTOPSIG (status));
}
g_main_loop_quit (app->loop);
}
+#ifdef DBUS_DAEMON
+static void
+setup_bus_child_daemon (gpointer data)
+{
+ A11yBusLauncher *app = data;
+ (void) app;
+
+ close (app->pipefd[0]);
+ dup2 (app->pipefd[1], 3);
+ close (app->pipefd[1]);
+
+ /* On Linux, tell the bus process to exit if this process goes away */
+#ifdef __linux
+ prctl (PR_SET_PDEATHSIG, 15);
+#endif
+}
+
static gboolean
-ensure_a11y_bus (A11yBusLauncher *app)
+ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path)
@ -102,7 +152,8 @@ index eb2b8e3..8aeb490 100644
if (pipe (app->pipefd) < 0)
g_error ("Failed to create pipe: %s", strerror (errno));
@@ -302,7 +296,7 @@ ensure_a11y_bus (A11yBusLauncher *app)
if (!g_spawn_async (NULL,
argv,
NULL,
G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
@ -111,7 +162,11 @@ index eb2b8e3..8aeb490 100644
app,
&pid,
&error))
@@ -335,6 +329,116 @@ ensure_a11y_bus (A11yBusLauncher *app)
{
app->a11y_bus_pid = -1;
@@ -333,10 +328,140 @@ ensure_a11y_bus (A11yBusLauncher *app)
/* Trim the trailing newline */
app->a11y_bus_address = g_strchomp (g_strdup (addr_buf));
g_debug ("a11y bus address: %s", app->a11y_bus_address);
@ -124,6 +179,13 @@ index eb2b8e3..8aeb490 100644
+
+ return FALSE;
+}
+#else
+static gboolean
+ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path)
+{
+ return FALSE;
+}
+#endif
+
+#ifdef DBUS_BROKER
+static void
@ -148,7 +210,7 @@ index eb2b8e3..8aeb490 100644
+static gboolean
+ensure_a11y_bus_broker (A11yBusLauncher *app, char *config_path)
+{
+ char *argv[] = { DBUS_BROKER, config_path, "--scope", "user", "--verbose", NULL };
+ char *argv[] = { DBUS_BROKER, config_path, "--scope", "user", NULL };
+ struct sockaddr_un addr = { .sun_family = AF_UNIX };
+ socklen_t addr_len = sizeof(addr);
+ GPid pid;
@ -200,6 +262,12 @@ index eb2b8e3..8aeb490 100644
+
+ return FALSE;
+}
+#else
+static gboolean
+ensure_a11y_bus_broker (A11yBusLauncher *app, char *config_path)
+{
+ return FALSE;
+}
+#endif
+
+static gboolean
@ -216,19 +284,30 @@ index eb2b8e3..8aeb490 100644
+ else
+ config_path = "--config-file="DATADIR"/defaults/at-spi2/accessibility.conf";
+
+#ifdef DBUS_BROKER
+#ifdef WANT_DBUS_BROKER
+ success = ensure_a11y_bus_broker (app, config_path);
+ if (!success)
+ {
+ if (!ensure_a11y_bus_daemon (app, config_path))
+ return FALSE;
+ }
+#else
+ success = ensure_a11y_bus_daemon (app, config_path);
+ if (!success)
+ {
+ if (!ensure_a11y_bus_broker (app, config_path))
+ return FALSE;
+ }
+#endif
+ if (!success)
+ {
+ if (!ensure_a11y_bus_daemon (app, config_path))
+ return FALSE;
+ }
+
#ifdef HAVE_X11
{
Display *display = XOpenDisplay (NULL);
@@ -353,13 +457,6 @@ ensure_a11y_bus (A11yBusLauncher *app)
if (display)
{
@@ -351,17 +476,10 @@ ensure_a11y_bus (A11yBusLauncher *app)
}
}
#endif
return TRUE;
@ -242,51 +321,72 @@ index eb2b8e3..8aeb490 100644
}
static void
handle_method_call (GDBusConnection *connection,
const gchar *sender,
diff --git a/bus/meson.build b/bus/meson.build
index 909103c..ba8ea2c 100644
index 909103ce1275e1f9cf812f0615ba2d87030d142c..5c7e03d348bab1af06d27f2b8cd91ce4f1d6f650 100644
--- a/bus/meson.build
+++ b/bus/meson.build
@@ -43,13 +43,30 @@ else
required: true).path()
endif
@@ -29,27 +29,45 @@ configure_file(input: 'at-spi-dbus-bus.service.in',
output: 'at-spi-dbus-bus.service',
configuration: libexec_conf,
install: true,
install_dir: systemd_user_dir)
-executable('at-spi-bus-launcher', 'at-spi-bus-launcher.c',
- include_directories: [ root_inc, include_directories('.') ],
- dependencies: [ gio_dep, x11_deps ],
- c_args: [
+launcher_args = [
'-DSYSCONFDIR="@0@"'.format(atspi_sysconfdir),
'-DDATADIR="@0@"'.format(atspi_datadir),
'-DDBUS_DAEMON="@0@"'.format(dbus_daemon),
- ],
+ '-DSYSCONFDIR="@0@"'.format(atspi_sysconfdir),
+ '-DDATADIR="@0@"'.format(atspi_datadir),
+ ]
+
if get_option('dbus_daemon') != 'default'
- dbus_daemon = get_option('dbus_daemon')
+ launcher_args += '-DDBUS_DAEMON="@0@"'.format(get_option('dbus_daemon'))
else
dbus_daemon = find_program('dbus-daemon',
'/sbin/dbus-daemon',
'/usr/sbin/dbus-daemon',
'/libexec/dbus-daemon',
'/usr/libexec/dbus-daemon',
'/usr/pkg/bin/dbus-daemon',
- required: true).path()
+ required: false)
+ if dbus_daemon.found()
+ launcher_args += '-DDBUS_DAEMON="@0@"'.format(dbus_daemon.path())
+ endif
+endif
+
+if get_option('dbus_broker') != 'default'
+ launcher_args += '-DDBUS_BROKER="@0@"'.format(get_option('dbus_broker'))
+else
+ dbus_broker = find_program('dbus-broker-launch',
+ '/sbin/dbus-broker-launch',
+ '/usr/sbin/dbus-broker-launch',
+ '/libexec/dbus-broker-launch',
+ '/usr/libexec/dbus-broker-launch',
+ '/usr/pkg/bin/dbus-broker-launch',
+ required: false)
+ if dbus_broker.found()
+ launcher_args += '-DDBUS_BROKER="@0@"'.format(dbus_broker.path())
+ endif
+endif
+
+executable('at-spi-bus-launcher', 'at-spi-bus-launcher.c',
+ include_directories: [ root_inc, include_directories('.') ],
+ dependencies: [ gio_dep, x11_deps ],
+if get_option('default_bus') == 'dbus-broker'
+ launcher_args += '-DWANT_DBUS_BROKER'
endif
executable('at-spi-bus-launcher', 'at-spi-bus-launcher.c',
include_directories: [ root_inc, include_directories('.') ],
dependencies: [ gio_dep, x11_deps ],
- c_args: [
- '-DSYSCONFDIR="@0@"'.format(atspi_sysconfdir),
- '-DDATADIR="@0@"'.format(atspi_datadir),
- '-DDBUS_DAEMON="@0@"'.format(dbus_daemon),
- ],
+ c_args: launcher_args,
install: true,
install_dir: atspi_libexecdir)
diff --git a/meson_options.txt b/meson_options.txt
index c9afe2f..494e83a 100644
index c9afe2faaba76c85091f51e554fe33567e4a1e13..f8ec8621a53d0f53398af240ea9b18f1d732b6f0 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,6 +6,10 @@ option('dbus_daemon',
@@ -4,10 +4,19 @@ option('dbus_services_dir',
value: 'default')
option('dbus_daemon',
description: 'The path of the DBus daemon',
type: 'string',
value: 'default')
@ -294,6 +394,16 @@ index c9afe2f..494e83a 100644
+ description: 'The path of the DBus broker',
+ type: 'string',
+ value: 'default')
+option('default_bus',
+ description: 'The default DBus implementation to use',
+ type: 'combo',
+ choices: ['dbus-daemon', 'dbus-broker'],
+ value: 'dbus-daemon')
option('systemd_user_dir',
description: 'Location of the systemd user services',
type: 'string',
value: 'default')
option('enable_docs',
--
2.19.0.rc0

View File

@ -1,7 +1,7 @@
From 85dedf4125d2107a4b095bbafe482bf6ecfd06f1 Mon Sep 17 00:00:00 2001
From 443e46d2d9d29cb9d20192e4978eb633bbbcc9b4 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Fri, 10 Aug 2018 16:35:31 +0200
Subject: [PATCH] bus-launch: use __linux__ over __linux
Subject: [PATCH 2/2] bus-launch: use __linux__ over __linux
The canonical way to check for linux support is '__linux__', not
'__linux'. Particularly, on ppc64le '__linux' is not defined and the
@ -15,10 +15,12 @@ For reference, see:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c
index 8aeb490..8fa566f 100644
index 354c04eec7ba1a1ee034a245ee25c0139c48a1e5..b65301def88c2ff8aa5d10ada67507d0201b0984 100644
--- a/bus/at-spi-bus-launcher.c
+++ b/bus/at-spi-bus-launcher.c
@@ -25,7 +25,7 @@
@@ -23,11 +23,11 @@
#include "config.h"
#include <unistd.h>
#include <string.h>
#include <signal.h>
@ -27,15 +29,21 @@ index 8aeb490..8fa566f 100644
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/un.h>
@@ -232,7 +232,7 @@ setup_bus_child_daemon (gpointer data)
#endif
#include <sys/wait.h>
@@ -275,11 +275,11 @@ setup_bus_child_daemon (gpointer data)
close (app->pipefd[0]);
dup2 (app->pipefd[1], 3);
close (app->pipefd[1]);
/* On Linux, tell the bus process to exit if this process goes away */
-#ifdef __linux
+#ifdef __linux__
prctl (PR_SET_PDEATHSIG, 15);
#endif
#endif
}
static gboolean
--
2.18.0
2.19.0.rc0

View File

@ -1,13 +1,14 @@
Name: at-spi2-core
Version: 2.28.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Protocol definitions and daemon for D-Bus at-spi
License: LGPLv2+
URL: http://www.linuxfoundation.org/en/AT-SPI_on_D-Bus
Source0: http://download.gnome.org/sources/at-spi2-core/2.28/%{name}-%{version}.tar.xz
Patch0: https://github.com/GNOME/at-spi2-core/commit/09e012860a6e1e074ac1950a4afc3d4131d046d9.patch
Patch1: 0001-bus-launch-use-__linux__-over-__linux.patch
# Patch0 based on https://github.com/GNOME/at-spi2-core/commit/d7f47c99d093ba91eb18523e14b23bde1794f5bc.patch
Patch0: 0001-bus-launch-add-dbus-broker-support.patch
Patch1: 0002-bus-launch-use-__linux__-over-__linux.patch
BuildRequires: dbus-devel
BuildRequires: gettext
@ -80,6 +81,10 @@ API documentation for libatspi.
%{_libdir}/pkgconfig/atspi-2.pc
%changelog
* Tue Aug 28 2018 Stephen Gallagher <sgallagh@redhat.com> - 2.28.0-4
- Update to newer version of dbus-broker support
- Resolves: rhbz#1622545
* Fri Aug 10 2018 David Herrmann <dh.herrmann@gmail.com> - 2.28.0-3
- Add support for dbus-broker alongside dbus-daemon