summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog8
-rw-r--r--debian/patches/dbus-launch-if-autolaunching-use-XDG_RUNTIME_DIR-bus.patch173
-rw-r--r--debian/patches/dbus-launch-use-libdbus-to-read-the-UUID.patch125
-rw-r--r--debian/patches/series2
4 files changed, 308 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 4e817102..85e48882 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+dbus (1.9.10-3) experimental; urgency=medium
+
+ * Update proposed fd.o #61301 patch set:
+ - dbus-launch --autolaunch now returns the XDG_RUNTIME_DIR/bus if
+ available
+
+ -- Simon McVittie <smcv@debian.org> Tue, 17 Feb 2015 18:18:18 +0000
+
dbus (1.9.10-2) experimental; urgency=low
* Remove debian/source/local-options, no longer necessary (dpkg-source now
diff --git a/debian/patches/dbus-launch-if-autolaunching-use-XDG_RUNTIME_DIR-bus.patch b/debian/patches/dbus-launch-if-autolaunching-use-XDG_RUNTIME_DIR-bus.patch
new file mode 100644
index 00000000..c0477ada
--- /dev/null
+++ b/debian/patches/dbus-launch-if-autolaunching-use-XDG_RUNTIME_DIR-bus.patch
@@ -0,0 +1,173 @@
+From: Simon McVittie <simon.mcvittie@collabora.co.uk>
+Date: Mon, 9 Feb 2015 13:47:19 +0000
+Subject: dbus-launch: if autolaunching, use XDG_RUNTIME_DIR/bus if available
+
+This provides backwards-compatible autolaunching behaviour, as long
+as dbus-launch inherits the XDG_RUNTIME_DIR (which it presumably did
+if it's going to work at all, since it must also have inherited the
+DISPLAY). In particular, we go through the motions of starting the
+dbus-daemon, so that we can start the "babysitter" process that will
+maintain the X11 window to store the bus address.
+
+Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301
+---
+ dbus/dbus-sysdeps-unix.c | 7 +++++-
+ tools/dbus-launch.c | 64 +++++++++++++++++++++++++++++++++++++++++++++---
+ tools/tool-common.h | 2 +-
+ 3 files changed, 68 insertions(+), 5 deletions(-)
+
+diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
+index 0b9829b..1d19dd1 100644
+--- a/dbus/dbus-sysdeps-unix.c
++++ b/dbus/dbus-sysdeps-unix.c
+@@ -3608,7 +3608,12 @@ _dbus_get_autolaunch_address (const char *scope,
+
+ /* fd.o #19997: if $DISPLAY isn't set to something useful, then
+ * dbus-launch-x11 is just going to fail. Rather than trying to
+- * run it, we might as well bail out early with a nice error. */
++ * run it, we might as well bail out early with a nice error.
++ *
++ * This is not strictly true in a world where the user bus exists,
++ * because dbus-launch --autolaunch knows how to connect to that -
++ * but if we were going to connect to the user bus, we'd have done
++ * so before trying autolaunch: in any case. */
+ display = _dbus_getenv ("DISPLAY");
+
+ if (display == NULL || display[0] == '\0')
+diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c
+index 1d9ab3e..eed146b 100644
+--- a/tools/dbus-launch.c
++++ b/tools/dbus-launch.c
+@@ -43,6 +43,11 @@
+ extern Display *xdisplay;
+ #endif
+
++#include "dbus/dbus-internals.h"
++#include "dbus/dbus-sysdeps-unix.h"
++
++#include "tool-common.h"
++
+ /* PROCESSES
+ *
+ * If you are in a shell and run "dbus-launch myapp", here is what happens:
+@@ -427,7 +432,8 @@ print_variables (const char *bus_address, pid_t bus_pid, long bus_wid,
+ else if (c_shell_syntax)
+ {
+ printf ("setenv DBUS_SESSION_BUS_ADDRESS '%s';\n", bus_address);
+- printf ("set DBUS_SESSION_BUS_PID=%ld;\n", (long) bus_pid);
++ if (bus_pid)
++ printf ("set DBUS_SESSION_BUS_PID=%ld;\n", (long) bus_pid);
+ if (bus_wid)
+ printf ("set DBUS_SESSION_BUS_WINDOWID=%ld;\n", (long) bus_wid);
+ fflush (stdout);
+@@ -436,7 +442,8 @@ print_variables (const char *bus_address, pid_t bus_pid, long bus_wid,
+ {
+ printf ("DBUS_SESSION_BUS_ADDRESS='%s';\n", bus_address);
+ printf ("export DBUS_SESSION_BUS_ADDRESS;\n");
+- printf ("DBUS_SESSION_BUS_PID=%ld;\n", (long) bus_pid);
++ if (bus_pid)
++ printf ("DBUS_SESSION_BUS_PID=%ld;\n", (long) bus_pid);
+ if (bus_wid)
+ printf ("DBUS_SESSION_BUS_WINDOWID=%ld;\n", (long) bus_wid);
+ fflush (stdout);
+@@ -444,7 +451,8 @@ print_variables (const char *bus_address, pid_t bus_pid, long bus_wid,
+ else
+ {
+ printf ("DBUS_SESSION_BUS_ADDRESS=%s\n", bus_address);
+- printf ("DBUS_SESSION_BUS_PID=%ld\n", (long) bus_pid);
++ if (bus_pid)
++ printf ("DBUS_SESSION_BUS_PID=%ld\n", (long) bus_pid);
+ if (bus_wid)
+ printf ("DBUS_SESSION_BUS_WINDOWID=%ld\n", (long) bus_wid);
+ fflush (stdout);
+@@ -838,6 +846,8 @@ main (int argc, char **argv)
+ int bus_pid_to_babysitter_pipe[2];
+ int bus_address_to_launcher_pipe[2];
+ char *config_file;
++ dbus_bool_t user_bus_supported = FALSE;
++ DBusString user_bus;
+
+ exit_with_session = FALSE;
+ config_file = NULL;
+@@ -991,6 +1001,7 @@ main (int argc, char **argv)
+ char *address;
+ pid_t pid;
+ long wid;
++ DBusError error = DBUS_ERROR_INIT;
+
+ if (get_machine_uuid () == NULL)
+ {
+@@ -998,6 +1009,37 @@ main (int argc, char **argv)
+ exit (1);
+ }
+
++ if (!_dbus_string_init (&user_bus))
++ tool_oom ("initializing");
++
++ /* If we have an XDG_RUNTIME_DIR and it contains a suitable socket,
++ * dbus-launch --autolaunch can use it, since --autolaunch implies
++ * "I'm OK with getting a bus that is already active".
++ *
++ * (However, plain dbus-launch without --autolaunch must not do so,
++ * because that would break lots of regression tests, which often
++ * use dbus-launch instead of the more appropriate dbus-run-session.)
++ *
++ * At this stage, we just save the user bus's address; later on, the
++ * "babysitter" process will be available to advertise the user-bus
++ * on the X11 display and in ~/.dbus/session-bus, for full
++ * backwards compatibility.
++ */
++ if (!_dbus_lookup_user_bus (&user_bus_supported, &user_bus, &error))
++ {
++ fprintf (stderr, "%s\n", error.message);
++ exit (1);
++ }
++ else if (user_bus_supported)
++ {
++ verbose ("=== Using existing user bus \"%s\"\n",
++ _dbus_string_get_const_data (&user_bus));
++ }
++ else
++ {
++ _dbus_string_free (&user_bus);
++ }
++
+ verbose ("Autolaunch enabled (using X11).\n");
+ if (!exit_with_session)
+ {
+@@ -1107,6 +1149,22 @@ main (int argc, char **argv)
+ close (bus_pid_to_babysitter_pipe[READ_END]);
+ close (bus_pid_to_babysitter_pipe[WRITE_END]);
+
++ /* If we have a user bus and want to use it, do so instead of
++ * exec'ing a new dbus-daemon. */
++ if (autolaunch && user_bus_supported)
++ {
++ do_write (bus_pid_to_launcher_pipe[WRITE_END], "0\n", 2);
++ close (bus_pid_to_launcher_pipe[WRITE_END]);
++
++ do_write (bus_address_to_launcher_pipe[WRITE_END],
++ _dbus_string_get_const_data (&user_bus),
++ _dbus_string_get_length (&user_bus));
++ do_write (bus_address_to_launcher_pipe[WRITE_END], "\n", 1);
++ close (bus_address_to_launcher_pipe[WRITE_END]);
++
++ exit (0);
++ }
++
+ sprintf (write_pid_fd_as_string,
+ "%d", bus_pid_to_launcher_pipe[WRITE_END]);
+
+diff --git a/tools/tool-common.h b/tools/tool-common.h
+index d56abf8..c598482 100644
+--- a/tools/tool-common.h
++++ b/tools/tool-common.h
+@@ -33,7 +33,7 @@
+ #endif
+
+ void tool_millisleep (int ms);
+-void tool_oom (const char *doing);
++void tool_oom (const char *doing) _DBUS_GNUC_NORETURN;
+ dbus_bool_t tool_write_all (int fd, const void *buf, size_t size);
+
+ #endif
diff --git a/debian/patches/dbus-launch-use-libdbus-to-read-the-UUID.patch b/debian/patches/dbus-launch-use-libdbus-to-read-the-UUID.patch
new file mode 100644
index 00000000..dd514b25
--- /dev/null
+++ b/debian/patches/dbus-launch-use-libdbus-to-read-the-UUID.patch
@@ -0,0 +1,125 @@
+From: Simon McVittie <simon.mcvittie@collabora.co.uk>
+Date: Tue, 17 Feb 2015 13:46:53 +0000
+Subject: dbus-launch: use libdbus to read the UUID
+
+As a side benefit, this means that dbus-launch now understands
+/etc/machine-id and not just /var/lib/dbus/machine-id.
+
+I'm using the "internal" (static) version of libdbus rather than
+the shared version, because my next commit is going to need that
+anyway.
+---
+ tools/Makefile.am | 17 ++++++++++++-----
+ tools/dbus-launch.c | 36 ++++++++++--------------------------
+ tools/dbus-launch.h | 2 ++
+ 3 files changed, 24 insertions(+), 31 deletions(-)
+
+diff --git a/tools/Makefile.am b/tools/Makefile.am
+index 9046282..fafee1b 100644
+--- a/tools/Makefile.am
++++ b/tools/Makefile.am
+@@ -48,7 +48,18 @@ else
+ dbus_launch_SOURCES= \
+ dbus-launch.c \
+ dbus-launch-x11.c \
+- dbus-launch.h
++ dbus-launch.h \
++ tool-common.c \
++ tool-common.h \
++ $(NULL)
++dbus_launch_CPPFLAGS = \
++ $(AM_CPPFLAGS) \
++ -DDBUS_STATIC_BUILD \
++ $(NULL)
++dbus_launch_LDADD = \
++ $(top_builddir)/dbus/libdbus-internal.la \
++ $(DBUS_X_LIBS) \
++ $(NULL)
+
+ dbus_run_session_SOURCES = \
+ dbus-run-session.c
+@@ -77,10 +88,6 @@ dbus_uuidgen_LDADD = \
+ $(top_builddir)/dbus/libdbus-1.la \
+ $(NULL)
+
+-dbus_launch_LDADD = \
+- $(DBUS_X_LIBS) \
+- $(NULL)
+-
+ examplesdir = ${docdir}/examples
+ dist_examples_SCRIPTS = \
+ GetAllMatchRules.py \
+diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c
+index 41a20e8..1d9ab3e 100644
+--- a/tools/dbus-launch.c
++++ b/tools/dbus-launch.c
+@@ -106,46 +106,30 @@ save_machine_uuid (const char *uuid_arg)
+ }
+
+ #ifdef DBUS_BUILD_X11
+-#define UUID_MAXLEN 40
+ /* Read the machine uuid from file if needed. Returns TRUE if machine_uuid is
+ * set after this function */
+ static int
+ read_machine_uuid_if_needed (void)
+ {
+- FILE *f;
+- char uuid[UUID_MAXLEN];
+- size_t len;
+- int ret = FALSE;
++ char *uuid;
+
+ if (machine_uuid != NULL)
+ return TRUE;
+
+- f = fopen (DBUS_MACHINE_UUID_FILE, "r");
+- if (f == NULL)
+- return FALSE;
+-
+- if (fgets (uuid, UUID_MAXLEN, f) == NULL)
+- goto out;
++ uuid = dbus_get_local_machine_id ();
+
+- len = strlen (uuid);
+- if (len < 32)
+- goto out;
++ if (uuid == NULL)
++ return FALSE;
+
+- /* rstrip the read uuid */
+- while (len > 31 && isspace((int) uuid[len - 1]))
+- len--;
++ /* one is allocated with malloc and the other with dbus_malloc so copy it */
++ machine_uuid = xstrdup (uuid);
+
+- if (len != 32)
+- goto out;
++ if (machine_uuid == NULL)
++ tool_oom ("reading machine UUID");
+
+- uuid[len] = '\0';
+- machine_uuid = xstrdup (uuid);
++ dbus_free (uuid);
+ verbose ("UID: %s\n", machine_uuid);
+- ret = TRUE;
+-
+-out:
+- fclose(f);
+- return ret;
++ return TRUE;
+ }
+ #endif /* DBUS_BUILD_X11 */
+
+diff --git a/tools/dbus-launch.h b/tools/dbus-launch.h
+index 8220bb8..d0ede6b 100644
+--- a/tools/dbus-launch.h
++++ b/tools/dbus-launch.h
+@@ -26,6 +26,8 @@
+
+ #include <sys/types.h>
+
++#include <dbus/dbus.h>
++
+ #ifndef TRUE
+ #define TRUE (1)
+ #endif
diff --git a/debian/patches/series b/debian/patches/series
index c522f444..0aceb571 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -8,4 +8,6 @@ On-Unix-platforms-try-XDG_RUNTIME_DIR-bus-before-def.patch
Add-a-regression-test-for-connecting-to-XDG_RUNTIME_.patch
Optionally-install-systemd-user-units-for-a-per-user.patch
Add-dbus-update-activation-environment-tool.patch
+dbus-launch-use-libdbus-to-read-the-UUID.patch
+dbus-launch-if-autolaunching-use-XDG_RUNTIME_DIR-bus.patch
Don-t-abort-on-fatal-warnings-by-default.patch