Merge branch 'dbus-1.4'
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 21 Sep 2011 10:39:32 +0000 (11:39 +0100)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Wed, 21 Sep 2011 10:39:32 +0000 (11:39 +0100)
Conflicts:
NEWS

1  2 
NEWS
bus/activation.c
configure.ac
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-util-unix.c
test/Makefile.am
test/name-test/Makefile.am

diff --combined NEWS
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -1,8 -1,16 +1,18 @@@
 -D-Bus 1.4.16 (UNRELEASED)
 +D-Bus 1.5.8 (UNRELEASED)
  ==
  
 -The "this answerphone fails to answer the phone" release.
++The "cross-metering" release.
++
 +• Clean up dead code (fd.o #39231, Simon McVittie)
  
+ • If full test coverage is requested via --enable-tests, strictly require
+   Python, pygobject and dbus-python, which are required by some tests; if not,
+   and Python is missing, skip those tests rather than failing
+   (fd.o #37847, Simon McVittie)
+ • When using cmake, provide the same version-info API in the installed headers
+   as for autotools (DBUS_VERSION, etc.) (fd.o #40905, Ralf Habacker)
  • Add a regression test for fd.o #38005 (fd.o #39836, Simon McVittie)
  
  • Make "NOCONFIGURE=1 ./autogen.sh" not run configure (Colin Walters)
@@@ -15,6 -23,9 +25,9 @@@
  • Fix broken links from dbus-tutorial.html if $(htmldir) != $(docdir)
    (fd.o #39879, Chris Mayo)
  
+ • Fix a small memory leak, and a failure to report errors, when updating
+   a service file entry for activation (fd.o #39230, Simon McVittie)
  • Unix-specific:
    · Clean up (non-abstract) Unix sockets on bus daemon exit (fd.o #38656;
      Brian Cameron, Simon McVittie)
      Simon McVittie)
    · Fix compilation on non-C99 systems that have inttypes.h but not stdint.h,
      like Solaris (fd.o #40313, Dagobert Michelsen)
+   · Define CMSG_ALIGN, CMSG_LEN, CMSG_SPACE on Solaris < 10
+     (fd.o #40235, Simon McVittie)
+   · Cope with Unixes that don't have LOG_PERROR, like Solaris 10
+     (fd.o #39987, Simon McVittie)
+   · Cope with platforms whose vsnprintf violates both POSIX and C99, like
+     Tru64, IRIX and HP-UX (fd.o #11668, Simon McVittie)
  
  • Windows-specific:
    · Fix compilation on MSVC, which doesn't understand "inline" with its
      C99 meaning (fd.o #40000; Ralf Habacker, Simon McVittie)
    · Fix misuse of GPid in test/dbus-daemon.c (fd.o #40003, Simon McVittie)
 +  · Fix cross-compilation to Windows with Automake (fd.o #40003, Simon McVittie)
  
 -D-Bus 1.4.14 (2011-07-29)
 +D-Bus 1.5.6 (2011-07-29)
  ==
  
 -The "Puny receptacle!" release.
 +The "weird, gravy-like aftertaste" release.
  
 -Changes:
 +In addition to new features and refactoring, this release contains all of the
 +bugfixes from 1.4.14.
 +
 +Potentially incompatible (Bustle and similar debugging tools will need
 +changes to work as intended):
 +
 +• Do not allow match rules to "eavesdrop" (receive messages intended for a
 +  different recipient) by mistake: eavesdroppers must now opt-in to this
 +  behaviour by putting "eavesdrop='true'" in the match rule, which will
 +  not have any practical effect on buses where eavesdropping is not allowed
 +  (fd.o #37890, Cosimo Alfarano)
 +
 +Other changes:
 +
 +• D-Bus Specification version 0.18 (fd.o #37890, fd.o #39450, fd.o #38252;
 +  Cosimo Alfarano, Simon McVittie)
 +  · add the "eavesdrop" keyword to match rules
 +  · define eavesdropping, unicast messages and broadcast messages
 +  · stop claiming that match rules are needed to match unicast messages to you
 +  · promote the type system to be a top-level section
  
  • Use DBUS_ERROR_OBJECT_PATH_IN_USE if dbus_connection_try_register_object_path
 -  or dbus_connection_try_register_fallback fails, not ...ADDRESS_IN_USE
 -  (fd.o #38874, Jiří Klimeš)
 +  or dbus_connection_try_register_fallback fails, not ...ADDRESS_IN_USE,
 +  and simplify object-path registration (fd.o #38874, Jiří Klimeš)
  
  • Consistently use atomic operations on everything that is ever manipulated
    via atomic ops, as was done for changes to DBusConnection's refcount in
  • Make "make check" in a clean tree work, by not running tests until
    test data has been set up (fd.o #34405, Simon McVittie)
  
 +• The dbus-daemon no longer busy-loops if it has a very large number of file
 +  descriptors (fd.o #23194, Simon McVittie)
 +
 +• Refactor message flow through dispatching to avoid locking violations if
 +  the bus daemon's message limit is hit; remove the per-connection link cache,
 +  which was meant to improve performance, but now reduces it (fd.o #34393,
 +  Simon McVittie)
 +
 +• Some cmake fixes (Ralf Habacker)
 +
 +• Remove dead code, mainly from DBusString (fd.o #38570, fd.o #39610;
 +  Simon McVittie, Lennart Poettering)
 +
 +• Stop storing two extra byte order indicators in each D-Bus message
 +  (fd.o #38287, Simon McVittie)
 +
 +• Add an optional Stats interface which can be used to get statistics from
 +  a running dbus-daemon if enabled at configure time with --enable-stats
 +  (fd.o #34040, Simon McVittie)
 +
  • Fix various typos (fd.o #27227, fd.o #38284; Sascha Silbe, Simon McVittie)
  
  • Documentation (fd.o #36156, Simon McVittie):
    · fix use of a mutex for autolaunch server detection
    · don't crash on malloc failure in _dbus_printf_string_upper_bound
  
 -D-Bus 1.4.12 (2011-06-10)
 +D-Bus 1.5.4 (2011-06-10)
  ==
  
  Security (local denial of service):
@@@ -150,10 -127,10 +169,10 @@@ Changes
  • Windows-specific changes:
    · don't try to build dbus-daemon-launch-helper (fd.o #37838, Mark Brand)
  
 -D-Bus 1.4.10 (2011-06-01)
 +D-Bus 1.5.2 (2011-06-01)
  ==
  
 -The "Ape Ale" release.
 +The "Boar Hunter" release.
  
  Notes for distributors:
  
  
  Changes:
  
 +  • D-Bus Specification v0.17
 +    · Reserve the extra characters used in signatures by GVariant
 +      (fd.o #34529, Simon McVittie)
 +    · Define the ObjectManager interface (fd.o #34869, David Zeuthen)
    • Don't force -fPIE: distributions and libtool know better than we do whether
      it's desirable (fd.o #16621, fd.o #27215; Simon McVittie)
    • Allow --disable-gc-sections, in case your toolchain offers the
      (fd.o #14512; Simon McVittie, loosely based on a patch from Luca Barbato)
    • Ensure that maintainers upload documentation with the right permissions
      (fd.o #36130, Simon McVittie)
 +  • Don't force users of libdbus to be linked against -lpthread, -lrt
 +    (fd.o #32827, Simon McVittie)
    • Log system-bus activation information to syslog (fd.o #35705,
      Colin Walters)
    • Log messages dropped due to quotas to syslog (fd.o #35358,
    • Windows:
      • Remove obsolete workaround for winioctl.h (fd.o #35083, Ralf Habacker)
  
 +D-Bus 1.5.0 (2011-04-11)
 +==
 +
 +The "you never know when you need to tow something from your giant
 +flying shark" release.
 +
 +  • D-Bus Specification v0.16
 +    · Add support for path_namespace and arg0namespace in match rules
 +      (fd.o #24317, #34870; Will Thompson, David Zeuthen, Simon McVittie)
 +    · Make argNpath support object paths, not just object-path-like strings,
 +      and document it better (fd.o #31818, Will Thompson)
 +  • Let the bus daemon implement more than one interface (fd.o #33757,
 +    Simon McVittie)
 +  • Optimize _dbus_string_replace_len to reduce waste (fd.o #21261,
 +    Roberto Guido)
 +  • Require user intervention to compile with missing 64-bit support
 +    (fd.o #35114, Simon McVittie)
 +  • Add dbus_type_is_valid as public API (fd.o #20496, Simon McVittie)
 +  • Raise UnknownObject instead of UnknownMethod for calls to methods on
 +    paths that are not part of the object tree, and UnknownInterface for calls
 +    to unknown interfaces in the bus daemon (fd.o #34527, Lennart Poettering)
 +
  D-Bus 1.4.8 (2011-04-08)
  ==
  
diff --combined bus/activation.c
@@@ -143,6 -143,16 +143,6 @@@ bus_pending_activation_entry_free (BusP
    dbus_free (entry);
  }
  
 -static void
 -handle_timeout_callback (DBusTimeout   *timeout,
 -                         void          *data)
 -{
 -  BusPendingActivation *pending_activation = data;
 -
 -  while (!dbus_timeout_handle (pending_activation->timeout))
 -    _dbus_wait_for_memory ();
 -}
 -
  static BusPendingActivation *
  bus_pending_activation_ref (BusPendingActivation *pending_activation)
  {
@@@ -169,7 -179,8 +169,7 @@@ bus_pending_activation_unref (BusPendin
    if (pending_activation->timeout_added)
      {
        _dbus_loop_remove_timeout (bus_context_get_loop (pending_activation->activation->context),
 -                                 pending_activation->timeout,
 -                                 handle_timeout_callback, pending_activation);
 +                                 pending_activation->timeout);
        pending_activation->timeout_added = FALSE;
      }
  
@@@ -257,6 -268,7 +257,7 @@@ update_desktop_file_entry (BusActivatio
  
    _DBUS_ASSERT_ERROR_IS_CLEAR (error);
  
+   retval = FALSE;
    name = NULL;
    exec = NULL;
    user = NULL;
  
        if (_dbus_hash_table_lookup_string (activation->entries, name))
          {
-           _dbus_verbose ("The new service name \"%s\" of service file \"%s\" already in cache, ignoring\n",
+           _dbus_verbose ("The new service name \"%s\" of service file \"%s\" is already in cache, ignoring\n",
                           name, _dbus_string_get_const_data (&file_path));
+           dbus_set_error (error, DBUS_ERROR_FAILED,
+                           "The new service name \"%s\" of service file \"%s\" is already in cache, ignoring\n",
+                           name, _dbus_string_get_const_data (&file_path));
            goto out;
          }
  
             * the entries hash table */
            _dbus_hash_table_remove_string (entry->s_dir->entries,
                                            entry->filename);
-           bus_activation_entry_unref (entry);
-           return FALSE;
+           goto out;
          }
      }
  
@@@ -465,7 -479,7 +468,7 @@@ out
    if (entry)
      bus_activation_entry_unref (entry);
  
-   return FALSE;
+   return retval;
  }
  
  static dbus_bool_t
@@@ -881,6 -895,8 +884,6 @@@ bus_activation_new (BusContext        *
                      DBusError         *error)
  {
    BusActivation *activation;
 -  DBusList      *link;
 -  char          *dir;
  
    _DBUS_ASSERT_ERROR_IS_CLEAR (error);
  
@@@ -1321,16 -1337,22 +1324,16 @@@ handle_servicehelper_exit_error (in
      }
  }
  
 -static dbus_bool_t
 -babysitter_watch_callback (DBusWatch     *watch,
 -                           unsigned int   condition,
 -                           void          *data)
 +static void
 +pending_activation_finished_cb (DBusBabysitter *babysitter,
 +                                void           *data)
  {
    BusPendingActivation *pending_activation = data;
 -  dbus_bool_t retval;
 -  DBusBabysitter *babysitter;
    dbus_bool_t uses_servicehelper;
  
 -  babysitter = pending_activation->babysitter;
 -
 +  _dbus_assert (babysitter == pending_activation->babysitter);
    _dbus_babysitter_ref (babysitter);
  
 -  retval = dbus_watch_handle (watch, condition);
 -
    /* There are two major cases here; are we the system bus or the session?  Here this
     * is distinguished by whether or not we use a setuid helper launcher.  With the launch helper,
     * some process exit codes are meaningful, processed by handle_servicehelper_exit_error.
     */
    uses_servicehelper = bus_context_get_servicehelper (pending_activation->activation->context) != NULL;
  
 -  /* FIXME this is broken in the same way that
 -   * connection watches used to be; there should be
 -   * a separate callback for status change, instead
 -   * of doing "if we handled a watch status might
 -   * have changed"
 -   *
 -   * Fixing this lets us move dbus_watch_handle
 -   * calls into dbus-mainloop.c
 -   */
 +  /* strictly speaking this is redundant with the check in dbus-spawn now */
    if (_dbus_babysitter_get_child_exited (babysitter))
      {
        DBusError error;
      }
  
    _dbus_babysitter_unref (babysitter);
 -
 -  return retval;
  }
  
  static dbus_bool_t
@@@ -1409,9 -1441,9 +1412,9 @@@ add_babysitter_watch (DBusWatch      *w
  {
    BusPendingActivation *pending_activation = data;
  
 -  return _dbus_loop_add_watch (bus_context_get_loop (pending_activation->activation->context),
 -                               watch, babysitter_watch_callback, pending_activation,
 -                               NULL);
 +  return _dbus_loop_add_watch (
 +      bus_context_get_loop (pending_activation->activation->context),
 +      watch);
  }
  
  static void
@@@ -1421,7 -1453,7 +1424,7 @@@ remove_babysitter_watch (DBusWatc
    BusPendingActivation *pending_activation = data;
  
    _dbus_loop_remove_watch (bus_context_get_loop (pending_activation->activation->context),
 -                           watch, babysitter_watch_callback, pending_activation);
 +                           watch);
  }
  
  static dbus_bool_t
@@@ -1669,6 -1701,7 +1672,6 @@@ bus_activation_activate_service (BusAct
    char **envp = NULL;
    int argc;
    dbus_bool_t retval;
 -  DBusHashIter iter;
    dbus_bool_t was_pending_activation;
    DBusString command;
  
          }
  
        if (!_dbus_loop_add_timeout (bus_context_get_loop (activation->context),
 -                                   pending_activation->timeout,
 -                                   handle_timeout_callback,
 -                                   pending_activation,
 -                                   NULL))
 +                                   pending_activation->timeout))
          {
            _dbus_verbose ("Failed to add timeout for pending activation\n");
  
  
    _dbus_assert (pending_activation->babysitter != NULL);
  
 +  _dbus_babysitter_set_result_function (pending_activation->babysitter,
 +                                        pending_activation_finished_cb,
 +                                        pending_activation);
 +
    if (!_dbus_babysitter_set_watch_functions (pending_activation->babysitter,
                                               add_babysitter_watch,
                                               remove_babysitter_watch,
diff --combined configure.ac
@@@ -2,8 -2,8 +2,8 @@@ dnl -*- mode: m4 -*
  AC_PREREQ([2.63])
  
  m4_define([dbus_major_version], [1])
 -m4_define([dbus_minor_version], [4])
 -m4_define([dbus_micro_version], [15])
 +m4_define([dbus_minor_version], [5])
 +m4_define([dbus_micro_version], [7])
  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])
@@@ -32,16 -32,16 +32,16 @@@ AC_DEFINE_UNQUOTED(DBUS_DAEMON_NAME,"db
  #
  
  ## increment if the interface has additions, changes, removals.
 -LT_CURRENT=8
 +LT_CURRENT=9
  
  ## increment any time the source changes; set to
  ##  0 if you increment CURRENT
 -LT_REVISION=7
 +LT_REVISION=3
  
  ## increment if any interfaces have been added; set to 0
  ## if any interfaces have been changed or removed. removal has
  ## precedence over adding, so set to 0 if both happened.
 -LT_AGE=5
 +LT_AGE=6
  
  AC_SUBST(LT_CURRENT)
  AC_SUBST(LT_REVISION)
@@@ -163,7 -163,14 +163,14 @@@ AC_ARG_ENABLE([modular-tests]
  AC_ARG_ENABLE([tests],
    AS_HELP_STRING([--enable-tests],
      [enable/disable all tests, overriding embedded-tests/modular-tests]),
-   [enable_embedded_tests=$enableval; enable_modular_tests=$enableval],
+   [
+   if test "x$enableval" = xyes; then
+     AC_MSG_NOTICE([Full test coverage was requested with --enable-tests=yes])
+     AC_MSG_NOTICE([This has many dependencies (GLib, dbus-glib, Python)])
+   fi
+   enable_embedded_tests=$enableval
+   enable_modular_tests=$enableval
+   ],
    [])
  
  # DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files
@@@ -187,7 -194,8 +194,8 @@@ if test "x$enable_modular_tests" != xno
    PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.22, gio-2.0 >= 2.22],
      [],
      [if test "x$enable_modular_tests" = xyes; then
-       AC_MSG_ERROR([GLib is required by the modular tests])
+       AC_MSG_NOTICE([Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires GLib])
+       AC_MSG_ERROR([$GLIB_ERRORS])
      else # assumed to be "auto"
        enable_modular_tests=no
      fi])
    PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1],
      [],
      [if test "x$enable_modular_tests" = xyes; then
-       AC_MSG_ERROR([dbus-glib is required by the modular tests (for now)])
+       AC_MSG_NOTICE([Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires dbus-glib])
+       AC_MSG_ERROR([$DBUS_GLIB_ERRORS])
      else # assumed to be "auto"
        enable_modular_tests=no
      fi])
@@@ -218,6 -227,22 +227,22 @@@ AC_ARG_ENABLE([installed-tests]
  AM_CONDITIONAL([DBUS_ENABLE_INSTALLED_TESTS],
    [test "x$enable_installed_tests" = xyes])
  
+ if test "x$enable_tests" = xyes; then
+   # full test coverage is required, Python is a hard dependency
+   AC_MSG_NOTICE([Full test coverage (--enable-tests=yes) requires Python, dbus-python, pygobject])
+   AM_PATH_PYTHON([2.6])
+   AC_MSG_CHECKING([for Python modules for full test coverage])
+   if "$PYTHON" -c "import dbus, gobject, dbus.mainloop.glib"; then
+     AC_MSG_RESULT([yes])
+   else
+     AC_MSG_RESULT([no])
+     AC_MSG_ERROR([cannot import dbus, gobject, dbus.mainloop.glib Python modules])
+   fi
+ else
+   # --enable-tests not given: do not abort if Python is missing
+   AM_PATH_PYTHON([2.6], [], [:])
+ fi
  if test x$enable_verbose_mode = xyes; then
      AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
  fi
@@@ -287,12 -312,6 +312,12 @@@ AC_CHECK_SIZEOF(void *
  AC_CHECK_SIZEOF(long long)
  AC_CHECK_SIZEOF(__int64)
  
 +AC_ARG_WITH([64-bit],
 +  [AS_HELP_STRING([--without-64-bit],
 +    [If you have to use this option, please report it as a bug])],
 +  [],
 +  [with_64_bit=yes])
 +
  ### See what our 64 bit type is called
  AC_MSG_CHECKING([64-bit integer type])
  
@@@ -330,32 -349,13 +355,32 @@@ $ac_cv_sizeof___int64
    ;;
  esac
  
 -if test -z "$dbusint64" ; then
 +AS_IF(
 +  [test "x$with_64_bit" = xno],
 +  [
          DBUS_INT64_TYPE="no_int64_type_detected"
          DBUS_HAVE_INT64=0
          DBUS_INT64_CONSTANT=
          DBUS_UINT64_CONSTANT=
 -        AC_MSG_RESULT([none found])
 -else
 +        AC_MSG_RESULT([disabled via --without-64-bit])
 +  ],
 +  dnl else if
 +  [test -z "$dbusint64"],
 +  [AC_MSG_RESULT([not found])
 +  AC_MSG_ERROR([Could not find a 64-bit integer type.
 +
 +Please report a bug here with details of your platform and compiler:
 +
 +    http://bugs.freedesktop.org/enter_bug.cgi?product=DBus&component=core
 +
 +To compile D-Bus with all 64-bit integer types removed (not recommended), use
 +the option "--without-64-bit".
 +
 +This option is likely to be removed in future, unless you report that your
 +platform needs it.])
 +  ],
 +  dnl else
 +  [
          DBUS_INT64_TYPE="$dbusint64"
          DBUS_HAVE_INT64=1
          DBUS_INT64_CONSTANT="$dbusint64_constant"
                AC_DEFINE_UNQUOTED(DBUS_INT64_PRINTF_MODIFIER, [$dbusint64_printf_modifier], [Define to printf modifier for 64 bit integer type])
        fi
          AC_MSG_RESULT($DBUS_INT64_TYPE)
 -fi
 +  ])
  
  AC_SUBST(DBUS_INT64_TYPE)
  AC_SUBST(DBUS_INT64_CONSTANT)
@@@ -545,6 -545,11 +570,11 @@@ AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_
  
  AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull)
  
+ AC_CHECK_HEADERS([syslog.h])
+ if test "x$ac_cv_header_syslog_h" = "xyes"; then
+   AC_CHECK_DECLS([LOG_PERROR], [], [], [[#include <syslog.h>]])
+ fi
  #### Check for broken poll; taken from Glib's configure
  
  AC_MSG_CHECKING([for broken poll])
@@@ -890,8 -895,6 +920,8 @@@ if $dbus_use_libxml; the
     XML_LIBS=$LIBXML_LIBS
     XML_CFLAGS=$LIBXML_CFLAGS
  fi
 +AC_SUBST([XML_CFLAGS])
 +AC_SUBST([XML_LIBS])
  
  # Thread lib detection
  AC_CHECK_FUNC(pthread_cond_timedwait,[AC_CHECK_LIB(pthread,pthread_cond_timedwait,
@@@ -922,8 -925,6 +952,8 @@@ f
  fi
  LIBS="$save_libs"
  
 +AC_SUBST([THREAD_LIBS])
 +
  # SELinux detection
  if test x$enable_selinux = xno ; then
      have_selinux=no;
@@@ -1091,9 -1092,7 +1121,9 @@@ if test x$have_libaudit = xyes ; the
      AC_DEFINE(HAVE_LIBAUDIT,1,[audit daemon SELinux support])
  fi
  
 -# Check for ADT API
 +AC_SUBST([SELINUX_LIBS])
 +
 +# Check for ADT API (Solaris Basic Security Mode auditing)
  AC_MSG_CHECKING(for ADT API)
  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
  #include <bsm/adt.h>
@@@ -1109,7 -1108,6 +1139,7 @@@ the
  else
     AC_MSG_RESULT(no)
  fi
 +AC_SUBST([ADT_LIBS])
  
  # Check for SCM_RIGHTS
  AC_MSG_CHECKING([for SCM_RIGHTS])
@@@ -1131,11 -1129,26 +1161,11 @@@ if test x$dbus_win = xyes ; the
    fi
  fi
  
 +AC_SUBST([NETWORK_libs])
 +
  #### Set up final flags
 -DBUS_CLIENT_CFLAGS=
 -DBUS_CLIENT_LIBS="$THREAD_LIBS $NETWORK_libs"
 -AC_SUBST(DBUS_CLIENT_CFLAGS)
 -AC_SUBST(DBUS_CLIENT_LIBS)
 -
 -DBUS_BUS_CFLAGS="$XML_CFLAGS"
 -DBUS_BUS_LIBS="$XML_LIBS $SELINUX_LIBS $THREAD_LIBS $ADT_LIBS $NETWORK_libs"
 -AC_SUBST(DBUS_BUS_CFLAGS)
 -AC_SUBST(DBUS_BUS_LIBS)
 -
 -DBUS_LAUNCHER_CFLAGS="$XML_CFLAGS"
 -DBUS_LAUNCHER_LIBS="$XML_LIBS $THREAD_LIBS $NETWORK_libs"
 -AC_SUBST(DBUS_LAUNCHER_CFLAGS)
 -AC_SUBST(DBUS_LAUNCHER_LIBS)
 -
 -DBUS_TEST_CFLAGS=
 -DBUS_TEST_LIBS="$THREAD_LIBS $NETWORK_libs"
 -AC_SUBST(DBUS_TEST_CFLAGS)
 -AC_SUBST(DBUS_TEST_LIBS)
 +LIBDBUS_LIBS="$THREAD_LIBS $NETWORK_libs"
 +AC_SUBST([LIBDBUS_LIBS])
  
  ### X11 detection
  DBUS_X_LIBS=
@@@ -1367,7 -1380,12 +1397,12 @@@ AM_CONDITIONAL(DBUS_INIT_SCRIPTS_CYGWIN
  ##### systemd unit files
  AC_ARG_WITH([systemdsystemunitdir],
  AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
-         [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
+     [],
+     [
+     PKG_CHECK_EXISTS([systemd],
+       [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)],
+       [with_systemdsystemunitdir=no])
+     ])
  if test "x$with_systemdsystemunitdir" != xno; then
     AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
  fi
@@@ -1552,15 -1570,6 +1587,15 @@@ AH_VERBATIM(_DARWIN_ENVIRON
  #endif
  ])
  
 +AC_ARG_ENABLE([stats],
 +  [AS_HELP_STRING([--enable-stats],
 +    [enable bus daemon usage statistics])],
 +  [], [enable_stats=no])
 +if test "x$enable_stats" = xyes; then
 +  AC_DEFINE([DBUS_ENABLE_STATS], [1],
 +    [Define to enable bus daemon usage statistics])
 +fi
 +
  AC_CONFIG_FILES([
  Doxyfile
  dbus/versioninfo.rc
@@@ -1636,7 -1645,6 +1671,7 @@@ echo 
          Building verbose mode:    ${enable_verbose_mode}
          Building assertions:      ${enable_asserts}
          Building checks:          ${enable_checks}
 +        Building bus stats API:   ${enable_stats}
          Building SELinux support: ${have_selinux}
          Building inotify support: ${have_inotify}
          Building dnotify support: ${have_dnotify}
@@@ -1687,16 -1695,3 +1722,16 @@@ if test x$dbus_use_libxml = xtrue; the
          echo
        echo "WARNING: You have chosen to use libxml as your xml parser however this code path is not maintained by the D-Bus developers and if it breaks you get to keep the pieces.  If you have selected this option in err please reconfigure with expat (e.g. --with-xml=expat)."
  fi
 +
 +if test "x$DBUS_HAVE_INT64" = x0; then
 +  AC_MSG_WARN([You have disabled 64-bit integers via --without-64-bit.
 +
 +  This removes parts of the standard D-Bus API and ABI (the 't' and 'x'
 +  typecodes, the dbus_int64_t and dbus_uint64_t types, etc.) and should only be
 +  used if your compiler lacks support for 64-bit integers. Please report a bug
 +  with details of your platform and compiler.
 +
 +  This option is likely to be removed in future, unless the D-Bus developers
 +  receive reports that it is still needed.
 +  ])
 +fi
diff --combined dbus/dbus-sysdeps-unix.c
  #define socklen_t int
  #endif
  
+ #if defined (__sun) || defined (__sun__)
+ /*
+  * CMS_SPACE etc. definitions for Solaris < 10, based on
+  *   http://mailman.videolan.org/pipermail/vlc-devel/2006-May/024402.html
+  * via
+  *   http://wiki.opencsw.org/porting-faq#toc10
+  *
+  * These are only redefined for Solaris, for now: if your OS needs these too,
+  * please file a bug. (Or preferably, improve your OS so they're not needed.)
+  */
+ # ifndef CMSG_ALIGN
+ #   ifdef __sun__
+ #     define CMSG_ALIGN(len) _CMSG_DATA_ALIGN (len)
+ #   else
+       /* aligning to sizeof (long) is assumed to be portable (fd.o#40235) */
+ #     define CMSG_ALIGN(len) (((len) + sizeof (long) - 1) & \
+                               ~(sizeof (long) - 1))
+ #   endif
+ # endif
+ # ifndef CMSG_SPACE
+ #   define CMSG_SPACE(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + \
+                             CMSG_ALIGN (len))
+ # endif
+ # ifndef CMSG_LEN
+ #   define CMSG_LEN(len) (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
+ # endif
+ #endif /* Solaris */
  static dbus_bool_t
  _dbus_open_socket (int              *fd_p,
                     int               domain,
      }
  }
  
 -dbus_bool_t
 -_dbus_open_tcp_socket (int              *fd,
 -                       DBusError        *error)
 -{
 -  return _dbus_open_socket(fd, AF_INET, SOCK_STREAM, 0, error);
 -}
 -
  /**
   * Opens a UNIX domain socket (as in the socket() call).
   * Does not bind the socket.
   * @param error return location for an error
   * @returns #FALSE if error is set
   */
 -dbus_bool_t
 +static dbus_bool_t
  _dbus_open_unix_socket (int              *fd,
                          DBusError        *error)
  {
@@@ -2493,6 -2532,8 +2525,6 @@@ voi
  _dbus_get_current_time (long *tv_sec,
                          long *tv_usec)
  {
 -  struct timeval t;
 -
  #ifdef HAVE_MONOTONIC_CLOCK
    struct timespec ts;
    clock_gettime (CLOCK_MONOTONIC, &ts);
    if (tv_usec)
      *tv_usec = ts.tv_nsec / 1000;
  #else
 +  struct timeval t;
 +
    gettimeofday (&t, NULL);
  
    if (tv_sec)
@@@ -2982,14 -3021,60 +3014,60 @@@ _dbus_full_duplex_pipe (int        *fd1
   *
   * @param format a printf-style format string
   * @param args arguments for the format string
-  * @returns length of the given format string and args
+  * @returns length of the given format string and args, or -1 if no memory
   */
  int
  _dbus_printf_string_upper_bound (const char *format,
                                   va_list     args)
  {
-   char c;
-   return vsnprintf (&c, 1, format, args);
+   char static_buf[1024];
+   int bufsize = sizeof (static_buf);
+   int len;
+   len = vsnprintf (static_buf, bufsize, format, args);
+   /* If vsnprintf() returned non-negative, then either the string fits in
+    * static_buf, or this OS has the POSIX and C99 behaviour where vsnprintf
+    * returns the number of characters that were needed, or this OS returns the
+    * truncated length.
+    *
+    * We ignore the possibility that snprintf might just ignore the length and
+    * overrun the buffer (64-bit Solaris 7), because that's pathological.
+    * If your libc is really that bad, come back when you have a better one. */
+   if (len == bufsize)
+     {
+       /* This could be the truncated length (Tru64 and IRIX have this bug),
+        * or the real length could be coincidentally the same. Which is it?
+        * If vsnprintf returns the truncated length, we'll go to the slow
+        * path. */
+       if (vsnprintf (static_buf, 1, format, args) == 1)
+         len = -1;
+     }
+   /* If vsnprintf() returned negative, we have to do more work.
+    * HP-UX returns negative. */
+   while (len < 0)
+     {
+       char *buf;
+       bufsize *= 2;
+       buf = dbus_malloc (bufsize);
+       if (buf == NULL)
+         return -1;
+       len = vsnprintf (buf, bufsize, format, args);
+       dbus_free (buf);
+       /* If the reported length is exactly the buffer size, round up to the
+        * next size, in case vsnprintf has been returning the truncated
+        * length */
+       if (len == bufsize)
+         len = -1;
+     }
+   return len;
  }
  
  /**
@@@ -3421,10 -3506,10 +3499,10 @@@ _dbus_lookup_launchd_socket (DBusStrin
  #endif
  }
  
 +#ifdef DBUS_ENABLE_LAUNCHD
  static dbus_bool_t
  _dbus_lookup_session_address_launchd (DBusString *address, DBusError  *error)
  {
 -#ifdef DBUS_ENABLE_LAUNCHD
    dbus_bool_t valid_socket;
    DBusString socket_path;
  
  
    _dbus_string_free(&socket_path);
    return TRUE;
 -#else
 -  dbus_set_error(error, DBUS_ERROR_NOT_SUPPORTED,
 -                "can't lookup session address from launchd; launchd support not compiled in");
 -  return FALSE;
 -#endif
  }
 +#endif
  
  /**
   * Determines the address of the session bus by querying a
@@@ -389,6 -389,7 +389,6 @@@ _dbus_request_file_descriptor_limit (un
  #ifdef HAVE_SETRLIMIT
    struct rlimit lim;
    struct rlimit target_lim;
 -  unsigned int current_limit;
  
    /* No point to doing this practically speaking
     * if we're not uid 0.  We expect the system
  #endif
  }
  
- void 
+ void
  _dbus_init_system_log (void)
  {
+ #ifdef HAVE_DECL_LOG_PERROR
    openlog ("dbus", LOG_PID | LOG_PERROR, LOG_DAEMON);
+ #else
+   openlog ("dbus", LOG_PID, LOG_DAEMON);
+ #endif
  }
  /**
   * Log a message to the system log file (e.g. syslog on Unix).
   *
@@@ -475,6 -481,19 +480,19 @@@ _dbus_system_logv (DBusSystemLogSeverit
          return;
      }
  
+ #ifndef HAVE_DECL_LOG_PERROR
+     {
+       /* vsyslog() won't write to stderr, so we'd better do it */
+       va_list tmp;
+       DBUS_VA_COPY (tmp, args);
+       fprintf (stderr, "dbus[" DBUS_PID_FORMAT "]: ", _dbus_getpid ());
+       vfprintf (stderr, msg, tmp);
+       fputc ('\n', stderr);
+       va_end (tmp);
+     }
+ #endif
    vsyslog (flags, msg, args);
  
    if (severity == DBUS_SYSTEM_LOG_FATAL)
diff --combined test/Makefile.am
@@@ -4,29 -4,9 +4,29 @@@
  SUBDIRS= . name-test 
  DIST_SUBDIRS=name-test
  
 -INCLUDES=-I$(top_srcdir) $(DBUS_TEST_CFLAGS) 
 +AM_CPPFLAGS = \
 +      -I$(top_srcdir) \
 +      $(GLIB_CFLAGS) \
 +      $(DBUS_GLIB_CFLAGS) \
 +      $(NULL)
 +
 +# improve backtraces from test stuff
 +AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
  
 -libdbus_testutils_la_SOURCES = test-utils.h test-utils.c
 +static_cppflags = \
 +      $(AM_CPPFLAGS) \
 +      -DDBUS_STATIC_BUILD \
 +      $(NULL)
 +
 +libdbus_testutils_la_CPPFLAGS = \
 +      $(static_cppflags)
 +libdbus_testutils_la_SOURCES = \
 +      test-utils.c \
 +      test-utils.h \
 +      $(NULL)
 +libdbus_testutils_la_LIBADD = \
 +      $(top_builddir)/dbus/libdbus-internal.la \
 +      $(NULL)
  
  noinst_LTLIBRARIES = libdbus-testutils.la
  
@@@ -72,23 -52,59 +72,27 @@@ endif !DBUS_BUILD_TEST
  
  noinst_PROGRAMS= $(TEST_BINARIES)
  
 -test_service_SOURCES=                         \
 -      test-service.c
 -
 -test_names_SOURCES=                           \
 -      test-names.c
 -
 -##break_loader_SOURCES=                               \
 -##    break-loader.c
 -
 -test_shell_service_SOURCES =                  \
 -      test-shell-service.c
 -
 -shell_test_SOURCES=                             \
 -        shell-test.c
 -
 -spawn_test_SOURCES=                           \
 -      spawn-test.c
 -
 -test_exit_SOURCES =                           \
 -      test-exit.c
 -
 -test_segfault_SOURCES =                               \
 -      test-segfault.c
 -
 -test_sleep_forever_SOURCES =                  \
 -      test-sleep-forever.c
 -
 -# This assumes that most tests will be linked to libdbus-internal;
 -# tests linked to only the public libdbus have their own CPPFLAGS.
 -AM_CPPFLAGS=-DDBUS_STATIC_BUILD
 -TEST_LIBS=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_TEST_LIBS)
 -
 -test_service_LDADD=libdbus-testutils.la $(TEST_LIBS)
 -test_service_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -test_names_LDADD=libdbus-testutils.la $(TEST_LIBS)
 -test_names_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -## break_loader_LDADD= $(TEST_LIBS)
 -## break_loader_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -test_shell_service_LDADD=libdbus-testutils.la $(TEST_LIBS)
 -test_shell_service_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -shell_test_LDADD=libdbus-testutils.la $(TEST_LIBS)
 -shell_test_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -spawn_test_LDADD=$(TEST_LIBS)
 -spawn_test_LDFLAGS=@R_DYNAMIC_LDFLAG@
 +test_service_CPPFLAGS = $(static_cppflags)
 +test_service_LDADD = libdbus-testutils.la
 +test_names_CPPFLAGS = $(static_cppflags)
 +test_names_LDADD = libdbus-testutils.la
 +## break_loader_CPPFLAGS = $(static_cppflags)
 +## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
 +test_shell_service_CPPFLAGS = $(static_cppflags)
 +test_shell_service_LDADD = libdbus-testutils.la
 +shell_test_CPPFLAGS = $(static_cppflags)
 +shell_test_LDADD = libdbus-testutils.la
 +spawn_test_CPPFLAGS = $(static_cppflags)
 +spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la
  
  test_refs_SOURCES = internals/refs.c
 -test_refs_CPPFLAGS = -DDBUS_STATIC_BUILD $(GLIB_CFLAGS)
 -test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) $(TEST_LIBS)
 +test_refs_CPPFLAGS = $(static_cppflags)
 +test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS)
  
+ test_syslog_SOURCES = internals/syslog.c
+ test_syslog_CPPFLAGS = -DDBUS_STATIC_BUILD $(GLIB_CFLAGS)
+ test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) $(TEST_LIBS)
  EXTRA_DIST = dbus-test-runner
  
  testexecdir = $(libdir)/dbus-1.0/test
@@@ -98,11 -114,11 +102,12 @@@ testexec_PROGRAMS 
  installable_tests = \
        test-corrupt \
        test-dbus-daemon \
 +      test-dbus-daemon-eavesdrop \
        test-loopback \
        test-marshal \
        test-refs \
        test-relay \
+       test-syslog \
        $(NULL)
  
  installcheck_tests =
@@@ -119,33 -135,36 +124,33 @@@ TESTS_ENVIRONMENT = 
        $(NULL)
  
  test_corrupt_SOURCES = corrupt.c
 -test_corrupt_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
 -test_corrupt_LDFLAGS = @R_DYNAMIC_LDFLAG@
  test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \
      $(GLIB_LIBS) \
      $(DBUS_GLIB_LIBS)
  
  test_loopback_SOURCES = loopback.c
 -test_loopback_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
 -test_loopback_LDFLAGS = @R_DYNAMIC_LDFLAG@
  test_loopback_LDADD = $(top_builddir)/dbus/libdbus-1.la \
      $(GLIB_LIBS) \
      $(DBUS_GLIB_LIBS)
  
  test_relay_SOURCES = relay.c
 -test_relay_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
 -test_relay_LDFLAGS = @R_DYNAMIC_LDFLAG@
  test_relay_LDADD = $(top_builddir)/dbus/libdbus-1.la \
      $(GLIB_LIBS) \
      $(DBUS_GLIB_LIBS)
  
  test_dbus_daemon_SOURCES = dbus-daemon.c
 -test_dbus_daemon_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
 -test_dbus_daemon_LDFLAGS = @R_DYNAMIC_LDFLAG@
  test_dbus_daemon_LDADD = $(top_builddir)/dbus/libdbus-1.la \
      $(GLIB_LIBS) \
      $(DBUS_GLIB_LIBS)
  
 +test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c
 +test_dbus_daemon_eavesdrop_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
 +test_dbus_daemon_eavesdrop_LDFLAGS = @R_DYNAMIC_LDFLAG@
 +test_dbus_daemon_eavesdrop_LDADD = $(top_builddir)/dbus/libdbus-1.la \
 +    $(GLIB_LIBS) \
 +    $(DBUS_GLIB_LIBS)
 +
  test_marshal_SOURCES = marshal.c
 -test_marshal_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS)
 -test_marshal_LDFLAGS = @R_DYNAMIC_LDFLAG@
  test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \
      $(GLIB_LIBS) \
      $(DBUS_GLIB_LIBS)
@@@ -258,6 -277,8 +263,8 @@@ clean-local
                        REVERSEDIRS="$$D $$REVERSEDIRS" ;               \
                done ;                                                  \
                for D in $$REVERSEDIRS; do                              \
-                       rmdir $(top_builddir)/test/$$D || exit 1 ;      \
+                       rmdir $(top_builddir)/test/$$D ||               \
+                               test ! -d $(top_builddir)/test/$$D ||   \
+                               exit 1 ;        \
                done ;                                                  \
        fi
@@@ -1,18 -1,10 +1,18 @@@
 -INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_GLIB_CFLAGS) $(DBUS_TEST_CFLAGS) -DDBUS_COMPILATION
 +# Everything in this directory is statically-linked to libdbus-internal
 +AM_CPPFLAGS = \
 +      -I$(top_srcdir) \
 +      -DDBUS_COMPILATION \
 +      -DDBUS_STATIC_BUILD \
 +      $(NULL)
 +
 +# if assertions are enabled, improve backtraces
 +AM_LDFLAGS = @R_DYNAMIC_LDFLAG@
  
  ## note that TESTS has special meaning (stuff to use in make check)
  ## so if adding tests not to be run in make check, don't add them to 
  ## TESTS
  if DBUS_BUILD_TESTS
- TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@
+ TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ PYTHON=@PYTHON@
  TESTS=run-test.sh run-test-systemserver.sh
  else
  TESTS=
@@@ -26,14 -18,57 +26,14 @@@ if DBUS_BUILD_TEST
  ## build even when not doing "make check"
  noinst_PROGRAMS=test-pending-call-dispatch test-pending-call-timeout test-threads-init test-ids test-shutdown test-privserver test-privserver-client test-autolaunch
  
 -AM_CPPFLAGS = -DDBUS_STATIC_BUILD
 -test_pending_call_dispatch_SOURCES =          \
 -      test-pending-call-dispatch.c
 -
 -test_pending_call_dispatch_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_TEST_LIBS)
 -test_pending_call_dispatch_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -
 -test_pending_call_timeout_SOURCES =           \
 -      test-pending-call-timeout.c
 -
 -test_pending_call_timeout_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_TEST_LIBS)
 -test_pending_call_timeout_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -
 -test_threads_init_SOURCES =            \
 -      test-threads-init.c
 -
 -test_threads_init_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_TEST_LIBS)
 -test_threads_init_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -
 -test_ids_SOURCES =            \
 -      test-ids.c
 -
 -test_ids_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_TEST_LIBS)
 -test_ids_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -
 -test_shutdown_SOURCES =            \
 -      test-shutdown.c
 -
 -test_shutdown_CFLAGS=
 -test_shutdown_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la $(DBUS_TEST_LIBS)
 -test_shutdown_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -
 -test_privserver_SOURCES =            \
 -      test-privserver.c
 -
 -test_privserver_CFLAGS=
 -test_privserver_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la $(DBUS_TEST_LIBS)
 -test_privserver_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -
 -test_privserver_client_SOURCES =            \
 -      test-privserver-client.c
 -
 -test_privserver_client_CFLAGS=
 -test_privserver_client_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la $(DBUS_TEST_LIBS)
 -test_privserver_client_LDFLAGS=@R_DYNAMIC_LDFLAG@
 -
 -test_autolaunch_SOURCES =            \
 -      test-autolaunch.c
 +test_pending_call_dispatch_LDADD=$(top_builddir)/dbus/libdbus-internal.la
 +test_pending_call_timeout_LDADD=$(top_builddir)/dbus/libdbus-internal.la
 +test_threads_init_LDADD=$(top_builddir)/dbus/libdbus-internal.la
 +test_ids_LDADD=$(top_builddir)/dbus/libdbus-internal.la
  
 -test_autolaunch_CFLAGS=
 -test_autolaunch_LDADD=$(top_builddir)/dbus/libdbus-internal.la ../libdbus-testutils.la $(DBUS_TEST_LIBS)
 -test_autolaunch_LDFLAGS=@R_DYNAMIC_LDFLAG@
 +test_shutdown_LDADD=../libdbus-testutils.la
 +test_privserver_LDADD=../libdbus-testutils.la
 +test_privserver_client_LDADD=../libdbus-testutils.la
 +test_autolaunch_LDADD=../libdbus-testutils.la
  
  endif