[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#929132: marked as done (unblock (pre-approval): dbus/1.12.14-1)



Your message dated Tue, 04 Jun 2019 06:02:00 +0000
with message-id <54b258ca-861a-731f-db4b-f0aca91e48da@thykier.net>
and subject line Re: Bug#929132: unblock (pre-approval): dbus/1.12.14-1
has caused the Debian Bug report #929132,
regarding unblock (pre-approval): dbus/1.12.14-1
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
929132: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929132
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

I would like to follow the dbus upstream 1.12.x stable branch in buster,
like I did for 1.8.x in jessie and 1.10.x in stretch. I am an upstream
maintainer and prepared all recent upstream releases.

If the timing of this release is not suitable to make it into
buster r0, it might be a good idea to backport the changes related to
_dbus_rlimit_raise_fd_limit() (Debian bug #928877) as a patch, so that
*those* can go into r0. As a result I haven't uploaded to unstable yet,
to keep it possible to upload a backport via unstable if you'd prefer.

Annotated diffstat for the attached diff, filtered with "filterdiff -p1
--exclude=Makefile.in --exclude=aclocal.m4 --exclude=build-aux/ltmain.sh
--exclude=configure --exclude='*/Makefile.in'
--exclude=aminclude_static.am --exclude=m4/libtool.m4":

 bus/bus.c                          |    8 -
 dbus/dbus-sysdeps-util-unix.c      |   64 +++++---
 dbus/dbus-sysdeps-util-win.c       |    3 
 dbus/dbus-sysdeps.h                |    3 

Fix #928877, which gives system services the wrong RLIMIT_NOFILE under
recent systemd versions (while logging a warning). See NEWS or #928877
for more details.

 cmake/DBus1Config.pkgconfig.in     |   27 +++

Avoid overwriting pkg-config-related global variables when a CMake project
depends on libdbus.

 Makefile.am                        |    2 
 bus/Makefile.am                    |    6 
 dbus/Makefile.am                   |    2 
 m4/ax_ac_append_to_file.m4         |   32 ++++
 m4/ax_ac_print_to_file.m4          |   32 ++++
 m4/ax_add_am_macro_static.m4       |   28 +++
 m4/ax_am_macros_static.m4          |   38 +++++
 m4/ax_code_coverage.m4             |  272 +++++++++++++++++++++++++++++++++++++
 m4/ax_file_escapes.m4              |   30 ++++
 test/Makefile.am                   |    9 -

Adapt to an API change in newer-than-buster autoconf-archive versions.
This is not directly helpful for buster, but we needed it upstream so that
users of more recently-updated autoconf-archive can still build dbus.
Unfortunately there does not seem to be anything we could do that would
be compatible with both older and newer versions, so I've had to bundle
the newer version. The built binaries shouldn't be affected.

 bus/desktop-file.c                 |   10 -
 dbus/dbus-sysdeps-unix.c           |    8 +
 tools/dbus-send.c                  |   11 -

Silence compiler warnings that apparently cause FTBFS on some systems
with newer-than-buster toolchains. The change in bus/desktop-file.c
could in principle reject some malformed .service files that would
previously have been wrongly accepted (although I suspect none exist).

 configure.ac                       |    6 

Avoid FTBFS with some newer-than-buster autoconf-archive versions that
break assumptions we previously made about their use of AX_-prefixed
strings. Again, this is not directly helpful for buster, but we needed it
upstream so that users of more recently-updated autoconf-archive can
still build dbus.

 test/Makefile.am                   |    9 -

Work around a build failure on MSYS2. The built binaries are unaffected.

 debian/rules                       |    1 
 debian/tests/gnome-desktop-testing |    1 

Disable tests for code paths that are only reached when malloc() returns
NULL, which in practice doesn't happen on Linux anyway. This significantly
speeds up the build, mitigating slowdown from increased test coverage in
recent releases.

 debian/tests/control               |    8 -
 debian/tests/system-bus            |   54 +++++++

Add smoke-tests to make sure that both code paths for system bus
activation still work, backported from experimental on the basis that
more coverage is better.

 NEWS                               |   42 +++++
 configure.ac                       |    6 
 debian/changelog                   |   11 +

Release preparation.

Thoughts?

Thanks,
    smcv
 Makefile.am                        |    2 
 NEWS                               |   42 +++++
 bus/Makefile.am                    |    6 
 bus/bus.c                          |    8 -
 bus/desktop-file.c                 |   10 -
 cmake/DBus1Config.pkgconfig.in     |   27 +++
 configure.ac                       |    6 
 dbus/Makefile.am                   |    2 
 dbus/dbus-sysdeps-unix.c           |    8 +
 dbus/dbus-sysdeps-util-unix.c      |   64 +++++---
 dbus/dbus-sysdeps-util-win.c       |    3 
 dbus/dbus-sysdeps.h                |    3 
 debian/changelog                   |   11 +
 debian/rules                       |    1 
 debian/tests/control               |    8 -
 debian/tests/gnome-desktop-testing |    1 
 debian/tests/system-bus            |   54 +++++++
 m4/ax_ac_append_to_file.m4         |   32 ++++
 m4/ax_ac_print_to_file.m4          |   32 ++++
 m4/ax_add_am_macro_static.m4       |   28 +++
 m4/ax_am_macros_static.m4          |   38 +++++
 m4/ax_code_coverage.m4             |  272 +++++++++++++++++++++++++++++++++++++
 m4/ax_file_escapes.m4              |   30 ++++
 test/Makefile.am                   |    9 -
 tools/dbus-send.c                  |   11 -
 25 files changed, 652 insertions(+), 56 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 9a902301..45183cb0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -51,4 +51,4 @@ DISTCHECK_CONFIGURE_FLAGS = \
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
 
 # Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-@CODE_COVERAGE_RULES@
+include $(top_srcdir)/aminclude_static.am
diff --git a/NEWS b/NEWS
index 6ac86c07..044e569d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,45 @@
+dbus 1.12.14 (2019-05-17)
+=========================
+
+The “reclaimed floorboards” release.
+
+Enhancements:
+
+• Raise soft fd limit to match hard limit, even if unprivileged.
+  This makes session buses with many clients, or with clients that make
+  heavy use of fd-passing, less likely to suffer from fd exhaustion.
+  (dbus!103, Simon McVittie)
+
+Fixes:
+
+• If a privileged dbus-daemon has a hard fd limit greater than 64K, don't
+  reduce it to 64K, ensuring that we can put back the original fd limits
+  when carrying out traditional (non-systemd) activation. This fixes a
+  regression with systemd >= 240 in which system services inherited
+  dbus-daemon's hard and soft limit of 64K fds, instead of the intended
+  soft limit of 1K and hard limit of 512K or 1M.
+  (dbus!103, Debian#928877; Simon McVittie)
+
+• Fix build failures caused by an AX_CODE_COVERAGE API change in newer
+  autoconf-archive versions (dbus#249, dbus!88; Simon McVittie)
+
+• Fix build failures with newer autoconf-archive versions that include
+  AX_-prefixed shell variable names (dbus#249, dbus!86; Simon McVittie)
+
+• Parse section/group names in .service files according to the syntax
+  from the Desktop Entry Specification, rejecting control characters
+  and non-ASCII in section/group names (dbus#208, David King)
+
+• Fix various -Wlogical-op issues that cause build failure with newer
+  gcc versions (dbus#225, dbus!109; David King)
+
+• Don't assume we can set permissions on a directory, for the benefit of
+  MSYS and Cygwin builds (dbus#216, dbus!110; Simon McVittie)
+
+• Don't overwrite PKG_CONFIG_PATH and related environment variables when
+  the pkg-config-based version of DBus1Config is used in a CMake project
+  (dbus#267, dbus!96; Clemens Lang)
+
 dbus 1.12.12 (2018-12-04)
 =========================
 
diff --git a/aminclude_static.am b/aminclude_static.am
new file mode 100644
index 00000000..ea8d5618
diff --git a/bus/Makefile.am b/bus/Makefile.am
index 9ae30716..c9170631 100644
--- a/bus/Makefile.am
+++ b/bus/Makefile.am
@@ -6,7 +6,7 @@ systemdtmpfilesdir = $(prefix)/lib/tmpfiles.d
 systemdsysusersdir = $(prefix)/lib/sysusers.d
 
 DBUS_BUS_LIBS = \
-	$(CODE_COVERAGE_LDFLAGS) \
+	$(CODE_COVERAGE_LIBS) \
 	$(EXPAT_LIBS) \
 	$(SELINUX_LIBS) \
 	$(APPARMOR_LIBS) \
@@ -16,7 +16,7 @@ DBUS_BUS_LIBS = \
 	$(NULL)
 
 DBUS_LAUNCHER_LIBS = \
-	$(CODE_COVERAGE_LDFLAGS) \
+	$(CODE_COVERAGE_LIBS) \
 	$(EXPAT_LIBS) \
 	$(THREAD_LIBS) \
 	$(NETWORK_libs) \
@@ -306,4 +306,4 @@ systemduserunit_DATA = \
 endif
 
 # Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-@CODE_COVERAGE_RULES@
+include $(top_srcdir)/aminclude_static.am
diff --git a/bus/bus.c b/bus/bus.c
index 30ce4e10..2ad8e789 100644
--- a/bus/bus.c
+++ b/bus/bus.c
@@ -693,11 +693,11 @@ raise_file_descriptor_limit (BusContext      *context)
   /* We used to compute a suitable rlimit based on the configured number
    * of connections, but that breaks down as soon as we allow fd-passing,
    * because each connection is allowed to pass 64 fds to us, and if
-   * they all did, we'd hit kernel limits. We now hard-code 64k as a
-   * good limit, like systemd does: that's enough to avoid DoS from
-   * anything short of multiple uids conspiring against us.
+   * they all did, we'd hit kernel limits. We now hard-code a good
+   * limit that is enough to avoid DoS from anything short of multiple
+   * uids conspiring against us, much like systemd does.
    */
-  if (!_dbus_rlimit_raise_fd_limit_if_privileged (65536, &error))
+  if (!_dbus_rlimit_raise_fd_limit (&error))
     {
       bus_context_log (context, DBUS_SYSTEM_LOG_WARNING,
                        "%s: %s", error.name, error.message);
diff --git a/bus/desktop-file.c b/bus/desktop-file.c
index 44598584..fd4f0d31 100644
--- a/bus/desktop-file.c
+++ b/bus/desktop-file.c
@@ -378,12 +378,16 @@ parse_comment_or_blank (BusDesktopFileParser *parser)
 static dbus_bool_t
 is_valid_section_name (const char *name)
 {
-  /* 5. Group names may contain all ASCII characters except for control characters and '[' and ']'. */
+  /* 5. Group names may contain all ASCII characters except for control characters and '[' and ']'.
+   *
+   * We don't use isprint() here because it's locale-dependent. ASCII
+   * characters <= 0x1f and 0x7f are control characters, and bytes with
+   * values >= 0x80 aren't ASCII. 0x20 is a space, which we must allow,
+   * not least because DBUS_SERVICE_SECTION contains one. */
 
   while (*name)
     {
-      if (!((*name >= 'A' && *name <= 'Z') || (*name >= 'a' || *name <= 'z') ||
-	    *name == '\n' || *name == '\t'))
+      if (*name <= 0x1f || *name >= 0x7f || *name  == '[' || *name == ']')
 	return FALSE;
       
       name++;
diff --git a/cmake/DBus1Config.pkgconfig.in b/cmake/DBus1Config.pkgconfig.in
index 7e090aa5..8c0a25e4 100644
--- a/cmake/DBus1Config.pkgconfig.in
+++ b/cmake/DBus1Config.pkgconfig.in
@@ -10,12 +10,39 @@
 
 get_filename_component(DBus1_PKGCONFIG_DIR "${CMAKE_CURRENT_LIST_DIR}/../../pkgconfig" ABSOLUTE)
 find_package(PkgConfig)
+if(DEFINED ENV{PKG_CONFIG_DIR})
+    set(_dbus_pkgconfig_dir "$ENV{PKG_CONFIG_DIR}")
+endif()
+if(DEFINED ENV{PKG_CONFIG_PATH})
+    set(_dbus_pkgconfig_path "$ENV{PKG_CONFIG_PATH}")
+endif()
+if(DEFINED ENV{PKG_CONFIG_LIBDIR})
+    set(_dbus_pkgconfig_libdir "$ENV{PKG_CONFIG_LIBDIR}")
+endif()
 set(ENV{PKG_CONFIG_DIR})
 set(ENV{PKG_CONFIG_PATH} ${DBus1_PKGCONFIG_DIR})
 set(ENV{PKG_CONFIG_LIBDIR} ${DBus1_PKGCONFIG_DIR})
 # for debugging
 #set(ENV{PKG_CONFIG_DEBUG_SPEW} 1)
 pkg_check_modules(PC_DBUS1 QUIET dbus-1)
+if(DEFINED _dbus_pkgconfig_dir)
+    set(ENV{PKG_CONFIG_DIR} "${_dbus_pkgconfig_dir}")
+else()
+    unset(ENV{PKG_CONFIG_DIR})
+endif()
+if(DEFINED _dbus_pkgconfig_path)
+    set(ENV{PKG_CONFIG_PATH} "${_dbus_pkgconfig_path}")
+else()
+    unset(ENV{PKG_CONFIG_PATH})
+endif()
+if(DEFINED _dbus_pkgconfig_libdir)
+    set(ENV{PKG_CONFIG_LIBDIR} "${_dbus_pkgconfig_libdir}")
+else()
+    unset(ENV{PKG_CONFIG_LIBDIR})
+endif()
+unset(_dbus_pkgconfig_dir)
+unset(_dbus_pkgconfig_path)
+unset(_dbus_pkgconfig_libdir)
 set(DBus1_DEFINITIONS ${PC_DBUS1_CFLAGS_OTHER})
 
 # find the real stuff and use pkgconfig variables as hints
diff --git a/configure.ac b/configure.ac
index be6b0652..34656120 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,14 +3,14 @@ AC_PREREQ([2.63])
 
 m4_define([dbus_major_version], [1])
 m4_define([dbus_minor_version], [12])
-m4_define([dbus_micro_version], [12])
+m4_define([dbus_micro_version], [14])
 m4_define([dbus_version],
           [dbus_major_version.dbus_minor_version.dbus_micro_version])
 AC_INIT([dbus],[dbus_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=dbus],[dbus])
 
 AC_CONFIG_AUX_DIR([build-aux])
 
-m4_pattern_forbid([^AX_],
+m4_pattern_forbid([^AX_(CHECK_ENABLE_DEBUG|CODE_COVERAGE|COMPILER_FLAGS|COMPILER_FLAGS_(CFLAGS|CXXFLAGS|LDFLAGS))\b],
   [Unexpanded AX_ macro found. Please install GNU autoconf-archive])
 
 AC_CANONICAL_HOST
@@ -42,7 +42,7 @@ LT_CURRENT=22
 
 ## increment any time the source changes; set to
 ##  0 if you increment CURRENT
-LT_REVISION=9
+LT_REVISION=10
 
 ## increment if any interfaces have been added; set to 0
 ## if any interfaces have been changed or removed. removal has
diff --git a/dbus/Makefile.am b/dbus/Makefile.am
index b2913ef0..ec8e2a5e 100644
--- a/dbus/Makefile.am
+++ b/dbus/Makefile.am
@@ -329,7 +329,7 @@ test_dbus_SOURCES=				\
 test_dbus_LDADD = libdbus-internal.la
 
 # Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-@CODE_COVERAGE_RULES@
+include $(top_srcdir)/aminclude_static.am
 
 clean-local:
 	$(AM_V_at)rm -fr ./.dbus-keyrings
diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
index 565e089c..e8cd5b33 100644
--- a/dbus/dbus-sysdeps-unix.c
+++ b/dbus/dbus-sysdeps-unix.c
@@ -4364,7 +4364,15 @@ _dbus_daemon_unpublish_session_bus_address (void)
 dbus_bool_t
 _dbus_get_is_errno_eagain_or_ewouldblock (int e)
 {
+  /* Avoid the -Wlogical-op GCC warning, which can be triggered when EAGAIN and
+   * EWOULDBLOCK are numerically equal, which is permitted as described by
+   * errno(3).
+   */
+#if EAGAIN == EWOULDBLOCK
+  return e == EAGAIN;
+#else
   return e == EAGAIN || e == EWOULDBLOCK;
+#endif
 }
 
 /**
diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c
index 2be5b779..7c4c3604 100644
--- a/dbus/dbus-sysdeps-util-unix.c
+++ b/dbus/dbus-sysdeps-util-unix.c
@@ -406,23 +406,15 @@ _dbus_rlimit_save_fd_limit (DBusError *error)
   return self;
 }
 
+/* Enough fds that we shouldn't run out, even if several uids work
+ * together to carry out a denial-of-service attack. This happens to be
+ * the same number that systemd < 234 would normally use. */
+#define ENOUGH_FDS 65536
+
 dbus_bool_t
-_dbus_rlimit_raise_fd_limit_if_privileged (unsigned int  desired,
-                                           DBusError    *error)
+_dbus_rlimit_raise_fd_limit (DBusError *error)
 {
-  struct rlimit lim;
-
-  /* No point to doing this practically speaking
-   * if we're not uid 0.  We expect the system
-   * bus to use this before we change UID, and
-   * the session bus takes the Linux default,
-   * currently 1024 for cur and 4096 for max.
-   */
-  if (getuid () != 0)
-    {
-      /* not an error, we're probably the session bus */
-      return TRUE;
-    }
+  struct rlimit old, lim;
 
   if (getrlimit (RLIMIT_NOFILE, &lim) < 0)
     {
@@ -431,22 +423,43 @@ _dbus_rlimit_raise_fd_limit_if_privileged (unsigned int  desired,
       return FALSE;
     }
 
-  if (lim.rlim_cur == RLIM_INFINITY || lim.rlim_cur >= desired)
+  old = lim;
+
+  if (getuid () == 0)
     {
-      /* not an error, everything is fine */
-      return TRUE;
+      /* We are privileged, so raise the soft limit to at least
+       * ENOUGH_FDS, and the hard limit to at least the desired soft
+       * limit. This assumes we can exercise CAP_SYS_RESOURCE on Linux,
+       * or other OSs' equivalents. */
+      if (lim.rlim_cur != RLIM_INFINITY &&
+          lim.rlim_cur < ENOUGH_FDS)
+        lim.rlim_cur = ENOUGH_FDS;
+
+      if (lim.rlim_max != RLIM_INFINITY &&
+          lim.rlim_max < lim.rlim_cur)
+        lim.rlim_max = lim.rlim_cur;
     }
 
-  /* Ignore "maximum limit", assume we have the "superuser"
-   * privileges.  On Linux this is CAP_SYS_RESOURCE.
-   */
-  lim.rlim_cur = lim.rlim_max = desired;
+  /* Raise the soft limit to match the hard limit, which we can do even
+   * if we are unprivileged. In particular, systemd >= 240 will normally
+   * set rlim_cur to 1024 and rlim_max to 512*1024, recent Debian
+   * versions end up setting rlim_cur to 1024 and rlim_max to 1024*1024,
+   * and older and non-systemd Linux systems would typically set rlim_cur
+   * to 1024 and rlim_max to 4096. */
+  if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max)
+    lim.rlim_cur = lim.rlim_max;
+
+  /* Early-return if there is nothing to do. */
+  if (lim.rlim_max == old.rlim_max &&
+      lim.rlim_cur == old.rlim_cur)
+    return TRUE;
 
   if (setrlimit (RLIMIT_NOFILE, &lim) < 0)
     {
       dbus_set_error (error, _dbus_error_from_errno (errno),
-                      "Failed to set fd limit to %u: %s",
-                      desired, _dbus_strerror (errno));
+                      "Failed to set fd limit to %lu: %s",
+                      (unsigned long) lim.rlim_cur,
+                      _dbus_strerror (errno));
       return FALSE;
     }
 
@@ -485,8 +498,7 @@ _dbus_rlimit_save_fd_limit (DBusError *error)
 }
 
 dbus_bool_t
-_dbus_rlimit_raise_fd_limit_if_privileged (unsigned int  desired,
-                                           DBusError    *error)
+_dbus_rlimit_raise_fd_limit (DBusError *error)
 {
   fd_limit_not_supported (error);
   return FALSE;
diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c
index 1ef4ae6c..1c1d9f7d 100644
--- a/dbus/dbus-sysdeps-util-win.c
+++ b/dbus/dbus-sysdeps-util-win.c
@@ -273,8 +273,7 @@ _dbus_rlimit_save_fd_limit (DBusError *error)
 }
 
 dbus_bool_t
-_dbus_rlimit_raise_fd_limit_if_privileged (unsigned int  desired,
-                                           DBusError    *error)
+_dbus_rlimit_raise_fd_limit (DBusError *error)
 {
   fd_limit_not_supported (error);
   return FALSE;
diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h
index ef786ecc..0b9d7696 100644
--- a/dbus/dbus-sysdeps.h
+++ b/dbus/dbus-sysdeps.h
@@ -698,8 +698,7 @@ dbus_bool_t _dbus_replace_install_prefix (DBusString *path);
 typedef struct DBusRLimit DBusRLimit;
 
 DBusRLimit     *_dbus_rlimit_save_fd_limit                 (DBusError    *error);
-dbus_bool_t     _dbus_rlimit_raise_fd_limit_if_privileged  (unsigned int  desired,
-                                                            DBusError    *error);
+dbus_bool_t     _dbus_rlimit_raise_fd_limit                (DBusError    *error);
 dbus_bool_t     _dbus_rlimit_restore_fd_limit              (DBusRLimit   *saved,
                                                             DBusError    *error);
 void            _dbus_rlimit_free                          (DBusRLimit   *lim);
diff --git a/debian/changelog b/debian/changelog
index c160f275..512710c6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,14 @@
+dbus (1.12.14-1) UNRELEASED; urgency=medium
+
+  * New upstream release
+  * d/rules, d/tests: Run automated tests with DBUS_TEST_MALLOC_FAILURES=0.
+    Testing the code paths for memory allocation failures is too slow
+    to do routinely as a downstream.
+  * d/tests/system-bus: Add a smoke-test for traditional activation,
+    and a smoke-test for systemd activation on systems booted with systemd.
+
+ -- Simon McVittie <smcv@debian.org>  Fri, 17 May 2019 12:20:47 +0100
+
 dbus (1.12.12-1) unstable; urgency=medium
 
   [ Ritesh Raj Sarraf ]
diff --git a/debian/rules b/debian/rules
index 6164c5ea..653a844f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -161,6 +161,7 @@ test_env = \
 	-u DISPLAY \
 	HOME=$(CURDIR)/debian/tmp-home \
 	DBUS_TEST_HOMEDIR=$(CURDIR)/debian/tmp-home \
+	DBUS_TEST_MALLOC_FAILURES=0 \
 	LD_PRELOAD=libnss_wrapper.so \
 	NSS_WRAPPER_HOSTS=$(CURDIR)/debian/hosts \
 	$(NULL)
diff --git a/debian/tests/control b/debian/tests/control
index 4e77199b..aff5eabe 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -9,10 +9,10 @@ Tests: root
 Restrictions: allow-stderr, needs-root
 Depends: dbus, dbus-tests
 
+Tests: system-bus
+Restrictions: isolation-machine, needs-reboot, needs-root
+Depends: dbus, dbus-tests, init
+
 Tests: build
 Restrictions: superficial
 Depends: libdbus-1-dev, dbus, build-essential
-
-Tests: system-bus
-Restrictions: isolation-machine, needs-reboot, needs-root
-Depends: dbus, init
diff --git a/debian/tests/gnome-desktop-testing b/debian/tests/gnome-desktop-testing
index 8f7c79be..dd2decdb 100755
--- a/debian/tests/gnome-desktop-testing
+++ b/debian/tests/gnome-desktop-testing
@@ -12,6 +12,7 @@ unset DISPLAY
 
 DBUS_TEST_HOMEDIR="$AUTOPKGTEST_TMP"
 export DBUS_TEST_HOMEDIR
+export DBUS_TEST_MALLOC_FAILURES=0
 
 exec 2>&1
 
diff --git a/debian/tests/system-bus b/debian/tests/system-bus
index 9f41f43f..61ad077d 100755
--- a/debian/tests/system-bus
+++ b/debian/tests/system-bus
@@ -76,7 +76,61 @@ if as_normal_user dbus-send --system --dest="org.freedesktop.DBus" \
     failed=1
 fi
 
+install -d /usr/local/share/dbus-1/system-services
+cat > /usr/local/share/dbus-1/system-services/org.debian.packages.dbus.TradActivation.service <<EOF
+[D-BUS Service]
+Name=org.debian.packages.dbus.TradActivation
+Exec=/usr/bin/dbus-test-tool echo --system --name=org.debian.packages.dbus.TradActivation
+User=daemon
+EOF
+cat > /usr/local/share/dbus-1/system-services/org.debian.packages.dbus.SystemdActivation.service <<EOF
+[D-BUS Service]
+Name=org.debian.packages.dbus.SystemdActivation
+Exec=/bin/false
+User=daemon
+SystemdService=dbus-org.debian.packages.dbus.SystemdActivation.service
+EOF
+install -d /etc/systemd/system
+cat > /etc/systemd/system/dbus-org.debian.packages.dbus.SystemdActivation.service <<EOF
+[Unit]
+Description=systemd-activatable D-Bus service
+[Service]
+Type=dbus
+BusName=org.debian.packages.dbus.SystemdActivation
+User=daemon
+ExecStart=/usr/bin/dbus-test-tool echo --system --name=org.debian.packages.dbus.SystemdActivation
+EOF
+
+install -d /etc/dbus-1/system.d
+cat > /etc/dbus-1/system.d/org.debian.packages.dbus.Test.conf <<EOF
+<busconfig>
+  <policy user="daemon">
+    <allow own="org.debian.packages.dbus.TradActivation"/>
+    <allow own="org.debian.packages.dbus.SystemdActivation"/>
+  </policy>
+  <policy context="default">
+    <allow send_destination="org.debian.packages.dbus.TradActivation"/>
+    <allow send_destination="org.debian.packages.dbus.SystemdActivation"/>
+  </policy>
+</busconfig>
+EOF
+
+dbus-send --system --dest=org.freedesktop.DBus --type=method_call \
+    --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ReloadConfig \
+    || failed=1
+dbus-send --system --dest="org.debian.packages.dbus.TradActivation" \
+    --type=method_call --print-reply \
+    / org.freedesktop.DBus.Peer.Ping \
+    || failed=1
+
 if [ -d /run/systemd ]; then
+    systemctl daemon-reload
+
+    dbus-send --system --dest="org.debian.packages.dbus.SystemdActivation" \
+        --type=method_call --print-reply \
+        / org.freedesktop.DBus.Peer.Ping \
+        || failed=1
+
     for api in hostname1 locale1 login1 systemd1 timedate1; do
         dbus-send --system --dest="org.freedesktop.$api" \
             --type=method_call --print-reply \
diff --git a/m4/ax_ac_append_to_file.m4 b/m4/ax_ac_append_to_file.m4
new file mode 100644
index 00000000..242b3d52
--- /dev/null
+++ b/m4/ax_ac_append_to_file.m4
@@ -0,0 +1,32 @@
+# ===========================================================================
+#   https://www.gnu.org/software/autoconf-archive/ax_ac_append_to_file.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_AC_APPEND_TO_FILE([FILE],[DATA])
+#
+# DESCRIPTION
+#
+#   Appends the specified data to the specified Autoconf is run. If you want
+#   to append to a file when configure is run use AX_APPEND_TO_FILE instead.
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 10
+
+AC_DEFUN([AX_AC_APPEND_TO_FILE],[
+AC_REQUIRE([AX_FILE_ESCAPES])
+m4_esyscmd(
+AX_FILE_ESCAPES
+[
+printf "%s" "$2" >> "$1"
+])
+])
diff --git a/m4/ax_ac_print_to_file.m4 b/m4/ax_ac_print_to_file.m4
new file mode 100644
index 00000000..642dfc15
--- /dev/null
+++ b/m4/ax_ac_print_to_file.m4
@@ -0,0 +1,32 @@
+# ===========================================================================
+#   https://www.gnu.org/software/autoconf-archive/ax_ac_print_to_file.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_AC_PRINT_TO_FILE([FILE],[DATA])
+#
+# DESCRIPTION
+#
+#   Writes the specified data to the specified file when Autoconf is run. If
+#   you want to print to a file when configure is run use AX_PRINT_TO_FILE
+#   instead.
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 10
+
+AC_DEFUN([AX_AC_PRINT_TO_FILE],[
+m4_esyscmd(
+AC_REQUIRE([AX_FILE_ESCAPES])
+[
+printf "%s" "$2" > "$1"
+])
+])
diff --git a/m4/ax_add_am_macro_static.m4 b/m4/ax_add_am_macro_static.m4
new file mode 100644
index 00000000..6442d24b
--- /dev/null
+++ b/m4/ax_add_am_macro_static.m4
@@ -0,0 +1,28 @@
+# ===========================================================================
+#  https://www.gnu.org/software/autoconf-archive/ax_add_am_macro_static.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_ADD_AM_MACRO_STATIC([RULE])
+#
+# DESCRIPTION
+#
+#   Adds the specified rule to $AMINCLUDE.
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net>
+#   Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 8
+
+AC_DEFUN([AX_ADD_AM_MACRO_STATIC],[
+  AC_REQUIRE([AX_AM_MACROS_STATIC])
+  AX_AC_APPEND_TO_FILE(AMINCLUDE_STATIC,[$1])
+])
diff --git a/m4/ax_am_macros_static.m4 b/m4/ax_am_macros_static.m4
new file mode 100644
index 00000000..f4cee8c8
--- /dev/null
+++ b/m4/ax_am_macros_static.m4
@@ -0,0 +1,38 @@
+# ===========================================================================
+#   https://www.gnu.org/software/autoconf-archive/ax_am_macros_static.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_AM_MACROS_STATIC
+#
+# DESCRIPTION
+#
+#   Adds support for macros that create Automake rules. You must manually
+#   add the following line
+#
+#     include $(top_srcdir)/aminclude_static.am
+#
+#   to your Makefile.am files.
+#
+# LICENSE
+#
+#   Copyright (c) 2009 Tom Howard <tomhoward@users.sf.net>
+#   Copyright (c) 2009 Allan Caffee <allan.caffee@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 11
+
+AC_DEFUN([AMINCLUDE_STATIC],[aminclude_static.am])
+
+AC_DEFUN([AX_AM_MACROS_STATIC],
+[
+AX_AC_PRINT_TO_FILE(AMINCLUDE_STATIC,[
+# ]AMINCLUDE_STATIC[ generated automatically by Autoconf
+# from AX_AM_MACROS_STATIC on ]m4_esyscmd([LC_ALL=C date])[
+])
+])
diff --git a/m4/ax_code_coverage.m4 b/m4/ax_code_coverage.m4
new file mode 100644
index 00000000..3d36924b
--- /dev/null
+++ b/m4/ax_code_coverage.m4
@@ -0,0 +1,272 @@
+# ===========================================================================
+#     https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CODE_COVERAGE()
+#
+# DESCRIPTION
+#
+#   Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS,
+#   CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included
+#   in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every
+#   build target (program or library) which should be built with code
+#   coverage support. Also add rules using AX_ADD_AM_MACRO_STATIC; and
+#   $enable_code_coverage which can be used in subsequent configure output.
+#   CODE_COVERAGE_ENABLED is defined and substituted, and corresponds to the
+#   value of the --enable-code-coverage option, which defaults to being
+#   disabled.
+#
+#   Test also for gcov program and create GCOV variable that could be
+#   substituted.
+#
+#   Note that all optimization flags in CFLAGS must be disabled when code
+#   coverage is enabled.
+#
+#   Usage example:
+#
+#   configure.ac:
+#
+#     AX_CODE_COVERAGE
+#
+#   Makefile.am:
+#
+#     include $(top_srcdir)/aminclude_static.am
+#
+#     my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ...
+#     my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ...
+#     my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ...
+#     my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ...
+#
+#     clean-local: code-coverage-clean
+#     distclean-local: code-coverage-dist-clean
+#
+#   This results in a "check-code-coverage" rule being added to any
+#   Makefile.am which do "include $(top_srcdir)/aminclude_static.am"
+#   (assuming the module has been configured with --enable-code-coverage).
+#   Running `make check-code-coverage` in that directory will run the
+#   module's test suite (`make check`) and build a code coverage report
+#   detailing the code which was touched, then print the URI for the report.
+#
+#   This code was derived from Makefile.decl in GLib, originally licensed
+#   under LGPLv2.1+.
+#
+# LICENSE
+#
+#   Copyright (c) 2012, 2016 Philip Withnall
+#   Copyright (c) 2012 Xan Lopez
+#   Copyright (c) 2012 Christian Persch
+#   Copyright (c) 2012 Paolo Borelli
+#   Copyright (c) 2012 Dan Winship
+#   Copyright (c) 2015,2018 Bastien ROUCARIES
+#
+#   This library is free software; you can redistribute it and/or modify it
+#   under the terms of the GNU Lesser General Public License as published by
+#   the Free Software Foundation; either version 2.1 of the License, or (at
+#   your option) any later version.
+#
+#   This library is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+#   General Public License for more details.
+#
+#   You should have received a copy of the GNU Lesser General Public License
+#   along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+#serial 32
+
+m4_define(_AX_CODE_COVERAGE_RULES,[
+AX_ADD_AM_MACRO_STATIC([
+# Code coverage
+#
+# Optional:
+#  - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting.
+#    Multiple directories may be specified, separated by whitespace.
+#    (Default: \$(top_builddir))
+#  - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated
+#    by lcov for code coverage. (Default:
+#    \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info)
+#  - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage
+#    reports to be created. (Default:
+#    \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage)
+#  - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage,
+#    set to 0 to disable it and leave empty to stay with the default.
+#    (Default: empty)
+#  - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov
+#    instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
+#  - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov
+#    instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
+#  - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov
+#  - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the
+#    collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
+#  - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov
+#    instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
+#  - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering
+#    lcov instance. (Default: empty)
+#  - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov
+#    instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
+#  - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the
+#    genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE)
+#  - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml
+#    instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
+#  - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore
+#
+# The generated report will be titled using the \$(PACKAGE_NAME) and
+# \$(PACKAGE_VERSION). In order to add the current git hash to the title,
+# use the git-version-gen script, available online.
+# Optional variables
+# run only on top dir
+if CODE_COVERAGE_ENABLED
+ ifeq (\$(abs_builddir), \$(abs_top_builddir))
+CODE_COVERAGE_DIRECTORY ?= \$(top_builddir)
+CODE_COVERAGE_OUTPUT_FILE ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage.info
+CODE_COVERAGE_OUTPUT_DIRECTORY ?= \$(PACKAGE_NAME)-\$(PACKAGE_VERSION)-coverage
+
+CODE_COVERAGE_BRANCH_COVERAGE ?=
+CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= \$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\
+--rc lcov_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE))
+CODE_COVERAGE_LCOV_SHOPTS ?= \$(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT)
+CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool \"\$(GCOV)\"
+CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= \$(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH)
+CODE_COVERAGE_LCOV_OPTIONS ?= \$(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT)
+CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?=
+CODE_COVERAGE_LCOV_RMOPTS ?= \$(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT)
+CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\
+\$(if \$(CODE_COVERAGE_BRANCH_COVERAGE),\
+--rc genhtml_branch_coverage=\$(CODE_COVERAGE_BRANCH_COVERAGE))
+CODE_COVERAGE_GENHTML_OPTIONS ?= \$(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT)
+CODE_COVERAGE_IGNORE_PATTERN ?=
+
+GITIGNOREFILES = \$(GITIGNOREFILES) \$(CODE_COVERAGE_OUTPUT_FILE) \$(CODE_COVERAGE_OUTPUT_DIRECTORY)
+code_coverage_v_lcov_cap = \$(code_coverage_v_lcov_cap_\$(V))
+code_coverage_v_lcov_cap_ = \$(code_coverage_v_lcov_cap_\$(AM_DEFAULT_VERBOSITY))
+code_coverage_v_lcov_cap_0 = @echo \"  LCOV   --capture\" \$(CODE_COVERAGE_OUTPUT_FILE);
+code_coverage_v_lcov_ign = \$(code_coverage_v_lcov_ign_\$(V))
+code_coverage_v_lcov_ign_ = \$(code_coverage_v_lcov_ign_\$(AM_DEFAULT_VERBOSITY))
+code_coverage_v_lcov_ign_0 = @echo \"  LCOV   --remove /tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN);
+code_coverage_v_genhtml = \$(code_coverage_v_genhtml_\$(V))
+code_coverage_v_genhtml_ = \$(code_coverage_v_genhtml_\$(AM_DEFAULT_VERBOSITY))
+code_coverage_v_genhtml_0 = @echo \"  GEN   \" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\";
+code_coverage_quiet = \$(code_coverage_quiet_\$(V))
+code_coverage_quiet_ = \$(code_coverage_quiet_\$(AM_DEFAULT_VERBOSITY))
+code_coverage_quiet_0 = --quiet
+
+# sanitizes the test-name: replaces with underscores: dashes and dots
+code_coverage_sanitize = \$(subst -,_,\$(subst .,_,\$(1)))
+
+# Use recursive makes in order to ignore errors during check
+check-code-coverage:
+	-\$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) -k check
+	\$(AM_V_at)\$(MAKE) \$(AM_MAKEFLAGS) code-coverage-capture
+
+# Capture code coverage data
+code-coverage-capture: code-coverage-capture-hook
+	\$(code_coverage_v_lcov_cap)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --capture --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" --test-name \"\$(call code_coverage_sanitize,\$(PACKAGE_NAME)-\$(PACKAGE_VERSION))\" --no-checksum --compat-libtool \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_OPTIONS)
+	\$(code_coverage_v_lcov_ign)\$(LCOV) \$(code_coverage_quiet) \$(addprefix --directory ,\$(CODE_COVERAGE_DIRECTORY)) --remove \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"/tmp/*\" \$(CODE_COVERAGE_IGNORE_PATTERN) --output-file \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_LCOV_SHOPTS) \$(CODE_COVERAGE_LCOV_RMOPTS)
+	-@rm -f \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\"
+	\$(code_coverage_v_genhtml)LANG=C \$(GENHTML) \$(code_coverage_quiet) \$(addprefix --prefix ,\$(CODE_COVERAGE_DIRECTORY)) --output-directory \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\" --title \"\$(PACKAGE_NAME)-\$(PACKAGE_VERSION) Code Coverage\" --legend --show-details \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \$(CODE_COVERAGE_GENHTML_OPTIONS)
+	@echo \"file://\$(abs_builddir)/\$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html\"
+
+code-coverage-clean:
+	-\$(LCOV) --directory \$(top_builddir) -z
+	-rm -rf \"\$(CODE_COVERAGE_OUTPUT_FILE)\" \"\$(CODE_COVERAGE_OUTPUT_FILE).tmp\" \"\$(CODE_COVERAGE_OUTPUT_DIRECTORY)\"
+	-find . \\( -name \"*.gcda\" -o -name \"*.gcno\" -o -name \"*.gcov\" \\) -delete
+
+code-coverage-dist-clean:
+
+A][M_DISTCHECK_CONFIGURE_FLAGS = \$(A][M_DISTCHECK_CONFIGURE_FLAGS) --disable-code-coverage
+ else # ifneq (\$(abs_builddir), \$(abs_top_builddir))
+check-code-coverage:
+
+code-coverage-capture: code-coverage-capture-hook
+
+code-coverage-clean:
+
+code-coverage-dist-clean:
+ endif # ifeq (\$(abs_builddir), \$(abs_top_builddir))
+else #! CODE_COVERAGE_ENABLED
+# Use recursive makes in order to ignore errors during check
+check-code-coverage:
+	@echo \"Need to reconfigure with --enable-code-coverage\"
+# Capture code coverage data
+code-coverage-capture: code-coverage-capture-hook
+	@echo \"Need to reconfigure with --enable-code-coverage\"
+
+code-coverage-clean:
+
+code-coverage-dist-clean:
+
+endif #CODE_COVERAGE_ENABLED
+# Hook rule executed before code-coverage-capture, overridable by the user
+code-coverage-capture-hook:
+
+.PHONY: check-code-coverage code-coverage-capture code-coverage-dist-clean code-coverage-clean code-coverage-capture-hook
+])
+])
+
+AC_DEFUN([_AX_CODE_COVERAGE_ENABLED],[
+	AX_CHECK_GNU_MAKE([],[AC_MSG_ERROR([not using GNU make that is needed for coverage])])
+	AC_REQUIRE([AX_ADD_AM_MACRO_STATIC])
+	# check for gcov
+	AC_CHECK_TOOL([GCOV],
+		  [$_AX_CODE_COVERAGE_GCOV_PROG_WITH],
+		  [:])
+	AS_IF([test "X$GCOV" = "X:"],
+	      [AC_MSG_ERROR([gcov is needed to do coverage])])
+	AC_SUBST([GCOV])
+
+	dnl Check if gcc is being used
+	AS_IF([ test "$GCC" = "no" ], [
+		AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage])
+	      ])
+
+	AC_CHECK_PROG([LCOV], [lcov], [lcov])
+	AC_CHECK_PROG([GENHTML], [genhtml], [genhtml])
+
+	AS_IF([ test x"$LCOV" = x ], [
+		AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed])
+	      ])
+
+	AS_IF([ test x"$GENHTML" = x ], [
+		AC_MSG_ERROR([Could not find genhtml from the lcov package])
+	])
+
+	dnl Build the code coverage flags
+	dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility
+	CODE_COVERAGE_CPPFLAGS="-DNDEBUG"
+	CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
+	CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -ftest-coverage"
+	CODE_COVERAGE_LIBS="-lgcov"
+
+	AC_SUBST([CODE_COVERAGE_CPPFLAGS])
+	AC_SUBST([CODE_COVERAGE_CFLAGS])
+	AC_SUBST([CODE_COVERAGE_CXXFLAGS])
+	AC_SUBST([CODE_COVERAGE_LIBS])
+])
+
+AC_DEFUN([AX_CODE_COVERAGE],[
+	dnl Check for --enable-code-coverage
+
+	# allow to override gcov location
+	AC_ARG_WITH([gcov],
+	  [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])],
+	  [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov],
+	  [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov])
+
+	AC_MSG_CHECKING([whether to build with code coverage support])
+	AC_ARG_ENABLE([code-coverage],
+	  AS_HELP_STRING([--enable-code-coverage],
+	  [Whether to enable code coverage support]),,
+	  enable_code_coverage=no)
+
+	AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test "x$enable_code_coverage" = xyes])
+	AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage])
+	AC_MSG_RESULT($enable_code_coverage)
+
+	AS_IF([ test "x$enable_code_coverage" = xyes ], [
+		_AX_CODE_COVERAGE_ENABLED
+	      ])
+
+	_AX_CODE_COVERAGE_RULES
+])
diff --git a/m4/ax_file_escapes.m4 b/m4/ax_file_escapes.m4
new file mode 100644
index 00000000..a86fdc32
--- /dev/null
+++ b/m4/ax_file_escapes.m4
@@ -0,0 +1,30 @@
+# ===========================================================================
+#     https://www.gnu.org/software/autoconf-archive/ax_file_escapes.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_FILE_ESCAPES
+#
+# DESCRIPTION
+#
+#   Writes the specified data to the specified file.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Tom Howard <tomhoward@users.sf.net>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 8
+
+AC_DEFUN([AX_FILE_ESCAPES],[
+AX_DOLLAR="\$"
+AX_SRB="\\135"
+AX_SLB="\\133"
+AX_BS="\\\\"
+AX_DQ="\""
+])
diff --git a/test/Makefile.am b/test/Makefile.am
index 6a6e1a30..3582932e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -39,9 +39,9 @@ libdbus_testutils_la_SOURCES += \
 endif
 
 libdbus_testutils_la_LIBADD = \
+	$(CODE_COVERAGE_LIBS) \
 	$(top_builddir)/dbus/libdbus-1.la \
 	$(top_builddir)/dbus/libdbus-internal.la \
-	$(CODE_COVERAGE_LDFLAGS) \
 	$(NULL)
 
 TEST_EXTENSIONS = .sh
@@ -554,8 +554,11 @@ EXTRA_DIST += $(static_data)
 
 ## copy tests to builddir so that generated tests and static tests
 ## are all in one place.
+## Note that we can't create the XDG_RUNTIME_DIR with permissions 0700
+## on MSYS2, which rejects attempts to change permissions, hence "|| true".
 all-local: copy-config-local uninstalled-config-local
-	$(AM_V_at)$(MKDIR_P) -m 700 XDG_RUNTIME_DIR
+	$(AM_V_at)$(MKDIR_P) XDG_RUNTIME_DIR
+	$(AM_V_at)chmod 0700 XDG_RUNTIME_DIR || true
 
 copy-config-local:
 	$(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d
@@ -672,4 +675,4 @@ $(installable_test_meta_with_config): %_with_config.test: %$(EXEEXT) Makefile
 	) > $@.tmp && mv $@.tmp $@
 
 # Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
-@CODE_COVERAGE_RULES@
+include $(top_srcdir)/aminclude_static.am
diff --git a/tools/dbus-send.c b/tools/dbus-send.c
index 6fb65fe0..efeb76e0 100644
--- a/tools/dbus-send.c
+++ b/tools/dbus-send.c
@@ -289,13 +289,16 @@ main (int argc, char *argv[])
         }
       else if ((strstr (arg, "--bus=") == arg) || (strstr (arg, "--peer=") == arg) || (strstr (arg, "--address=") == arg))
         {
-          if (arg[2] == 'b') /* bus */
+          /* Check for peer first, to avoid the GCC -Wduplicated-branches
+           * warning.
+           */
+          if (arg[2] == 'p') /* peer */
             {
-              is_bus = TRUE;
+              is_bus = FALSE;
             }
-          else if (arg[2] == 'p') /* peer */
+          else if (arg[2] == 'b') /* bus */
             {
-              is_bus = FALSE;
+              is_bus = TRUE;
             }
           else /* address; keeping backwards compatibility */
             {

--- End Message ---
--- Begin Message ---
Cyril Brulebois:
> Niels Thykier <niels@thykier.net> (2019-05-19):
>> Ok. I have added an unblock and age-days 8 hint.  Also CC'ing KiBi for
>> a d-i ack before adding an unblock-udeb hint.
> 
> Apologies for the delay; no objections.
> 
> 
> Cheers,
> 

Unblocked, thanks.
~Niels

--- End Message ---

Reply to: