From 870351439769a35344ead435f2490ed933dd8ff4 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Thu, 12 Apr 2012 11:16:48 -0400 Subject: Avoid using monotonic time in the DBUS_COOKIE_SHA1 authentication method When libdbus-1 moved to using monotonic time support for the DBUS_COOKIE_SHA1 authentication was broken, in particular interoperability with non-libdbus-1 implementations such as GDBus. The problem is that if monotonic clocks are available in the OS, _dbus_get_current_time() will not return the number of seconds since the Epoch so using it for DBUS_COOKIE_SHA1 will violate the D-Bus specification. If both peers are using libdbus-1 it's not a problem since both ends will use the wrong time and thus agree. However, if the other end is another implementation and following the spec it will not work. First, we change _dbus_get_current_time() back so it always returns time since the Epoch and we then rename it _dbus_get_real_time() to make this clear. We then introduce _dbus_get_monotonic_time() and carefully make all current users of _dbus_get_current_time() use it, if applicable. During this audit, one of the callers, _dbus_generate_uuid(), was currently using monotonic time but it was decided to make it use real time instead. Signed-off-by: David Zeuthen Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48580 --- bus/connection.c | 10 +++++----- bus/expirelist.c | 4 ++-- dbus/dbus-connection.c | 4 ++-- dbus/dbus-internals.c | 2 +- dbus/dbus-keyring.c | 6 +++--- dbus/dbus-mainloop.c | 8 ++++---- dbus/dbus-sysdeps-unix.c | 25 +++++++++++++++++++++++-- dbus/dbus-sysdeps-win.c | 18 ++++++++++++++++-- dbus/dbus-sysdeps.c | 2 +- dbus/dbus-sysdeps.h | 7 +++++-- test/break-loader.c | 2 +- test/name-test/test-pending-call-dispatch.c | 4 ++-- test/name-test/test-pending-call-timeout.c | 4 ++-- 13 files changed, 67 insertions(+), 29 deletions(-) diff --git a/bus/connection.c b/bus/connection.c index 8e7d222a..727d6a8f 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -623,8 +623,8 @@ bus_connections_setup_connection (BusConnections *connections, d->connections = connections; d->connection = connection; - _dbus_get_current_time (&d->connection_tv_sec, - &d->connection_tv_usec); + _dbus_get_monotonic_time (&d->connection_tv_sec, + &d->connection_tv_usec); _dbus_assert (connection_data_slot >= 0); @@ -793,7 +793,7 @@ bus_connections_expire_incomplete (BusConnections *connections) DBusList *link; int auth_timeout; - _dbus_get_current_time (&tv_sec, &tv_usec); + _dbus_get_monotonic_time (&tv_sec, &tv_usec); auth_timeout = bus_context_get_auth_timeout (connections->context); link = _dbus_list_get_first_link (&connections->incomplete); @@ -1763,8 +1763,8 @@ bus_connections_expect_reply (BusConnections *connections, cprd->pending = pending; cprd->connections = connections; - _dbus_get_current_time (&pending->expire_item.added_tv_sec, - &pending->expire_item.added_tv_usec); + _dbus_get_monotonic_time (&pending->expire_item.added_tv_sec, + &pending->expire_item.added_tv_usec); _dbus_verbose ("Added pending reply %p, replier %p receiver %p serial %u\n", pending, diff --git a/bus/expirelist.c b/bus/expirelist.c index 946a615c..5d45b9a5 100644 --- a/bus/expirelist.c +++ b/bus/expirelist.c @@ -205,7 +205,7 @@ bus_expirelist_expire (BusExpireList *list) { long tv_sec, tv_usec; - _dbus_get_current_time (&tv_sec, &tv_usec); + _dbus_get_monotonic_time (&tv_sec, &tv_usec); next_interval = do_expiration_with_current_time (list, tv_sec, tv_usec); } @@ -351,7 +351,7 @@ bus_expire_list_test (const DBusString *test_data_dir) test_expire_func, NULL); _dbus_assert (list != NULL); - _dbus_get_current_time (&tv_sec, &tv_usec); + _dbus_get_monotonic_time (&tv_sec, &tv_usec); tv_sec_not_expired = tv_sec; tv_usec_not_expired = tv_usec; diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 8b8310dd..4f2eb6b8 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2377,7 +2377,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) * below */ timeout = _dbus_pending_call_get_timeout_unlocked (pending); - _dbus_get_current_time (&start_tv_sec, &start_tv_usec); + _dbus_get_monotonic_time (&start_tv_sec, &start_tv_usec); if (timeout) { timeout_milliseconds = dbus_timeout_get_interval (timeout); @@ -2434,7 +2434,7 @@ _dbus_connection_block_pending_call (DBusPendingCall *pending) return; } - _dbus_get_current_time (&tv_sec, &tv_usec); + _dbus_get_monotonic_time (&tv_sec, &tv_usec); elapsed_milliseconds = (tv_sec - start_tv_sec) * 1000 + (tv_usec - start_tv_usec) / 1000; diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 95a491f9..8c1dd222 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -595,7 +595,7 @@ _dbus_generate_uuid (DBusGUID *uuid) { long now; - _dbus_get_current_time (&now, NULL); + _dbus_get_real_time (&now, NULL); uuid->as_uint32s[DBUS_UUID_LENGTH_WORDS - 1] = DBUS_UINT32_TO_BE (now); diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 35e8d74e..23b9df5a 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -353,7 +353,7 @@ add_new_key (DBusKey **keys_p, goto out; } - _dbus_get_current_time (×tamp, NULL); + _dbus_get_real_time (×tamp, NULL); keys[n_keys-1].id = id; keys[n_keys-1].creation_time = timestamp; @@ -428,7 +428,7 @@ _dbus_keyring_reload (DBusKeyring *keyring, retval = FALSE; have_lock = FALSE; - _dbus_get_current_time (&now, NULL); + _dbus_get_real_time (&now, NULL); if (add_new) { @@ -908,7 +908,7 @@ find_recent_key (DBusKeyring *keyring) int i; long tv_sec, tv_usec; - _dbus_get_current_time (&tv_sec, &tv_usec); + _dbus_get_real_time (&tv_sec, &tv_usec); i = 0; while (i < keyring->n_keys) diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 43159a70..1ff8425c 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -136,8 +136,8 @@ timeout_callback_new (DBusTimeout *timeout, cb->timeout = timeout; cb->function = function; - _dbus_get_current_time (&cb->last_tv_sec, - &cb->last_tv_usec); + _dbus_get_monotonic_time (&cb->last_tv_sec, + &cb->last_tv_usec); cb->callback.refcount = 1; cb->callback.type = CALLBACK_TIMEOUT; cb->callback.data = data; @@ -653,7 +653,7 @@ _dbus_loop_iterate (DBusLoop *loop, unsigned long tv_sec; unsigned long tv_usec; - _dbus_get_current_time (&tv_sec, &tv_usec); + _dbus_get_monotonic_time (&tv_sec, &tv_usec); link = _dbus_list_get_first_link (&loop->callbacks); while (link != NULL) @@ -723,7 +723,7 @@ _dbus_loop_iterate (DBusLoop *loop, unsigned long tv_sec; unsigned long tv_usec; - _dbus_get_current_time (&tv_sec, &tv_usec); + _dbus_get_monotonic_time (&tv_sec, &tv_usec); /* It'd be nice to avoid this O(n) thingy here */ link = _dbus_list_get_first_link (&loop->callbacks); diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 1a8f6fc2..aec03e83 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -2529,8 +2529,8 @@ _dbus_poll (DBusPollFD *fds, * @param tv_usec return location for number of microseconds (thousandths) */ void -_dbus_get_current_time (long *tv_sec, - long *tv_usec) +_dbus_get_monotonic_time (long *tv_sec, + long *tv_usec) { struct timeval t; @@ -2552,6 +2552,27 @@ _dbus_get_current_time (long *tv_sec, #endif } +/** + * Get current time, as in gettimeofday(). Never uses the monotonic + * clock. + * + * @param tv_sec return location for number of seconds + * @param tv_usec return location for number of microseconds (thousandths) + */ +void +_dbus_get_real_time (long *tv_sec, + long *tv_usec) +{ + struct timeval t; + + gettimeofday (&t, NULL); + + if (tv_sec) + *tv_sec = t.tv_sec; + if (tv_usec) + *tv_usec = t.tv_usec; +} + /** * Creates a directory; succeeds if the directory * is created or already existed. diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index aea704d2..b22a3718 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1888,8 +1888,8 @@ _dbus_sleep_milliseconds (int milliseconds) * @param tv_usec return location for number of microseconds */ void -_dbus_get_current_time (long *tv_sec, - long *tv_usec) +_dbus_get_real_time (long *tv_sec, + long *tv_usec) { FILETIME ft; dbus_uint64_t time64; @@ -1911,6 +1911,20 @@ _dbus_get_current_time (long *tv_sec, *tv_usec = time64 % 1000000; } +/** + * Get current time, as in gettimeofday(). Use the monotonic clock if ++ * available, to avoid problems when the system time changes. + * + * @param tv_sec return location for number of seconds + * @param tv_usec return location for number of microseconds + */ +void +_dbus_get_monotonic_time (long *tv_sec, + long *tv_usec) +{ + /* no implementation yet, fall back to wall-clock time */ + _dbus_get_real_time (tv_sec, tv_usec); +} /** * signal (SIGPIPE, SIG_IGN); diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 89062764..1b220313 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -805,7 +805,7 @@ _dbus_generate_pseudorandom_bytes_buffer (char *buffer, _dbus_verbose ("Falling back to pseudorandom for %d bytes\n", n_bytes); - _dbus_get_current_time (NULL, &tv_usec); + _dbus_get_monotonic_time (NULL, &tv_usec); srand (tv_usec); i = 0; diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index d4883c1b..a784db27 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -310,8 +310,11 @@ int _dbus_poll (DBusPollFD *fds, void _dbus_sleep_milliseconds (int milliseconds); -void _dbus_get_current_time (long *tv_sec, - long *tv_usec); +void _dbus_get_monotonic_time (long *tv_sec, + long *tv_usec); + +void _dbus_get_real_time (long *tv_sec, + long *tv_usec); /** * directory interface diff --git a/test/break-loader.c b/test/break-loader.c index 7bfa7227..1e222569 100644 --- a/test/break-loader.c +++ b/test/break-loader.c @@ -667,7 +667,7 @@ get_random_seed (void) fprintf (stderr, "could not open/read /dev/urandom, using current time for seed\n"); - _dbus_get_current_time (NULL, &tv_usec); + _dbus_get_monotonic_time (NULL, &tv_usec); seed = tv_usec; } diff --git a/test/name-test/test-pending-call-dispatch.c b/test/name-test/test-pending-call-dispatch.c index 57582d49..c8b5a467 100644 --- a/test/name-test/test-pending-call-dispatch.c +++ b/test/name-test/test-pending-call-dispatch.c @@ -98,9 +98,9 @@ main (int argc, char *argv[]) { long delta; - _dbus_get_current_time (&start_tv_sec, &start_tv_usec); + _dbus_get_monotonic_time (&start_tv_sec, &start_tv_usec); _run_iteration (conn); - _dbus_get_current_time (&end_tv_sec, &end_tv_usec); + _dbus_get_monotonic_time (&end_tv_sec, &end_tv_usec); /* we just care about seconds */ delta = end_tv_sec - start_tv_sec; diff --git a/test/name-test/test-pending-call-timeout.c b/test/name-test/test-pending-call-timeout.c index 381113bd..d051faba 100644 --- a/test/name-test/test-pending-call-timeout.c +++ b/test/name-test/test-pending-call-timeout.c @@ -82,9 +82,9 @@ main (int argc, char *argv[]) { long delta; - _dbus_get_current_time (&start_tv_sec, &start_tv_usec); + _dbus_get_monotonic_time (&start_tv_sec, &start_tv_usec); _run_iteration (conn); - _dbus_get_current_time (&end_tv_sec, &end_tv_usec); + _dbus_get_monotonic_time (&end_tv_sec, &end_tv_usec); /* we just care about seconds */ delta = end_tv_sec - start_tv_sec; -- cgit v1.2.1 From 069c96ccde7d480f0d7d74bfc19163938ef4a3d5 Mon Sep 17 00:00:00 2001 From: Antoine Jacoutot Date: Wed, 25 Apr 2012 19:04:07 +0100 Subject: use cp and mkdir -p instead of install within source tree $(INSTALL) and $(INSTALL_DATA) try to change ownerships to root:bin when copying tests to builddir. Presumably this is a difference in behaviour between GNU and BSD install(1): the one in GNU coreutils doesn't try-and-fail to change ownership if you're not root. [Commit message added by smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48127 Reviewed-by: Simon McVittie --- test/Makefile.am | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 55610c18..207a5252 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -296,14 +296,14 @@ EXTRA_DIST += $(static_data) ## copy tests to builddir so that generated tests and static tests ## are all in one place. all-local: - $(AM_V_at)$(INSTALL) -d data/valid-config-files/session.d + $(AM_V_at)$(MKDIR_P) data/valid-config-files/session.d $(AM_V_at)set -e && \ if test $(srcdir) = . || test $(srcdir) -ef .; then \ echo '-- No need to copy test data as srcdir = builddir'; \ else \ for F in $(static_data); do \ - $(INSTALL) -d $${F%/*}; \ - $(INSTALL_DATA) $(srcdir)/$$F $$F; \ + $(MKDIR_P) $${F%/*}; \ + cp $(srcdir)/$$F $$F; \ done; \ fi @@ -324,9 +324,9 @@ noinst_DATA = $(imported_data) CLEANFILES = $(noinst_DATA) data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf - $(AM_V_at)$(INSTALL) -d data/valid-config-files - $(AM_V_GEN)$(INSTALL_DATA) $< $@ + $(AM_V_at)$(MKDIR_P) data/valid-config-files + $(AM_V_GEN)cp $< $@ data/valid-config-files/system.conf: $(top_builddir)/bus/system.conf - $(AM_V_at)$(INSTALL) -d data/valid-config-files - $(AM_V_GEN)$(INSTALL_DATA) $< $@ + $(AM_V_at)$(MKDIR_P) data/valid-config-files + $(AM_V_GEN)cp $< $@ -- cgit v1.2.1 From b19e14330fd87228368acd82dc5160ec85cb8243 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 25 Apr 2012 19:12:15 +0100 Subject: NEWS --- NEWS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/NEWS b/NEWS index e03afb05..187b215d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,14 @@ +D-Bus 1.4.22 (UNRELEASED) +== + +Changes: + +• Be more careful about monotonic time vs. real time, fixing DBUS_COOKIE_SHA1 + spec-compliance (fd.o #48580, David Zeuthen) + +• Don't use install(1) within the source/build trees, fixing the build as + non-root when using OpenBSD install(1) (fd.o #48217, Antoine Jacoutot) + D-Bus 1.4.20 (2012-03-27) == -- cgit v1.2.1 From ad7245627cde935297d83be0e918fa66852cc1c8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 Feb 2012 15:20:42 +0000 Subject: Remove duplicate nonce-tcp (client side) transport on Windows _dbus_transport_open_socket is called before _dbus_transport_open_platform_specific, and now handles nonce-tcp, so this version is no longer useful. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=45896 Reviewed-by: Ralf Habacker Tested-by: Ralf Habacker --- dbus/dbus-transport-win.c | 35 ++--------------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/dbus/dbus-transport-win.c b/dbus/dbus-transport-win.c index faaf1bd2..8fc15749 100644 --- a/dbus/dbus-transport-win.c +++ b/dbus/dbus-transport-win.c @@ -51,39 +51,8 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, DBusTransport **transport_p, DBusError *error) { - const char *method; - - const char *host = dbus_address_entry_get_value (entry, "host"); - const char *port = dbus_address_entry_get_value (entry, "port"); - const char *family = dbus_address_entry_get_value (entry, "family"); - const char *noncefile = dbus_address_entry_get_value (entry, "noncefile"); - - method = dbus_address_entry_get_method (entry); - _dbus_assert (method != NULL); - - if (strcmp (method, "nonce-tcp") != 0) - { - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - return DBUS_TRANSPORT_OPEN_NOT_HANDLED; - } - - if (port == NULL) - { - _dbus_set_bad_address (error, "nonce-tcp", "port", NULL); - return DBUS_TRANSPORT_OPEN_BAD_ADDRESS; - } - - *transport_p = _dbus_transport_new_for_tcp_socket (host, port, family, noncefile, error); - if (*transport_p == NULL) - { - _DBUS_ASSERT_ERROR_IS_SET (error); - return DBUS_TRANSPORT_OPEN_DID_NOT_CONNECT; - } - else - { - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - return DBUS_TRANSPORT_OPEN_OK; - } + /* currently no Windows-specific transports */ + return DBUS_TRANSPORT_OPEN_NOT_HANDLED; } /** @} */ -- cgit v1.2.1 From df80949d92df8695900f8dda51c1d5ea23bbb6d2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 Feb 2012 15:22:16 +0000 Subject: Remove duplicate nonce-tcp (service-side) transport on Windows Turns out this was duplicated too. We can just use the platform-independent version, which uses the same code. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=45896 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker Tested-by: Ralf Habacker --- dbus/dbus-server-win.c | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/dbus/dbus-server-win.c b/dbus/dbus-server-win.c index bf1c896c..bb6da483 100644 --- a/dbus/dbus-server-win.c +++ b/dbus/dbus-server-win.c @@ -57,33 +57,7 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry, method = dbus_address_entry_get_method (entry); - if (strcmp (method, "nonce-tcp") == 0) - { - const char *host; - const char *port; - const char *bind; - const char *family; - - host = dbus_address_entry_get_value (entry, "host"); - bind = dbus_address_entry_get_value (entry, "bind"); - port = dbus_address_entry_get_value (entry, "port"); - family = dbus_address_entry_get_value (entry, "family"); - - *server_p = _dbus_server_new_for_tcp_socket (host, bind, port, - family, error, TRUE); - - if (*server_p) - { - _DBUS_ASSERT_ERROR_IS_CLEAR(error); - return DBUS_SERVER_LISTEN_OK; - } - else - { - _DBUS_ASSERT_ERROR_IS_SET(error); - return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; - } - } - else if (strcmp (method, "autolaunch") == 0) + if (strcmp (method, "autolaunch") == 0) { const char *host = "localhost"; const char *bind = "localhost"; -- cgit v1.2.1 From 6a2af7b9a965c4a598ef2ace29b11b006b2c6b0a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 24 Feb 2012 11:15:21 +0000 Subject: _dbus_transport_new_for_tcp_socket: add missing commas to address Ralf pointed out that the address doesn't round-trip correctly. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=45896 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker Tested-by: Ralf Habacker --- dbus/dbus-transport-socket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 0673a8ce..544d00a9 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -1337,12 +1337,12 @@ _dbus_transport_new_for_tcp_socket (const char *host, goto error; if (family != NULL && - (!_dbus_string_append (&address, "family=") || + (!_dbus_string_append (&address, ",family=") || !_dbus_string_append (&address, family))) goto error; if (noncefile != NULL && - (!_dbus_string_append (&address, "noncefile=") || + (!_dbus_string_append (&address, ",noncefile=") || !_dbus_string_append (&address, noncefile))) goto error; -- cgit v1.2.1 From 9a727711a55c8b9d23b3fd445e39019a850f149f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 5 Jun 2012 13:14:07 +0100 Subject: Prepare version 1.6.0 (new stable branch) --- NEWS | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- configure.ac | 6 +++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 74566f99..04c603a3 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,51 @@ -D-Bus 1.5.14 (UNRELEASED) +D-Bus 1.6.0 (2012-06-05) == -Changes: +The “soul of this machine has improved” release. + +This version starts a new stable branch of D-Bus: only bug fixes will +be accepted into 1.6.x. Other changes will now go to the 1.7.x branch. + +Summary of changes since 1.4.x: + +• New requirements + · PTHREAD_MUTEX_RECURSIVE on Unix + · compiler support for 64-bit integers (int64_t or equivalent) + +• D-Bus Specification v0.19 + +• New dbus-daemon features + · rules allow the service to + own names like com.example.Service.Instance3 + · optional systemd integration when checking at_console policies + · --nopidfile option, mainly for use by systemd + · path_namespace and arg0namespace may appear in match rules + · eavesdropping is disabled unless the match rule contains eavesdrop=true + +• New public API + · functions to validate various string types (dbus_validate_path() etc.) + · dbus_type_is_valid() + · DBusBasicValue, a union of every basic type + +• Bug fixes + · removed an unsafe reimplementation of recursive mutexes + · dbus-daemon no longer busy-loops if it has far too many file descriptors + · dbus-daemon.exe --print-address works on Windows + · all the other bug fixes from 1.4.20 + +• Other major implementation changes + · on Linux, dbus-daemon uses epoll if supported, for better scalability + · dbus_threads_init() ignores its argument and behaves like + dbus_threads_init_default() instead + · removed the per-connection link cache, improving dbus-daemon performance + +• Developer features + · optional Valgrind instrumentation (--with-valgrind) + · optional Stats interface on the dbus-daemon (--enable-stats) + · optionally abort whenever malloc() fails (--enable-embedded-tests + and export DBUS_MALLOC_CANNOT_FAIL=1) + +Changes since 1.5.12: • Be more careful about monotonic time vs. real time, fixing DBUS_COOKIE_SHA1 spec-compliance (fd.o #48580, David Zeuthen) @@ -9,6 +53,10 @@ Changes: • Don't use install(1) within the source/build trees, fixing the build as non-root when using OpenBSD install(1) (fd.o #48217, Antoine Jacoutot) +• Add missing commas in some tcp and nonce-tcp addresses, and remove + an unused duplicate copy of the nonce-tcp transport in Windows builds + (fd.o #45896, Simon McVittie) + D-Bus 1.5.12 (2012-03-27) == diff --git a/configure.ac b/configure.ac index 59b23d27..c42170a7 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ dnl -*- mode: m4 -*- AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) -m4_define([dbus_minor_version], [5]) -m4_define([dbus_micro_version], [13]) +m4_define([dbus_minor_version], [6]) +m4_define([dbus_micro_version], [0]) 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]) @@ -36,7 +36,7 @@ LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=0 +LT_REVISION=1 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From 7db205d25d93f801b5f22dfb8afd059c3961ff4f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 5 Jun 2012 13:27:23 +0100 Subject: Fix distcheck: remove potentially-read-only files from builddir During distcheck, the srcdir is read-only. During "make all", cp may preserve the read-only status of the file copied from the srcdir, resulting in failure to overwrite it with an identical file during "make check" (which depends on all-local). Signed-off-by: Simon McVittie --- test/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Makefile.am b/test/Makefile.am index 0418e595..aa04792b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -294,6 +294,7 @@ all-local: else \ for F in $(static_data); do \ $(MKDIR_P) $${F%/*}; \ + rm -f $$F; \ cp $(srcdir)/$$F $$F; \ done; \ fi -- cgit v1.2.1 From 8f7e9cdd6005efb354a6efba83200fbfd01efa6a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 5 Jun 2012 13:29:11 +0100 Subject: Fix distcheck with newer Doxygen: remove *.js, too, during uninstall --- doc/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/Makefile.am b/doc/Makefile.am index 591efc99..b2659871 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -106,6 +106,7 @@ uninstall-local:: rm -f $(DESTDIR)$(apidir)/*.html rm -f $(DESTDIR)$(apidir)/*.png rm -f $(DESTDIR)$(apidir)/*.css + rm -f $(DESTDIR)$(apidir)/*.js rm -f $(DESTDIR)$(htmldir)/*.html rm -f $(DESTDIR)$(docdir)/*.txt rm -f $(DESTDIR)$(htmldir)/*.png -- cgit v1.2.1 From faf0c88dfa131016fc7e8d649e420c953144e0cd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 5 Jun 2012 15:03:58 +0100 Subject: Start 1.6.2 development --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 04c603a3..d18b29d9 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +D-Bus 1.6.2 (UNRELEASED) +== + D-Bus 1.6.0 (2012-06-05) == diff --git a/configure.ac b/configure.ac index c42170a7..837e7b25 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [0]) +m4_define([dbus_micro_version], [1]) 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]) -- cgit v1.2.1 From f141c260ce4d438299804e89bb77c3bef81ed86b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 5 Jun 2012 15:04:25 +0100 Subject: Start 1.7.0 development --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 04c603a3..320c78bf 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +D-Bus 1.7.0 (UNRELEASED) +== + D-Bus 1.6.0 (2012-06-05) == diff --git a/configure.ac b/configure.ac index c42170a7..6c494f1a 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [0]) +m4_define([dbus_micro_version], [999]) 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]) -- cgit v1.2.1 From ab0cebd8830f6d48e49083a06de17a6a9e5d4d98 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 16 Jun 2011 11:56:30 +0100 Subject: document how the various processes in dbus-launch interact Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197 --- tools/dbus-launch.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index bbaac2c3..7b1bb37b 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -43,6 +43,47 @@ extern Display *xdisplay; #endif +/* PROCESSES + * + * If you are in a shell and run "dbus-launch myapp", here is what happens: + * + * shell [*] + * \- main() --exec--> myapp[*] + * \- "intermediate parent" + * \- bus-runner --exec--> dbus-daemon --fork + * \- babysitter[*] \- final dbus-daemon[*] + * + * Processes marked [*] survive the initial flurry of activity. + * + * If you run "dbus-launch --sh-syntax" then the diagram is the same, except + * that main() prints variables and exits 0 instead of exec'ing myapp. + * + * PIPES + * + * dbus-daemon --print-pid -> bus_pid_to_launcher_pipe -> main + * dbus-daemon --print-address -> bus_address_to_launcher_pipe -> main + * main -> bus_pid_to_babysitter_pipe -> babysitter + * + * The intermediate parent looks pretty useless at first glance. Its purpose + * is to avoid the bus-runner becoming a zombie: when the intermediate parent + * terminates, the bus-runner and babysitter are reparented to init, which + * reaps them if they have finished. We can't rely on main() to reap arbitrary + * children because it might exec myapp, after which it can't be relied on to + * reap its children. We *can* rely on main() to reap the intermediate parent, + * because that happens before it execs myapp. + * + * It's unclear why dbus-daemon needs to fork, but we explicitly tell it to + * for some reason, then wait for it. If we left it undefined, a forking + * dbus-daemon would get the parent process reparented to init and reaped + * when the intermediate parent terminated, and a non-forking dbus-daemon + * would get reparented to init and carry on there. + * + * myapp is exec'd by the process that initially ran main() so that it's + * the shell's child, so the shell knows how to do job control and stuff. + * This is desirable for the "dbus-launch an application" use-case, less so + * for the "dbus-launch a test suite in an isolated session" use-case. + */ + static char* machine_uuid = NULL; const char* -- cgit v1.2.1 From 1785b37e430efd912ef9dda0c728984a3eba4f09 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 7 Feb 2012 16:55:05 +0000 Subject: dbus-launch: if using X to define the session lifetime, do not poll stdin dbus-launch --exit-with-session attempts to scope the session length to various things: - if DISPLAY points to an X server, exit when the X session ends - if stdin is a terminal, exit when end-of-file is reached - if both are true, exit when one of them happens, whichever is first - if neither is true, fail These are not particularly useful semantics: if the session is scoped to the X session, then the terminal from which dbus-launch was launched is irrelevant. This also causes practical problems when dbus-launch consumes characters from the terminal from which it happens to have been launched (some display managers, like slim and nodm, run users' X sessions with stdin pointing to the terminal from which the init daemon happens to have started the display manager during boot, usually tty1 on Linux). Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197 --- tools/dbus-launch.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 7b1bb37b..1ec9ae59 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -492,11 +492,20 @@ kill_bus_when_session_ends (void) else tty_fd = -1; - if (tty_fd >= 0) - verbose ("stdin isatty(), monitoring it\n"); + if (x_fd >= 0) + { + verbose ("session lifetime is defined by X, not monitoring stdin\n"); + tty_fd = -1; + } + else if (tty_fd >= 0) + { + verbose ("stdin isatty(), monitoring it\n"); + } else - verbose ("stdin was not a TTY, not monitoring it\n"); - + { + verbose ("stdin was not a TTY, not monitoring it\n"); + } + if (tty_fd < 0 && x_fd < 0) { fprintf (stderr, "No terminal on standard input and no X display; cannot attach message bus to session lifetime\n"); -- cgit v1.2.1 From fcc656d430f53ad62c25e41d7e7bd880cbb726a0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 7 Feb 2012 16:58:01 +0000 Subject: dbus-launch: add --exit-with-x11 option This is more suitable for distributions' Xsession scripts: it verifies that X is already available, and so never results in an attempt to poll stdin. Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197 --- doc/dbus-launch.1 | 26 ++++++++++++++++++++------ tools/dbus-launch.c | 33 +++++++++++++++++++++++++++------ 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/doc/dbus-launch.1 b/doc/dbus-launch.1 index a7687cad..53d69f6d 100644 --- a/doc/dbus-launch.1 +++ b/doc/dbus-launch.1 @@ -7,7 +7,7 @@ dbus\-launch \- Utility to start a message bus from a shell script .SH SYNOPSIS .PP -.B dbus\-launch [\-\-version] [\-\-sh\-syntax] [\-\-csh\-syntax] [\-\-auto\-syntax] [\-\-exit\-with\-session] [\-\-autolaunch=MACHINEID] [\-\-config\-file=FILENAME] [PROGRAM] [ARGS...] +.B dbus\-launch [\-\-version] [\-\-sh\-syntax] [\-\-csh\-syntax] [\-\-auto\-syntax] [\-\-exit\-with\-session] [\-\-exit\-with\-x11] [\-\-autolaunch=MACHINEID] [\-\-config\-file=FILENAME] [PROGRAM] [ARGS...] .SH DESCRIPTION @@ -152,11 +152,25 @@ the \-\-session argument. See the man page for dbus\-daemon Emit csh compatible code to set up environment variables. .TP -.I "\-\-exit\-with\-session" -If this option is provided, a persistent "babysitter" process will be -created that watches stdin for HUP and tries to connect to the X -server. If this process gets a HUP on stdin or loses its X connection, -it kills the message bus daemon. +.I \-\-exit\-with\-x11 +If this option is provided, a persistent "babysitter" process will be +created, and will connect to the X server. If it cannot do so, launching +fails. If the "babysitter" process loses its X connection, +it kills the message bus daemon, disconnecting all of its clients (which +should exit in response). This avoids having leftover daemon +processes from a user X session, after the X session has ended. + +.TP +.I \-\-exit\-with\-session +If this option is provided, a persistent "babysitter" process will be +created, as if for +.BR \-\-exit\-with\-x11 . +If it cannot connect to the X server, it will monitor the terminal from which +.B dbus-launch +was started instead, and if it gets a HUP on stdin, the message bus daemon +will be killed. This option is not recommended, since it will consume input +from the terminal where it was started; it is mainly provided for +backwards compatibility. .TP .I "\-\-autolaunch=MACHINEID" diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 1ec9ae59..dcce646e 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -181,7 +181,7 @@ verbose (const char *format, static void usage (int ecode) { - fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session]\n"); + fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session] [--exit-with-x11]\n"); exit (ecode); } @@ -809,6 +809,7 @@ main (int argc, char **argv) const char *runprog = NULL; int remaining_args = 0; int exit_with_session; + int exit_with_x11 = FALSE; int binary_syntax = FALSE; int c_shell_syntax = FALSE; int bourne_shell_syntax = FALSE; @@ -850,6 +851,8 @@ main (int argc, char **argv) version (); else if (strcmp (arg, "--exit-with-session") == 0) exit_with_session = TRUE; + else if (strcmp (arg, "--exit-with-x11") == 0) + exit_with_x11 = TRUE; else if (strcmp (arg, "--close-stderr") == 0) close_stderr = TRUE; else if (strstr (arg, "--autolaunch=") == arg) @@ -961,6 +964,9 @@ main (int argc, char **argv) if (exit_with_session) verbose ("--exit-with-session enabled\n"); + if (exit_with_x11) + verbose ("--exit-with-x11 enabled\n"); + if (autolaunch) { #ifndef DBUS_BUILD_X11 @@ -983,10 +989,10 @@ main (int argc, char **argv) } verbose ("Autolaunch enabled (using X11).\n"); - if (!exit_with_session) + if (!exit_with_x11) { - verbose ("--exit-with-session automatically enabled\n"); - exit_with_session = TRUE; + verbose ("--exit-with-x11 automatically enabled\n"); + exit_with_x11 = TRUE; } if (!x11_init ()) @@ -1009,12 +1015,27 @@ main (int argc, char **argv) exit (0); } #endif /* DBUS_ENABLE_X11_AUTOLAUNCH */ +#endif /* DBUS_BUILD_X11 */ + } + else if (exit_with_x11) + { +#ifndef DBUS_BUILD_X11 + fprintf (stderr, "Session lifetime based on X11 requested, but X11 support not compiled in.\n"); + exit (1); +#else /* DBUS_BUILD_X11 */ + if (!x11_init ()) + { + fprintf (stderr, "Session lifetime based on X11 requested, but X11 initialization failed.\n"); + exit (1); + } +#endif /* DBUS_BUILD_X11 */ } +#ifdef DBUS_BUILD_X11 else if (read_machine_uuid_if_needed()) { x11_init(); -#endif /* DBUS_BUILD_X11 */ } +#endif /* DBUS_BUILD_X11 */ if (pipe (bus_pid_to_launcher_pipe) < 0 || @@ -1076,7 +1097,7 @@ main (int argc, char **argv) * and will also reap the pre-forked bus * daemon */ - babysit (exit_with_session, ret, + babysit (exit_with_session || exit_with_x11, ret, bus_pid_to_babysitter_pipe[READ_END]); exit (0); } -- cgit v1.2.1 From ba433723f79c7a69e7107ae5818ecd869aeb4d33 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 7 Feb 2012 17:00:46 +0000 Subject: dbus-launch: revise recommendations and put them in an EXAMPLES section The first thing we should talk about is how to get a D-Bus session in your X session - that's the common case. Secondarily, we can tell command-line addicts how to have a D-Bus session. Do not recommend --exit-with-session here, since that polls (and reads from) stdin, which is harmful to precisely those command-line users! Until we have some better tool, the best we can do here is note that the dbus-daemon is not automatically terminated. Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197 --- doc/dbus-launch.1 | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/doc/dbus-launch.1 b/doc/dbus-launch.1 index 53d69f6d..1707f3d3 100644 --- a/doc/dbus-launch.1 +++ b/doc/dbus-launch.1 @@ -51,30 +51,45 @@ know which shell your script is written in. See http://www.freedesktop.org/software/dbus/ for more information about D\-Bus. See also the man page for \fIdbus\-daemon\fP. -.PP -Here is an example of how to use \fIdbus\-launch\fP with an -sh\-compatible shell to start the per\-session bus daemon: -.nf +.SH EXAMPLES + +Distributions running +.B dbus\-launch +as part of a standard X session should run +.B "dbus\-launch \-\-exit\-with\-x11" +after the X server has started and become available, as a wrapper around +the "main" X client (typically a session manager or window manager), as in +these examples: + +.RS +.B "dbus\-launch \-\-exit\-with\-x11 gnome\-session" + +.B "dbus\-launch \-\-exit\-with\-x11 openbox" + +.B "dbus\-launch \-\-exit\-with\-x11 ~/.xsession" +.RE + +If your distribution does not do this, you can achieve similar results +by running your session or window manager in the same way in a script +run by your X session, such as +.BR ~/.xsession , +.B ~/.xinitrc +or +.BR ~/.Xclients . + +To start a D-Bus session within a text-mode session, you can run +dbus-launch in the background. For instance, in a sh-compatible shell: +.nf ## test for an existing bus daemon, just to be safe if test \-z "$DBUS_SESSION_BUS_ADDRESS" ; then ## if not found, launch a new one - eval `dbus\-launch \-\-sh\-syntax \-\-exit\-with\-session` + eval `dbus\-launch \-\-sh\-syntax` echo "D\-Bus per\-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" fi - -.fi -You might run something like that in your login scripts. - -.PP -Another way to use \fIdbus\-launch\fP is to run your main session -program, like so: -.nf - -dbus\-launch gnome\-session - .fi -The above would likely be appropriate for ~/.xsession or ~/.Xclients. +Note that in this case, dbus-launch will exit, and dbus-daemon will not be +terminated automatically on logout. .SH AUTOMATIC LAUNCHING -- cgit v1.2.1 From e9762e1542449601ff23b0c5fc8d6764e0898d3f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 7 Feb 2012 17:43:28 +0000 Subject: Document that dbus-launch is not dbus-run-session Architectural assumptions inside dbus-launch mean that it is unsuitable for use in contexts where a particular process's lifetime defines the session, unless there is an out-of-band mechanism (like the X server) which can signal the end of the session. Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39197 --- doc/dbus-launch.1 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/dbus-launch.1 b/doc/dbus-launch.1 index 1707f3d3..4902b40a 100644 --- a/doc/dbus-launch.1 +++ b/doc/dbus-launch.1 @@ -204,6 +204,19 @@ Emit Bourne\-shell compatible code to set up environment variables. .I "\-\-version" Print the version of dbus\-launch +.SH NOTES + +If you run +.B "dbus\-launch myapp" +(with any other options), dbus\-daemon will +.I not +exit when +.B myapp +terminates: this is because +.B myapp +is assumed to be part of a larger session, rather than a session in its +own right. + .SH AUTHOR See http://www.freedesktop.org/software/dbus/doc/AUTHORS -- cgit v1.2.1 From 09d71f92c349fb25053136fd329b5903c7216bdd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 15 Jun 2012 13:22:16 +0100 Subject: NEWS --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index d18b29d9..2a8f8ed0 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ D-Bus 1.6.2 (UNRELEASED) == +Fixes: + +• Add dbus-launch --exit-with-x11 option. Distributions should use this + in their X11 session startup infrastructure, in preference to + the --exit-with-session option. (fd.o #39197, Simon McVittie) + D-Bus 1.6.0 (2012-06-05) == -- cgit v1.2.1 From 8624dbec2d4ed866da31eb06e2f0aff5bc9496e6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 25 May 2011 18:03:01 +0100 Subject: Split Basic and Container types into subsections, promote "Type Signatures" to be an intro The "Type Signatures" subsection is basically an introduction to the type system, so it doesn't need a heading of its own. Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38252 --- doc/dbus-specification.xml | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index d806b8ea..3828db7f 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -292,18 +292,18 @@ it back from the wire format is unmarshaling. - - Type Signatures + + The D-Bus protocol does not include type tags in the marshaled data; a + block of marshaled values must have a known type + signature. The type signature is made up of type + codes. A type code is an ASCII character representing the + type of a value. Because ASCII characters are used, the type signature + will always form a valid ASCII string. A simple string compare + determines whether two type signatures are equivalent. + - - The D-Bus protocol does not include type tags in the marshaled data; a - block of marshaled values must have a known type - signature. The type signature is made up of type - codes. A type code is an ASCII character representing the - type of a value. Because ASCII characters are used, the type signature - will always form a valid ASCII string. A simple string compare - determines whether two type signatures are equivalent. - + + Basic types As a simple example, the type code for 32-bit integer (INT32) is @@ -323,6 +323,13 @@ INT32 in this example. To marshal and unmarshal basic types, you simply read one value from the data block corresponding to each type code in the signature. + + + + + Container types + + In addition to basic types, there are four container types: STRUCT, ARRAY, VARIANT, and DICT_ENTRY. @@ -435,6 +442,10 @@ In most languages, an array of dict entry would be represented as a map, hash table, or dict object. + + + + Summary of types The following table summarizes the D-Bus types. -- cgit v1.2.1 From 7461c704b9041da2e99decbccc59c2c1e58716d1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 25 May 2011 17:59:07 +0100 Subject: Define single complete types in the overview of the type system Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38252 --- doc/dbus-specification.xml | 69 ++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 3828db7f..05597619 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -295,13 +295,50 @@ The D-Bus protocol does not include type tags in the marshaled data; a block of marshaled values must have a known type - signature. The type signature is made up of type - codes. A type code is an ASCII character representing the + signature. The type signature is made up of zero or more + single complete + types, each made up of one or more + type codes. + + + + A type code is an ASCII character representing the type of a value. Because ASCII characters are used, the type signature will always form a valid ASCII string. A simple string compare determines whether two type signatures are equivalent. + + A single complete type is a sequence of type codes that fully describes + one type: either a basic type, or a single fully-described container type. + A single complete type is a basic type code, a variant type code, + an array with its element type, or a struct with its fields (all of which + are defined below). So the following signatures are not single complete + types: + + "aa" + + + "(ii" + + + "ii)" + + And the following signatures contain multiple complete types: + + "ii" + + + "aiai" + + + "(ii)(ii)" + + Note however that a single complete type may contain + multiple other single complete types, by containing a struct or dict + entry. + + Basic types @@ -384,34 +421,6 @@ - - The phrase single complete type deserves some - definition. A single complete type is a basic type code, a variant type code, - an array with its element type, or a struct with its fields. - So the following signatures are not single complete types: - - "aa" - - - "(ii" - - - "ii)" - - And the following signatures contain multiple complete types: - - "ii" - - - "aiai" - - - "(ii)(ii)" - - Note however that a single complete type may contain - multiple other single complete types. - - VARIANT has ASCII character 'v' as its type code. A marshaled value of type VARIANT will have the signature of a single complete type as part -- cgit v1.2.1 From 7fd69d123fec3c2e5cf9d9a0e0b0b1a33a713eb3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 26 Apr 2011 18:03:35 +0100 Subject: Don't claim that all basic types work like INT32: strings don't! Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38252 --- doc/dbus-specification.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 05597619..9907fa3b 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -356,9 +356,9 @@ - All basic types work like - INT32 in this example. To marshal and unmarshal - basic types, you simply read one value from the data + All fixed types work like + INT32 in this example: to marshal and unmarshal + fixed types, you simply read one value from the data block corresponding to each type code in the signature. -- cgit v1.2.1 From c8e7a5690b19a2ba37fd2e22fd800a842f1c8af8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Jun 2011 13:24:40 +0100 Subject: Define the fixed and string-like types a bit more formally Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38252 --- doc/dbus-specification.xml | 168 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 164 insertions(+), 4 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 9907fa3b..eea9ef34 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -342,6 +342,20 @@ Basic types + + The simplest type codes are the basic + types, which are the types whose structure is entirely + defined by their 1-character type code. Basic types consist of + fixed types and string-like types. + + + + The fixed types + are basic types whose values have a fixed length, namely BYTE, + BOOLEAN, DOUBLE, UNIX_FD, and signed or unsigned integers of length + 16, 32 or 64 bits. + + As a simple example, the type code for 32-bit integer (INT32) is the ASCII character 'i'. So the signature for a block of values @@ -356,11 +370,130 @@ - All fixed types work like - INT32 in this example: to marshal and unmarshal - fixed types, you simply read one value from the data - block corresponding to each type code in the signature. + The characteristics of the fixed types are listed in this table. + + + + + + Conventional name + ASCII type-code + Encoding + + + + + BYTE + y (121) + Unsigned 8-bit integer + + + BOOLEAN + b (98) + Boolean value: 0 is false, 1 is true, any other value + allowed by the marshalling format is invalid + + + INT16 + n (110) + Signed (two's complement) 16-bit integer + + + UINT16 + q (113) + Unsigned 16-bit integer + + + INT32 + i (105) + Signed (two's complement) 32-bit integer + + + UINT32 + u (117) + Unsigned 32-bit integer + + + INT64 + x (120) + Signed (two's complement) 64-bit integer + (mnemonic: x and t are the first characters in "sixty" not + already used for something more common) + + + UINT64 + t (116) + Unsigned 64-bit integer + + + DOUBLE + d (100) + IEEE 754 double-precision floating point + + + UNIX_FD + h (104) + Unsigned 32-bit integer representing an index into an + out-of-band array of file descriptors, transferred via some + platform-specific mechanism (mnemonic: h for handle) + + + + + + + + The string-like types + are basic types with a variable length. The value of any string-like + type is conceptually 0 or more Unicode codepoints encoded in UTF-8, + none of which may be U+0000. The UTF-8 text must be validated + strictly: in particular, it must not contain overlong sequences, + noncharacters such as U+FFFE, or codepoints above U+10FFFF. + + + + The marshalling formats for the string-like types all end with a + single zero (NUL) byte, but that byte is not considered to be part of + the text. + + + + The characteristics of the string-like types are listed in this table. + + + + + + Conventional name + ASCII type-code + Validity constraints + + + + + STRING + s (115) + No extra constraints + + + OBJECT_PATH + o (111) + Must be + a + syntactically valid object path + + + SIGNATURE + g (103) + Zero or more + single + complete types + + + + + @@ -616,6 +749,33 @@ than required must not be used. + + To marshal and unmarshal fixed types, you simply read one value + from the data block corresponding to each type code in the signature. + All signed integer values are encoded in two's complement, DOUBLE + values are IEEE 754 double-precision floating-point, and BOOLEAN + values are encoded in 32 bits (of which only the least significant + bit is used). + + + + The string-like types are all marshalled as a + fixed-length unsigned integer n giving the + length of the variable part, followed by n + nonzero bytes of UTF-8 text, followed by a single zero (nul) byte + which is not considered to be part of the text. The alignment + of the string-like type is the same as the alignment of + n. + + + + For the STRING and OBJECT_PATH types, n is + encoded in 4 bytes, leading to 4-byte alignment. + For the SIGNATURE type, n is encoded as a single + byte. As a result, alignment padding is never required before a + SIGNATURE. + + Given all this, the types are marshaled on the wire as follows: -- cgit v1.2.1 From 7b81cecae005b189f1d8616e0c23c0c0c86ba9dd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 15 Jun 2012 13:58:24 +0100 Subject: Promote the definition of valid object paths and signatures into the type system Also remove the (double!) requirement that signatures be nul-terminated, and turn it into a note about the marshalling format. Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38252 --- doc/dbus-specification.xml | 251 +++++++++++++++++++++++---------------------- 1 file changed, 126 insertions(+), 125 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index eea9ef34..52c9e6c3 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -494,6 +494,130 @@ + + Valid Object Paths + + + An object path is a name used to refer to an object instance. + Conceptually, each participant in a D-Bus message exchange may have + any number of object instances (think of C++ or Java objects) and each + such instance will have a path. Like a filesystem, the object + instances in an application form a hierarchical tree. + + + + Object paths are often namespaced by starting with a reversed + domain name and containing an interface version number, in the + same way as + interface + names and + well-known + bus names. + This makes it possible to implement more than one service, or + more than one version of a service, in the same process, + even if the services share a connection but cannot otherwise + co-operate (for instance, if they are implemented by different + plugins). + + + + For instance, if the owner of example.com is + developing a D-Bus API for a music player, they might use the + hierarchy of object paths that start with + /com/example/MusicPlayer1 for its objects. + + + + The following rules define a valid object path. Implementations must + not send or accept messages with invalid object paths. + + + + The path may be of any length. + + + + + The path must begin with an ASCII '/' (integer 47) character, + and must consist of elements separated by slash characters. + + + + + Each element must only contain the ASCII characters + "[A-Z][a-z][0-9]_" + + + + + No element may be the empty string. + + + + + Multiple '/' characters cannot occur in sequence. + + + + + A trailing '/' character is not allowed unless the + path is the root path (a single '/' character). + + + + + + + + + Valid Signatures + + An implementation must not send or accept invalid signatures. + Valid signatures will conform to the following rules: + + + + The signature is a list of single complete types. + Arrays must have element types, and structs must + have both open and close parentheses. + + + + + Only type codes, open and close parentheses, and open and + close curly brackets are allowed in the signature. The + STRUCT type code + is not allowed in signatures, because parentheses + are used instead. Similarly, the + DICT_ENTRY type code is not allowed in + signatures, because curly brackets are used instead. + + + + + The maximum depth of container type nesting is 32 array type + codes and 32 open parentheses. This implies that the maximum + total depth of recursion is 64, for an "array of array of array + of ... struct of struct of struct of ..." where there are 32 + array and 32 struct. + + + + + The maximum length of a signature is 255. + + + + + + + When signatures appear in messages, the marshalling format + guarantees that they will be followed by a nul byte (which can + be interpreted as either C-style string termination or the INVALID + type-code), but this is not conceptually part of the signature. + + + @@ -841,7 +965,7 @@ OBJECT_PATH Exactly the same as STRING except the - content must be a valid object path (see below). + content must be a valid object path (see above). 4 (for the length) @@ -850,7 +974,7 @@ SIGNATURE The same as STRING except the length is a single byte (thus signatures have a maximum length of 255) - and the content must be a valid signature (see below). + and the content must be a valid signature (see above). 1 @@ -919,130 +1043,7 @@ - - - Valid Object Paths - - - An object path is a name used to refer to an object instance. - Conceptually, each participant in a D-Bus message exchange may have - any number of object instances (think of C++ or Java objects) and each - such instance will have a path. Like a filesystem, the object - instances in an application form a hierarchical tree. - - - - The following rules define a valid object path. Implementations must - not send or accept messages with invalid object paths. - - - - The path may be of any length. - - - - - The path must begin with an ASCII '/' (integer 47) character, - and must consist of elements separated by slash characters. - - - - - Each element must only contain the ASCII characters - "[A-Z][a-z][0-9]_" - - - - - No element may be the empty string. - - - - - Multiple '/' characters cannot occur in sequence. - - - - - A trailing '/' character is not allowed unless the - path is the root path (a single '/' character). - - - - - - - Object paths are often namespaced by starting with a reversed - domain name and containing an interface version number, in the - same way as - interface - names and - well-known - bus names. - This makes it possible to implement more than one service, or - more than one version of a service, in the same process, - even if the services share a connection but cannot otherwise - co-operate (for instance, if they are implemented by different - plugins). - - - - For instance, if the owner of example.com is - developing a D-Bus API for a music player, they might use the - hierarchy of object paths that start with - /com/example/MusicPlayer1 for its objects. - - - - Valid Signatures - - An implementation must not send or accept invalid signatures. - Valid signatures will conform to the following rules: - - - - The signature ends with a nul byte. - - - - - The signature is a list of single complete types. - Arrays must have element types, and structs must - have both open and close parentheses. - - - - - Only type codes and open and close parentheses are - allowed in the signature. The STRUCT type code - is not allowed in signatures, because parentheses - are used instead. - - - - - The maximum depth of container type nesting is 32 array type - codes and 32 open parentheses. This implies that the maximum - total depth of recursion is 64, for an "array of array of array - of ... struct of struct of struct of ..." where there are 32 - array and 32 struct. - - - - - The maximum length of a signature is 255. - - - - - Signatures must be nul-terminated. - - - - - - -- cgit v1.2.1 From 12f2bd641e602e2ce83c3f3a31931b7bbe5db430 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Jun 2011 15:24:21 +0100 Subject: Promote the marshalling format to a top-level section Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38252 --- doc/dbus-specification.xml | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 52c9e6c3..e5687ab3 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -843,9 +843,21 @@ + + + + Marshaling (Wire Format) + + + D-Bus defines a marshalling format for its type system, which is + used in D-Bus messages. This is not the only possible marshalling + format for the type system: for instance, GVariant (part of GLib) + re-uses the D-Bus type system but implements an alternative marshalling + format. + - - Marshaling (Wire Format) + + Byte order and alignment Given a type signature, a block of bytes can be converted into typed @@ -854,11 +866,11 @@ - A block of bytes has an associated byte order. The byte order - has to be discovered in some way; for D-Bus messages, the - byte order is part of the message header as described in - . For now, assume - that the byte order is known to be either little endian or big + A block of bytes has an associated byte order. The byte order + has to be discovered in some way; for D-Bus messages, the + byte order is part of the message header as described in + . For now, assume + that the byte order is known to be either little endian or big endian. @@ -872,6 +884,10 @@ not be left uninitialized (it can't contain garbage), and more padding than required must not be used. + + + + Marshalling basic types To marshal and unmarshal fixed types, you simply read one value @@ -899,6 +915,16 @@ byte. As a result, alignment padding is never required before a SIGNATURE. + + + + Marshalling containers + + ... to be written ... + + + + Summary of D-Bus marshalling Given all this, the types are marshaled on the wire as follows: -- cgit v1.2.1 From 04cb0a6b0bd897bc80648ea82bba05d22d47d025 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Jun 2011 14:59:20 +0100 Subject: Describe how to marshal arrays, structs, dict-entries, variants in prose Reviewed-by: Will Thompson Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38252 --- doc/dbus-specification.xml | 79 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 62 insertions(+), 17 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index e5687ab3..32a20915 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -685,6 +685,14 @@ marshaled value of that type. + + Unlike a message signature, the variant signature can + contain only a single complete type. So "i", "ai" + or "(ii)" is OK, but "ii" is not. Use of variants may not + cause a total message depth to be larger than 64, including + other container types such as structures. + + A DICT_ENTRY works exactly like a struct, but rather than parentheses it uses curly braces, and it has more restrictions. @@ -884,6 +892,12 @@ not be left uninitialized (it can't contain garbage), and more padding than required must not be used. + + + As an exception to natural alignment, STRUCT and + DICT_ENTRY values are always aligned to an 8-byte + boundary, regardless of the alignments of their contents. + @@ -920,7 +934,49 @@ Marshalling containers - ... to be written ... + + Arrays are marshalled as a UINT32 + n giving the length of the array data in bytes, + followed by alignment padding to the alignment boundary of the array + element type, followed by the n bytes of the + array elements marshalled in sequence. n does not + include the padding after the length, or any padding after the + last element. + + + + For instance, if the current position in the message is a multiple + of 8 bytes and the byte-order is big-endian, an array containing only + the 64-bit integer 5 would be marshalled as: + + +00 00 00 08 8 bytes of data +00 00 00 00 padding to 8-byte boundary +00 00 00 00 00 00 00 05 first element = 5 + + + + + Arrays have a maximum length defined to be 2 to the 26th power or + 67108864. Implementations must not send or accept arrays exceeding this + length. + + + + Structs and dict entries are marshalled in the same way as their + contents, but their alignment is always to an 8-byte boundary, + even if their contents would normally be less strictly aligned. + + + + Variants are marshalled as the SIGNATURE of + the contents (which must be a single complete type), followed by a + marshalled value with the type given by that signature. The + variant has the same 1-byte alignment as the signature, which means + that alignment padding before a variant is never needed. + Use of variants may not cause a total message depth to be larger + than 64, including other container types such as structures. + @@ -1009,14 +1065,8 @@ ARRAY A UINT32 giving the length of the array data in bytes, followed by - alignment padding to the alignment boundary of the array element type, - followed by each array element. The array length is from the - end of the alignment padding to the end of the last element, - i.e. it does not include the padding after the length, - or any padding after the last element. - Arrays have a maximum length defined to be 2 to the 26th power or - 67108864. Implementations must not send or accept arrays exceeding this - length. + alignment padding to the alignment boundary of the array element type, + followed by each array element. 4 (for the length) @@ -1035,14 +1085,9 @@ VARIANT - A variant type has a marshaled - SIGNATURE followed by a marshaled - value with the type given in the signature. Unlike - a message signature, the variant signature can - contain only a single complete type. So "i", "ai" - or "(ii)" is OK, but "ii" is not. Use of variants may not - cause a total message depth to be larger than 64, including - other container types such as structures. + The marshaled SIGNATURE of a single + complete type, followed by a marshaled value with the type + given in the signature. 1 (alignment of the signature) -- cgit v1.2.1 From 5a100d8c2ce5301322a4ad65e2999c61fe48945f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 15 Jun 2012 14:11:50 +0100 Subject: Cut minor version down to 255 Entertainingly, bits of libdbus assume that one byte is enough for each version number component (as API!), and one test even fails if this isn't true. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6c494f1a..ad7459d6 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [999]) +m4_define([dbus_micro_version], [255]) 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]) -- cgit v1.2.1 From efddba53da6b76478064f43d8235de12151f33ad Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 12 Mar 2012 14:15:48 +0000 Subject: When not producing a dynamic library, define DBUS_STATIC_BUILD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When targeting Windows, linking against the static library requires special effort to turn off DLL import/export processing. We normally link some things against the dynamic library, but if we're not building that, we'll have to link everything statically. Based on patches from 'william' on fd.o #46367. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33973 Tested-by: René Berber --- configure.ac | 10 ++++++++++ dbus-1-uninstalled.pc.in | 2 +- dbus-1.pc.in | 2 +- test/Makefile.am | 3 +++ tools/Makefile.am | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 837e7b25..8d952278 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,16 @@ AM_CONDITIONAL(DBUS_WINCE, test "$dbus_wince" = yes) AM_CONDITIONAL(DBUS_UNIX, test "$dbus_unix" = yes) AM_CONDITIONAL(DBUS_CYGWIN, test "$dbus_cygwin" = yes) +DBUS_STATIC_BUILD_CPPFLAGS= +if test "x$enable_shared" = xno; then + # On Windows, linking against the static library requires special effort + # to turn off DLL import/export processing. We normally link some things + # against the dynamic library, but if we're not building that, we'll + # have to link everything statically. + DBUS_STATIC_BUILD_CPPFLAGS=-DDBUS_STATIC_BUILD +fi +AC_SUBST([DBUS_STATIC_BUILD_CPPFLAGS]) + AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE) AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) diff --git a/dbus-1-uninstalled.pc.in b/dbus-1-uninstalled.pc.in index f0072325..038c83e2 100644 --- a/dbus-1-uninstalled.pc.in +++ b/dbus-1-uninstalled.pc.in @@ -14,4 +14,4 @@ Description: Free desktop message bus (uninstalled copy) Version: @VERSION@ Libs: ${abs_top_builddir}/dbus/libdbus-1.la Libs.private: @LIBDBUS_LIBS@ -Cflags: -I${abs_top_srcdir} +Cflags: -I${abs_top_srcdir} @DBUS_STATIC_BUILD_CPPFLAGS@ diff --git a/dbus-1.pc.in b/dbus-1.pc.in index 7201e07f..25f8bcee 100644 --- a/dbus-1.pc.in +++ b/dbus-1.pc.in @@ -14,4 +14,4 @@ Description: Free desktop message bus Version: @VERSION@ Libs: -L${libdir} -ldbus-1 Libs.private: @LIBDBUS_LIBS@ -Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include +Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include @DBUS_STATIC_BUILD_CPPFLAGS@ diff --git a/test/Makefile.am b/test/Makefile.am index aa04792b..e9448998 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,8 +4,10 @@ SUBDIRS= . name-test DIST_SUBDIRS=name-test +# CPPFLAGS for binaries that are normally dynamic AM_CPPFLAGS = \ -I$(top_srcdir) \ + $(DBUS_STATIC_BUILD_CPPFLAGS) \ $(GLIB_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \ $(NULL) @@ -13,6 +15,7 @@ AM_CPPFLAGS = \ # improve backtraces from test stuff AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ +# CPPFLAGS for binaries that are always static static_cppflags = \ $(AM_CPPFLAGS) \ -DDBUS_STATIC_BUILD \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 08b90234..c4632e3e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,6 +2,7 @@ configdir=$(sysconfdir)/dbus-1 AM_CPPFLAGS = \ -I$(top_srcdir) \ + $(DBUS_STATIC_BUILD_CPPFLAGS) \ $(DBUS_X_CFLAGS) \ -DDBUS_COMPILATION \ -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" \ -- cgit v1.2.1 From b47f4c22ee7adf57e1a5377d5f9cbdbe6423a111 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 12 Mar 2012 15:40:30 +0000 Subject: On Unix, link libdbus to a platform-specific threading library On Linux, this is libpthread; on other Unixes, in principle it might be called libpthreads or libthreads or something. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=47237 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker --- cmake/CMakeLists.txt | 2 ++ cmake/dbus/CMakeLists.txt | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ba44d575..000acda2 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -83,6 +83,8 @@ option (DBUS_USE_EXPAT "Use expat (== ON) or libxml2 (==OFF)" ON) if(NOT WIN32) option (DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON) + set (CMAKE_THREAD_PREFER_PTHREAD ON) + include (FindThreads) endif(NOT WIN32) #AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 13d6f87a..d09e63df 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -266,6 +266,8 @@ if(WIN32) else(WINCE) target_link_libraries(dbus-1 ws2_32 advapi32 netapi32) endif(WINCE) +else(WIN32) + target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT}) endif(WIN32) install_targets(/lib dbus-1 ) @@ -289,6 +291,8 @@ if(WIN32) else(WINCE) target_link_libraries(dbus-internal ws2_32 advapi32 netapi32) endif(WINCE) +else(WIN32) + target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT}) endif(WIN32) if (DBUS_BUILD_TESTS) -- cgit v1.2.1 From 3624e65986453d90ff571bdb738b4370f621cf88 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 15 Jun 2012 16:03:39 +0100 Subject: NEWS --- NEWS | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 2a8f8ed0..6e5d9bca 100644 --- a/NEWS +++ b/NEWS @@ -3,9 +3,14 @@ D-Bus 1.6.2 (UNRELEASED) Fixes: -• Add dbus-launch --exit-with-x11 option. Distributions should use this - in their X11 session startup infrastructure, in preference to - the --exit-with-session option. (fd.o #39197, Simon McVittie) +• Automatically define DBUS_STATIC_BUILD in static-only Autotools builds, + fixing linking when targeting Windows (fd.o #33973; william, Simon McVittie) + +• Unix-specific: + · Add dbus-launch --exit-with-x11 option. Distributions should use this + in their X11 session startup infrastructure, in preference to + the --exit-with-session option. (fd.o #39197, Simon McVittie) + · Check for libpthread under CMake on Unix (fd.o #47237, Simon McVittie) D-Bus 1.6.0 (2012-06-05) == -- cgit v1.2.1 From eb2300b593e585857f55a05826f3b63cb035a11d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 15 Jun 2012 16:18:02 +0100 Subject: additional NEWS: spec 0.20, WiP --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index a1778bf4..d75d7ada 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ D-Bus 1.7.0 (UNRELEASED) == +Enhancements: + +• D-Bus Specification 0.20 + · various reorganisation for better clarity (fd.o #38252, Simon McVittie) + · stop claiming that all basic types work just like INT32 (strings don't!) + Fixes: • Automatically define DBUS_STATIC_BUILD in static-only Autotools builds, -- cgit v1.2.1 From e1427a2d662ca18cff5beb2dddd8490891d02a9f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 25 Jun 2012 11:55:22 +0100 Subject: Set configure defaults from --enable-developer, not Automake maintainer mode Automake maintainer mode isn't about whether you're a maintainer or not (although its name would suggest that), it's about whether files that are normally distributed in the tarball get regenerated. As such, it's not really appropriate to use it to drive defaults for things like assertions and extra test code. The desired effect is that developers building from git normally get tests and assertions, while distribution packagers don't. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34671 Signed-off-by: Simon McVittie Reviewed-by: Colin Walters --- autogen.sh | 2 +- configure.ac | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/autogen.sh b/autogen.sh index d139fa47..f66e7781 100755 --- a/autogen.sh +++ b/autogen.sh @@ -101,7 +101,7 @@ else fi if $run_configure; then - $srcdir/configure --enable-maintainer-mode --config-cache "$@" + $srcdir/configure --enable-maintainer-mode --enable-developer --config-cache "$@" echo echo "Now type 'make' to compile $PROJECT." else diff --git a/configure.ac b/configure.ac index 8d952278..9feebfc2 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,6 @@ GETTEXT_PACKAGE=dbus-1 AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain]) - ## must come before we use the $USE_MAINTAINER_MODE variable later AM_MAINTAINER_MODE m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) @@ -123,6 +122,12 @@ AM_CONDITIONAL(DBUS_WINCE, test "$dbus_wince" = yes) AM_CONDITIONAL(DBUS_UNIX, test "$dbus_unix" = yes) AM_CONDITIONAL(DBUS_CYGWIN, test "$dbus_cygwin" = yes) +# this must come first: other options use this to set their defaults +AC_ARG_ENABLE([developer], + [AS_HELP_STRING([--enable-developer], + [set defaults to be appropriate for a D-Bus developer instead of a distribution/end-user]), + [], enable_developer=no]) + DBUS_STATIC_BUILD_CPPFLAGS= if test "x$enable_shared" = xno; then # On Windows, linking against the static library requires special effort @@ -134,8 +139,8 @@ fi AC_SUBST([DBUS_STATIC_BUILD_CPPFLAGS]) AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) -AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE) -AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) +AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$enable_developer) +AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$enable_developer) AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes) AC_ARG_ENABLE(xml-docs, AS_HELP_STRING([--enable-xml-docs],[build XML documentation (requires xmlto)]),enable_xml_docs=$enableval,enable_xml_docs=auto) AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs],[build DOXYGEN documentation (requires Doxygen)]),enable_doxygen_docs=$enableval,enable_doxygen_docs=auto) @@ -166,7 +171,7 @@ AC_ARG_WITH(dbus_session_bus_default_address, AS_HELP_STRING([--with-dbus-sessio AC_ARG_ENABLE([embedded-tests], AS_HELP_STRING([--enable-embedded-tests], [enable unit test code in the library and binaries]), - [], [enable_embedded_tests=$USE_MAINTAINER_MODE]) + [], [enable_embedded_tests=$enable_developer]) AC_ARG_ENABLE([modular-tests], AS_HELP_STRING([--enable-modular-tests], [enable modular regression tests (requires GLib)]), @@ -1308,9 +1313,9 @@ cc_supports_flag() { TP_COMPILER_WARNINGS([WARNING_CFLAGS], dnl Use -Werror by default if: dnl - we're not on Windows (too many warnings), and - dnl - we're in maintainer mode (a D-Bus developer, not a distro or end-user) + dnl - we're in developer mode (a D-Bus developer, not a distro or end-user) dnl Override with --enable-Werror or --disable-Werror - [test x$dbus_win != xyes -a x$dbus_cygwin != xyes -a x$USE_MAINTAINER_MODE = xyes], + [test x$dbus_win != xyes -a x$dbus_cygwin != xyes -a x$enable_developer = xyes], dnl Enable these warnings if possible: [all \ @@ -1754,7 +1759,7 @@ echo " man2html: ${MAN2HTML:-not found}" echo " - Maintainer mode: ${USE_MAINTAINER_MODE} + Rebuilding generated files: ${USE_MAINTAINER_MODE} gcc coverage profiling: ${enable_compiler_coverage} Building embedded tests: ${enable_embedded_tests} Building modular tests: ${enable_modular_tests} -- cgit v1.2.1 From f51a9648ff1a893cecd34136adff02168db8b689 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 Feb 2012 12:09:48 +0000 Subject: Enable Automake maintainer mode by default, but let distros disable it See http://blogs.gnome.org/desrt/2011/09/08/am_maintainer_mode-is-not-cool/ for more information. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34671 Signed-off-by: Simon McVittie --- autogen.sh | 2 +- configure.ac | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/autogen.sh b/autogen.sh index f66e7781..15581120 100755 --- a/autogen.sh +++ b/autogen.sh @@ -101,7 +101,7 @@ else fi if $run_configure; then - $srcdir/configure --enable-maintainer-mode --enable-developer --config-cache "$@" + $srcdir/configure --enable-developer --config-cache "$@" echo echo "Now type 'make' to compile $PROJECT." else diff --git a/configure.ac b/configure.ac index 9feebfc2..52d23177 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,9 @@ GETTEXT_PACKAGE=dbus-1 AC_SUBST(GETTEXT_PACKAGE) AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The name of the gettext domain]) -AM_MAINTAINER_MODE +# By default, rebuild autotools files on demand; only use ./missing if the +# user says --disable-maintainer-mode (some distributions like to do this) +AM_MAINTAINER_MODE([enable]) m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])]) -- cgit v1.2.1 From a12e6f3ccf30d97fe5fcbd4ecd4dba6e1c550123 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 25 Jun 2012 13:16:53 +0100 Subject: NEWS --- NEWS | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6e5d9bca..81c32f9d 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,11 @@ D-Bus 1.6.2 (UNRELEASED) == -Fixes: +• Disconnect "developer mode" (assertions, verbose mode etc.) from + Automake maintainer mode. D-Bus developers should now configure with + --enable-developer. Automake maintainer mode is now on by default; + distributions can disable it with --disable-maintainer-mode. + (fd.o #34671, Simon McVittie) • Automatically define DBUS_STATIC_BUILD in static-only Autotools builds, fixing linking when targeting Windows (fd.o #33973; william, Simon McVittie) -- cgit v1.2.1 From e29efffd88881eb765ded94e9ebdbb5a76d2fd5f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 25 Jun 2012 12:20:45 +0100 Subject: dbus_pending_call_set_notify: don't leave the connection locked on OOM Bug: https://bugs.freedesktop.org/show_bug.cgi?id=51032 Signed-off-by: Simon McVittie Reviewed-by: Lennart Poettering --- dbus/dbus-pending-call.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index 8a9d2f49..62c6c748 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -631,6 +631,8 @@ dbus_pending_call_set_notify (DBusPendingCall *pending, void *user_data, DBusFreeFunction free_user_data) { + dbus_bool_t ret = FALSE; + _dbus_return_val_if_fail (pending != NULL, FALSE); CONNECTION_LOCK (pending->connection); @@ -638,13 +640,15 @@ dbus_pending_call_set_notify (DBusPendingCall *pending, /* could invoke application code! */ if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot, user_data, free_user_data)) - return FALSE; + goto out; pending->function = function; + ret = TRUE; +out: CONNECTION_UNLOCK (pending->connection); - return TRUE; + return ret; } /** -- cgit v1.2.1 From e2b3b745128f85d015683119218c65e65b012e2a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 25 Jun 2012 13:26:35 +0100 Subject: Create /var/lib/dbus explicitly rather than as a side-effect Since Automake 1.11.4, an empty localstatelib_DATA variable will not create $(localstatelibdir) as a side-effect. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=51406 Signed-off-by: Simon McVittie Reviewed-by: Lennart Poettering --- tools/Makefile.am | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index c4632e3e..cfd54b8b 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -72,6 +72,9 @@ EXTRA_DIST = run-with-tmp-session-bus.sh strtoll.c strtoull.c CLEANFILES = \ run-with-tmp-session-bus.conf -#create the /var/lib/data directory for dbus-uuidgen -localstatelibdir = $(localstatedir)/lib/dbus -localstatelib_DATA = +# create the /var/lib/dbus directory for dbus-uuidgen +install-data-local: + $(MKDIR_P) $(DESTDIR)$(localstatedir)/lib/dbus + +installcheck-local: + test -d $(DESTDIR)$(localstatedir)/lib/dbus -- cgit v1.2.1 From 453457904b2126d20dfabc85d6f57940b3eef84f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 25 Jun 2012 15:27:05 +0100 Subject: Prepare 1.6.2 --- NEWS | 10 +++++++++- configure.ac | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 81c32f9d..e55b5240 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,14 @@ -D-Bus 1.6.2 (UNRELEASED) +D-Bus 1.6.2 (2012-06-25) == +The "Ice Cabbage" release. + +• Change how we create /var/lib/dbus so it works under Automake >= 1.11.4 + (fd.o #51406, Simon McVittie) + +• Don't return from dbus_pending_call_set_notify with a lock held on OOM + (fd.o #51032, Simon McVittie) + • Disconnect "developer mode" (assertions, verbose mode etc.) from Automake maintainer mode. D-Bus developers should now configure with --enable-developer. Automake maintainer mode is now on by default; diff --git a/configure.ac b/configure.ac index 52d23177..fc75c0b4 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [1]) +m4_define([dbus_micro_version], [2]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=1 +LT_REVISION=2 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From 589ca59b2ffd749d1bf021f688dd54bcf759e5ea Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 25 Jun 2012 20:54:56 +0100 Subject: Stop release preparation, --exit-with-x11 doesn't work --- NEWS | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index e55b5240..87a43736 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -D-Bus 1.6.2 (2012-06-25) +D-Bus 1.6.2 (UNRELEASED) == The "Ice Cabbage" release. diff --git a/configure.ac b/configure.ac index fc75c0b4..3f710f76 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [2]) +m4_define([dbus_micro_version], [1]) 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]) -- cgit v1.2.1 From 6ec9900bc121d71b0b91c1d988406155406a38a5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Jun 2012 11:31:22 +0100 Subject: Revert "dbus-launch: add --exit-with-x11 option" This reverts commit fcc656d430f53ad62c25e41d7e7bd880cbb726a0. --- doc/dbus-launch.1 | 26 ++++++-------------------- tools/dbus-launch.c | 33 ++++++--------------------------- 2 files changed, 12 insertions(+), 47 deletions(-) diff --git a/doc/dbus-launch.1 b/doc/dbus-launch.1 index 4902b40a..e4341e54 100644 --- a/doc/dbus-launch.1 +++ b/doc/dbus-launch.1 @@ -7,7 +7,7 @@ dbus\-launch \- Utility to start a message bus from a shell script .SH SYNOPSIS .PP -.B dbus\-launch [\-\-version] [\-\-sh\-syntax] [\-\-csh\-syntax] [\-\-auto\-syntax] [\-\-exit\-with\-session] [\-\-exit\-with\-x11] [\-\-autolaunch=MACHINEID] [\-\-config\-file=FILENAME] [PROGRAM] [ARGS...] +.B dbus\-launch [\-\-version] [\-\-sh\-syntax] [\-\-csh\-syntax] [\-\-auto\-syntax] [\-\-exit\-with\-session] [\-\-autolaunch=MACHINEID] [\-\-config\-file=FILENAME] [PROGRAM] [ARGS...] .SH DESCRIPTION @@ -167,25 +167,11 @@ the \-\-session argument. See the man page for dbus\-daemon Emit csh compatible code to set up environment variables. .TP -.I \-\-exit\-with\-x11 -If this option is provided, a persistent "babysitter" process will be -created, and will connect to the X server. If it cannot do so, launching -fails. If the "babysitter" process loses its X connection, -it kills the message bus daemon, disconnecting all of its clients (which -should exit in response). This avoids having leftover daemon -processes from a user X session, after the X session has ended. - -.TP -.I \-\-exit\-with\-session -If this option is provided, a persistent "babysitter" process will be -created, as if for -.BR \-\-exit\-with\-x11 . -If it cannot connect to the X server, it will monitor the terminal from which -.B dbus-launch -was started instead, and if it gets a HUP on stdin, the message bus daemon -will be killed. This option is not recommended, since it will consume input -from the terminal where it was started; it is mainly provided for -backwards compatibility. +.I "\-\-exit\-with\-session" +If this option is provided, a persistent "babysitter" process will be +created that watches stdin for HUP and tries to connect to the X +server. If this process gets a HUP on stdin or loses its X connection, +it kills the message bus daemon. .TP .I "\-\-autolaunch=MACHINEID" diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index dcce646e..1ec9ae59 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -181,7 +181,7 @@ verbose (const char *format, static void usage (int ecode) { - fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session] [--exit-with-x11]\n"); + fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session]\n"); exit (ecode); } @@ -809,7 +809,6 @@ main (int argc, char **argv) const char *runprog = NULL; int remaining_args = 0; int exit_with_session; - int exit_with_x11 = FALSE; int binary_syntax = FALSE; int c_shell_syntax = FALSE; int bourne_shell_syntax = FALSE; @@ -851,8 +850,6 @@ main (int argc, char **argv) version (); else if (strcmp (arg, "--exit-with-session") == 0) exit_with_session = TRUE; - else if (strcmp (arg, "--exit-with-x11") == 0) - exit_with_x11 = TRUE; else if (strcmp (arg, "--close-stderr") == 0) close_stderr = TRUE; else if (strstr (arg, "--autolaunch=") == arg) @@ -964,9 +961,6 @@ main (int argc, char **argv) if (exit_with_session) verbose ("--exit-with-session enabled\n"); - if (exit_with_x11) - verbose ("--exit-with-x11 enabled\n"); - if (autolaunch) { #ifndef DBUS_BUILD_X11 @@ -989,10 +983,10 @@ main (int argc, char **argv) } verbose ("Autolaunch enabled (using X11).\n"); - if (!exit_with_x11) + if (!exit_with_session) { - verbose ("--exit-with-x11 automatically enabled\n"); - exit_with_x11 = TRUE; + verbose ("--exit-with-session automatically enabled\n"); + exit_with_session = TRUE; } if (!x11_init ()) @@ -1015,27 +1009,12 @@ main (int argc, char **argv) exit (0); } #endif /* DBUS_ENABLE_X11_AUTOLAUNCH */ -#endif /* DBUS_BUILD_X11 */ - } - else if (exit_with_x11) - { -#ifndef DBUS_BUILD_X11 - fprintf (stderr, "Session lifetime based on X11 requested, but X11 support not compiled in.\n"); - exit (1); -#else /* DBUS_BUILD_X11 */ - if (!x11_init ()) - { - fprintf (stderr, "Session lifetime based on X11 requested, but X11 initialization failed.\n"); - exit (1); - } -#endif /* DBUS_BUILD_X11 */ } -#ifdef DBUS_BUILD_X11 else if (read_machine_uuid_if_needed()) { x11_init(); - } #endif /* DBUS_BUILD_X11 */ + } if (pipe (bus_pid_to_launcher_pipe) < 0 || @@ -1097,7 +1076,7 @@ main (int argc, char **argv) * and will also reap the pre-forked bus * daemon */ - babysit (exit_with_session || exit_with_x11, ret, + babysit (exit_with_session, ret, bus_pid_to_babysitter_pipe[READ_END]); exit (0); } -- cgit v1.2.1 From 27a7eb41f6a363cbae71c47e3c6ed7e732bdf43c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Jun 2012 11:32:29 +0100 Subject: Still recommend --exit-with-session in documentation, --exit-with-x11 was reverted --- doc/dbus-launch.1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/dbus-launch.1 b/doc/dbus-launch.1 index e4341e54..e22a3be0 100644 --- a/doc/dbus-launch.1 +++ b/doc/dbus-launch.1 @@ -56,17 +56,17 @@ about D\-Bus. See also the man page for \fIdbus\-daemon\fP. Distributions running .B dbus\-launch as part of a standard X session should run -.B "dbus\-launch \-\-exit\-with\-x11" +.B "dbus\-launch \-\-exit\-with\-session" after the X server has started and become available, as a wrapper around the "main" X client (typically a session manager or window manager), as in these examples: .RS -.B "dbus\-launch \-\-exit\-with\-x11 gnome\-session" +.B "dbus\-launch \-\-exit\-with\-session gnome\-session" -.B "dbus\-launch \-\-exit\-with\-x11 openbox" +.B "dbus\-launch \-\-exit\-with\-session openbox" -.B "dbus\-launch \-\-exit\-with\-x11 ~/.xsession" +.B "dbus\-launch \-\-exit\-with\-session ~/.xsession" .RE If your distribution does not do this, you can achieve similar results -- cgit v1.2.1 From b54fd09aed39aeac66b25e3af134e30659139c79 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Jun 2012 11:33:29 +0100 Subject: Revise NEWS to not mention --exit-with-x11 --- NEWS | 3 --- 1 file changed, 3 deletions(-) diff --git a/NEWS b/NEWS index 87a43736..faced8e6 100644 --- a/NEWS +++ b/NEWS @@ -19,9 +19,6 @@ The "Ice Cabbage" release. fixing linking when targeting Windows (fd.o #33973; william, Simon McVittie) • Unix-specific: - · Add dbus-launch --exit-with-x11 option. Distributions should use this - in their X11 session startup infrastructure, in preference to - the --exit-with-session option. (fd.o #39197, Simon McVittie) · Check for libpthread under CMake on Unix (fd.o #47237, Simon McVittie) D-Bus 1.6.0 (2012-06-05) -- cgit v1.2.1 From 564e7fc66fe32199621f706ca4cc505fbb5dcf49 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Jun 2012 17:48:33 +0100 Subject: Second go at 1.6.2 --- NEWS | 2 +- configure.ac | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index faced8e6..aad2a1f8 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -D-Bus 1.6.2 (UNRELEASED) +D-Bus 1.6.2 (2012-06-27) == The "Ice Cabbage" release. diff --git a/configure.ac b/configure.ac index 3f710f76..fc75c0b4 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [1]) +m4_define([dbus_micro_version], [2]) 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]) -- cgit v1.2.1 From 93616f0d3712388fbee7927ca5b58421d3a9359c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Jun 2012 18:52:53 +0100 Subject: Resume development --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index aad2a1f8..0942b737 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.6.4 (UNRELEASED) +== + +... + D-Bus 1.6.2 (2012-06-27) == diff --git a/configure.ac b/configure.ac index fc75c0b4..f1b40a0c 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [2]) +m4_define([dbus_micro_version], [3]) 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]) -- cgit v1.2.1 From b138aa0f9403878376b8ca4b64cf52f65eecb90f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Thu, 28 Jun 2012 15:50:46 +0100 Subject: Properly concat DBUS_CONSOLE_AUTH_DIR with username This removes the assumption that DBUS_CONSOLE_AUTH_DIR ends with a trailing /. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=51521 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-util-unix.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index ef86d738..caa38d0e 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -540,7 +540,7 @@ _dbus_user_at_console (const char *username, DBusError *error) { - DBusString f; + DBusString u, f; dbus_bool_t result; result = FALSE; @@ -556,8 +556,9 @@ _dbus_user_at_console (const char *username, goto out; } + _dbus_string_init_const (&u, username); - if (!_dbus_string_append (&f, username)) + if (!_dbus_concat_dir_and_file (&f, &u)) { _DBUS_SET_OOM (error); goto out; -- cgit v1.2.1 From 4f6d717197d225af36bb7dd191e504c9c6a4dfb8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 28 Jun 2012 16:49:01 +0100 Subject: NEWS --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 0942b737..b6b4bbd9 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,9 @@ D-Bus 1.6.4 (UNRELEASED) == -... +• Detect that users are "at the console" correctly when configured with + a non-default path such as --enable-console-auth-dir=/run/console + (fd.o #51521, Dave Reisner) D-Bus 1.6.2 (2012-06-27) == -- cgit v1.2.1 From e5a945507b045eb46c43da5c0f29a6ee9ab5dbee Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Jul 2012 09:26:27 +0100 Subject: DBusTransport: do not assert that autolaunch address is non-empty dbus-launch can apparently return an empty address under certain circumstances, and dbus_parse_address() in the next line will return a nice DBusError for an empty address rather than aborting the process. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=51657 Bug-Debian: http://bugs.debian.org/680027 Reviewed-by: David Zeuthen --- dbus/dbus-transport.c | 1 - 1 file changed, 1 deletion(-) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index ba720f25..6b58fda2 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -253,7 +253,6 @@ check_address (const char *address, DBusError *error) int len, i; _dbus_assert (address != NULL); - _dbus_assert (*address != '\0'); if (!dbus_parse_address (address, &entries, &len, error)) return NULL; /* not a valid address */ -- cgit v1.2.1 From d8de80969c090c70e0bfe1d5e68fc7f783fd18e4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Jul 2012 15:53:31 +0100 Subject: Set enable-developer default to 'no' Misplaced [] and () led to enable_developer=no being part of the option's documentation instead of actually being the default value. Regression in 1.6.2, caused by #34671. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=51657 Bug-Debian: http://bugs.debian.org/680027 Reviewed-by: David Zeuthen --- configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index f1b40a0c..698fcd15 100644 --- a/configure.ac +++ b/configure.ac @@ -127,8 +127,9 @@ AM_CONDITIONAL(DBUS_CYGWIN, test "$dbus_cygwin" = yes) # this must come first: other options use this to set their defaults AC_ARG_ENABLE([developer], [AS_HELP_STRING([--enable-developer], - [set defaults to be appropriate for a D-Bus developer instead of a distribution/end-user]), - [], enable_developer=no]) + [set defaults to be appropriate for a D-Bus developer instead of a distribution/end-user])], + [], + [enable_developer=no]) DBUS_STATIC_BUILD_CPPFLAGS= if test "x$enable_shared" = xno; then -- cgit v1.2.1 From a5d4c4aa35c3115f963a263ecae5879b5f58c453 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Jul 2012 20:12:10 +0100 Subject: NEWS --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index b6b4bbd9..1d1be192 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,12 @@ D-Bus 1.6.4 (UNRELEASED) a non-default path such as --enable-console-auth-dir=/run/console (fd.o #51521, Dave Reisner) +• Remove an incorrect assertion from DBusTransport (fd.o #51657, + Simon McVittie) + +• Make --enable-developer default to "no" (regression in 1.6.2; + fd.o #51657, Simon McVittie) + D-Bus 1.6.2 (2012-06-27) == -- cgit v1.2.1 From 88f8d44aed231729f7e6ed70d4a46dc4aad59975 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 8 Jul 2012 09:37:09 -0400 Subject: spec: Mention object path and interface name We didn't actually have /org/freedesktop/DBus in the spec, nor did we explicitly mention the existence of "org.freedesktop.DBus" as an interface, although it is implicit in the method names. https://bugs.freedesktop.org/show_bug.cgi?id=51865 --- doc/dbus-specification.xml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 32a20915..1c54c155 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -3805,10 +3805,13 @@ that connection is said to own the name. - The bus itself owns a special name, org.freedesktop.DBus. - This name routes messages to the bus, allowing applications to make - administrative requests. For example, applications can ask the bus - to assign a name to a connection. + The bus itself owns a special name, + org.freedesktop.DBus, with an object + located at /org/freedesktop/DBus that + implements the org.freedesktop.DBus + interface. This service allows applications to make + administrative requests of the bus itself. For example, + applications can ask the bus to assign a name to a connection. Each name may have queued owners. When an -- cgit v1.2.1 From 2a50cb475bfaf331e2451bbe70c2b3bbdd1ad69d Mon Sep 17 00:00:00 2001 From: Wolfgang Baron Date: Wed, 18 Jul 2012 18:09:44 +0100 Subject: Fix launching of dbus-daemon on Windows in paths containing spaces If dbus is installed in a path, which contains a space, dbus-launch will not launch the daemon. That is so, because a command line is built from just the path to the daemon and a parameter. The path has to be surrounded with quotes. This can be done unconditionally, because the quotes do not cause any trouble even if they are not needed. Reviewed-by: Ralf Habacker Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49450 --- tools/dbus-launch-win.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index ea4bf0dd..215fac3f 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -130,9 +130,10 @@ main (int argc, char **argv) fprintf (stderr, "%ls %ls\n", dbusDaemonPath, command); #else command[0] = L'\0'; - /* Windows CE has a different interpretation of cmdline: Start with argv[1]. */ - wcscpy_s (command, sizeof (command), dbusDaemonPath); - wcscat_s (command, sizeof (command), L" --session"); + /* Windows cmdline starts with path, which can contain spaces. */ + wcscpy_s (command, sizeof (command), L"\""); + wcscat_s (command, sizeof (command), dbusDaemonPath); + wcscat_s (command, sizeof (command), L"\" --session"); if (verbose) fprintf (stderr, "%ls\n", command); #endif -- cgit v1.2.1 From 93f78602b248c6e2809d449b7d27b399d7a4b208 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 18 Jul 2012 18:11:49 +0100 Subject: Prepare 1.6.4 release --- NEWS | 6 +++++- configure.ac | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 1d1be192..ed7c01dd 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -D-Bus 1.6.4 (UNRELEASED) +D-Bus 1.6.4 (2012-07-18) == • Detect that users are "at the console" correctly when configured with @@ -11,6 +11,10 @@ D-Bus 1.6.4 (UNRELEASED) • Make --enable-developer default to "no" (regression in 1.6.2; fd.o #51657, Simon McVittie) +• Windows-specific: + · Launch dbus-daemon correctly if its path contains a space + (fd.o #49450, Wolfgang Baron) + D-Bus 1.6.2 (2012-06-27) == diff --git a/configure.ac b/configure.ac index 698fcd15..bdee9da3 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [3]) +m4_define([dbus_micro_version], [4]) 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]) -- cgit v1.2.1 From 15e990d68d13ec7df055d7795621f6074f575b32 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 18 Jul 2012 19:30:23 +0100 Subject: 1.6.5 --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ed7c01dd..c2bb54e1 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.6.6 (UNRELEASED) +== + +... + D-Bus 1.6.4 (2012-07-18) == diff --git a/configure.ac b/configure.ac index bdee9da3..4f86e9df 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [4]) +m4_define([dbus_micro_version], [5]) 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]) -- cgit v1.2.1 From e98107548c5cd0a9da9d5a15e20177be0e479459 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Thu, 9 Aug 2012 12:25:02 +0100 Subject: Check HAVE_DECL_LOG_PERROR with #if, not #ifdef It's always defined. [smcv: commit message added] Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=53286 --- dbus/dbus-sysdeps-util-unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index caa38d0e..76423ab8 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -424,7 +424,7 @@ _dbus_request_file_descriptor_limit (unsigned int limit) void _dbus_init_system_log (void) { -#ifdef HAVE_DECL_LOG_PERROR +#if HAVE_DECL_LOG_PERROR openlog ("dbus", LOG_PID | LOG_PERROR, LOG_DAEMON); #else openlog ("dbus", LOG_PID, LOG_DAEMON); -- cgit v1.2.1 From ed0e9e982e720d56274d5c0b2cf4fe2f983f9cc4 Mon Sep 17 00:00:00 2001 From: Jonathan Perkin Date: Thu, 9 Aug 2012 12:26:06 +0100 Subject: Define __EXTENSIONS__ on Solaris to get sockaddr_in6 and sockaddr_storage [smcv: comments updated, commit message added] Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=53286 --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 4f86e9df..e8fc1aef 100644 --- a/configure.ac +++ b/configure.ac @@ -1379,6 +1379,8 @@ case $host_os in solaris*) # Solaris' C library apparently needs these runes to be threadsafe... CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT" + # ... this opt-in to get sockaddr_in6 and sockaddr_storage... + CFLAGS="$CFLAGS -D__EXTENSIONS__" # ... and this opt-in to get file descriptor passing support CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500" ;; -- cgit v1.2.1 From 9436816175060f038af9c06cf135246f955f9ed4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 9 Aug 2012 12:31:48 +0100 Subject: NEWS --- NEWS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index c2bb54e1..769fcadc 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,8 @@ D-Bus 1.6.6 (UNRELEASED) == -... +• Unix-specific: + · Fix compilation on Solaris (fd.o #53286, Jonathan Perkin) D-Bus 1.6.4 (2012-07-18) == -- cgit v1.2.1 From e33c318c1399e58c8e1c0934282d2d47d9539b9b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 9 Aug 2012 12:42:52 +0100 Subject: NEWS --- NEWS | 16 ++++++++++------ doc/dbus-specification.xml | 9 +++++---- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index dfac67f5..ccf681e6 100644 --- a/NEWS +++ b/NEWS @@ -1,18 +1,22 @@ D-Bus 1.7.0 (UNRELEASED) == +Enhancements: + +• D-Bus Specification 0.21 + · actually say that /org/freedesktop/DBus is the object that + implements o.fd.DBus (fd.o #51865, Colin Walters) + · various reorganisation for better clarity (fd.o #38252, Simon McVittie) + · stop claiming that all basic types work just like INT32 (strings don't!) + +Fixes: + • Unix-specific: · Fix compilation on Solaris (fd.o #53286, Jonathan Perkin) D-Bus 1.6.4 (2012-07-18) == -Enhancements: - -• D-Bus Specification 0.20 - · various reorganisation for better clarity (fd.o #38252, Simon McVittie) - · stop claiming that all basic types work just like INT32 (strings don't!) - Fixes: • Detect that users are "at the console" correctly when configured with diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 1c54c155..b3130708 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.19 - 2012-02-21 + Version 0.20 + unreleased Havoc @@ -74,8 +74,9 @@ current commit log - - + smcv, walters + reorganise for clarity, remove false claims about + basic types, mention /o/fd/DBus 0.19 -- cgit v1.2.1 From 05b0b9e65b6a58f0b0cb56d6ee8cf100061250b3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 4 Jan 2012 19:39:54 +0000 Subject: cmake: use the same default system bus address as for autotools The system bus is unsupported (and rather meaningless) on Windows anyway, so we can use anything. Also, make it clear that it has to be a "specific" address that can be listened on *and* connected to, like unix:path=/xxx - a listen-only address like unix:tmpdir=/xxx or nonce-tcp: would not be suitable. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38201 Reviewed-by: David Zeuthen --- README.cmake | 6 +++--- cmake/CMakeLists.txt | 11 +++++++++-- configure.ac | 13 +++++++++++-- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/README.cmake b/README.cmake index 5feaf551..0e923356 100644 --- a/README.cmake +++ b/README.cmake @@ -80,7 +80,7 @@ Configuration flags When using the cmake build system the dbus-specific configuration flags that can be given to the cmake program are these (use -D= on command line). The listed values -are the defaults. +are the defaults (in a typical build - some are platform-specific). // Choose the type of build, options are: None(CMAKE_CXX_FLAGS or // CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. @@ -132,8 +132,8 @@ DBUS_INSTALL_SYSTEM_LIBS:BOOL=OFF // session bus default address DBUS_SESSION_BUS_DEFAULT_ADDRESS:STRING=nonce-tcp: -// system bus default address -DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=nonce-tcp: +// system bus default address (only useful on Unix) +DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket // Use atomic integer implementation for 486 DBUS_USE_ATOMIC_INT_486:BOOL=OFF diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 000acda2..5174469d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -431,9 +431,17 @@ endif (WIN32) set (DBUS_USER ) +# This won't work on Windows. It's not meant to - the system bus is +# meaningless on Windows anyway. +# +# This has to be suitable for hard-coding in client libraries as well as +# in the dbus-daemon's configuration, so it has to be valid to listen on +# and also to connect to. If this ever changes, it'll need to be split into +# two variables, one for the listening address and one for the connecting +# address. +set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket" CACHE STRING "system bus default address") if (WIN32) - set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "system bus default address") set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "session bus default address") set (DBUS_SYSTEM_CONFIG_FILE "etc/dbus-1/system.conf") @@ -441,7 +449,6 @@ if (WIN32) # bus-test expects a non empty string set (DBUS_USER "Administrator") else (WIN32) - set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:tmpdir=" CACHE STRING "system bus default address") set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default address") set (sysconfdir "") set (configdir ${sysconfdir}/dbus-1 ) diff --git a/configure.ac b/configure.ac index e8fc1aef..12847c4a 100644 --- a/configure.ac +++ b/configure.ac @@ -1521,8 +1521,17 @@ fi AC_SUBST(DBUS_SYSTEM_SOCKET) AC_DEFINE_UNQUOTED(DBUS_SYSTEM_SOCKET,"$DBUS_SYSTEM_SOCKET",[The name of the socket the system bus listens on by default]) -## system bus only listens on local domain sockets, and never -## on an abstract socket (so only root can create the socket) +## System bus only listens on local domain sockets, and never +## on an abstract socket (so only root can create the socket). +## +## This won't work on Windows. It's not meant to - the system bus is +## meaningless on Windows anyway. +## +## This has to be suitable for hard-coding in client libraries as well as +## in the dbus-daemon's configuration, so it has to be valid to listen on +## and also to connect to. If this ever changes, it'll need to be split into +## two variables, one for the listening address and one for the connecting +## address. DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET" AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS) AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-Bus address of the system bus]) -- cgit v1.2.1 From b5d36dc27d1905d4d46ad7f0097f0ea0e0776adb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Aug 2012 19:57:13 +0100 Subject: Split DBUS_SESSION_BUS_DEFAULT_ADDRESS into listen, connect addresses and set better defaults On Unix, the connect address should basically always be "autolaunch:" but the listen address has to be something you can listen on. On Windows, you can listen on "autolaunch:" or "autolaunch:scope=*install-path", for instance, and the dbus-daemon is involved in the auto-launching process. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=38201 Reviewed-by: David Zeuthen [default address changed to autolaunch: for interop with GDBus -smcv] Signed-off-by: Simon McVittie --- README.cmake | 7 ++++-- bus/session.conf.in | 2 +- cmake/CMakeLists.txt | 9 ++++--- cmake/config.h.cmake | 2 +- cmake/dbus-env.bat.cmake | 4 +-- configure.ac | 64 ++++++++++++++++++++++++++++++++++++++++++------ dbus/dbus-bus.c | 8 +++--- dbus/dbus-internals.h | 4 --- 8 files changed, 76 insertions(+), 24 deletions(-) diff --git a/README.cmake b/README.cmake index 0e923356..0c30ba66 100644 --- a/README.cmake +++ b/README.cmake @@ -129,8 +129,11 @@ DBUS_HAVE_ATOMIC_INT:BOOL=OFF // install required system libraries DBUS_INSTALL_SYSTEM_LIBS:BOOL=OFF -// session bus default address -DBUS_SESSION_BUS_DEFAULT_ADDRESS:STRING=nonce-tcp: +// session bus default listening address +DBUS_SESSION_BUS_LISTEN_ADDRESS:STRING=autolaunch: + +// session bus fallback address for clients +DBUS_SESSION_BUS_CONNECT_ADDRESS:STRING=autolaunch: // system bus default address (only useful on Unix) DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket diff --git a/bus/session.conf.in b/bus/session.conf.in index e121ff93..716b5e79 100644 --- a/bus/session.conf.in +++ b/bus/session.conf.in @@ -12,7 +12,7 @@ the behavior of child processes. --> - @DBUS_SESSION_BUS_DEFAULT_ADDRESS@ + @DBUS_SESSION_BUS_LISTEN_ADDRESS@ diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5174469d..52a48fdc 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -442,14 +442,16 @@ set (DBUS_USER ) set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket" CACHE STRING "system bus default address") if (WIN32) - set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "session bus default address") + set (DBUS_SESSION_BUS_LISTEN_ADDRESS "autolaunch:" CACHE STRING "session bus default listening address") + set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients") set (DBUS_SYSTEM_CONFIG_FILE "etc/dbus-1/system.conf") set (DBUS_SESSION_CONFIG_FILE "etc/dbus-1/session.conf") # bus-test expects a non empty string set (DBUS_USER "Administrator") else (WIN32) - set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default address") + set (DBUS_SESSION_BUS_LISTEN_ADDRESS "unix:tmpdir=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default listening address") + set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients") set (sysconfdir "") set (configdir ${sysconfdir}/dbus-1 ) set (DBUS_SYSTEM_CONFIG_FILE ${configdir}/system.conf) @@ -569,7 +571,8 @@ message(" Using XML parser: ${XML_LIB} " message(" Daemon executable name: ${DBUS_DAEMON_NAME}") if (WIN32) message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") -message(" Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} ") +message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ") +message(" Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ") else (WIN32) #message(" Init scripts style: ${with_init_scripts} ") #message(" Abstract socket names: ${have_abstract_sockets} ") diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 6221c190..76ccb866 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -15,8 +15,8 @@ #cmakedefine DBUS_SESSION_CONFIG_FILE "@DBUS_SESSION_CONFIG_FILE@" #cmakedefine DBUS_DAEMON_NAME "@DBUS_DAEMON_NAME@" #cmakedefine DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@" +#cmakedefine DBUS_SESSION_BUS_CONNECT_ADDRESS "@DBUS_SESSION_BUS_CONNECT_ADDRESS@" #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@" -#cmakedefine DBUS_SESSION_BUS_DEFAULT_ADDRESS "@DBUS_SESSION_BUS_DEFAULT_ADDRESS@" #cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@" #cmakedefine PACKAGE "@PACKAGE@" /* Version number of package */ diff --git a/cmake/dbus-env.bat.cmake b/cmake/dbus-env.bat.cmake index 85f70051..d859ce03 100644 --- a/cmake/dbus-env.bat.cmake +++ b/cmake/dbus-env.bat.cmake @@ -2,7 +2,7 @@ @echo off :: session bus address -set DBUS_SESSION_BUS_ADDRESS=@DBUS_SESSION_BUS_DEFAULT_ADDRESS@ +set DBUS_SESSION_BUS_ADDRESS=@DBUS_SESSION_BUS_CONNECT_ADDRESS@ :: system bus address -set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@ \ No newline at end of file +set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@ diff --git a/configure.ac b/configure.ac index 12847c4a..b54d29d8 100644 --- a/configure.ac +++ b/configure.ac @@ -169,7 +169,6 @@ AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filen AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (default: /Library/LaunchAgents)])) AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=],[User for running the DBUS daemon (messagebus)])) AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon])) -AC_ARG_WITH(dbus_session_bus_default_address, AS_HELP_STRING([--with-dbus-session-bus-default-address=[nonce-tcp:/autolaunch:/tcp:host:port]],[Transport Type to be used (default: nonce-tcp:)]),with_dbus_session_bus_default_address=$withval,with_dbus_session_bus_default_address=nonce-tcp:) AC_ARG_ENABLE([embedded-tests], AS_HELP_STRING([--enable-embedded-tests], @@ -1675,14 +1674,64 @@ fi AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets]) AC_SUBST(DBUS_SESSION_SOCKET_DIR) -if test x$dbus_win = xyes; then - DBUS_SESSION_BUS_DEFAULT_ADDRESS="$with_dbus_session_bus_default_address" +# This must be a listening address. It doesn't necessarily need to be an +# address you can connect to - it can be something vague like +# "nonce-tcp:". +# +# The default varies by platform. +AC_ARG_WITH([dbus_session_bus_listen_address], + AS_HELP_STRING([--with-dbus-session-bus-listen-address=[ADDRESS]], + [default address for a session bus to listen on (see configure.ac)]), + [with_dbus_session_bus_listen_address=$withval], + [with_dbus_session_bus_listen_address=]) + +if test "x$with_dbus_session_bus_listen_address" != "x"; then + # the user specified something, trust them + DBUS_SESSION_BUS_LISTEN_ADDRESS="$with_dbus_session_bus_listen_address" +elif test x$dbus_win = xyes; then + # On Windows, you can (and should) listen on autolaunch addresses, + # because autolaunching is different. + # See https://bugs.freedesktop.org/show_bug.cgi?id=38201 + DBUS_SESSION_BUS_LISTEN_ADDRESS="autolaunch:" elif test x$have_launchd = xyes; then - DBUS_SESSION_BUS_DEFAULT_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET" + # Mac OS X default is to use launchd + DBUS_SESSION_BUS_LISTEN_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET" +else + # The default on all other Unix platforms (notably Linux) + # is to create a randomly named socket in /tmp or similar + DBUS_SESSION_BUS_LISTEN_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR" +fi +AC_SUBST([DBUS_SESSION_BUS_LISTEN_ADDRESS]) + +# This must be an address you can connect to. It doesn't necessarily +# need to be an address you can listen on - it can be "autolaunch:", +# even on Unix. +# +# The default varies by platform. +AC_ARG_WITH([dbus_session_bus_connect_address], + AS_HELP_STRING([--with-dbus-session-bus-connect-address=[ADDRESS]], + [fallback address for a session bus client to connect to (see configure.ac)]), + [with_dbus_session_bus_connect_address=$withval], + [with_dbus_session_bus_connect_address=]) + +if test "x$with_dbus_session_bus_connect_address" != "x"; then + # the user specified something, trust them + DBUS_SESSION_BUS_CONNECT_ADDRESS="$with_dbus_session_bus_connect_address" +elif test x$dbus_win = xyes; then + # Windows autolaunching is a bit different; leaving it in its own + # branch of the conditional because the default might conceivably + # change (see #38201) + DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:" else - DBUS_SESSION_BUS_DEFAULT_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR" + # The default on all other Unix platforms (notably Linux) + # is to use auto-launching - this works a bit differently on Mac OS X + # but comes out basically the same in the end + DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:" fi -AC_SUBST(DBUS_SESSION_BUS_DEFAULT_ADDRESS) +AC_SUBST([DBUS_SESSION_BUS_CONNECT_ADDRESS]) +AC_DEFINE_UNQUOTED([DBUS_SESSION_BUS_CONNECT_ADDRESS], + ["$DBUS_SESSION_BUS_CONNECT_ADDRESS"], + [Fallback address for session bus clients]) # darwin needs this to initialize the environment AC_CHECK_HEADERS(crt_externs.h) @@ -1798,7 +1847,8 @@ echo " System bus socket: ${DBUS_SYSTEM_SOCKET} System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} System bus PID file: ${DBUS_SYSTEM_PID_FILE} - Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} + Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} + Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} Console auth dir: ${DBUS_CONSOLE_AUTH_DIR} Console owner file: ${have_console_owner_file} Console owner file path: ${DBUS_CONSOLE_OWNER_FILE} diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index fadc3a8b..6f81c74a 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -192,12 +192,12 @@ init_session_address (void) if (!retval) return FALSE; - /* The DBUS_SESSION_BUS_DEFAULT_ADDRESS should have really been named - * DBUS_SESSION_BUS_FALLBACK_ADDRESS. - */ + /* We have a hard-coded (but compile-time-configurable) fallback address for + * the session bus. */ if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL) bus_connection_addresses[DBUS_BUS_SESSION] = - _dbus_strdup (DBUS_SESSION_BUS_DEFAULT_ADDRESS); + _dbus_strdup (DBUS_SESSION_BUS_CONNECT_ADDRESS); + if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL) return FALSE; diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 8036a2ba..80376ad5 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -35,10 +35,6 @@ DBUS_BEGIN_DECLS -#ifndef DBUS_SESSION_BUS_DEFAULT_ADDRESS -#define DBUS_SESSION_BUS_DEFAULT_ADDRESS "autolaunch:" -#endif - void _dbus_warn (const char *format, ...) _DBUS_GNUC_PRINTF (1, 2); -- cgit v1.2.1 From 627cdde0ebe00678a71e0bf3f21aedcbd4c7a940 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Aug 2012 20:12:59 +0100 Subject: Revert "Split DBUS_SESSION_BUS_DEFAULT_ADDRESS into listen, connect addresses and set better defaults" This reverts commit b5d36dc27d1905d4d46ad7f0097f0ea0e0776adb. On second thoughts, this is too big a change for a stable branch. --- README.cmake | 7 ++---- bus/session.conf.in | 2 +- cmake/CMakeLists.txt | 9 +++---- cmake/config.h.cmake | 2 +- cmake/dbus-env.bat.cmake | 4 +-- configure.ac | 64 ++++++------------------------------------------ dbus/dbus-bus.c | 8 +++--- dbus/dbus-internals.h | 4 +++ 8 files changed, 24 insertions(+), 76 deletions(-) diff --git a/README.cmake b/README.cmake index 0c30ba66..0e923356 100644 --- a/README.cmake +++ b/README.cmake @@ -129,11 +129,8 @@ DBUS_HAVE_ATOMIC_INT:BOOL=OFF // install required system libraries DBUS_INSTALL_SYSTEM_LIBS:BOOL=OFF -// session bus default listening address -DBUS_SESSION_BUS_LISTEN_ADDRESS:STRING=autolaunch: - -// session bus fallback address for clients -DBUS_SESSION_BUS_CONNECT_ADDRESS:STRING=autolaunch: +// session bus default address +DBUS_SESSION_BUS_DEFAULT_ADDRESS:STRING=nonce-tcp: // system bus default address (only useful on Unix) DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket diff --git a/bus/session.conf.in b/bus/session.conf.in index 716b5e79..e121ff93 100644 --- a/bus/session.conf.in +++ b/bus/session.conf.in @@ -12,7 +12,7 @@ the behavior of child processes. --> - @DBUS_SESSION_BUS_LISTEN_ADDRESS@ + @DBUS_SESSION_BUS_DEFAULT_ADDRESS@ diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 52a48fdc..5174469d 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -442,16 +442,14 @@ set (DBUS_USER ) set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket" CACHE STRING "system bus default address") if (WIN32) - set (DBUS_SESSION_BUS_LISTEN_ADDRESS "autolaunch:" CACHE STRING "session bus default listening address") - set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients") + set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "session bus default address") set (DBUS_SYSTEM_CONFIG_FILE "etc/dbus-1/system.conf") set (DBUS_SESSION_CONFIG_FILE "etc/dbus-1/session.conf") # bus-test expects a non empty string set (DBUS_USER "Administrator") else (WIN32) - set (DBUS_SESSION_BUS_LISTEN_ADDRESS "unix:tmpdir=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default listening address") - set (DBUS_SESSION_BUS_CONNECT_ADDRESS "autolaunch:" CACHE STRING "session bus fallback address for clients") + set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default address") set (sysconfdir "") set (configdir ${sysconfdir}/dbus-1 ) set (DBUS_SYSTEM_CONFIG_FILE ${configdir}/system.conf) @@ -571,8 +569,7 @@ message(" Using XML parser: ${XML_LIB} " message(" Daemon executable name: ${DBUS_DAEMON_NAME}") if (WIN32) message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") -message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ") -message(" Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ") +message(" Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} ") else (WIN32) #message(" Init scripts style: ${with_init_scripts} ") #message(" Abstract socket names: ${have_abstract_sockets} ") diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 76ccb866..6221c190 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -15,8 +15,8 @@ #cmakedefine DBUS_SESSION_CONFIG_FILE "@DBUS_SESSION_CONFIG_FILE@" #cmakedefine DBUS_DAEMON_NAME "@DBUS_DAEMON_NAME@" #cmakedefine DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@" -#cmakedefine DBUS_SESSION_BUS_CONNECT_ADDRESS "@DBUS_SESSION_BUS_CONNECT_ADDRESS@" #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@" +#cmakedefine DBUS_SESSION_BUS_DEFAULT_ADDRESS "@DBUS_SESSION_BUS_DEFAULT_ADDRESS@" #cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@" #cmakedefine PACKAGE "@PACKAGE@" /* Version number of package */ diff --git a/cmake/dbus-env.bat.cmake b/cmake/dbus-env.bat.cmake index d859ce03..85f70051 100644 --- a/cmake/dbus-env.bat.cmake +++ b/cmake/dbus-env.bat.cmake @@ -2,7 +2,7 @@ @echo off :: session bus address -set DBUS_SESSION_BUS_ADDRESS=@DBUS_SESSION_BUS_CONNECT_ADDRESS@ +set DBUS_SESSION_BUS_ADDRESS=@DBUS_SESSION_BUS_DEFAULT_ADDRESS@ :: system bus address -set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@ +set DBUS_SYSTEM_BUS_DEFAULT_ADDRESS=@DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@ \ No newline at end of file diff --git a/configure.ac b/configure.ac index b54d29d8..12847c4a 100644 --- a/configure.ac +++ b/configure.ac @@ -169,6 +169,7 @@ AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filen AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname]],[directory to put the launchd agent (default: /Library/LaunchAgents)])) AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=],[User for running the DBUS daemon (messagebus)])) AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon])) +AC_ARG_WITH(dbus_session_bus_default_address, AS_HELP_STRING([--with-dbus-session-bus-default-address=[nonce-tcp:/autolaunch:/tcp:host:port]],[Transport Type to be used (default: nonce-tcp:)]),with_dbus_session_bus_default_address=$withval,with_dbus_session_bus_default_address=nonce-tcp:) AC_ARG_ENABLE([embedded-tests], AS_HELP_STRING([--enable-embedded-tests], @@ -1674,64 +1675,14 @@ fi AC_DEFINE_UNQUOTED(DBUS_SESSION_SOCKET_DIR, "$DBUS_SESSION_SOCKET_DIR", [Where per-session bus puts its sockets]) AC_SUBST(DBUS_SESSION_SOCKET_DIR) -# This must be a listening address. It doesn't necessarily need to be an -# address you can connect to - it can be something vague like -# "nonce-tcp:". -# -# The default varies by platform. -AC_ARG_WITH([dbus_session_bus_listen_address], - AS_HELP_STRING([--with-dbus-session-bus-listen-address=[ADDRESS]], - [default address for a session bus to listen on (see configure.ac)]), - [with_dbus_session_bus_listen_address=$withval], - [with_dbus_session_bus_listen_address=]) - -if test "x$with_dbus_session_bus_listen_address" != "x"; then - # the user specified something, trust them - DBUS_SESSION_BUS_LISTEN_ADDRESS="$with_dbus_session_bus_listen_address" -elif test x$dbus_win = xyes; then - # On Windows, you can (and should) listen on autolaunch addresses, - # because autolaunching is different. - # See https://bugs.freedesktop.org/show_bug.cgi?id=38201 - DBUS_SESSION_BUS_LISTEN_ADDRESS="autolaunch:" +if test x$dbus_win = xyes; then + DBUS_SESSION_BUS_DEFAULT_ADDRESS="$with_dbus_session_bus_default_address" elif test x$have_launchd = xyes; then - # Mac OS X default is to use launchd - DBUS_SESSION_BUS_LISTEN_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET" -else - # The default on all other Unix platforms (notably Linux) - # is to create a randomly named socket in /tmp or similar - DBUS_SESSION_BUS_LISTEN_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR" -fi -AC_SUBST([DBUS_SESSION_BUS_LISTEN_ADDRESS]) - -# This must be an address you can connect to. It doesn't necessarily -# need to be an address you can listen on - it can be "autolaunch:", -# even on Unix. -# -# The default varies by platform. -AC_ARG_WITH([dbus_session_bus_connect_address], - AS_HELP_STRING([--with-dbus-session-bus-connect-address=[ADDRESS]], - [fallback address for a session bus client to connect to (see configure.ac)]), - [with_dbus_session_bus_connect_address=$withval], - [with_dbus_session_bus_connect_address=]) - -if test "x$with_dbus_session_bus_connect_address" != "x"; then - # the user specified something, trust them - DBUS_SESSION_BUS_CONNECT_ADDRESS="$with_dbus_session_bus_connect_address" -elif test x$dbus_win = xyes; then - # Windows autolaunching is a bit different; leaving it in its own - # branch of the conditional because the default might conceivably - # change (see #38201) - DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:" + DBUS_SESSION_BUS_DEFAULT_ADDRESS="launchd:env=DBUS_LAUNCHD_SESSION_BUS_SOCKET" else - # The default on all other Unix platforms (notably Linux) - # is to use auto-launching - this works a bit differently on Mac OS X - # but comes out basically the same in the end - DBUS_SESSION_BUS_CONNECT_ADDRESS="autolaunch:" + DBUS_SESSION_BUS_DEFAULT_ADDRESS="unix:tmpdir=$DBUS_SESSION_SOCKET_DIR" fi -AC_SUBST([DBUS_SESSION_BUS_CONNECT_ADDRESS]) -AC_DEFINE_UNQUOTED([DBUS_SESSION_BUS_CONNECT_ADDRESS], - ["$DBUS_SESSION_BUS_CONNECT_ADDRESS"], - [Fallback address for session bus clients]) +AC_SUBST(DBUS_SESSION_BUS_DEFAULT_ADDRESS) # darwin needs this to initialize the environment AC_CHECK_HEADERS(crt_externs.h) @@ -1847,8 +1798,7 @@ echo " System bus socket: ${DBUS_SYSTEM_SOCKET} System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} System bus PID file: ${DBUS_SYSTEM_PID_FILE} - Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} - Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} + Session bus address: ${DBUS_SESSION_BUS_DEFAULT_ADDRESS} Console auth dir: ${DBUS_CONSOLE_AUTH_DIR} Console owner file: ${have_console_owner_file} Console owner file path: ${DBUS_CONSOLE_OWNER_FILE} diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 6f81c74a..fadc3a8b 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -192,12 +192,12 @@ init_session_address (void) if (!retval) return FALSE; - /* We have a hard-coded (but compile-time-configurable) fallback address for - * the session bus. */ + /* The DBUS_SESSION_BUS_DEFAULT_ADDRESS should have really been named + * DBUS_SESSION_BUS_FALLBACK_ADDRESS. + */ if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL) bus_connection_addresses[DBUS_BUS_SESSION] = - _dbus_strdup (DBUS_SESSION_BUS_CONNECT_ADDRESS); - + _dbus_strdup (DBUS_SESSION_BUS_DEFAULT_ADDRESS); if (bus_connection_addresses[DBUS_BUS_SESSION] == NULL) return FALSE; diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 80376ad5..8036a2ba 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -35,6 +35,10 @@ DBUS_BEGIN_DECLS +#ifndef DBUS_SESSION_BUS_DEFAULT_ADDRESS +#define DBUS_SESSION_BUS_DEFAULT_ADDRESS "autolaunch:" +#endif + void _dbus_warn (const char *format, ...) _DBUS_GNUC_PRINTF (1, 2); -- cgit v1.2.1 From dddedfa27db3afab96cba443d07ee81594817a01 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Aug 2012 20:13:16 +0100 Subject: Revert "cmake: use the same default system bus address as for autotools" This reverts commit 05b0b9e65b6a58f0b0cb56d6ee8cf100061250b3. --- README.cmake | 6 +++--- cmake/CMakeLists.txt | 11 ++--------- configure.ac | 13 ++----------- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/README.cmake b/README.cmake index 0e923356..5feaf551 100644 --- a/README.cmake +++ b/README.cmake @@ -80,7 +80,7 @@ Configuration flags When using the cmake build system the dbus-specific configuration flags that can be given to the cmake program are these (use -D= on command line). The listed values -are the defaults (in a typical build - some are platform-specific). +are the defaults. // Choose the type of build, options are: None(CMAKE_CXX_FLAGS or // CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel. @@ -132,8 +132,8 @@ DBUS_INSTALL_SYSTEM_LIBS:BOOL=OFF // session bus default address DBUS_SESSION_BUS_DEFAULT_ADDRESS:STRING=nonce-tcp: -// system bus default address (only useful on Unix) -DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket +// system bus default address +DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=nonce-tcp: // Use atomic integer implementation for 486 DBUS_USE_ATOMIC_INT_486:BOOL=OFF diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5174469d..000acda2 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -431,17 +431,9 @@ endif (WIN32) set (DBUS_USER ) -# This won't work on Windows. It's not meant to - the system bus is -# meaningless on Windows anyway. -# -# This has to be suitable for hard-coding in client libraries as well as -# in the dbus-daemon's configuration, so it has to be valid to listen on -# and also to connect to. If this ever changes, it'll need to be split into -# two variables, one for the listening address and one for the connecting -# address. -set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:path=${EXPANDED_LOCALSTATEDIR}/run/dbus/system_bus_socket" CACHE STRING "system bus default address") if (WIN32) + set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "system bus default address") set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "nonce-tcp:" CACHE STRING "session bus default address") set (DBUS_SYSTEM_CONFIG_FILE "etc/dbus-1/system.conf") @@ -449,6 +441,7 @@ if (WIN32) # bus-test expects a non empty string set (DBUS_USER "Administrator") else (WIN32) + set (DBUS_SYSTEM_BUS_DEFAULT_ADDRESS "unix:tmpdir=" CACHE STRING "system bus default address") set (DBUS_SESSION_BUS_DEFAULT_ADDRESS "unix:path=${DBUS_SESSION_SOCKET_DIR}" CACHE STRING "session bus default address") set (sysconfdir "") set (configdir ${sysconfdir}/dbus-1 ) diff --git a/configure.ac b/configure.ac index 12847c4a..e8fc1aef 100644 --- a/configure.ac +++ b/configure.ac @@ -1521,17 +1521,8 @@ fi AC_SUBST(DBUS_SYSTEM_SOCKET) AC_DEFINE_UNQUOTED(DBUS_SYSTEM_SOCKET,"$DBUS_SYSTEM_SOCKET",[The name of the socket the system bus listens on by default]) -## System bus only listens on local domain sockets, and never -## on an abstract socket (so only root can create the socket). -## -## This won't work on Windows. It's not meant to - the system bus is -## meaningless on Windows anyway. -## -## This has to be suitable for hard-coding in client libraries as well as -## in the dbus-daemon's configuration, so it has to be valid to listen on -## and also to connect to. If this ever changes, it'll need to be split into -## two variables, one for the listening address and one for the connecting -## address. +## system bus only listens on local domain sockets, and never +## on an abstract socket (so only root can create the socket) DBUS_SYSTEM_BUS_DEFAULT_ADDRESS="unix:path=$DBUS_SYSTEM_SOCKET" AC_SUBST(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS) AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS_DEFAULT_ADDRESS, "$DBUS_SYSTEM_BUS_DEFAULT_ADDRESS",[The default D-Bus address of the system bus]) -- cgit v1.2.1 From 8d012ff68d245c4812b3e8929fcec949e8881ae1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Aug 2012 20:15:19 +0100 Subject: NEWS for #38201 --- NEWS | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/NEWS b/NEWS index ccf681e6..ed3f000b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,18 @@ D-Bus 1.7.0 (UNRELEASED) == +Build-time configuration changes: + +• The --with-dbus-session-bus-default-address configure option is no longer + supported. Use the new --with-dbus-session-bus-connect-address and + --with-dbus-session-bus-listen-address options instead. On Windows, you + usually want them to have the same argument; on Unix, the defaults are + usually correct. + +• Similarly, the DBUS_SESSION_BUS_DEFAULT_ADDRESS cmake variable is no longer + supported; use the new DBUS_SESSION_BUS_LISTEN_ADDRESS and + DBUS_SESSION_BUS_CONNECT_ADDRESS variables instead. + Enhancements: • D-Bus Specification 0.21 @@ -14,6 +26,13 @@ Fixes: • Unix-specific: · Fix compilation on Solaris (fd.o #53286, Jonathan Perkin) +• Windows-specific: + · The default session bus listening and connecting address is now + "autolaunch:", which makes D-Bus on Windows interoperate with itself + and GDBus "out of the box". Use the configure options and cmake variables + described above if you require a different autolaunch scope. + (fd.o #38201, Simon McVittie) + D-Bus 1.6.4 (2012-07-18) == -- cgit v1.2.1 From 712f148205c007e8b1de6e2e889e8257b69ca6af Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Mon, 3 Sep 2012 10:12:02 +0100 Subject: Detect MSG_NOSIGNAL and SCM_RIGHTS on OpenBSD On OpenBSD, sys/socket.h requires sys/types.h to be included first. Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54418 --- configure.ac | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e8fc1aef..2e34f565 100644 --- a/configure.ac +++ b/configure.ac @@ -766,7 +766,8 @@ dnl needed on darwin for NAME_MAX AC_CHECK_HEADERS(sys/syslimits.h) dnl Make it easy to check if we have MSG_NOSIGNAL without actually having to include sys/socket.h -AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [[ #include ]]) +AC_CHECK_DECLS([MSG_NOSIGNAL], [], [], [[ #include +#include ]]) dnl check for flavours of varargs macros (test from GLib) AC_MSG_CHECKING(for ISO C99 varargs macros in C) @@ -1220,6 +1221,7 @@ AC_SUBST([ADT_LIBS]) # Check for SCM_RIGHTS AC_MSG_CHECKING([for SCM_RIGHTS]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include #include #include static int x = SCM_RIGHTS; -- cgit v1.2.1 From 6dcef0c8f0d3ef541d215b892f08645d3f187e24 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 3 Sep 2012 10:19:29 +0100 Subject: NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 769fcadc..bab9dda5 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ D-Bus 1.6.6 (UNRELEASED) • Unix-specific: · Fix compilation on Solaris (fd.o #53286, Jonathan Perkin) + · Work around interdependent headers on OpenBSD by including sys/types.h + before each use of sys/socket.h (fd.o #54418, Brad Smith) D-Bus 1.6.4 (2012-07-18) == -- cgit v1.2.1 From 23fe78ceefb6cefcd58a49c77d1154b68478c8d2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 22 Aug 2012 10:03:34 -0400 Subject: CVE-2012-3524: Don't access environment variables or run dbus-launch when setuid This matches a corresponding change in GLib. See glib/gutils.c:g_check_setuid(). Some programs attempt to use libdbus when setuid; notably the X.org server is shipped in such a configuration. libdbus never had an explicit policy about its use in setuid programs. I'm not sure whether we should advertise such support. However, given that there are real-world programs that do this currently, we can make them safer with not too much effort. Better to fix a problem caused by an interaction between two components in *both* places if possible. How to determine whether or not we're running in a privilege-escalated path is operating system specific. Note that GTK+'s code to check euid versus uid worked historically on Unix, more modern systems have filesystem capabilities and SELinux domain transitions, neither of which are captured by the uid comparison. On Linux/glibc, the way this works is that the kernel sets an AT_SECURE flag in the ELF auxiliary vector, and glibc looks for it on startup. If found, then glibc sets a public-but-undocumented __libc_enable_secure variable which we can use. Unfortunately, while it *previously* worked to check this variable, a combination of newer binutils and RPM break it: http://www.openwall.com/lists/owl-dev/2012/08/14/1 So for now on Linux/glibc, we fall back to the historical Unix version until we get glibc fixed. On some BSD variants, there is a issetugid() function. On other Unix variants, we fall back to what GTK+ has been doing. Reported-by: Sebastian Krahmer Signed-off-by: Colin Walters --- configure.ac | 2 +- dbus/dbus-keyring.c | 7 +++++ dbus/dbus-sysdeps-unix.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-sysdeps-win.c | 6 ++++ dbus/dbus-sysdeps.c | 5 ++++ dbus/dbus-sysdeps.h | 1 + 6 files changed, 94 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e2c9bdf7..b0f2ec20 100644 --- a/configure.ac +++ b/configure.ac @@ -595,7 +595,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension] AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid) AC_CHECK_HEADERS([syslog.h]) if test "x$ac_cv_header_syslog_h" = "xyes"; then diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 23b9df5a..3b9ce315 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -717,6 +717,13 @@ _dbus_keyring_new_for_credentials (DBusCredentials *credentials, DBusCredentials *our_credentials; _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to create DBus keyring when setuid"); + return NULL; + } keyring = NULL; error_set = FALSE; diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index cef8bd31..b4ecc96e 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3434,6 +3434,13 @@ _dbus_get_autolaunch_address (const char *scope, DBusString uuid; dbus_bool_t retval; + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to autolaunch when setuid"); + return FALSE; + } + _DBUS_ASSERT_ERROR_IS_CLEAR (error); retval = FALSE; @@ -3551,6 +3558,13 @@ _dbus_lookup_launchd_socket (DBusString *socket_path, _DBUS_ASSERT_ERROR_IS_CLEAR (error); + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to find launchd socket when setuid"); + return FALSE; + } + i = 0; argv[i] = "launchctl"; ++i; @@ -3591,6 +3605,13 @@ _dbus_lookup_session_address_launchd (DBusString *address, DBusError *error) dbus_bool_t valid_socket; DBusString socket_path; + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to find launchd socket when setuid"); + return FALSE; + } + if (!_dbus_string_init (&socket_path)) { _DBUS_SET_OOM (error); @@ -4086,4 +4107,57 @@ _dbus_close_all (void) close (i); } +/** + * **NOTE**: If you modify this function, please also consider making + * the corresponding change in GLib. See + * glib/gutils.c:g_check_setuid(). + * + * Returns TRUE if the current process was executed as setuid (or an + * equivalent __libc_enable_secure is available). See: + * http://osdir.com/ml/linux.lfs.hardened/2007-04/msg00032.html + */ +dbus_bool_t +_dbus_check_setuid (void) +{ + /* TODO: get __libc_enable_secure exported from glibc. + * See http://www.openwall.com/lists/owl-dev/2012/08/14/1 + */ +#if 0 && defined(HAVE_LIBC_ENABLE_SECURE) + { + /* See glibc/include/unistd.h */ + extern int __libc_enable_secure; + return __libc_enable_secure; + } +#elif defined(HAVE_ISSETUGID) + /* BSD: http://www.freebsd.org/cgi/man.cgi?query=issetugid&sektion=2 */ + return issetugid (); +#else + uid_t ruid, euid, suid; /* Real, effective and saved user ID's */ + gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */ + + static dbus_bool_t check_setuid_initialised; + static dbus_bool_t is_setuid; + + if (_DBUS_UNLIKELY (!check_setuid_initialised)) + { +#ifdef HAVE_GETRESUID + if (getresuid (&ruid, &euid, &suid) != 0 || + getresgid (&rgid, &egid, &sgid) != 0) +#endif /* HAVE_GETRESUID */ + { + suid = ruid = getuid (); + sgid = rgid = getgid (); + euid = geteuid (); + egid = getegid (); + } + + check_setuid_initialised = TRUE; + is_setuid = (ruid != euid || ruid != suid || + rgid != egid || rgid != sgid); + + } + return is_setuid; +#endif +} + /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 397520af..bc4951b5 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3632,6 +3632,12 @@ _dbus_path_is_absolute (const DBusString *filename) return FALSE; } +dbus_bool_t +_dbus_check_setuid (void) +{ + return FALSE; +} + /** @} end of sysdeps-win */ /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 861bfec9..04fb8d76 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -182,6 +182,11 @@ _dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { + /* Don't respect any environment variables if the current process is + * setuid. This is the equivalent of glibc's __secure_getenv(). + */ + if (_dbus_check_setuid ()) + return NULL; return getenv (varname); } diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 4052cda9..eee91608 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -87,6 +87,7 @@ typedef struct DBusPipe DBusPipe; void _dbus_abort (void) _DBUS_GNUC_NORETURN; +dbus_bool_t _dbus_check_setuid (void); const char* _dbus_getenv (const char *varname); dbus_bool_t _dbus_setenv (const char *varname, const char *value); -- cgit v1.2.1 From d839f027ed2cf320ac8b762ea93ba8af74ef50c6 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 27 Sep 2012 21:29:29 -0400 Subject: hardening: Use __secure_getenv if available This helps us in the case where we were executed via filesystem capabilities or a SELinux domain transition, not necessarily a plain old setuid binary. https://bugs.freedesktop.org/show_bug.cgi?id=52202 --- configure.ac | 2 +- dbus/dbus-sysdeps.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b0f2ec20..4fdf82bc 100644 --- a/configure.ac +++ b/configure.ac @@ -595,7 +595,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension] AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid secure_getenv __secure_getenv ) AC_CHECK_HEADERS([syslog.h]) if test "x$ac_cv_header_syslog_h" = "xyes"; then diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 04fb8d76..976c7e4b 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -182,12 +182,18 @@ _dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { +#if defined(HAVE_SECURE_GETENV) + return secure_getenv (varname); +#elif defined(HAVE___SECURE_GETENV) + return __secure_getenv (varname); +#else /* Don't respect any environment variables if the current process is * setuid. This is the equivalent of glibc's __secure_getenv(). */ if (_dbus_check_setuid ()) return NULL; return getenv (varname); +#endif } /** -- cgit v1.2.1 From 4b351918b9f70eaedbdb3ab39208bc1f131efae0 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 27 Sep 2012 21:35:22 -0400 Subject: hardening: Ensure _dbus_check_setuid() is initialized threadsafe manner This is a highly theoretical concern, but we might as well. https://bugs.freedesktop.org/show_bug.cgi?id=52202 --- dbus/dbus-sysdeps-pthread.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index c9ec9e5b..c60457be 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -275,6 +275,11 @@ check_monotonic_clock (void) dbus_bool_t _dbus_threads_init_platform_specific (void) { + /* These have static variables, and we need to handle both the case + * where dbus_threads_init() has been called and when it hasn't; + * so initialize them before any threads are allowed to enter. + */ check_monotonic_clock (); + (void) _dbus_check_setuid (); return dbus_threads_init (NULL); } -- cgit v1.2.1 From d4379ee8dbbe157db173464530df7c069b6fd86f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 10:05:59 -0400 Subject: hardening: Use __secure_getenv() in *addition* to _dbus_check_setuid() This is a further security measure for the case of Linux/glibc when we're linked into a binary that's using filesystem capabilities or SELinux domain transitions (i.e. not plain old setuid). In this case, _dbus_getenv () will return NULL because it will use __secure_getenv(), which handles those via AT_SECURE. https://bugs.freedesktop.org/show_bug.cgi?id=52202 --- dbus/dbus-keyring.c | 6 ++++++ dbus/dbus-sysdeps-unix.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 3b9ce315..2516bc34 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -718,6 +718,12 @@ _dbus_keyring_new_for_credentials (DBusCredentials *credentials, _DBUS_ASSERT_ERROR_IS_CLEAR (error); + if (_dbus_getenv ("HOME") == NULL) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to create DBus keyring with no $HOME"); + return FALSE; + } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index b4ecc96e..6fa5bcb6 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3434,6 +3434,12 @@ _dbus_get_autolaunch_address (const char *scope, DBusString uuid; dbus_bool_t retval; + if (_dbus_getenv ("PATH") == NULL) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to autolaunch when PATH is unset"); + return FALSE; + } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, -- cgit v1.2.1 From 57ae3670508bbf4ec57049de47c9cae727a64802 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 12:01:56 -0400 Subject: hardening: Remove activation helper handling for DBUS_VERBOSE It's not really useful. See https://bugs.freedesktop.org/show_bug.cgi?id=52202#c17 --- bus/activation-helper.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/bus/activation-helper.c b/bus/activation-helper.c index ab9d6010..7864e0fe 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -140,17 +140,11 @@ out_all: return desktop_file; } -/* Cleares the environment, except for DBUS_VERBOSE and DBUS_STARTER_x */ +/* Clears the environment, except for DBUS_STARTER_x */ static dbus_bool_t clear_environment (DBusError *error) { const char *starter_env = NULL; -#ifdef DBUS_ENABLE_VERBOSE_MODE - const char *debug_env = NULL; - - /* are we debugging */ - debug_env = _dbus_getenv ("DBUS_VERBOSE"); -#endif /* we save the starter */ starter_env = _dbus_getenv ("DBUS_STARTER_ADDRESS"); @@ -165,12 +159,6 @@ clear_environment (DBusError *error) } #endif -#ifdef DBUS_ENABLE_VERBOSE_MODE - /* restore the debugging environment setting if set */ - if (debug_env) - _dbus_setenv ("DBUS_VERBOSE", debug_env); -#endif - /* restore the starter */ if (starter_env) _dbus_setenv ("DBUS_STARTER_ADDRESS", starter_env); -- cgit v1.2.1 From f68dbdc3e6f895012ce33939fb524accf31bcca5 Mon Sep 17 00:00:00 2001 From: Geoffrey Thomas Date: Thu, 27 Sep 2012 22:02:06 -0700 Subject: activation-helper: Ensure DBUS_STARTER_ADDRESS is set correctly The fix for CVE-2012-3524 filters out all environment variables if libdbus is used from a setuid program, to prevent various spoofing attacks. Unfortunately, the activation helper is a setuid program linking libdbus, and this creates a regression for launched programs using DBUS_STARTER_ADDRESS, since it will no longer exist. Fix this by hardcoding the starter address to the default system bus address. Signed-off-by: Geoffrey Thomas Signed-off-by: Colin Walters --- bus/activation-helper.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/bus/activation-helper.c b/bus/activation-helper.c index 7864e0fe..cbc00d2f 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -140,15 +140,12 @@ out_all: return desktop_file; } -/* Clears the environment, except for DBUS_STARTER_x */ +/* Clears the environment, except for DBUS_STARTER_x, + * which we hardcode to the system bus. + */ static dbus_bool_t clear_environment (DBusError *error) { - const char *starter_env = NULL; - - /* we save the starter */ - starter_env = _dbus_getenv ("DBUS_STARTER_ADDRESS"); - #ifndef ACTIVATION_LAUNCHER_TEST /* totally clear the environment */ if (!_dbus_clearenv ()) @@ -159,11 +156,8 @@ clear_environment (DBusError *error) } #endif - /* restore the starter */ - if (starter_env) - _dbus_setenv ("DBUS_STARTER_ADDRESS", starter_env); - - /* set the type, which must be system if we got this far */ + /* Ensure the bus is set to system */ + _dbus_setenv ("DBUS_STARTER_ADDRESS", DBUS_SYSTEM_BUS_DEFAULT_ADDRESS); _dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system"); return TRUE; -- cgit v1.2.1 From a52319bc294d05445fd8aa8f4a7f759c34558b5d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 22 Aug 2012 10:03:34 -0400 Subject: CVE-2012-3524: Don't access environment variables or run dbus-launch when setuid This matches a corresponding change in GLib. See glib/gutils.c:g_check_setuid(). Some programs attempt to use libdbus when setuid; notably the X.org server is shipped in such a configuration. libdbus never had an explicit policy about its use in setuid programs. I'm not sure whether we should advertise such support. However, given that there are real-world programs that do this currently, we can make them safer with not too much effort. Better to fix a problem caused by an interaction between two components in *both* places if possible. How to determine whether or not we're running in a privilege-escalated path is operating system specific. Note that GTK+'s code to check euid versus uid worked historically on Unix, more modern systems have filesystem capabilities and SELinux domain transitions, neither of which are captured by the uid comparison. On Linux/glibc, the way this works is that the kernel sets an AT_SECURE flag in the ELF auxiliary vector, and glibc looks for it on startup. If found, then glibc sets a public-but-undocumented __libc_enable_secure variable which we can use. Unfortunately, while it *previously* worked to check this variable, a combination of newer binutils and RPM break it: http://www.openwall.com/lists/owl-dev/2012/08/14/1 So for now on Linux/glibc, we fall back to the historical Unix version until we get glibc fixed. On some BSD variants, there is a issetugid() function. On other Unix variants, we fall back to what GTK+ has been doing. Reported-by: Sebastian Krahmer Signed-off-by: Colin Walters --- configure.ac | 2 +- dbus/dbus-keyring.c | 7 +++++ dbus/dbus-sysdeps-unix.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-sysdeps-win.c | 6 ++++ dbus/dbus-sysdeps.c | 5 ++++ dbus/dbus-sysdeps.h | 1 + 6 files changed, 94 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2e34f565..df909856 100644 --- a/configure.ac +++ b/configure.ac @@ -596,7 +596,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension] AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid) AC_CHECK_HEADERS([syslog.h]) if test "x$ac_cv_header_syslog_h" = "xyes"; then diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 23b9df5a..3b9ce315 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -717,6 +717,13 @@ _dbus_keyring_new_for_credentials (DBusCredentials *credentials, DBusCredentials *our_credentials; _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to create DBus keyring when setuid"); + return NULL; + } keyring = NULL; error_set = FALSE; diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index cef8bd31..b4ecc96e 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3434,6 +3434,13 @@ _dbus_get_autolaunch_address (const char *scope, DBusString uuid; dbus_bool_t retval; + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to autolaunch when setuid"); + return FALSE; + } + _DBUS_ASSERT_ERROR_IS_CLEAR (error); retval = FALSE; @@ -3551,6 +3558,13 @@ _dbus_lookup_launchd_socket (DBusString *socket_path, _DBUS_ASSERT_ERROR_IS_CLEAR (error); + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to find launchd socket when setuid"); + return FALSE; + } + i = 0; argv[i] = "launchctl"; ++i; @@ -3591,6 +3605,13 @@ _dbus_lookup_session_address_launchd (DBusString *address, DBusError *error) dbus_bool_t valid_socket; DBusString socket_path; + if (_dbus_check_setuid ()) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to find launchd socket when setuid"); + return FALSE; + } + if (!_dbus_string_init (&socket_path)) { _DBUS_SET_OOM (error); @@ -4086,4 +4107,57 @@ _dbus_close_all (void) close (i); } +/** + * **NOTE**: If you modify this function, please also consider making + * the corresponding change in GLib. See + * glib/gutils.c:g_check_setuid(). + * + * Returns TRUE if the current process was executed as setuid (or an + * equivalent __libc_enable_secure is available). See: + * http://osdir.com/ml/linux.lfs.hardened/2007-04/msg00032.html + */ +dbus_bool_t +_dbus_check_setuid (void) +{ + /* TODO: get __libc_enable_secure exported from glibc. + * See http://www.openwall.com/lists/owl-dev/2012/08/14/1 + */ +#if 0 && defined(HAVE_LIBC_ENABLE_SECURE) + { + /* See glibc/include/unistd.h */ + extern int __libc_enable_secure; + return __libc_enable_secure; + } +#elif defined(HAVE_ISSETUGID) + /* BSD: http://www.freebsd.org/cgi/man.cgi?query=issetugid&sektion=2 */ + return issetugid (); +#else + uid_t ruid, euid, suid; /* Real, effective and saved user ID's */ + gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */ + + static dbus_bool_t check_setuid_initialised; + static dbus_bool_t is_setuid; + + if (_DBUS_UNLIKELY (!check_setuid_initialised)) + { +#ifdef HAVE_GETRESUID + if (getresuid (&ruid, &euid, &suid) != 0 || + getresgid (&rgid, &egid, &sgid) != 0) +#endif /* HAVE_GETRESUID */ + { + suid = ruid = getuid (); + sgid = rgid = getgid (); + euid = geteuid (); + egid = getegid (); + } + + check_setuid_initialised = TRUE; + is_setuid = (ruid != euid || ruid != suid || + rgid != egid || rgid != sgid); + + } + return is_setuid; +#endif +} + /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 397520af..bc4951b5 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3632,6 +3632,12 @@ _dbus_path_is_absolute (const DBusString *filename) return FALSE; } +dbus_bool_t +_dbus_check_setuid (void) +{ + return FALSE; +} + /** @} end of sysdeps-win */ /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 861bfec9..04fb8d76 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -182,6 +182,11 @@ _dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { + /* Don't respect any environment variables if the current process is + * setuid. This is the equivalent of glibc's __secure_getenv(). + */ + if (_dbus_check_setuid ()) + return NULL; return getenv (varname); } diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 4052cda9..eee91608 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -87,6 +87,7 @@ typedef struct DBusPipe DBusPipe; void _dbus_abort (void) _DBUS_GNUC_NORETURN; +dbus_bool_t _dbus_check_setuid (void); const char* _dbus_getenv (const char *varname); dbus_bool_t _dbus_setenv (const char *varname, const char *value); -- cgit v1.2.1 From 1a556443757b19fee67ef4441141246dd9cfed4f Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 27 Sep 2012 21:29:29 -0400 Subject: hardening: Use __secure_getenv if available This helps us in the case where we were executed via filesystem capabilities or a SELinux domain transition, not necessarily a plain old setuid binary. https://bugs.freedesktop.org/show_bug.cgi?id=52202 --- configure.ac | 2 +- dbus/dbus-sysdeps.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index df909856..4eb530ae 100644 --- a/configure.ac +++ b/configure.ac @@ -596,7 +596,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension] AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid secure_getenv __secure_getenv ) AC_CHECK_HEADERS([syslog.h]) if test "x$ac_cv_header_syslog_h" = "xyes"; then diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 04fb8d76..976c7e4b 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -182,12 +182,18 @@ _dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { +#if defined(HAVE_SECURE_GETENV) + return secure_getenv (varname); +#elif defined(HAVE___SECURE_GETENV) + return __secure_getenv (varname); +#else /* Don't respect any environment variables if the current process is * setuid. This is the equivalent of glibc's __secure_getenv(). */ if (_dbus_check_setuid ()) return NULL; return getenv (varname); +#endif } /** -- cgit v1.2.1 From c27c5004132e597a8f386be6f9e4235519096398 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 27 Sep 2012 21:35:22 -0400 Subject: hardening: Ensure _dbus_check_setuid() is initialized threadsafe manner This is a highly theoretical concern, but we might as well. https://bugs.freedesktop.org/show_bug.cgi?id=52202 --- dbus/dbus-sysdeps-pthread.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index c9ec9e5b..c60457be 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -275,6 +275,11 @@ check_monotonic_clock (void) dbus_bool_t _dbus_threads_init_platform_specific (void) { + /* These have static variables, and we need to handle both the case + * where dbus_threads_init() has been called and when it hasn't; + * so initialize them before any threads are allowed to enter. + */ check_monotonic_clock (); + (void) _dbus_check_setuid (); return dbus_threads_init (NULL); } -- cgit v1.2.1 From d7ffad72146c2329692e0cf32eb1ac1dbb4fb51c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 10:05:59 -0400 Subject: hardening: Use __secure_getenv() in *addition* to _dbus_check_setuid() This is a further security measure for the case of Linux/glibc when we're linked into a binary that's using filesystem capabilities or SELinux domain transitions (i.e. not plain old setuid). In this case, _dbus_getenv () will return NULL because it will use __secure_getenv(), which handles those via AT_SECURE. https://bugs.freedesktop.org/show_bug.cgi?id=52202 --- dbus/dbus-keyring.c | 6 ++++++ dbus/dbus-sysdeps-unix.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 3b9ce315..2516bc34 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -718,6 +718,12 @@ _dbus_keyring_new_for_credentials (DBusCredentials *credentials, _DBUS_ASSERT_ERROR_IS_CLEAR (error); + if (_dbus_getenv ("HOME") == NULL) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to create DBus keyring with no $HOME"); + return FALSE; + } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index b4ecc96e..6fa5bcb6 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3434,6 +3434,12 @@ _dbus_get_autolaunch_address (const char *scope, DBusString uuid; dbus_bool_t retval; + if (_dbus_getenv ("PATH") == NULL) + { + dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, + "Unable to autolaunch when PATH is unset"); + return FALSE; + } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, -- cgit v1.2.1 From 9a0c289be67735870d208e2dca2b679da0c31c41 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 12:01:56 -0400 Subject: hardening: Remove activation helper handling for DBUS_VERBOSE It's not really useful. See https://bugs.freedesktop.org/show_bug.cgi?id=52202#c17 --- bus/activation-helper.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/bus/activation-helper.c b/bus/activation-helper.c index ab9d6010..7864e0fe 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -140,17 +140,11 @@ out_all: return desktop_file; } -/* Cleares the environment, except for DBUS_VERBOSE and DBUS_STARTER_x */ +/* Clears the environment, except for DBUS_STARTER_x */ static dbus_bool_t clear_environment (DBusError *error) { const char *starter_env = NULL; -#ifdef DBUS_ENABLE_VERBOSE_MODE - const char *debug_env = NULL; - - /* are we debugging */ - debug_env = _dbus_getenv ("DBUS_VERBOSE"); -#endif /* we save the starter */ starter_env = _dbus_getenv ("DBUS_STARTER_ADDRESS"); @@ -165,12 +159,6 @@ clear_environment (DBusError *error) } #endif -#ifdef DBUS_ENABLE_VERBOSE_MODE - /* restore the debugging environment setting if set */ - if (debug_env) - _dbus_setenv ("DBUS_VERBOSE", debug_env); -#endif - /* restore the starter */ if (starter_env) _dbus_setenv ("DBUS_STARTER_ADDRESS", starter_env); -- cgit v1.2.1 From fc4547fe089136f119b49dd067a3cb876d487893 Mon Sep 17 00:00:00 2001 From: Geoffrey Thomas Date: Thu, 27 Sep 2012 22:02:06 -0700 Subject: activation-helper: Ensure DBUS_STARTER_ADDRESS is set correctly The fix for CVE-2012-3524 filters out all environment variables if libdbus is used from a setuid program, to prevent various spoofing attacks. Unfortunately, the activation helper is a setuid program linking libdbus, and this creates a regression for launched programs using DBUS_STARTER_ADDRESS, since it will no longer exist. Fix this by hardcoding the starter address to the default system bus address. Signed-off-by: Geoffrey Thomas Signed-off-by: Colin Walters --- bus/activation-helper.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/bus/activation-helper.c b/bus/activation-helper.c index 7864e0fe..cbc00d2f 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -140,15 +140,12 @@ out_all: return desktop_file; } -/* Clears the environment, except for DBUS_STARTER_x */ +/* Clears the environment, except for DBUS_STARTER_x, + * which we hardcode to the system bus. + */ static dbus_bool_t clear_environment (DBusError *error) { - const char *starter_env = NULL; - - /* we save the starter */ - starter_env = _dbus_getenv ("DBUS_STARTER_ADDRESS"); - #ifndef ACTIVATION_LAUNCHER_TEST /* totally clear the environment */ if (!_dbus_clearenv ()) @@ -159,11 +156,8 @@ clear_environment (DBusError *error) } #endif - /* restore the starter */ - if (starter_env) - _dbus_setenv ("DBUS_STARTER_ADDRESS", starter_env); - - /* set the type, which must be system if we got this far */ + /* Ensure the bus is set to system */ + _dbus_setenv ("DBUS_STARTER_ADDRESS", DBUS_SYSTEM_BUS_DEFAULT_ADDRESS); _dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system"); return TRUE; -- cgit v1.2.1 From cf13cd08c74bd35bf834befb27af56a7f7ed7de1 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 13:08:42 -0400 Subject: Release 1.6.6 --- NEWS | 7 ++++++- configure.ac | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index bab9dda5..ae87020c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ -D-Bus 1.6.6 (UNRELEASED) +D-Bus 1.6.6 (2012-09-28) == +The "Clear the environment in your setuid binaries, please" release. + +• CVE-2012-3524: Don't access environment variables (fd.o #52202) + Thanks to work and input from Colin Walters, Simon McVittie, + Geoffrey Thomas, and others. • Unix-specific: · Fix compilation on Solaris (fd.o #53286, Jonathan Perkin) · Work around interdependent headers on OpenBSD by including sys/types.h diff --git a/configure.ac b/configure.ac index 4eb530ae..4cdb71b8 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [5]) +m4_define([dbus_micro_version], [6]) 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]) -- cgit v1.2.1 From 819eb8a9f5c852af3b5dca2bbea3b434d9d06404 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 13:20:14 -0400 Subject: Resume development --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4cdb71b8..3a06bb0c 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [6]) +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]) -- cgit v1.2.1 From dcee0dd7c0a80b35d92712024507929303b9f07a Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 15:31:05 -0400 Subject: Revert "hardening: Use __secure_getenv if available" It breaks gnome-keyring-daemon at least in some configurations; see https://bugs.freedesktop.org/show_bug.cgi?id=52202#c24 This reverts commit 1a556443757b19fee67ef4441141246dd9cfed4f. --- configure.ac | 2 +- dbus/dbus-sysdeps.c | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 3a06bb0c..f2107956 100644 --- a/configure.ac +++ b/configure.ac @@ -596,7 +596,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension] AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid secure_getenv __secure_getenv ) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid) AC_CHECK_HEADERS([syslog.h]) if test "x$ac_cv_header_syslog_h" = "xyes"; then diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 976c7e4b..04fb8d76 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -182,18 +182,12 @@ _dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { -#if defined(HAVE_SECURE_GETENV) - return secure_getenv (varname); -#elif defined(HAVE___SECURE_GETENV) - return __secure_getenv (varname); -#else /* Don't respect any environment variables if the current process is * setuid. This is the equivalent of glibc's __secure_getenv(). */ if (_dbus_check_setuid ()) return NULL; return getenv (varname); -#endif } /** -- cgit v1.2.1 From fb8b8ce72c5725cd18507d1c824870a6c37ed7f2 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 15:31:47 -0400 Subject: Revert "hardening: Use __secure_getenv() in *addition* to _dbus_check_setuid()" Follow to reverting a556443757b19fee67ef4441141246dd9cfed4f. See https://bugs.freedesktop.org/show_bug.cgi?id=52202#c24 This reverts commit d7ffad72146c2329692e0cf32eb1ac1dbb4fb51c. --- dbus/dbus-keyring.c | 6 ------ dbus/dbus-sysdeps-unix.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 2516bc34..3b9ce315 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -718,12 +718,6 @@ _dbus_keyring_new_for_credentials (DBusCredentials *credentials, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - if (_dbus_getenv ("HOME") == NULL) - { - dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, - "Unable to create DBus keyring with no $HOME"); - return FALSE; - } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 6fa5bcb6..b4ecc96e 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3434,12 +3434,6 @@ _dbus_get_autolaunch_address (const char *scope, DBusString uuid; dbus_bool_t retval; - if (_dbus_getenv ("PATH") == NULL) - { - dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, - "Unable to autolaunch when PATH is unset"); - return FALSE; - } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, -- cgit v1.2.1 From 1cad15cc272446ade9987840642aa6730ebe92be Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 15:44:59 -0400 Subject: Release 1.6.8 --- NEWS | 12 ++++++++++++ configure.ac | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ae87020c..02fa1457 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,15 @@ +D-Bus 1.6.8 (2012-09-28) +== + +The "Fix one thing, break another" release. + +• Follow up to CVE-2012-3524: The additional hardening + work to use __secure_getenv() as a followup to bug #52202 + broke certain configurations of gnome-keyring. Given + the difficulty of making this work without extensive + changes to gnome-keyring, use of __secure_getenv() is + deferred. + D-Bus 1.6.6 (2012-09-28) == diff --git a/configure.ac b/configure.ac index f2107956..24fcc9e7 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [7]) +m4_define([dbus_micro_version], [8]) 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]) -- cgit v1.2.1 From 19fa7c547fb0ae4f7a2190f7978627fa4f48aedf Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 15:31:05 -0400 Subject: Revert "hardening: Use __secure_getenv if available" It breaks gnome-keyring-daemon at least in some configurations; see https://bugs.freedesktop.org/show_bug.cgi?id=52202#c24 This reverts commit 1a556443757b19fee67ef4441141246dd9cfed4f. --- configure.ac | 2 +- dbus/dbus-sysdeps.c | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 4fdf82bc..b0f2ec20 100644 --- a/configure.ac +++ b/configure.ac @@ -595,7 +595,7 @@ AC_DEFINE_UNQUOTED([DBUS_USE_SYNC], [$have_sync], [Use the gcc __sync extension] AC_SEARCH_LIBS(socket,[socket network]) AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)]) -AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid secure_getenv __secure_getenv ) +AC_CHECK_FUNCS(vsnprintf vasprintf nanosleep usleep setenv clearenv unsetenv socketpair getgrouplist fpathconf setrlimit poll setlocale localeconv strtoll strtoull issetugid getresuid) AC_CHECK_HEADERS([syslog.h]) if test "x$ac_cv_header_syslog_h" = "xyes"; then diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 976c7e4b..04fb8d76 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -182,18 +182,12 @@ _dbus_setenv (const char *varname, const char* _dbus_getenv (const char *varname) { -#if defined(HAVE_SECURE_GETENV) - return secure_getenv (varname); -#elif defined(HAVE___SECURE_GETENV) - return __secure_getenv (varname); -#else /* Don't respect any environment variables if the current process is * setuid. This is the equivalent of glibc's __secure_getenv(). */ if (_dbus_check_setuid ()) return NULL; return getenv (varname); -#endif } /** -- cgit v1.2.1 From c7495461fe6b48b4070452ed8640fbc4888f1210 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 28 Sep 2012 15:31:47 -0400 Subject: Revert "hardening: Use __secure_getenv() in *addition* to _dbus_check_setuid()" Follow to reverting a556443757b19fee67ef4441141246dd9cfed4f. See https://bugs.freedesktop.org/show_bug.cgi?id=52202#c24 This reverts commit d7ffad72146c2329692e0cf32eb1ac1dbb4fb51c. --- dbus/dbus-keyring.c | 6 ------ dbus/dbus-sysdeps-unix.c | 6 ------ 2 files changed, 12 deletions(-) diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 2516bc34..3b9ce315 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -718,12 +718,6 @@ _dbus_keyring_new_for_credentials (DBusCredentials *credentials, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - if (_dbus_getenv ("HOME") == NULL) - { - dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, - "Unable to create DBus keyring with no $HOME"); - return FALSE; - } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 6fa5bcb6..b4ecc96e 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3434,12 +3434,6 @@ _dbus_get_autolaunch_address (const char *scope, DBusString uuid; dbus_bool_t retval; - if (_dbus_getenv ("PATH") == NULL) - { - dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, - "Unable to autolaunch when PATH is unset"); - return FALSE; - } if (_dbus_check_setuid ()) { dbus_set_error_const (error, DBUS_ERROR_NOT_SUPPORTED, -- cgit v1.2.1 From 40cc5ebd4a5242e39a60111addbf6dd09a760174 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 2 Oct 2012 09:47:20 +0100 Subject: Post-release version bump --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 02fa1457..618de454 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.6.10 (UNRELEASED) +== + +... + D-Bus 1.6.8 (2012-09-28) == diff --git a/configure.ac b/configure.ac index 24fcc9e7..5490cf02 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [8]) +m4_define([dbus_micro_version], [9]) 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]) -- cgit v1.2.1 From e296f5c824321d5c12be3121d8159fe6a248c3fc Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 8 Jan 2012 12:11:11 -0500 Subject: build: Make --disable-xml-docs build work again We can't build the .html files without xmlto, so don't add them to a dist_ variable. https://bugs.freedesktop.org/show_bug.cgi?id=55426 --- doc/Makefile.am | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index b2659871..db81b5c7 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -59,9 +59,6 @@ STATIC_HTML = \ dist_html_DATA += $(STATIC_HTML) -# we distribute these in the tarball so users don't necessarily need xmlto -dist_html_DATA += $(XMLTO_OUTPUT) - XMLTO_OUTPUT= \ dbus-faq.html \ dbus-specification.html \ @@ -69,6 +66,10 @@ XMLTO_OUTPUT= \ dbus-tutorial.html if DBUS_XML_DOCS_ENABLED + +# we distribute these in the tarball so users don't necessarily need xmlto +dist_html_DATA += $(XMLTO_OUTPUT) + dbus-specification.html: dbus-specification.xml $(XMLTO) html-nochunks $< -- cgit v1.2.1 From 62aec8838a2d3841c5f1377c6eef429a7df84aed Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 2 Oct 2012 09:34:48 +0100 Subject: activation helper: when compiled for tests, do not reset system bus address Otherwise, the tests try to connect to the real system bus, which will often fail - particularly if you run the tests configured for the default /usr/local (with no intention of installing the result), in which case the tests would try to connect to /usr/local/var/run/dbus/system_bus_socket. Reviewed-by: Colin Walters Bug: https://bugs.freedesktop.org/show_bug.cgi?id=52202 --- bus/activation-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/activation-helper.c b/bus/activation-helper.c index cbc00d2f..8d7ae36f 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -154,11 +154,11 @@ clear_environment (DBusError *error) "could not clear environment\n"); return FALSE; } -#endif /* Ensure the bus is set to system */ _dbus_setenv ("DBUS_STARTER_ADDRESS", DBUS_SYSTEM_BUS_DEFAULT_ADDRESS); _dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system"); +#endif return TRUE; } -- cgit v1.2.1 From d728fdc655f17031da3bb129ab2fd17dadf0fe3a Mon Sep 17 00:00:00 2001 From: Simon Peeters Date: Sun, 7 Oct 2012 16:59:30 +0200 Subject: Set correct address when using --address=systemd: When dbus gets launched through systemd, we need to create an address string based on the sockets passed. The _dbus_append_addres_from_socket() function is responsible for extracting the address information from the file-descriptor and formatting it in a dbus friendly way. This fixes bus activation when running dbus under a systemd session. https://bugs.freedesktop.org/show_bug.cgi?id=50962 Signed-off-by: Simon Peeters --- dbus/dbus-server-unix.c | 38 ++++++++++++++++++--------- dbus/dbus-sysdeps-unix.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-sysdeps-unix.h | 4 +++ 3 files changed, 97 insertions(+), 13 deletions(-) diff --git a/dbus/dbus-server-unix.c b/dbus/dbus-server-unix.c index 130f66ec..d9952404 100644 --- a/dbus/dbus-server-unix.c +++ b/dbus/dbus-server-unix.c @@ -149,7 +149,7 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry, } else if (strcmp (method, "systemd") == 0) { - int n, *fds; + int i, n, *fds; DBusString address; n = _dbus_listen_systemd_sockets (&fds, error); @@ -159,27 +159,39 @@ _dbus_server_listen_platform_specific (DBusAddressEntry *entry, return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; } - _dbus_string_init_const (&address, "systemd:"); + if (!_dbus_string_init (&address)) + goto systemd_oom; - *server_p = _dbus_server_new_for_socket (fds, n, &address, NULL); - if (*server_p == NULL) + for (i = 0; i < n; i++) { - int i; - - for (i = 0; i < n; i++) + if (i > 0) { - _dbus_close_socket (fds[i], NULL); + if (!_dbus_string_append (&address, ";")) + goto systemd_oom; } - dbus_free (fds); - - dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); - return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; + if (!_dbus_append_address_from_socket (fds[i], &address, error)) + goto systemd_err; } + *server_p = _dbus_server_new_for_socket (fds, n, &address, NULL); + if (*server_p == NULL) + goto systemd_oom; + dbus_free (fds); return DBUS_SERVER_LISTEN_OK; - } + systemd_oom: + _DBUS_SET_OOM (error); + systemd_err: + for (i = 0; i < n; i++) + { + _dbus_close_socket (fds[i], NULL); + } + dbus_free (fds); + _dbus_string_free (&address); + + return DBUS_SERVER_LISTEN_DID_NOT_CONNECT; + } #ifdef DBUS_ENABLE_LAUNCHD else if (strcmp (method, "launchd") == 0) { diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index b4ecc96e..55743b19 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -55,6 +55,7 @@ #include #include #include +#include #ifdef HAVE_ERRNO_H #include @@ -4160,4 +4161,71 @@ _dbus_check_setuid (void) #endif } +/** + * Read the address from the socket and append it to the string + * + * @param fd the socket + * @param address + * @param error return location for error code + */ +dbus_bool_t +_dbus_append_address_from_socket (int fd, + DBusString *address, + DBusError *error) +{ + union { + struct sockaddr sa; + struct sockaddr_storage storage; + struct sockaddr_un un; + struct sockaddr_in ipv4; + struct sockaddr_in6 ipv6; + } socket; + char hostip[INET6_ADDRSTRLEN]; + int size = sizeof (socket); + + if (getsockname (fd, &socket.sa, &size)) + goto err; + + switch (socket.sa.sa_family) + { + case AF_UNIX: + if (socket.un.sun_path[0]=='\0') + { + if (_dbus_string_append_printf (address, "unix:abstract=%s", &(socket.un.sun_path[1]))) + return TRUE; + } + else + { + if (_dbus_string_append_printf (address, "unix:path=%s", socket.un.sun_path)) + return TRUE; + } + break; + case AF_INET: + if (inet_ntop (AF_INET, &socket.ipv4.sin_addr, hostip, sizeof (hostip))) + if (_dbus_string_append_printf (address, "tcp:family=ipv4,host=%s,port=%u", + hostip, ntohs (socket.ipv4.sin_port))) + return TRUE; + break; +#ifdef AF_INET6 + case AF_INET6: + if (inet_ntop (AF_INET6, &socket.ipv6.sin6_addr, hostip, sizeof (hostip))) + if (_dbus_string_append_printf (address, "tcp:family=ipv6,host=%s,port=%u", + hostip, ntohs (socket.ipv6.sin6_port))) + return TRUE; + break; +#endif + default: + dbus_set_error (error, + _dbus_error_from_errno (EINVAL), + "Failed to read address from socket: Unknown socket type."); + return FALSE; + } + err: + dbus_set_error (error, + _dbus_error_from_errno (errno), + "Failed to open socket: %s", + _dbus_strerror (errno)); + return FALSE; +} + /* tests in dbus-sysdeps-util.c */ diff --git a/dbus/dbus-sysdeps-unix.h b/dbus/dbus-sysdeps-unix.h index 9b708967..a265b335 100644 --- a/dbus/dbus-sysdeps-unix.h +++ b/dbus/dbus-sysdeps-unix.h @@ -138,6 +138,10 @@ dbus_bool_t _dbus_parse_uid (const DBusString *uid_str, void _dbus_close_all (void); +dbus_bool_t _dbus_append_address_from_socket (int fd, + DBusString *address, + DBusError *error); + /** @} */ DBUS_END_DECLS -- cgit v1.2.1 From 90f939f155bd120f44ff3906296707a6c00cd462 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 16 Oct 2012 14:38:28 -0400 Subject: dbus-spawn: set SIGPIPE to SIG_IGN before activating services dbus's service activation code sets SIGPIPE to SIG_DFL as a sort of poor man's prctl(... PR_SET_PDEATHSIG) to detect when the parent goes away. It neglects to reignore the infamous signal before performing activation, however. This means if, for instance, journald is restarted all services activated after it will die with SIGPIPE when logging messages unless they explicitly ignore SIGPIPE themselves. This commit changes dbus's service activation code to correctly ignore SIGPIPE to protect activated services from a gruesome, premature death. Reviewed-by: Lennart Poettering https://bugzilla.redhat.com/show_bug.cgi?id=839258 --- dbus/dbus-spawn.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index ef00801c..1e3a3516 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1256,7 +1256,11 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, _dbus_assert_not_reached ("Got to code after write_err_and_exit()"); } else if (grandchild_pid == 0) - { + { + /* Go back to ignoring SIGPIPE, since it's evil + */ + signal (SIGPIPE, SIG_IGN); + do_exec (child_err_report_pipe[WRITE_END], argv, env, -- cgit v1.2.1 From 4bec2c72e85b7516b83a426f847b3228356770a8 Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Tue, 16 Oct 2012 15:29:27 -0400 Subject: dbus-spawn: fix spacing mistake in comment commit 90f939f155bd120f44ff3906296707a6c00cd462 had two problems. 1) a small whitespace error in the added comment 2) the wrong bug reference at the bottom I'm using 1) as an excuse to add additional commit for the sake of 2). https://bugs.freedesktop.org/show_bug.cgi?id=56043 --- dbus/dbus-spawn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 1e3a3516..55a7e1e6 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1258,7 +1258,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, else if (grandchild_pid == 0) { /* Go back to ignoring SIGPIPE, since it's evil - */ + */ signal (SIGPIPE, SIG_IGN); do_exec (child_err_report_pipe[WRITE_END], -- cgit v1.2.1 From 847c542374d3896a66133867c9d3b89e1c47e21e Mon Sep 17 00:00:00 2001 From: Pavel Strashkin Date: Thu, 1 Nov 2012 12:29:23 -0700 Subject: spec: fix command name REJECT -> REJECTED Signed-off-by: Pavel Strashkin Signed-off-by: Colin Walters --- doc/dbus-specification.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index b3130708..5d1cd106 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -2427,7 +2427,7 @@ - Receive REJECT [mechs] → send AUTH [next mech], + Receive REJECTED [mechs] → send AUTH [next mech], goto WaitingForData or WaitingForOK @@ -2463,7 +2463,7 @@ - Receive REJECT [mechs] → send AUTH [next mech], + Receive REJECTED [mechs] → send AUTH [next mech], goto WaitingForData or WaitingForOK @@ -2505,7 +2505,7 @@ - REJECT means that the client failed to authenticate or + REJECTED means that the client failed to authenticate or there was an error in RESP. @@ -2552,7 +2552,7 @@ - MECH(RESP) returns REJECT → send REJECTED + MECH(RESP) returns REJECTED → send REJECTED [mechs], goto WaitingForAuth @@ -2606,7 +2606,7 @@ - MECH(RESP) returns REJECT → send REJECTED + MECH(RESP) returns REJECTED → send REJECTED [mechs], goto WaitingForAuth -- cgit v1.2.1 From e516a31f59abbbf7cbfcc3396ef41162188a7f5c Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Fri, 12 Oct 2012 21:52:03 +0530 Subject: Fix building with newer Valgrind Newer valgrind (tried with 3.8.0) defines macros so that a terminating semi-colon is required. This fixes usage to follow that convention. [edited to remove comments that are no longer useful -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55932 Reviewed-by: Simon McVittie --- dbus/dbus-mempool.c | 12 ++++++------ dbus/dbus-valgrind-internal.h | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dbus/dbus-mempool.c b/dbus/dbus-mempool.c index 33aabf9c..0c3f117d 100644 --- a/dbus/dbus-mempool.c +++ b/dbus/dbus-mempool.c @@ -173,7 +173,7 @@ _dbus_mem_pool_new (int element_size, _dbus_assert ((pool->block_size % pool->element_size) == 0); - VALGRIND_CREATE_MEMPOOL (pool, 0, zero_elements) + VALGRIND_CREATE_MEMPOOL (pool, 0, zero_elements); return pool; } @@ -188,7 +188,7 @@ _dbus_mem_pool_free (DBusMemPool *pool) { DBusMemBlock *block; - VALGRIND_DESTROY_MEMPOOL (pool) + VALGRIND_DESTROY_MEMPOOL (pool); block = pool->blocks; while (block != NULL) @@ -241,7 +241,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) pool->allocated_elements += 1; VALGRIND_MEMPOOL_ALLOC (pool, (void *) &block->elements[0], - pool->element_size) + pool->element_size); return (void*) &block->elements[0]; } else @@ -261,7 +261,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) pool->free_elements = pool->free_elements->next; - VALGRIND_MEMPOOL_ALLOC (pool, element, pool->element_size) + VALGRIND_MEMPOOL_ALLOC (pool, element, pool->element_size); if (pool->zero_elements) memset (element, '\0', pool->element_size); @@ -329,7 +329,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) pool->allocated_elements += 1; - VALGRIND_MEMPOOL_ALLOC (pool, element, pool->element_size) + VALGRIND_MEMPOOL_ALLOC (pool, element, pool->element_size); return element; } } @@ -347,7 +347,7 @@ dbus_bool_t _dbus_mem_pool_dealloc (DBusMemPool *pool, void *element) { - VALGRIND_MEMPOOL_FREE (pool, element) + VALGRIND_MEMPOOL_FREE (pool, element); #ifdef DBUS_BUILD_TESTS if (_dbus_disable_mem_pools ()) diff --git a/dbus/dbus-valgrind-internal.h b/dbus/dbus-valgrind-internal.h index 55566ec0..6760b40d 100644 --- a/dbus/dbus-valgrind-internal.h +++ b/dbus/dbus-valgrind-internal.h @@ -32,10 +32,10 @@ # include # include #else -# define VALGRIND_CREATE_MEMPOOL(_1, _2, _3) /* nothing */ -# define VALGRIND_DESTROY_MEMPOOL(_1) /* nothing */ -# define VALGRIND_MEMPOOL_ALLOC(_1, _2, _3) /* nothing */ -# define VALGRIND_MEMPOOL_FREE(_1, _2) /* nothing */ +# define VALGRIND_CREATE_MEMPOOL(_1, _2, _3) do { } while (0) +# define VALGRIND_DESTROY_MEMPOOL(_1) do { } while (0) +# define VALGRIND_MEMPOOL_ALLOC(_1, _2, _3) do { } while (0) +# define VALGRIND_MEMPOOL_FREE(_1, _2) do { } while (0) /* Recent gcc will warn if you have a statement that's just a macro * expanding to (0), but not if you have an inline stub function that -- cgit v1.2.1 From d9f470a7f434f13d43f36d0023f108c2d2ed2bd9 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 4 Oct 2012 16:54:02 -0400 Subject: build: Ensure docs are enabled for distcheck https://bugs.freedesktop.org/show_bug.cgi?id=55426 Signed-off-by: Colin Walters Reviewed-by: Simon McVittie --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 10b96703..463c4aab 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,6 +26,7 @@ update-authors: git shortlog -s -e | cut -c 8- | sort > AUTHORS DISTCHECK_CONFIGURE_FLAGS = \ + --enable-xml-docs \ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} -- cgit v1.2.1 From ad6e1b0420d5da61459a5532d61f03a61e6c8b14 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Fri, 12 Oct 2012 22:04:11 +0530 Subject: Add documentation on running clients with Valgrind Quick documentation on how Valgrind can be run in clients without triggering false positives. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55933 Reviewed-by: Simon McVittie --- README.valgrind | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 README.valgrind diff --git a/README.valgrind b/README.valgrind new file mode 100644 index 00000000..c13f5304 --- /dev/null +++ b/README.valgrind @@ -0,0 +1,24 @@ +Running D-Bus clients with Valgrind +==== + +When running programs using libdbus in Valgrind, some special care needs to be +taken so as to avoid incorrect detection of leaks in libdbus. To avoid these +false positives, do the following: + +* Grab a copy of the D-Bus source code + +* Run configure with the --enable-developer and --with-valgrind options + +* Run make + +* Either make sure your code calls dbus_shutdown() (at least while running in + Valgrind) or set DBUS_MESSAGE_CACHE=0 in your environment + +* Run Valgrind on your program with the /path/to/dbus/source/dbus/.libs in your + LD_LIBRARY_PATH + +Your Valgrind log should now be free of any (spurious) libdbus-related leaks. + +For the curious, the DBUS_MESSAGE_CACHE=0 is required because by +default, libdbus uses a recyclable pool of message structs. These help +performance a bit. -- cgit v1.2.1 From 96cb1542c22ad236e5bb0abbf3c5aede1c6b6e04 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 9 Nov 2012 15:28:16 +0000 Subject: include README.valgrind in tarballs --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 463c4aab..a19d4405 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,6 +14,7 @@ EXTRA_DIST = \ NEWS.pre-1-0 \ ChangeLog.pre-1-2 \ NEWS.pre-1-2 \ + README.valgrind \ README.win \ README.wince \ README.cygwin \ -- cgit v1.2.1 From 1e494ecc6094d412c3ae4ce25f51946b9278f3dd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Aug 2012 18:00:23 +0100 Subject: Use InterlockedExchange to get a full memory barrier on Windows See the bug for extensive discussion. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41423 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index bc4951b5..5a2fb209 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3121,8 +3121,18 @@ _dbus_atomic_dec (DBusAtomic *atomic) dbus_int32_t _dbus_atomic_get (DBusAtomic *atomic) { - /* this is what GLib does, hopefully it's right... */ - MemoryBarrier (); + /* In this situation, GLib issues a MemoryBarrier() and then returns + * atomic->value. However, mingw from mingw.org (not to be confused with + * mingw-w64 from mingw-w64.sf.net) does not have MemoryBarrier in its + * headers, so we have to get a memory barrier some other way. + * + * InterlockedIncrement is older, and is documented on MSDN to be a full + * memory barrier, so let's use that. + */ + long dummy = 0; + + InterlockedExchange (&dummy, 1); + return atomic->value; } -- cgit v1.2.1 From 9a9b0e2736378d1a8961fb264d7314e921231e8e Mon Sep 17 00:00:00 2001 From: Michel HERMIER Date: Fri, 9 Nov 2012 15:44:43 +0000 Subject: Don't leak temporary fds pointing to /dev/null Bug: https://bugs.freedesktop.org/show_bug.cgi?id=56927 [commit message added -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-util-unix.c | 1 + tools/dbus-launch.c | 1 + 2 files changed, 2 insertions(+) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 76423ab8..6cff3fe2 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -123,6 +123,7 @@ _dbus_become_daemon (const DBusString *pidfile, dup2 (dev_null_fd, 2); else _dbus_verbose ("keeping stderr open due to DBUS_DEBUG_OUTPUT\n"); + close (dev_null_fd); } if (!keep_umask) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 1ec9ae59..2a9dabfa 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -633,6 +633,7 @@ babysit (int exit_with_session, s = getenv ("DBUS_DEBUG_OUTPUT"); if (s == NULL || *s == '\0') dup2 (dev_null_fd, 2); + close (dev_null_fd); } else { -- cgit v1.2.1 From 9b04b927ee61da9639f20410d6f535aaccd76e0d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 9 Nov 2012 16:02:53 +0000 Subject: NEWS --- NEWS | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 618de454..b4a2094d 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,13 @@ D-Bus 1.6.10 (UNRELEASED) == -... +• In the activation helper, when compiled for tests, do not reset the system + bus address, fixing the regression tests. (fd.o #52202, Simon) + +• Fix building with Valgrind 3.8, at the cost of causing harmless warnings + with Valgrind 3.6 on some compilers (fd.o #55932, Arun Raghavan) + +• Don't leak temporary fds pointing to /dev/null (fd.o #56927, Michel HERMIER) D-Bus 1.6.8 (2012-09-28) == -- cgit v1.2.1 From b8b3feb98646c8294c86f8391d243aaf3f8ac684 Mon Sep 17 00:00:00 2001 From: Michel HERMIER Date: Fri, 9 Nov 2012 15:53:46 +0000 Subject: Remove redundant close() calls The dup2() calls immediately afterwards will close the "destination" fd if necessary. [commit message added -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 55743b19..a0310592 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3300,15 +3300,12 @@ _read_subprocess_line_argv (const char *progpath, /* set-up stdXXX */ close (result_pipe[READ_END]); close (errors_pipe[READ_END]); - close (0); /* close stdin */ - close (1); /* close stdout */ - close (2); /* close stderr */ - if (dup2 (fd, 0) == -1) + if (dup2 (fd, 0) == -1) /* setup stdin */ _exit (1); - if (dup2 (result_pipe[WRITE_END], 1) == -1) + if (dup2 (result_pipe[WRITE_END], 1) == -1) /* setup stdout */ _exit (1); - if (dup2 (errors_pipe[WRITE_END], 2) == -1) + if (dup2 (errors_pipe[WRITE_END], 2) == -1) /* setup stderr */ _exit (1); _dbus_close_all (); -- cgit v1.2.1 From 16d0564f30dbe975409e36af5e63ab3ececedda4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 9 Nov 2012 14:24:26 +0000 Subject: Don't include generated documentation in the tarball Building it unconditionally causes problems for minimal installations (OSTree), and building it opportunistically means the tarball isn't guaranteed to contain it, depending who releases libdbus and which packages they happen to have installed at the time. If this documentation is important enough that we need to ship it precompiled in tarballs, we should guarantee it; or if it isn't important enough to justify that, we should just drop it. I don't think we really need it in the tarballs at all: most users will get their libdbus from a binary distribution (in which case I expect the distribution's dbus maintainers to set appropriate build-dependencies), and those who build from source can either install xmlto, read the documentation on our website, or at worst, read the source XML. (We don't put the Doxygen-generated API reference HTML in the tarball either, and I haven't heard any complaints.) Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55426 Reviewed-by: Colin Walters --- doc/Makefile.am | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index db81b5c7..96f7bc38 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -66,9 +66,7 @@ XMLTO_OUTPUT= \ dbus-tutorial.html if DBUS_XML_DOCS_ENABLED - -# we distribute these in the tarball so users don't necessarily need xmlto -dist_html_DATA += $(XMLTO_OUTPUT) +html_DATA += $(XMLTO_OUTPUT) dbus-specification.html: dbus-specification.xml $(XMLTO) html-nochunks $< @@ -132,7 +130,7 @@ BONUS_FILES = \ $(top_srcdir)/COPYING \ $(top_srcdir)/ChangeLog -dbus-docs: $(STATIC_DOCS) $(dist_doc_DATA) $(dist_html_DATA) $(MAN_HTML_FILES) $(BONUS_FILES) doxygen.stamp +dbus-docs: $(STATIC_DOCS) $(dist_doc_DATA) $(dist_html_DATA) $(MAN_HTML_FILES) $(BONUS_FILES) doxygen.stamp $(XMLTO_OUTPUT) $(AM_V_at)rm -rf $@ $@.tmp $(AM_V_GEN)$(MKDIR_P) $@.tmp/api $(AM_V_at)cd $(srcdir) && cp $(STATIC_DOCS) @abs_builddir@/$@.tmp -- cgit v1.2.1 From 277675a40e7252a1c5c479b0e0572d9b8a4014ae Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Aug 2012 19:43:12 +0100 Subject: configure: redo pthread check to check for more things In principle, anything in the pthread namespace might either be in the platform-specific thread library (libpthread or libpthreads or libthreads or ...), or in libc. In particular, it seems that pthread_mutexattr_init and pthread_mutexattr_settype are in libpthread, not libc, on Linux. We previously didn't (intentionally) look for them in libpthread, only in libc; so this check deserved to fail. However, a faulty configure check for pthread_cond_timedwait worked around this on Linux by checking for -lpthread and adding it to THREAD_LIBS if pthread_cond_timedwait *was* found in libc (even though that behaviour makes no sense). The practical impact was that D-Bus would fail to compile on platforms where pthread_cond_timedwait is in a special threading library that is not linked by default, and at least one of (pthread_mutexattr_init, pthread_mutexattr_settype) is also in a special threading library. This is the case on at least OpenBSD (fd.o #54416). So far I've only added checks for the new symbols introduced by using recursive pthreads mutexes. If we get reports of compilation failures on weird platforms, we can check for more symbols. Also clarify the indentation, which was turning into quite a mess, and use AS_IF instead of if/elif/else/fi in accordance with Autoconf best-practice. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=47239 Reviewed-by: Colin Walters --- configure.ac | 72 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 16 deletions(-) diff --git a/configure.ac b/configure.ac index b0f2ec20..1c8b7058 100644 --- a/configure.ac +++ b/configure.ac @@ -952,15 +952,53 @@ AC_SUBST([XML_CFLAGS]) AC_SUBST([XML_LIBS]) # Thread lib detection -AC_CHECK_FUNC(pthread_cond_timedwait,[AC_CHECK_LIB(pthread,pthread_cond_timedwait, - [THREAD_LIBS="-lpthread"])]) +AC_ARG_VAR([THREAD_LIBS]) save_libs="$LIBS" LIBS="$LIBS $THREAD_LIBS" -AC_CHECK_FUNC(pthread_condattr_setclock,have_pthread_condattr_setclock=true,have_pthread_condattr_setclock=false) -if test x$have_pthread_condattr_setclock = xtrue; then - AC_SEARCH_LIBS([clock_getres],[rt],[THREAD_LIBS="$THREAD_LIBS -lrt"]) - AC_MSG_CHECKING([for CLOCK_MONOTONIC]) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include + +is_missing_pthread_function="is required when compiling D-Bus on Unix platforms, but is not in your libc or libpthread. Please open a bug on https://bugs.freedesktop.org/enter_bug.cgi?product=dbus with details of your platform." + +# Don't do these automatic checks if the user set THREAD_LIBS on the +# configure command-line. If they did, we assume they're right. +# +# We also don't do these checks on Windows, because you don't need magical +# linker flags to have threading support there. +AS_IF([test "x$dbus_unix" = xyes && test "x$THREAD_LIBS" = x], + [ + # Mandatory pthread functions. In principle, some of these could be made + # optional if there are platforms that don't have them. + # + # Currently, we only look in -lpthread. + # In principle we might need to look in -lpthreads, -lthreads, ... + # as well - please file a bug if your platform needs this. + AC_SEARCH_LIBS([pthread_cond_timedwait], + [pthread], + [THREAD_LIBS="$LIBS"], + [AC_MSG_ERROR([pthread_cond_timedwait $is_missing_pthread_function])], + []) + AC_SEARCH_LIBS([pthread_mutexattr_init], + [pthread], + [THREAD_LIBS="$LIBS"], + [AC_MSG_ERROR([pthread_mutexattr_init $is_missing_pthread_function])], + []) + AC_SEARCH_LIBS([pthread_mutexattr_settype], + [pthread], + [THREAD_LIBS="$LIBS"], + [AC_MSG_ERROR([pthread_mutexattr_settype $is_missing_pthread_function])], + []) + + # Optional, for monotonic clocks. Because it's optional, this check + # is non-fatal if we don't find it. + AC_SEARCH_LIBS([pthread_condattr_setclock], + [pthread], + [THREAD_LIBS="$LIBS"]) + + AS_IF([test "x$ac_cv_search_pthread_condattr_setclock" != xno], + [ + AC_SEARCH_LIBS([clock_getres], [rt], [THREAD_LIBS="$LIBS"]) + AC_MSG_CHECKING([for CLOCK_MONOTONIC]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[#include #include ]], [[ struct timespec monotonic_timer; @@ -969,15 +1007,17 @@ pthread_condattr_init (&attr); pthread_condattr_setclock (&attr, CLOCK_MONOTONIC); clock_getres (CLOCK_MONOTONIC,&monotonic_timer); ]])], -[have_clock_monotonic=true], -[have_clock_monotonic=false]) -if test x$have_clock_monotonic = xtrue; then - AC_MSG_RESULT([found]) - AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, [Define if we have CLOCK_MONOTONIC]) -else - AC_MSG_RESULT([not found]) -fi -fi + [have_clock_monotonic=true], + [have_clock_monotonic=false]) + AS_IF([test x$have_clock_monotonic = xtrue], + [ + AC_MSG_RESULT([found]) + AC_DEFINE(HAVE_MONOTONIC_CLOCK, 1, [Define if we have CLOCK_MONOTONIC]) + ], + [AC_MSG_RESULT([not found])]) + ]) dnl have pthread_condattr_setclock + ]) dnl on Unix + LIBS="$save_libs" AC_SUBST([THREAD_LIBS]) -- cgit v1.2.1 From 0b7ab6cf1cf54080f9cd4851a7b7f4b247af7d99 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 13 Aug 2012 19:43:56 +0100 Subject: dbus-sysdeps-pthread.c: don't fail if !HAVE_MONOTONIC_CLOCK under -Werror=unused Bug: https://bugs.freedesktop.org/show_bug.cgi?id=47239 --- dbus/dbus-sysdeps-pthread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index c60457be..439c9c62 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -36,12 +36,14 @@ #include +#ifdef HAVE_MONOTONIC_CLOCK /* Whether we have a "monotonic" clock; i.e. a clock not affected by * changes in system time. * This is initialized once in check_monotonic_clock below. * https://bugs.freedesktop.org/show_bug.cgi?id=18121 */ static dbus_bool_t have_monotonic_clock = 0; +#endif struct DBusRMutex { pthread_mutex_t lock; /**< the lock */ -- cgit v1.2.1 From d8e3f0d5a63d87c3d85232cdb6ea506c615b01d9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 19 Nov 2012 15:21:57 +0000 Subject: NEWS As well as documenting recent changes, this sorts out some divergence between the master and dbus-1.6 versions of NEWS, so the 1.6 entries are the same as in the corresponding releases. --- NEWS | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/NEWS b/NEWS index c2eef3a7..43996634 100644 --- a/NEWS +++ b/NEWS @@ -29,7 +29,18 @@ Fixes: • Fix building with Valgrind 3.8, at the cost of causing harmless warnings with Valgrind 3.6 on some compilers (fd.o #55932, Arun Raghavan) -• Don't leak temporary fds pointing to /dev/null (fd.o #56927, Michel HERMIER) +• Unix-specific: + · Check for functions in libpthread correctly, fixing compilation on + (at least) OpenBSD (fd.o #47239, Simon) + · Don't leak temporary fds pointing to /dev/null (fd.o #56927, + Michel HERMIER) + +• Windows-specific: + · The default session bus listening and connecting address is now + "autolaunch:", which makes D-Bus on Windows interoperate with itself + and GDBus "out of the box". Use the configure options and cmake variables + described above if you require a different autolaunch scope. + (fd.o #38201, Simon McVittie) D-Bus 1.6.8 (2012-09-28) == @@ -48,29 +59,17 @@ D-Bus 1.6.6 (2012-09-28) The "Clear the environment in your setuid binaries, please" release. -Fixes: - • CVE-2012-3524: Don't access environment variables (fd.o #52202) Thanks to work and input from Colin Walters, Simon McVittie, Geoffrey Thomas, and others. - • Unix-specific: · Fix compilation on Solaris (fd.o #53286, Jonathan Perkin) · Work around interdependent headers on OpenBSD by including sys/types.h before each use of sys/socket.h (fd.o #54418, Brad Smith) -• Windows-specific: - · The default session bus listening and connecting address is now - "autolaunch:", which makes D-Bus on Windows interoperate with itself - and GDBus "out of the box". Use the configure options and cmake variables - described above if you require a different autolaunch scope. - (fd.o #38201, Simon McVittie) - D-Bus 1.6.4 (2012-07-18) == -Fixes: - • Detect that users are "at the console" correctly when configured with a non-default path such as --enable-console-auth-dir=/run/console (fd.o #51521, Dave Reisner) -- cgit v1.2.1 From fccb9560b39d3108a06e985fe8f208d50bf2def5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 5 Sep 2012 05:07:20 +0200 Subject: Create missing directories in cmake /bus/session.d and /bus/system.d Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41319 Reviewed-by: Simon McVittie --- cmake/bus/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index faf9a8e9..2657605e 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -12,7 +12,10 @@ set (config_DATA # config files for installation CONFIGURE_FILE( "${BUS_DIR}/session.conf.in" "${CMAKE_CURRENT_BINARY_DIR}/session.conf" IMMEDIATE @ONLY) +FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/session.d) + CONFIGURE_FILE( "system.conf.cmake" "${CMAKE_CURRENT_BINARY_DIR}/system.conf" IMMEDIATE @ONLY) +FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/system.d) # copy services for local daemon start to local service dir data/dbus-1/services SET (SERVICE_FILES test/data/valid-service-files) -- cgit v1.2.1 From 91f2dd538820efc5fb7200d7a9c9f69201c6ae87 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 5 Sep 2012 05:07:20 +0200 Subject: Create missing directories in cmake /bus/session.d and /bus/system.d Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41319 Reviewed-by: Simon McVittie --- cmake/bus/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index faf9a8e9..2657605e 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -12,7 +12,10 @@ set (config_DATA # config files for installation CONFIGURE_FILE( "${BUS_DIR}/session.conf.in" "${CMAKE_CURRENT_BINARY_DIR}/session.conf" IMMEDIATE @ONLY) +FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/session.d) + CONFIGURE_FILE( "system.conf.cmake" "${CMAKE_CURRENT_BINARY_DIR}/system.conf" IMMEDIATE @ONLY) +FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/system.d) # copy services for local daemon start to local service dir data/dbus-1/services SET (SERVICE_FILES test/data/valid-service-files) -- cgit v1.2.1 From 3a600899d43b9d92d348fc6cfd44846a1d6f96d7 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 15 Jan 2013 10:09:25 +0100 Subject: Fixed cmake warning related to WIN32 macro when configuring on cygwin Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59401 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 52a48fdc..51aa4f4a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,3 +1,6 @@ +# we do not need to have WIN32 defined +set(CMAKE_LEGACY_CYGWIN_WIN32 0) + project(dbus) # we need to be up to date -- cgit v1.2.1 From 1e1e4c92ac169131d36349965a0665aed5434068 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 28 Jan 2013 19:55:10 +0100 Subject: CMake build system fix: Lets check for xmlto doc book generator first. We shouldn't try to build the documentation with meinproc *and* xmlto. Prefer xmlto, since it's also the one we use under Autotools. We still need to support meinproc as a fallback, because xmlto isn't available on Windows. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59733 Reviewed-by: Simon McVittie --- cmake/doc/CMakeLists.txt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index df6b587b..e1079182 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -23,7 +23,12 @@ if (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) OPTION(DBUS_ENABLE_XML_DOCS "build XML documentation (requires xmlto or meinproc4)" ON) endif (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) -if (MEINPROC4_EXECUTABLE) +if (XMLTO_EXECUTABLE) + set (DOCBOOK_GENERATOR_NAME "xmlto" PARENT_SCOPE) + set(DBUS_XML_DOCS_ENABLED 1) + set(MEINPROC4_EXECUTABLE 0) + MESSAGE(STATUS "xmlto docbook generator found") +elseif (MEINPROC4_EXECUTABLE) set(DOCBOOK_GENERATOR_NAME "meinproc4" PARENT_SCOPE) set(DBUS_XML_DOCS_ENABLED 1) if(WIN32) @@ -33,14 +38,7 @@ if (MEINPROC4_EXECUTABLE) set(_meinproc_install_path ${CMAKE_INSTALL_PREFIX}) endif(WIN32) set(STYLESHEET "${_meinproc_install_path}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl") -endif (MEINPROC4_EXECUTABLE) - - -if (XMLTO_EXECUTABLE) - set (DOCBOOK_GENERATOR_NAME "xmlto" PARENT_SCOPE) - set(DBUS_XML_DOCS_ENABLED 1) - MESSAGE(STATUS "xmlto docbook generator found") -endif (XMLTO_EXECUTABLE) +endif () if (DBUS_ENABLE_XML_DOCS) -- cgit v1.2.1 From 325c018c1f8a6b45de8d0280e062fdfaf49fe52e Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 5 Feb 2013 12:22:13 -0500 Subject: build: Dist autogen.sh For convenience of people who have to patch the autotools. See also http://people.gnome.org/~walters/docs/build-api.txt https://bugs.freedesktop.org/show_bug.cgi?id=60330 --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index a19d4405..756ab8b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -7,6 +7,7 @@ DISTCLEANFILES = \ dbus-1.pc EXTRA_DIST = \ + autogen.sh \ HACKING \ dbus-1.pc.in \ cleanup-man-pages.sh \ -- cgit v1.2.1 From 161b7d7007dc17f7540bf5735487cc2e53865168 Mon Sep 17 00:00:00 2001 From: Krzysztof Konopko Date: Fri, 29 Jun 2012 13:40:37 +0100 Subject: Merge from included config file is not supported in the included config file, i. e. it's not merged in merge_included(). There's clearly no reason it shouldn't be supported in the included config file along with , and others. It's quite reasonable for a client willing to override the default servicehelper, e. g. in system-local.conf. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=51560 Reviewed-by: Simon McVittie --- bus/config-parser.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bus/config-parser.c b/bus/config-parser.c index 07e8fbb6..1d1b8bf0 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -323,7 +323,14 @@ merge_included (BusConfigParser *parser, parser->pidfile = included->pidfile; included->pidfile = NULL; } - + + if (included->servicehelper != NULL) + { + dbus_free (parser->servicehelper); + parser->servicehelper = included->servicehelper; + included->servicehelper = NULL; + } + while ((link = _dbus_list_pop_first_link (&included->listen_on))) _dbus_list_append_link (&parser->listen_on, link); -- cgit v1.2.1 From 48fb808351957096330b742b6da096e3fe9493ae Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 29 Jan 2013 19:52:06 +0100 Subject: Uses cmake provided expat find package. The cmake provided expat find package is more up to date. There is no need to maintain an additional one. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59733 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 15 +++++----- cmake/modules/FindLibExpat.cmake | 61 ---------------------------------------- 2 files changed, 8 insertions(+), 68 deletions(-) delete mode 100644 cmake/modules/FindLibExpat.cmake diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 51aa4f4a..9a37e40f 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -1,3 +1,6 @@ +# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked +list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") + # we do not need to have WIN32 defined set(CMAKE_LEGACY_CYGWIN_WIN32 0) @@ -9,8 +12,6 @@ if(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) endif(COMMAND cmake_policy) -# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked -set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules") # detect version include(MacrosAutotools) @@ -98,7 +99,7 @@ option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) if (DBUS_USE_EXPAT) - find_package(LibExpat) + find_package(EXPAT) else () find_package(LibXml2) endif () @@ -298,14 +299,14 @@ if("${sysname}" MATCHES ".*SOLARIS.*") endif("${sysname}" MATCHES ".*SOLARIS.*") #AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use])) -if(NOT LIBXML2_FOUND AND NOT LIBEXPAT_FOUND) +if(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) message(FATAL "Neither expat nor libxml2 found!") -endif(NOT LIBXML2_FOUND AND NOT LIBEXPAT_FOUND) +endif(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) if(DBUS_USE_EXPAT) SET(XML_LIB "Expat") - SET(XML_LIBRARY ${LIBEXPAT_LIBRARIES}) - SET(XML_INCLUDE_DIR ${LIBEXPAT_INCLUDE_DIR}) + SET(XML_LIBRARY ${EXPAT_LIBRARIES}) + SET(XML_INCLUDE_DIR ${EXPAT_INCLUDE_DIR}) else(DBUS_USE_EXPAT) SET(XML_LIB "LibXML2") SET(XML_LIBRARY ${LIBXML2_LIBRARIES}) diff --git a/cmake/modules/FindLibExpat.cmake b/cmake/modules/FindLibExpat.cmake deleted file mode 100644 index a07c8de4..00000000 --- a/cmake/modules/FindLibExpat.cmake +++ /dev/null @@ -1,61 +0,0 @@ -# - Try to find LIBEXPAT -# Once done this will define -# -# LIBEXPAT_FOUND - system has LIBEXPAT -# LIBEXPAT_INCLUDE_DIR - the LIBEXPAT include directory -# LIBEXPAT_LIBRARIES - the libraries needed to use LIBEXPAT -# LIBEXPAT_DEFINITIONS - Compiler switches required for using LIBEXPAT - -if (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES) - - # in cache already - SET(LIBEXPAT_FOUND TRUE) - -else (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES) - - IF (WIN32) - file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _progFiles) - find_FILE(LIBEXPAT_DIR expat Source/lib/expat.h - PATHS - "${_progFiles}" - ) - if (LIBEXPAT_DIR) - set (_LIBEXPATIncDir ${LIBEXPAT_DIR}/Source/lib) - set (_LIBEXPATLinkDir ${LIBEXPAT_DIR}/libs) - endif (LIBEXPAT_DIR) - ELSE (WIN32) - # use pkg-config to get the directories and then use these values - # in the FIND_PATH() and FIND_LIBRARY() calls - INCLUDE(UsePkgConfig) - PKGCONFIG(LIBEXPAT-2.0 _LIBEXPATIncDir _LIBEXPATLinkDir _LIBEXPATLinkFlags _LiIconvCflags) - SET(LIBEXPAT_DEFINITIONS ${_LIBEXPATCflags}) - ENDIF (WIN32) - - FIND_PATH(LIBEXPAT_INCLUDE_DIR expat.h - PATHS - ${_LIBEXPATIncDir} - PATH_SUFFIXES LIBEXPAT - ) - - FIND_LIBRARY(LIBEXPAT_LIBRARIES NAMES expat libexpat - PATHS - ${_LIBEXPATLinkDir} - ) - - if (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES) - set(LIBEXPAT_FOUND TRUE) - endif (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES) - - if (LIBEXPAT_FOUND) - if (NOT LIBEXPAT_FIND_QUIETLY) - message(STATUS "Found libexpat: ${LIBEXPAT_LIBRARIES}") - endif (NOT LIBEXPAT_FIND_QUIETLY) - else (LIBEXPAT_FOUND) - if (LIBEXPAT_FIND_REQUIRED) - message(SEND_ERROR "Could NOT find libexpat") - endif (LIBEXPAT_FIND_REQUIRED) - endif (LIBEXPAT_FOUND) - - MARK_AS_ADVANCED(LIBEXPAT_INCLUDE_DIR LIBEXPAT_LIBRARIES) - -endif (LIBEXPAT_INCLUDE_DIR AND LIBEXPAT_LIBRARIES) -- cgit v1.2.1 From 29a27c47e68004ea1241afc09efabfa7db894e67 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 28 Jan 2013 20:05:34 +0100 Subject: Fixed cmake cross compile timestamp creating. We only need to distinct "Windows" from unix like systems Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59733 Reviewed-by: Simon McVittie --- cmake/modules/Macros.cmake | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index b6371568..adb34b51 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -1,15 +1,12 @@ MACRO(TIMESTAMP RESULT) - IF(WIN32) + if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE DATE) string(REGEX REPLACE "(..)[/.](..)[/.](....).*" "\\3\\2\\1" DATE ${DATE}) EXECUTE_PROCESS(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE TIME) string(REGEX REPLACE "(..):(..)" "\\1\\2" TIME ${TIME}) set (${RESULT} "${DATE}${TIME}") - ELSEIF(UNIX) + else () EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d%H%M" OUTPUT_VARIABLE ${RESULT}) - ELSE() - MESSAGE(SEND_ERROR "date not implemented") - SET(${RESULT} 000000000000) - ENDIF() + endif () ENDMACRO() -- cgit v1.2.1 From 71992e9fd70ef56d0c22cdc000ffafc617ece48e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Feb 2013 11:14:55 +0000 Subject: Update sd-daemon.[ch] from systemd Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60681 --- dbus/Makefile.am | 4 +- dbus/sd-daemon.c | 153 +++++++++++++++++++++++++++++++++++++++++++++---------- dbus/sd-daemon.h | 59 ++++++++++++++------- 3 files changed, 171 insertions(+), 45 deletions(-) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index bb5cccaf..3679e3f9 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -308,5 +308,5 @@ clean-local: /bin/rm *.bb *.bbg *.da *.gcov .libs/*.da .libs/*.bbg || true update-systemd: - curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c > sd-daemon.c - curl http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h > sd-daemon.h + curl http://cgit.freedesktop.org/systemd/systemd/plain/src/libsystemd-daemon/sd-daemon.c > $(srcdir)/sd-daemon.c + curl http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h > $(srcdir)/sd-daemon.h diff --git a/dbus/sd-daemon.c b/dbus/sd-daemon.c index 9c23b917..80aadf7a 100644 --- a/dbus/sd-daemon.c +++ b/dbus/sd-daemon.c @@ -32,7 +32,11 @@ #include #include #include +#ifdef __BIONIC__ +#include +#else #include +#endif #include #include #include @@ -40,10 +44,28 @@ #include #include #include +#include +#include + +#if defined(__linux__) +#include +#endif #include "sd-daemon.h" -int sd_listen_fds(int unset_environment) { +#if (__GNUC__ >= 4) +#ifdef SD_EXPORT_SYMBOLS +/* Export symbols */ +#define _sd_export_ __attribute__ ((visibility("default"))) +#else +/* Don't export the symbols */ +#define _sd_export_ __attribute__ ((visibility("hidden"))) +#endif +#else +#define _sd_export_ +#endif + +_sd_export_ int sd_listen_fds(int unset_environment) { #if defined(DISABLE_SYSTEMD) || !defined(__linux__) return 0; @@ -53,7 +75,8 @@ int sd_listen_fds(int unset_environment) { char *p = NULL; unsigned long l; - if (!(e = getenv("LISTEN_PID"))) { + e = getenv("LISTEN_PID"); + if (!e) { r = 0; goto finish; } @@ -66,7 +89,7 @@ int sd_listen_fds(int unset_environment) { goto finish; } - if (!p || *p || l <= 0) { + if (!p || p == e || *p || l <= 0) { r = -EINVAL; goto finish; } @@ -77,7 +100,8 @@ int sd_listen_fds(int unset_environment) { goto finish; } - if (!(e = getenv("LISTEN_FDS"))) { + e = getenv("LISTEN_FDS"); + if (!e) { r = 0; goto finish; } @@ -90,7 +114,7 @@ int sd_listen_fds(int unset_environment) { goto finish; } - if (!p || *p) { + if (!p || p == e || *p) { r = -EINVAL; goto finish; } @@ -98,7 +122,8 @@ int sd_listen_fds(int unset_environment) { for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + (int) l; fd ++) { int flags; - if ((flags = fcntl(fd, F_GETFD)) < 0) { + flags = fcntl(fd, F_GETFD); + if (flags < 0) { r = -errno; goto finish; } @@ -124,13 +149,12 @@ finish: #endif } -int sd_is_fifo(int fd, const char *path) { +_sd_export_ int sd_is_fifo(int fd, const char *path) { struct stat st_fd; if (fd < 0) return -EINVAL; - memset(&st_fd, 0, sizeof(st_fd)); if (fstat(fd, &st_fd) < 0) return -errno; @@ -140,7 +164,6 @@ int sd_is_fifo(int fd, const char *path) { if (path) { struct stat st_path; - memset(&st_path, 0, sizeof(st_path)); if (stat(path, &st_path) < 0) { if (errno == ENOENT || errno == ENOTDIR) @@ -157,6 +180,42 @@ int sd_is_fifo(int fd, const char *path) { return 1; } +_sd_export_ int sd_is_special(int fd, const char *path) { + struct stat st_fd; + + if (fd < 0) + return -EINVAL; + + if (fstat(fd, &st_fd) < 0) + return -errno; + + if (!S_ISREG(st_fd.st_mode) && !S_ISCHR(st_fd.st_mode)) + return 0; + + if (path) { + struct stat st_path; + + if (stat(path, &st_path) < 0) { + + if (errno == ENOENT || errno == ENOTDIR) + return 0; + + return -errno; + } + + if (S_ISREG(st_fd.st_mode) && S_ISREG(st_path.st_mode)) + return + st_path.st_dev == st_fd.st_dev && + st_path.st_ino == st_fd.st_ino; + else if (S_ISCHR(st_fd.st_mode) && S_ISCHR(st_path.st_mode)) + return st_path.st_rdev == st_fd.st_rdev; + else + return 0; + } + + return 1; +} + static int sd_is_socket_internal(int fd, int type, int listening) { struct stat st_fd; @@ -208,13 +267,14 @@ union sockaddr_union { struct sockaddr_storage storage; }; -int sd_is_socket(int fd, int family, int type, int listening) { +_sd_export_ int sd_is_socket(int fd, int family, int type, int listening) { int r; if (family < 0) return -EINVAL; - if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) + r = sd_is_socket_internal(fd, type, listening); + if (r <= 0) return r; if (family > 0) { @@ -236,7 +296,7 @@ int sd_is_socket(int fd, int family, int type, int listening) { return 1; } -int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) { +_sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) { union sockaddr_union sockaddr; socklen_t l; int r; @@ -244,7 +304,8 @@ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port if (family != 0 && family != AF_INET && family != AF_INET6) return -EINVAL; - if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) + r = sd_is_socket_internal(fd, type, listening); + if (r <= 0) return r; memset(&sockaddr, 0, sizeof(sockaddr)); @@ -281,12 +342,13 @@ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port return 1; } -int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) { +_sd_export_ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) { union sockaddr_union sockaddr; socklen_t l; int r; - if ((r = sd_is_socket_internal(fd, type, listening)) <= 0) + r = sd_is_socket_internal(fd, type, listening); + if (r <= 0) return r; memset(&sockaddr, 0, sizeof(sockaddr)); @@ -302,29 +364,66 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t return 0; if (path) { - if (length <= 0) + if (length == 0) length = strlen(path); - if (length <= 0) + if (length == 0) /* Unnamed socket */ - return l == sizeof(sa_family_t); + return l == offsetof(struct sockaddr_un, sun_path); if (path[0]) /* Normal path socket */ return - (l >= sizeof(sa_family_t) + length + 1) && + (l >= offsetof(struct sockaddr_un, sun_path) + length + 1) && memcmp(path, sockaddr.un.sun_path, length+1) == 0; else /* Abstract namespace socket */ return - (l == sizeof(sa_family_t) + length) && + (l == offsetof(struct sockaddr_un, sun_path) + length) && memcmp(path, sockaddr.un.sun_path, length) == 0; } return 1; } -int sd_notify(int unset_environment, const char *state) { +_sd_export_ int sd_is_mq(int fd, const char *path) { +#if !defined(__linux__) + return 0; +#else + struct mq_attr attr; + + if (fd < 0) + return -EINVAL; + + if (mq_getattr(fd, &attr) < 0) + return -errno; + + if (path) { + char fpath[PATH_MAX]; + struct stat a, b; + + if (path[0] != '/') + return -EINVAL; + + if (fstat(fd, &a) < 0) + return -errno; + + strncpy(stpcpy(fpath, "/dev/mqueue"), path, sizeof(fpath) - 12); + fpath[sizeof(fpath)-1] = 0; + + if (stat(fpath, &b) < 0) + return -errno; + + if (a.st_dev != b.st_dev || + a.st_ino != b.st_ino) + return 0; + } + + return 1; +#endif +} + +_sd_export_ int sd_notify(int unset_environment, const char *state) { #if defined(DISABLE_SYSTEMD) || !defined(__linux__) || !defined(SOCK_CLOEXEC) return 0; #else @@ -339,7 +438,8 @@ int sd_notify(int unset_environment, const char *state) { goto finish; } - if (!(e = getenv("NOTIFY_SOCKET"))) + e = getenv("NOTIFY_SOCKET"); + if (!e) return 0; /* Must be an abstract socket, or an absolute path */ @@ -348,7 +448,8 @@ int sd_notify(int unset_environment, const char *state) { goto finish; } - if ((fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0)) < 0) { + fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC, 0); + if (fd < 0) { r = -errno; goto finish; } @@ -366,7 +467,7 @@ int sd_notify(int unset_environment, const char *state) { memset(&msghdr, 0, sizeof(msghdr)); msghdr.msg_name = &sockaddr; - msghdr.msg_namelen = sizeof(sa_family_t) + strlen(e); + msghdr.msg_namelen = offsetof(struct sockaddr_un, sun_path) + strlen(e); if (msghdr.msg_namelen > sizeof(struct sockaddr_un)) msghdr.msg_namelen = sizeof(struct sockaddr_un); @@ -392,7 +493,7 @@ finish: #endif } -int sd_notifyf(int unset_environment, const char *format, ...) { +_sd_export_ int sd_notifyf(int unset_environment, const char *format, ...) { #if defined(DISABLE_SYSTEMD) || !defined(__linux__) return 0; #else @@ -414,7 +515,7 @@ int sd_notifyf(int unset_environment, const char *format, ...) { #endif } -int sd_booted(void) { +_sd_export_ int sd_booted(void) { #if defined(DISABLE_SYSTEMD) || !defined(__linux__) return 0; #else diff --git a/dbus/sd-daemon.h b/dbus/sd-daemon.h index c68c96d2..fb7456d5 100644 --- a/dbus/sd-daemon.h +++ b/dbus/sd-daemon.h @@ -58,21 +58,21 @@ extern "C" { You may find an up-to-date version of these source files online: - http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.h - http://cgit.freedesktop.org/systemd/plain/src/sd-daemon.c + http://cgit.freedesktop.org/systemd/systemd/plain/src/systemd/sd-daemon.h + http://cgit.freedesktop.org/systemd/systemd/plain/src/libsystemd-daemon/sd-daemon.c This should compile on non-Linux systems, too, but with the exception of the sd_is_xxx() calls all functions will become NOPs. - See sd-daemon(7) for more information. + See sd-daemon(3) for more information. */ +#ifndef _sd_printf_attr_ #if __GNUC__ >= 4 #define _sd_printf_attr_(a,b) __attribute__ ((format (printf, a, b))) -#define _sd_hidden_ __attribute__ ((visibility("hidden"))) #else #define _sd_printf_attr_(a,b) -#define _sd_hidden_ +#endif #endif /* @@ -109,7 +109,7 @@ extern "C" { See sd_listen_fds(3) for more information. */ -int sd_listen_fds(int unset_environment) _sd_hidden_; +int sd_listen_fds(int unset_environment); /* Helper call for identifying a passed file descriptor. Returns 1 if @@ -121,7 +121,19 @@ int sd_listen_fds(int unset_environment) _sd_hidden_; See sd_is_fifo(3) for more information. */ -int sd_is_fifo(int fd, const char *path) _sd_hidden_; +int sd_is_fifo(int fd, const char *path); + +/* + Helper call for identifying a passed file descriptor. Returns 1 if + the file descriptor is a special character device on the file + system stored under the specified path, 0 otherwise. + If path is NULL a path name check will not be done and the call + only verifies if the file descriptor refers to a special character. + Returns a negative errno style error code on failure. + + See sd_is_special(3) for more information. +*/ +int sd_is_special(int fd, const char *path); /* Helper call for identifying a passed file descriptor. Returns 1 if @@ -137,7 +149,7 @@ int sd_is_fifo(int fd, const char *path) _sd_hidden_; See sd_is_socket(3) for more information. */ -int sd_is_socket(int fd, int family, int type, int listening) _sd_hidden_; +int sd_is_socket(int fd, int family, int type, int listening); /* Helper call for identifying a passed file descriptor. Returns 1 if @@ -151,7 +163,7 @@ int sd_is_socket(int fd, int family, int type, int listening) _sd_hidden_; See sd_is_socket_inet(3) for more information. */ -int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) _sd_hidden_; +int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port); /* Helper call for identifying a passed file descriptor. Returns 1 if @@ -167,17 +179,25 @@ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port See sd_is_socket_unix(3) for more information. */ -int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) _sd_hidden_; +int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length); + +/* + Helper call for identifying a passed file descriptor. Returns 1 if + the file descriptor is a POSIX Message Queue of the specified name, + 0 otherwise. If path is NULL a message queue name check is not + done. Returns a negative errno style error code on failure. +*/ +int sd_is_mq(int fd, const char *path); /* Informs systemd about changed daemon state. This takes a number of - newline seperated environment-style variable assignments in a + newline separated environment-style variable assignments in a string. The following variables are known: READY=1 Tells systemd that daemon startup is finished (only relevant for services of Type=notify). The passed argument is a boolean "1" or "0". Since there is - little value in signalling non-readiness the only + little value in signaling non-readiness the only value daemons should send is "READY=1". STATUS=... Passes a single-line status string back to systemd @@ -197,8 +217,13 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t MAINPID=... The main pid of a daemon, in case systemd did not fork off the process itself. Example: "MAINPID=4711" + WATCHDOG=1 Tells systemd to update the watchdog timestamp. + Services using this feature should do this in + regular intervals. A watchdog framework can use the + timestamps to detect failed services. + Daemons can choose to send additional variables. However, it is - recommened to prefix variable names not listed above with X_. + recommended to prefix variable names not listed above with X_. Returns a negative errno-style error code on failure. Returns > 0 if systemd could be notified, 0 if it couldn't possibly because @@ -213,7 +238,7 @@ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t See sd_notify(3) for more information. */ -int sd_notify(int unset_environment, const char *state) _sd_hidden_; +int sd_notify(int unset_environment, const char *state); /* Similar to sd_notify() but takes a format string. @@ -235,7 +260,7 @@ int sd_notify(int unset_environment, const char *state) _sd_hidden_; See sd_notifyf(3) for more information. */ -int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3) _sd_hidden_; +int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_(2,3); /* Returns > 0 if the system was booted with systemd. Returns < 0 on @@ -244,11 +269,11 @@ int sd_notifyf(int unset_environment, const char *format, ...) _sd_printf_attr_( fine. You should NOT protect them with a call to this function. Also note that this function checks whether the system, not the user session is controlled by systemd. However the functions above work - for both session and system services. + for both user and system services. See sd_booted(3) for more information. */ -int sd_booted(void) _sd_hidden_; +int sd_booted(void); #ifdef __cplusplus } -- cgit v1.2.1 From 452484e831f7545c1f80cb666db79aa6ed021498 Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Mon, 4 Feb 2013 18:14:31 -0600 Subject: Add poll constants for QNX The QNX operating system uses different values for its poll constants, so they must be added into dbus-sysdeps.h in order for poll() to work correctly. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60339 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index eee91608..f4b0ac97 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -278,6 +278,19 @@ dbus_int32_t _dbus_atomic_get (DBusAtomic *atomic); #define _DBUS_POLLHUP 0x0080 /** Invalid request: fd not open */ #define _DBUS_POLLNVAL 0x1000 +#elif defined(__QNX__) +/** Writing now will not block */ +#define _DBUS_POLLOUT 0x0002 +/** There is data to read */ +#define _DBUS_POLLIN 0x0005 +/** There is urgent data to read */ +#define _DBUS_POLLPRI 0x0008 +/** Error condition */ +#define _DBUS_POLLERR 0x0020 +/** Hung up */ +#define _DBUS_POLLHUP 0x0040 +/** Invalid request: fd not open */ +#define _DBUS_POLLNVAL 0x1000 #else /** There is data to read */ #define _DBUS_POLLIN 0x0001 -- cgit v1.2.1 From 74b4c3ac947f68a58fc0d8723850789bbb2614cf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Feb 2013 11:44:11 +0000 Subject: NEWS for 1.6 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index b4a2094d..061ca186 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ D-Bus 1.6.10 (UNRELEASED) • Don't leak temporary fds pointing to /dev/null (fd.o #56927, Michel HERMIER) +• Create session.d, system.d directories under CMake (fd.o #41319, + Ralf Habacker) + D-Bus 1.6.8 (2012-09-28) == -- cgit v1.2.1 From b6769bc6a3514169abc8e3c2fa77e5727165e030 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Feb 2013 11:45:26 +0000 Subject: More NEWS for 1.7 --- NEWS | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/NEWS b/NEWS index 5905ec92..3295f903 100644 --- a/NEWS +++ b/NEWS @@ -29,11 +29,24 @@ Fixes: • Fix building with Valgrind 3.8, at the cost of causing harmless warnings with Valgrind 3.6 on some compilers (fd.o #55932, Arun Raghavan) +• Merge from system-local.conf if necessary (fd.o #51560, + Krzysztof Konopko) + +• Under CMake, prefer xmlto over meinproc (fd.o #59733, Ralf Habacker) + +• Stop duplicating CMake's own logic to find libexpat + (fd.o #59733, Ralf Habacker) + +• Don't assume CMake host and build system are the same (fd.o #59733, + Ralf Habacker) + • Unix-specific: · Check for functions in libpthread correctly, fixing compilation on (at least) OpenBSD (fd.o #47239, Simon) · Don't leak temporary fds pointing to /dev/null (fd.o #56927, Michel HERMIER) + · Update sd-daemon.[ch] from systemd (fd.o #60681) + · Add partial support for QNX (fd.o #60339, Matt Fischer) • Windows-specific: · The default session bus listening and connecting address is now @@ -41,6 +54,7 @@ Fixes: and GDBus "out of the box". Use the configure options and cmake variables described above if you require a different autolaunch scope. (fd.o #38201, Simon McVittie) + · Avoid a CMake warning under Cygwin (fd.o #59401, Ralf Habacker) • Create session.d, system.d directories under CMake (fd.o #41319, Ralf Habacker) -- cgit v1.2.1 From 6676a7db9cb30dad9bdd477e5949ca12a3c15cf6 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 5 Feb 2013 01:20:46 +0100 Subject: Moved docbook sources used by cmake into doc subdir and adapted cmake build system. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Simon McVittie --- cmake/bus/dbus-daemon.xml | 752 ------------------------------------------- cmake/doc/CMakeLists.txt | 18 +- cmake/tools/dbus-launch.xml | 240 -------------- cmake/tools/dbus-monitor.xml | 121 ------- cmake/tools/dbus-send.xml | 143 -------- doc/dbus-daemon.1.xml.in | 752 +++++++++++++++++++++++++++++++++++++++++++ doc/dbus-launch.1.xml | 240 ++++++++++++++ doc/dbus-monitor.1.xml | 121 +++++++ doc/dbus-send.1.xml | 143 ++++++++ 9 files changed, 1266 insertions(+), 1264 deletions(-) delete mode 100644 cmake/bus/dbus-daemon.xml delete mode 100644 cmake/tools/dbus-launch.xml delete mode 100644 cmake/tools/dbus-monitor.xml delete mode 100644 cmake/tools/dbus-send.xml create mode 100644 doc/dbus-daemon.1.xml.in create mode 100644 doc/dbus-launch.1.xml create mode 100644 doc/dbus-monitor.1.xml create mode 100644 doc/dbus-send.1.xml diff --git a/cmake/bus/dbus-daemon.xml b/cmake/bus/dbus-daemon.xml deleted file mode 100644 index f331699c..00000000 --- a/cmake/bus/dbus-daemon.xml +++ /dev/null @@ -1,752 +0,0 @@ - - - - - - - - - -dbus-daemon -1 - - -dbus-daemon -Message bus daemon - - - - - dbus-daemon - - dbus-daemon --version - --session - --system - --config-file=FILE - --print-address =DESCRIPTOR - --print-pid =DESCRIPTOR - --fork - - - - - -DESCRIPTION -dbus-daemon is the D-Bus message bus daemon. See -http://www.freedesktop.org/software/dbus/ for more information about -the big picture. D-Bus is first a library that provides one-to-one -communication between any two applications; dbus-daemon is an -application that uses this library to implement a message bus -daemon. Multiple programs connect to the message bus daemon and can -exchange messages with one another. - - -There are two standard message bus instances: the systemwide message bus -(installed on many systems as the "messagebus" init service) and the -per-user-login-session message bus (started each time a user logs in). -dbus-daemon is used for both of these instances, but with -a different configuration file. - - -The --session option is equivalent to -"--config-file=/etc/dbus-1/session.conf" and the --system -option is equivalent to -"--config-file=/etc/dbus-1/system.conf". By creating -additional configuration files and using the --config-file option, -additional special-purpose message bus daemons could be created. - - -The systemwide daemon is normally launched by an init script, -standardly called simply "messagebus". - - -The systemwide daemon is largely used for broadcasting system events, -such as changes to the printer queue, or adding/removing devices. - - -The per-session daemon is used for various interprocess communication -among desktop applications (however, it is not tied to X or the GUI -in any way). - - -SIGHUP will cause the D-Bus daemon to PARTIALLY reload its -configuration file and to flush its user/group information caches. Some -configuration changes would require kicking all apps off the bus; so they will -only take effect if you restart the daemon. Policy changes should take effect -with SIGHUP. - - - -OPTIONS -The following options are supported: - - - - -Use the given configuration file. - - - - - -Force the message bus to fork and become a daemon, even if -the configuration file does not specify that it should. -In most contexts the configuration file already gets this -right, though. - - - - - -Print the address of the message bus to standard output, or -to the given file descriptor. This is used by programs that -launch the message bus. - - - - - -Print the process ID of the message bus to standard output, or -to the given file descriptor. This is used by programs that -launch the message bus. - - - - - -Use the standard configuration file for the per-login-session message -bus. - - - - - -Use the standard configuration file for the systemwide message bus. - - - - - -Print the version of the daemon. - - - - - - -CONFIGURATION FILE -A message bus daemon has a configuration file that specializes it -for a particular application. For example, one configuration -file might set up the message bus to be a systemwide message bus, -while another might set it up to be a per-user-login-session bus. - - -The configuration file also establishes resource limits, security -parameters, and so forth. - - -The configuration file is not part of any interoperability -specification and its backward compatibility is not guaranteed; this -document is documentation, not specification. - - -The standard systemwide and per-session message bus setups are -configured in the files "/etc/dbus-1/system.conf" and -"/etc/dbus-1/session.conf". These files normally -<include> a system-local.conf or session-local.conf; you can put local -overrides in those files to avoid modifying the primary configuration -files. - - -The configuration file is an XML document. It must have the following -doctype declaration: - - - <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" - "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> - - - - -The following elements may be present in the configuration file. - - - - <busconfig> - - - - - - -Root element. - - - - <type> - - - - - - - -The well-known type of the message bus. Currently known values are -"system" and "session"; if other values are set, they should be -either added to the D-Bus specification, or namespaced. The last -<type> element "wins" (previous values are ignored). - - -Example: <type>session</type> - - - - <include> - - - - - - -Include a file <include>filename.conf</include> at this point. If the -filename is relative, it is located relative to the configuration file -doing the including. - - -<include> has an optional attribute "ignore_missing=(yes|no)" -which defaults to "no" if not provided. This attribute -controls whether it's a fatal error for the included file -to be absent. - - - - <includedir> - - - - - - - -Include all files in <includedir>foo.d</includedir> at this -point. Files in the directory are included in undefined order. -Only files ending in ".conf" are included. - - -This is intended to allow extension of the system bus by particular -packages. For example, if CUPS wants to be able to send out -notification of printer queue changes, it could install a file to -/etc/dbus-1/system.d that allowed all apps to receive -this message and allowed the printer daemon user to send it. - - - - <user> - - - - - - - -The user account the daemon should run as, as either a username or a -UID. If the daemon cannot change to this UID on startup, it will exit. -If this element is not present, the daemon will not change or care -about its UID. - - -The last <user> entry in the file "wins", the others are ignored. - - -The user is changed after the bus has completed initialization. So -sockets etc. will be created before changing user, but no data will be -read from clients before changing user. This means that sockets -and PID files can be created in a location that requires root -privileges for writing. - - - - <fork> - - - - - - -If present, the bus daemon becomes a real daemon (forks -into the background, etc.). This is generally used -rather than the --fork command line option. - - - - <listen> - - - - - - - -Add an address that the bus should listen on. The -address is in the standard D-Bus format that contains -a transport name plus possible parameters/options. - - -Example: <listen>unix:path=/tmp/foo</listen> - - -If there are multiple <listen> elements, then the bus listens -on multiple addresses. The bus will pass its address to -started services or other interested parties with -the last address given in <listen> first. That is, -apps will try to connect to the last <listen> address first. - - - - <auth> - - - - - - - -Lists permitted authorization mechanisms. If this element doesn't -exist, then all known mechanisms are allowed. If there are multiple -<auth> elements, all the listed mechanisms are allowed. The order in -which mechanisms are listed is not meaningful. - - -Example: <auth>EXTERNAL</auth> - - -Example: <auth>DBUS_COOKIE_SHA1</auth> - - - - <servicedir> - - - - - - - -Adds a directory to scan for .service files. Directories are -scanned starting with the last to appear in the config file -(the first .service file found that provides a particular -service will be used). - - -Service files tell the bus how to automatically start a program. -They are primarily used with the per-user-session bus, -not the systemwide bus. - - - - <standard_session_servicedirs/> - - - - - - - -<standard_session_servicedirs/> is equivalent to specifying a series -of <servicedir/> elements for each of the data directories in the "XDG -Base Directory Specification" with the subdirectory "dbus-1/services", -so for example "/usr/share/dbus-1/services" would be among the -directories searched. - - -The "XDG Base Directory Specification" can be found at -http://freedesktop.org/wiki/Standards/basedir-spec if it hasn't moved, -otherwise try your favorite search engine. - - -The <standard_session_servicedirs/> option is only relevant to the -per-user-session bus daemon defined in -/etc/dbus-1/session.conf. Putting it in any other -configuration file would probably be nonsense. - - - - <limit> - - - - - - - -<limit> establishes a resource limit. For example: - - <limit name="max_message_size">64</limit> - <limit name="max_completed_connections">512</limit> - - - -The name attribute is mandatory. -Available limit names are: - - "max_incoming_bytes" : total size in bytes of messages - incoming from a single connection - "max_outgoing_bytes" : total size in bytes of messages - queued up for a single connection - "max_message_size" : max size of a single message in - bytes - "service_start_timeout" : milliseconds (thousandths) until - a started service has to connect - "auth_timeout" : milliseconds (thousandths) a - connection is given to - authenticate - "max_completed_connections" : max number of authenticated connections - "max_incomplete_connections" : max number of unauthenticated - connections - "max_connections_per_user" : max number of completed connections from - the same user - "max_pending_service_starts" : max number of service launches in - progress at the same time - "max_names_per_connection" : max number of names a single - connection can own - "max_match_rules_per_connection": max number of match rules for a single - connection - "max_replies_per_connection" : max number of pending method - replies per connection - (number of calls-in-progress) - "reply_timeout" : milliseconds (thousandths) - until a method call times out - - - -The max incoming/outgoing queue sizes allow a new message to be queued -if one byte remains below the max. So you can in fact exceed the max -by max_message_size. - - -max_completed_connections divided by max_connections_per_user is the -number of users that can work together to denial-of-service all other users by using -up all connections on the systemwide bus. - - -Limits are normally only of interest on the systemwide bus, not the user session -buses. - - - - <policy> - - - - - - - -The <policy> element defines a security policy to be applied to a particular -set of connections to the bus. A policy is made up of -<allow> and <deny> elements. Policies are normally used with the systemwide bus; -they are analogous to a firewall in that they allow expected traffic -and prevent unexpected traffic. - - -The <policy> element has one of three attributes: - - context="(default|mandatory)" - user="username or userid" - group="group name or gid" - - - - -Policies are applied to a connection as follows: - - - all context="default" policies are applied - - all group="connection's user's group" policies are applied - in undefined order - - all user="connection's auth user" policies are applied - in undefined order - - all context="mandatory" policies are applied - - - -Policies applied later will override those applied earlier, -when the policies overlap. Multiple policies with the same -user/group/context are applied in the order they appear -in the config file. - - - - <deny> - -<allow> - - - - - -A <deny> element appears below a <policy> element and prohibits some -action. The <allow> element makes an exception to previous <deny> -statements, and works just like <deny> but with the inverse meaning. - - -The possible attributes of these elements are: - - send_interface="interface_name" - send_member="method_or_signal_name" - send_error="error_name" - send_destination="name" - send_type="method_call" | "method_return" | "signal" | "error" - send_path="/path/name" - - receive_interface="interface_name" - receive_member="method_or_signal_name" - receive_error="error_name" - receive_sender="name" - receive_type="method_call" | "method_return" | "signal" | "error" - receive_path="/path/name" - - send_requested_reply="true" | "false" - receive_requested_reply="true" | "false" - - eavesdrop="true" | "false" - - own="name" - own_prefix="name" - user="username" - group="groupname" - - - -Examples: - - <deny send_interface="org.freedesktop.System" send_member="Reboot"/> - <deny receive_interface="org.freedesktop.System" receive_member="Reboot"/> - <deny own="org.freedesktop.System"/> - <deny send_destination="org.freedesktop.System"/> - <deny receive_sender="org.freedesktop.System"/> - <deny user="john"/> - <deny group="enemies"/> - - - -The <deny> element's attributes determine whether the deny "matches" a -particular action. If it matches, the action is denied (unless later -rules in the config file allow it). - - -send_destination and receive_sender rules mean that messages may not be -sent to or received from the *owner* of the given name, not that -they may not be sent *to that name*. That is, if a connection -owns services A, B, C, and sending to A is denied, sending to B or C -will not work either. - - -The other send_* and receive_* attributes are purely textual/by-value -matches against the given field in the message header. - - -"Eavesdropping" occurs when an application receives a message that -was explicitly addressed to a name the application does not own. -Eavesdropping thus only applies to messages that are addressed to -services (i.e. it does not apply to signals). - - -For <allow>, eavesdrop="true" indicates that the rule matches even -when eavesdropping. eavesdrop="false" is the default and means that -the rule only allows messages to go to their specified recipient. -For <deny>, eavesdrop="true" indicates that the rule matches -only when eavesdropping. eavesdrop="false" is the default for <deny> -also, but here it means that the rule applies always, even when -not eavesdropping. The eavesdrop attribute can only be combined with -receive rules (with receive_* attributes). - - - -The [send|receive]_requested_reply attribute works similarly to the eavesdrop -attribute. It controls whether the <deny> or <allow> matches a reply -that is expected (corresponds to a previous method call message). -This attribute only makes sense for reply messages (errors and method -returns), and is ignored for other message types. - - -For <allow>, [send|receive]_requested_reply="true" is the default and indicates that -only requested replies are allowed by the -rule. [send|receive]_requested_reply="false" means that the rule allows any reply -even if unexpected. - - -For <deny>, [send|receive]_requested_reply="false" is the default but indicates that -the rule matches only when the reply was not -requested. [send|receive]_requested_reply="true" indicates that the rule applies -always, regardless of pending reply state. - - -user and group denials mean that the given user or group may -not connect to the message bus. - - -For "name", "username", "groupname", etc. -the character "*" can be substituted, meaning "any." Complex globs -like "foo.bar.*" aren't allowed for now because they'd be work to -implement and maybe encourage sloppy security anyway. - -<allow own_prefix="a.b"/> allows you to own the name "a.b" or any -name whose first dot-separated elements are "a.b": in particular, -you can own "a.b.c" or "a.b.c.d", but not "a.bc" or "a.c". -This is useful when services like Telepathy and ReserveDevice -define a meaning for subtrees of well-known names, such as -org.freedesktop.Telepathy.ConnectionManager.(anything) -and org.freedesktop.ReserveDevice1.(anything). - -It does not make sense to deny a user or group inside a <policy> -for a user or group; user/group denials can only be inside -context="default" or context="mandatory" policies. - - -A single <deny> rule may specify combinations of attributes such as -send_destination and send_interface and send_type. In this case, the -denial applies only if both attributes match the message being denied. -e.g. <deny send_interface="foo.bar" send_destination="foo.blah"/> would -deny messages with the given interface AND the given bus name. -To get an OR effect you specify multiple <deny> rules. - - -You can't include both send_ and receive_ attributes on the same -rule, since "whether the message can be sent" and "whether it can be -received" are evaluated separately. - - -Be careful with send_interface/receive_interface, because the -interface field in messages is optional. - - - - <selinux> - - - - - - - -The <selinux> element contains settings related to Security Enhanced Linux. -More details below. - - - - <associate> - - - - - - - -An <associate> element appears below an <selinux> element and -creates a mapping. Right now only one kind of association is possible: - - <associate own="org.freedesktop.Foobar" context="foo_t"/> - - - -This means that if a connection asks to own the name -"org.freedesktop.Foobar" then the source context will be the context -of the connection and the target context will be "foo_t" - see the -short discussion of SELinux below. - - -Note, the context here is the target context when requesting a name, -NOT the context of the connection owning the name. - - -There's currently no way to set a default for owning any name, if -we add this syntax it will look like: - - <associate own="*" context="foo_t"/> - -If you find a reason this is useful, let the developers know. -Right now the default will be the security context of the bus itself. - - -If two <associate> elements specify the same name, the element -appearing later in the configuration file will be used. - - - -SELinux -See http://www.nsa.gov/selinux/ for full details on SELinux. Some useful excerpts: - - -Every subject (process) and object (e.g. file, socket, IPC object, -etc) in the system is assigned a collection of security attributes, -known as a security context. A security context contains all of the -security attributes associated with a particular subject or object -that are relevant to the security policy. - - -In order to better encapsulate security contexts and to provide -greater efficiency, the policy enforcement code of SELinux typically -handles security identifiers (SIDs) rather than security contexts. A -SID is an integer that is mapped by the security server to a security -context at runtime. - - -When a security decision is required, the policy enforcement code -passes a pair of SIDs (typically the SID of a subject and the SID of -an object, but sometimes a pair of subject SIDs or a pair of object -SIDs), and an object security class to the security server. The object -security class indicates the kind of object, e.g. a process, a regular -file, a directory, a TCP socket, etc. - - -Access decisions specify whether or not a permission is granted for a -given pair of SIDs and class. Each object class has a set of -associated permissions defined to control operations on objects with -that class. - - -D-Bus performs SELinux security checks in two places. - - -First, any time a message is routed from one connection to another -connection, the bus daemon will check permissions with the security context of -the first connection as source, security context of the second connection -as target, object class "dbus" and requested permission "send_msg". - - -If a security context is not available for a connection -(impossible when using UNIX domain sockets), then the target -context used is the context of the bus daemon itself. -There is currently no way to change this default, because we're -assuming that only UNIX domain sockets will be used to -connect to the systemwide bus. If this changes, we'll -probably add a way to set the default connection context. - - -Second, any time a connection asks to own a name, -the bus daemon will check permissions with the security -context of the connection as source, the security context specified -for the name in the config file as target, object -class "dbus" and requested permission "acquire_svc". - - -The security context for a bus name is specified with the -<associate> element described earlier in this document. -If a name has no security context associated in the -configuration file, the security context of the bus daemon -itself will be used. - - - -AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index e1079182..3c6d9525 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -44,19 +44,20 @@ if (DBUS_ENABLE_XML_DOCS) macro (DOCBOOK _sources _options) get_filename_component(_infile ${_sources} ABSOLUTE) - get_filename_component(_basename ${_infile} NAME_WE) - set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.html) + get_filename_component(_name ${_infile} NAME) + string(REPLACE ".xml" ".html" _outname ${_name}) + set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname}) if (EXISTS ${_sources}) if (MEINPROC4_EXECUTABLE) - ADD_CUSTOM_TARGET(${_basename}.html ALL + ADD_CUSTOM_TARGET(${_outname} ALL ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} DEPENDS ${_infile} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif () if (XMLTO_EXECUTABLE) - ADD_CUSTOM_TARGET(${_basename}.html ALL + ADD_CUSTOM_TARGET(${_outname} ALL ${XMLTO_EXECUTABLE} -vv ${_options} ${_infile} DEPENDS ${_infile} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} @@ -96,10 +97,11 @@ DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-test-plan.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-tutorial.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-specification.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-faq.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/bus/dbus-daemon.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-monitor.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-send.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/tools/dbus-launch.xml html-nochunks) +configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-daemon.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml) +DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml html-nochunks) +DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml html-nochunks) +DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml html-nochunks) +DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml html-nochunks) # # handle html index file diff --git a/cmake/tools/dbus-launch.xml b/cmake/tools/dbus-launch.xml deleted file mode 100644 index dc34898f..00000000 --- a/cmake/tools/dbus-launch.xml +++ /dev/null @@ -1,240 +0,0 @@ - - - - - - - - - -dbus-launch -1 - - -dbus-launch -Utility to start a message bus from a shell script - - - - - dbus-launch --version - --sh-syntax - --csh-syntax - --auto-syntax - --exit-with-session - --autolaunch=MACHINEID - --config-file=FILENAME - PROGRAM - ARGS - - - - - -DESCRIPTION -The dbus-launch command is used to start a session bus -instance of dbus-daemon from a shell script. -It would normally be called from a user's login -scripts. Unlike the daemon itself, dbus-launch exits, so -backticks or the $() construct can be used to read information from -dbus-launch. - -With no arguments, dbus-launch will launch a session bus -instance and print the address and pid of that instance to standard -output. - -You may specify a program to be run; in this case, dbus-launch -will launch a session bus instance, set the appropriate environment -variables so the specified program can find the bus, and then execute the -specified program, with the specified arguments. See below for -examples. - -If you launch a program, dbus-launch will not print the -information about the new bus to standard output. - -When dbus-launch prints bus information to standard output, by -default it is in a simple key-value pairs format. However, you may -request several alternate syntaxes using the --sh-syntax, --csh-syntax, ---binary-syntax, or ---auto-syntax options. Several of these cause dbus-launch to emit shell code -to set up the environment. - -With the --auto-syntax option, dbus-launch looks at the value -of the SHELL environment variable to determine which shell syntax -should be used. If SHELL ends in "csh", then csh-compatible code is -emitted; otherwise Bourne shell code is emitted. Instead of passing ---auto-syntax, you may explicity specify a particular one by using ---sh-syntax for Bourne syntax, or --csh-syntax for csh syntax. -In scripts, it's more robust to avoid --auto-syntax and you hopefully -know which shell your script is written in. - - -See http://www.freedesktop.org/software/dbus/ for more information -about D-Bus. See also the man page for dbus-daemon. - - -Here is an example of how to use dbus-launch with an -sh-compatible shell to start the per-session bus daemon: - - - ## test for an existing bus daemon, just to be safe - if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then - ## if not found, launch a new one - eval `dbus-launch --sh-syntax --exit-with-session` - echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" - fi - - -You might run something like that in your login scripts. - - -Another way to use dbus-launch is to run your main session -program, like so: - - -dbus-launch gnome-session - - -The above would likely be appropriate for ~/.xsession or ~/.Xclients. - - - -AUTOMATIC LAUNCHING -If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use -D-Bus, by default the process will attempt to invoke dbus-launch with -the --autolaunch option to start up a new session bus or find the -existing bus address on the X display or in a file in -~/.dbus/session-bus/ - - -Whenever an autolaunch occurs, the application that had to -start a new bus will be in its own little world; it can effectively -end up starting a whole new session if it tries to use a lot of -bus services. This can be suboptimal or even totally broken, depending -on the app and what it tries to do. - - -There are two common reasons for autolaunch. One is ssh to a remote -machine. The ideal fix for that would be forwarding of -DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded. -In the meantime, you can edit the session.conf config file to -have your session bus listen on TCP, and manually set -DBUS_SESSION_BUS_ADDRESS, if you like. - - -The second common reason for autolaunch is an su to another user, and -display of X applications running as the second user on the display -belonging to the first user. Perhaps the ideal fix in this case -would be to allow the second user to connect to the session bus of the -first user, just as they can connect to the first user's display. -However, a mechanism for that has not been coded. - - -You can always avoid autolaunch by manually setting -DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default -address if none is set is "autolaunch:", so if any other address is -set there will be no autolaunch. You can however include autolaunch in -an explicit session bus address as a fallback, for example -DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if -the first address doesn't work, processes will autolaunch. (The bus -address variable contains a comma-separated list of addresses to try.) - - -The --autolaunch option is considered an internal implementation -detail of libdbus, and in fact there are plans to change it. There's -no real reason to use it outside of the libdbus implementation anyhow. - - - -OPTIONS -The following options are supported: - - - - -Choose --csh-syntax or --sh-syntax based on the SHELL environment variable. - - -Write to stdout a nul-terminated bus address, then the bus PID as a -binary integer of size sizeof(pid_t), then the bus X window ID as a -binary integer of size sizeof(long). Integers are in the machine's -byte order, not network byte order or any other canonical byte order. - - - - - - -Close the standard error output stream before starting the D-Bus -daemon. This is useful if you want to capture dbus-launch error -messages but you don't want dbus-daemon to keep the stream open to -your application. - - - - - - -Pass --config-file=FILENAME to the bus daemon, instead of passing it -the --session argument. See the man page for dbus-daemon - - - - - - -Emit csh compatible code to set up environment variables. - - - - - - -If this option is provided, a persistent "babysitter" process will be -created that watches stdin for HUP and tries to connect to the X -server. If this process gets a HUP on stdin or loses its X connection, -it kills the message bus daemon. - - - - - - -This option implies that dbus-launch should scan for a -previously-started session and reuse the values found there. If no -session is found, it will start a new session. The ---exit-with-session option is implied if --autolaunch is given. -This option is for the exclusive use of libdbus, you do not want to -use it manually. It may change in the future. - - - - - - -Emit Bourne-shell compatible code to set up environment variables. - - - - - - -Print the version of dbus-launch - - - - - - -AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/cmake/tools/dbus-monitor.xml b/cmake/tools/dbus-monitor.xml deleted file mode 100644 index b41cace2..00000000 --- a/cmake/tools/dbus-monitor.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - -dbus-monitor -1 - - -dbus-monitor -debug probe to print message bus messages - - - - - dbus-monitor - --system --session --address ADDRESS - --profile --monitor - watchexpressions - - - - - -DESCRIPTION -The dbus-monitor command is used to monitor messages going -through a D-Bus message bus. See -http://www.freedesktop.org/software/dbus/ for more information about -the big picture. - - -There are two well-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per-user-login-session message bus (started each time a user logs in). -The --system and --session options direct dbus-monitor to -monitor the system or session buses respectively. If neither is -specified, dbus-monitor monitors the session bus. - - -dbus-monitor has two different output modes, the 'classic'-style -monitoring mode and profiling mode. The profiling format is a compact -format with a single line per message and microsecond-resolution timing -information. The --profile and --monitor options select the profiling -and monitoring output format respectively. If neither is specified, -dbus-monitor uses the monitoring output format. - - -In order to get dbus-monitor to see the messages you are interested -in, you should specify a set of watch expressions as you would expect to -be passed to the dbus_bus_add_match function. - - -The message bus configuration may keep dbus-monitor from seeing -all messages, especially if you run the monitor as a non-root user. - - - -OPTIONS - - - - -Monitor the system message bus. - - - - - -Monitor the session message bus. (This is the default.) - - - - - -Monitor an arbitrary message bus given at ADDRESS. - - - - - -Use the profiling output format. - - - - - -Use the monitoring output format. (This is the default.) - - - - - - -EXAMPLE -Here is an example of using dbus-monitor to watch for the gnome typing -monitor to say things - - - dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" - - - - - -AUTHOR -dbus-monitor was written by Philip Blundell. -The profiling output mode was added by Olli Salli. - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/cmake/tools/dbus-send.xml b/cmake/tools/dbus-send.xml deleted file mode 100644 index 7fefc03e..00000000 --- a/cmake/tools/dbus-send.xml +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - - - - -dbus-send -1 - - -dbus-send -Send a message to a message bus - - - - - dbus-send - --system --session - --dest=NAME - --print-reply - --type=TYPE - <destination - object - path> - <message - name> - contents - - - - - -DESCRIPTION -The dbus-send command is used to send a message to a D-Bus message -bus. See http://www.freedesktop.org/software/dbus/ for more -information about the big picture. - - -There are two well-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per-user-login-session message bus (started each time a user logs in). -The --system and --session options direct dbus-send to send -messages to the system or session buses respectively. If neither is -specified, dbus-send sends to the session bus. - - -Nearly all uses of dbus-send must provide the --dest argument -which is the name of a connection on the bus to send the message to. If ---dest is omitted, no destination is set. - - -The object path and the name of the message to send must always be -specified. Following arguments, if any, are the message contents -(message arguments). These are given as type-specified values and -may include containers (arrays, dicts, and variants) as described below. - - -<contents> ::= <item> | <container> [ <item> | <container>...] -<item> ::= <type>:<value> -<container> ::= <array> | <dict> | <variant> -<array> ::= array:<type>:<value>[,<value>...] -<dict> ::= dict:<type>:<type>:<key>,<value>[,<key>,<value>...] -<variant> ::= variant:<type>:<value> -<type> ::= string | int16 | uint 16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath - - -D-Bus supports more types than these, but dbus-send currently -does not. Also, dbus-send does not permit empty containers -or nested containers (e.g. arrays of variants). - - -Here is an example invocation: - - - dbus-send --dest=org.freedesktop.ExampleName \ - /org/freedesktop/sample/object/name \ - org.freedesktop.ExampleInterface.ExampleMethod \ - int32:47 string:'hello world' double:65.32 \ - array:string:"1st item","next item","last item" \ - dict:string:int32:"one",1,"two",2,"three",3 \ - variant:int32:-8 \ - objpath:/org/freedesktop/sample/object/name - - - -Note that the interface is separated from a method or signal -name by a dot, though in the actual protocol the interface -and the interface member are separate fields. - - - -OPTIONS -The following options are supported: - - - - -Specify the name of the connection to receive the message. - - - - - -Block for a reply to the message sent, and print any reply received. - - - - - -Send to the system message bus. - - - - - -Send to the session message bus. (This is the default.) - - - - - -Specify "method_call" or "signal" (defaults to "signal"). - - - - - - -AUTHOR -dbus-send was written by Philip Blundell. - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in new file mode 100644 index 00000000..f331699c --- /dev/null +++ b/doc/dbus-daemon.1.xml.in @@ -0,0 +1,752 @@ + + + + + + + + + +dbus-daemon +1 + + +dbus-daemon +Message bus daemon + + + + + dbus-daemon + + dbus-daemon --version + --session + --system + --config-file=FILE + --print-address =DESCRIPTOR + --print-pid =DESCRIPTOR + --fork + + + + + +DESCRIPTION +dbus-daemon is the D-Bus message bus daemon. See +http://www.freedesktop.org/software/dbus/ for more information about +the big picture. D-Bus is first a library that provides one-to-one +communication between any two applications; dbus-daemon is an +application that uses this library to implement a message bus +daemon. Multiple programs connect to the message bus daemon and can +exchange messages with one another. + + +There are two standard message bus instances: the systemwide message bus +(installed on many systems as the "messagebus" init service) and the +per-user-login-session message bus (started each time a user logs in). +dbus-daemon is used for both of these instances, but with +a different configuration file. + + +The --session option is equivalent to +"--config-file=/etc/dbus-1/session.conf" and the --system +option is equivalent to +"--config-file=/etc/dbus-1/system.conf". By creating +additional configuration files and using the --config-file option, +additional special-purpose message bus daemons could be created. + + +The systemwide daemon is normally launched by an init script, +standardly called simply "messagebus". + + +The systemwide daemon is largely used for broadcasting system events, +such as changes to the printer queue, or adding/removing devices. + + +The per-session daemon is used for various interprocess communication +among desktop applications (however, it is not tied to X or the GUI +in any way). + + +SIGHUP will cause the D-Bus daemon to PARTIALLY reload its +configuration file and to flush its user/group information caches. Some +configuration changes would require kicking all apps off the bus; so they will +only take effect if you restart the daemon. Policy changes should take effect +with SIGHUP. + + + +OPTIONS +The following options are supported: + + + + +Use the given configuration file. + + + + + +Force the message bus to fork and become a daemon, even if +the configuration file does not specify that it should. +In most contexts the configuration file already gets this +right, though. + + + + + +Print the address of the message bus to standard output, or +to the given file descriptor. This is used by programs that +launch the message bus. + + + + + +Print the process ID of the message bus to standard output, or +to the given file descriptor. This is used by programs that +launch the message bus. + + + + + +Use the standard configuration file for the per-login-session message +bus. + + + + + +Use the standard configuration file for the systemwide message bus. + + + + + +Print the version of the daemon. + + + + + + +CONFIGURATION FILE +A message bus daemon has a configuration file that specializes it +for a particular application. For example, one configuration +file might set up the message bus to be a systemwide message bus, +while another might set it up to be a per-user-login-session bus. + + +The configuration file also establishes resource limits, security +parameters, and so forth. + + +The configuration file is not part of any interoperability +specification and its backward compatibility is not guaranteed; this +document is documentation, not specification. + + +The standard systemwide and per-session message bus setups are +configured in the files "/etc/dbus-1/system.conf" and +"/etc/dbus-1/session.conf". These files normally +<include> a system-local.conf or session-local.conf; you can put local +overrides in those files to avoid modifying the primary configuration +files. + + +The configuration file is an XML document. It must have the following +doctype declaration: + + + <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> + + + + +The following elements may be present in the configuration file. + + + + <busconfig> + + + + + + +Root element. + + + + <type> + + + + + + + +The well-known type of the message bus. Currently known values are +"system" and "session"; if other values are set, they should be +either added to the D-Bus specification, or namespaced. The last +<type> element "wins" (previous values are ignored). + + +Example: <type>session</type> + + + + <include> + + + + + + +Include a file <include>filename.conf</include> at this point. If the +filename is relative, it is located relative to the configuration file +doing the including. + + +<include> has an optional attribute "ignore_missing=(yes|no)" +which defaults to "no" if not provided. This attribute +controls whether it's a fatal error for the included file +to be absent. + + + + <includedir> + + + + + + + +Include all files in <includedir>foo.d</includedir> at this +point. Files in the directory are included in undefined order. +Only files ending in ".conf" are included. + + +This is intended to allow extension of the system bus by particular +packages. For example, if CUPS wants to be able to send out +notification of printer queue changes, it could install a file to +/etc/dbus-1/system.d that allowed all apps to receive +this message and allowed the printer daemon user to send it. + + + + <user> + + + + + + + +The user account the daemon should run as, as either a username or a +UID. If the daemon cannot change to this UID on startup, it will exit. +If this element is not present, the daemon will not change or care +about its UID. + + +The last <user> entry in the file "wins", the others are ignored. + + +The user is changed after the bus has completed initialization. So +sockets etc. will be created before changing user, but no data will be +read from clients before changing user. This means that sockets +and PID files can be created in a location that requires root +privileges for writing. + + + + <fork> + + + + + + +If present, the bus daemon becomes a real daemon (forks +into the background, etc.). This is generally used +rather than the --fork command line option. + + + + <listen> + + + + + + + +Add an address that the bus should listen on. The +address is in the standard D-Bus format that contains +a transport name plus possible parameters/options. + + +Example: <listen>unix:path=/tmp/foo</listen> + + +If there are multiple <listen> elements, then the bus listens +on multiple addresses. The bus will pass its address to +started services or other interested parties with +the last address given in <listen> first. That is, +apps will try to connect to the last <listen> address first. + + + + <auth> + + + + + + + +Lists permitted authorization mechanisms. If this element doesn't +exist, then all known mechanisms are allowed. If there are multiple +<auth> elements, all the listed mechanisms are allowed. The order in +which mechanisms are listed is not meaningful. + + +Example: <auth>EXTERNAL</auth> + + +Example: <auth>DBUS_COOKIE_SHA1</auth> + + + + <servicedir> + + + + + + + +Adds a directory to scan for .service files. Directories are +scanned starting with the last to appear in the config file +(the first .service file found that provides a particular +service will be used). + + +Service files tell the bus how to automatically start a program. +They are primarily used with the per-user-session bus, +not the systemwide bus. + + + + <standard_session_servicedirs/> + + + + + + + +<standard_session_servicedirs/> is equivalent to specifying a series +of <servicedir/> elements for each of the data directories in the "XDG +Base Directory Specification" with the subdirectory "dbus-1/services", +so for example "/usr/share/dbus-1/services" would be among the +directories searched. + + +The "XDG Base Directory Specification" can be found at +http://freedesktop.org/wiki/Standards/basedir-spec if it hasn't moved, +otherwise try your favorite search engine. + + +The <standard_session_servicedirs/> option is only relevant to the +per-user-session bus daemon defined in +/etc/dbus-1/session.conf. Putting it in any other +configuration file would probably be nonsense. + + + + <limit> + + + + + + + +<limit> establishes a resource limit. For example: + + <limit name="max_message_size">64</limit> + <limit name="max_completed_connections">512</limit> + + + +The name attribute is mandatory. +Available limit names are: + + "max_incoming_bytes" : total size in bytes of messages + incoming from a single connection + "max_outgoing_bytes" : total size in bytes of messages + queued up for a single connection + "max_message_size" : max size of a single message in + bytes + "service_start_timeout" : milliseconds (thousandths) until + a started service has to connect + "auth_timeout" : milliseconds (thousandths) a + connection is given to + authenticate + "max_completed_connections" : max number of authenticated connections + "max_incomplete_connections" : max number of unauthenticated + connections + "max_connections_per_user" : max number of completed connections from + the same user + "max_pending_service_starts" : max number of service launches in + progress at the same time + "max_names_per_connection" : max number of names a single + connection can own + "max_match_rules_per_connection": max number of match rules for a single + connection + "max_replies_per_connection" : max number of pending method + replies per connection + (number of calls-in-progress) + "reply_timeout" : milliseconds (thousandths) + until a method call times out + + + +The max incoming/outgoing queue sizes allow a new message to be queued +if one byte remains below the max. So you can in fact exceed the max +by max_message_size. + + +max_completed_connections divided by max_connections_per_user is the +number of users that can work together to denial-of-service all other users by using +up all connections on the systemwide bus. + + +Limits are normally only of interest on the systemwide bus, not the user session +buses. + + + + <policy> + + + + + + + +The <policy> element defines a security policy to be applied to a particular +set of connections to the bus. A policy is made up of +<allow> and <deny> elements. Policies are normally used with the systemwide bus; +they are analogous to a firewall in that they allow expected traffic +and prevent unexpected traffic. + + +The <policy> element has one of three attributes: + + context="(default|mandatory)" + user="username or userid" + group="group name or gid" + + + + +Policies are applied to a connection as follows: + + - all context="default" policies are applied + - all group="connection's user's group" policies are applied + in undefined order + - all user="connection's auth user" policies are applied + in undefined order + - all context="mandatory" policies are applied + + + +Policies applied later will override those applied earlier, +when the policies overlap. Multiple policies with the same +user/group/context are applied in the order they appear +in the config file. + + + + <deny> + +<allow> + + + + + +A <deny> element appears below a <policy> element and prohibits some +action. The <allow> element makes an exception to previous <deny> +statements, and works just like <deny> but with the inverse meaning. + + +The possible attributes of these elements are: + + send_interface="interface_name" + send_member="method_or_signal_name" + send_error="error_name" + send_destination="name" + send_type="method_call" | "method_return" | "signal" | "error" + send_path="/path/name" + + receive_interface="interface_name" + receive_member="method_or_signal_name" + receive_error="error_name" + receive_sender="name" + receive_type="method_call" | "method_return" | "signal" | "error" + receive_path="/path/name" + + send_requested_reply="true" | "false" + receive_requested_reply="true" | "false" + + eavesdrop="true" | "false" + + own="name" + own_prefix="name" + user="username" + group="groupname" + + + +Examples: + + <deny send_interface="org.freedesktop.System" send_member="Reboot"/> + <deny receive_interface="org.freedesktop.System" receive_member="Reboot"/> + <deny own="org.freedesktop.System"/> + <deny send_destination="org.freedesktop.System"/> + <deny receive_sender="org.freedesktop.System"/> + <deny user="john"/> + <deny group="enemies"/> + + + +The <deny> element's attributes determine whether the deny "matches" a +particular action. If it matches, the action is denied (unless later +rules in the config file allow it). + + +send_destination and receive_sender rules mean that messages may not be +sent to or received from the *owner* of the given name, not that +they may not be sent *to that name*. That is, if a connection +owns services A, B, C, and sending to A is denied, sending to B or C +will not work either. + + +The other send_* and receive_* attributes are purely textual/by-value +matches against the given field in the message header. + + +"Eavesdropping" occurs when an application receives a message that +was explicitly addressed to a name the application does not own. +Eavesdropping thus only applies to messages that are addressed to +services (i.e. it does not apply to signals). + + +For <allow>, eavesdrop="true" indicates that the rule matches even +when eavesdropping. eavesdrop="false" is the default and means that +the rule only allows messages to go to their specified recipient. +For <deny>, eavesdrop="true" indicates that the rule matches +only when eavesdropping. eavesdrop="false" is the default for <deny> +also, but here it means that the rule applies always, even when +not eavesdropping. The eavesdrop attribute can only be combined with +receive rules (with receive_* attributes). + + + +The [send|receive]_requested_reply attribute works similarly to the eavesdrop +attribute. It controls whether the <deny> or <allow> matches a reply +that is expected (corresponds to a previous method call message). +This attribute only makes sense for reply messages (errors and method +returns), and is ignored for other message types. + + +For <allow>, [send|receive]_requested_reply="true" is the default and indicates that +only requested replies are allowed by the +rule. [send|receive]_requested_reply="false" means that the rule allows any reply +even if unexpected. + + +For <deny>, [send|receive]_requested_reply="false" is the default but indicates that +the rule matches only when the reply was not +requested. [send|receive]_requested_reply="true" indicates that the rule applies +always, regardless of pending reply state. + + +user and group denials mean that the given user or group may +not connect to the message bus. + + +For "name", "username", "groupname", etc. +the character "*" can be substituted, meaning "any." Complex globs +like "foo.bar.*" aren't allowed for now because they'd be work to +implement and maybe encourage sloppy security anyway. + +<allow own_prefix="a.b"/> allows you to own the name "a.b" or any +name whose first dot-separated elements are "a.b": in particular, +you can own "a.b.c" or "a.b.c.d", but not "a.bc" or "a.c". +This is useful when services like Telepathy and ReserveDevice +define a meaning for subtrees of well-known names, such as +org.freedesktop.Telepathy.ConnectionManager.(anything) +and org.freedesktop.ReserveDevice1.(anything). + +It does not make sense to deny a user or group inside a <policy> +for a user or group; user/group denials can only be inside +context="default" or context="mandatory" policies. + + +A single <deny> rule may specify combinations of attributes such as +send_destination and send_interface and send_type. In this case, the +denial applies only if both attributes match the message being denied. +e.g. <deny send_interface="foo.bar" send_destination="foo.blah"/> would +deny messages with the given interface AND the given bus name. +To get an OR effect you specify multiple <deny> rules. + + +You can't include both send_ and receive_ attributes on the same +rule, since "whether the message can be sent" and "whether it can be +received" are evaluated separately. + + +Be careful with send_interface/receive_interface, because the +interface field in messages is optional. + + + + <selinux> + + + + + + + +The <selinux> element contains settings related to Security Enhanced Linux. +More details below. + + + + <associate> + + + + + + + +An <associate> element appears below an <selinux> element and +creates a mapping. Right now only one kind of association is possible: + + <associate own="org.freedesktop.Foobar" context="foo_t"/> + + + +This means that if a connection asks to own the name +"org.freedesktop.Foobar" then the source context will be the context +of the connection and the target context will be "foo_t" - see the +short discussion of SELinux below. + + +Note, the context here is the target context when requesting a name, +NOT the context of the connection owning the name. + + +There's currently no way to set a default for owning any name, if +we add this syntax it will look like: + + <associate own="*" context="foo_t"/> + +If you find a reason this is useful, let the developers know. +Right now the default will be the security context of the bus itself. + + +If two <associate> elements specify the same name, the element +appearing later in the configuration file will be used. + + + +SELinux +See http://www.nsa.gov/selinux/ for full details on SELinux. Some useful excerpts: + + +Every subject (process) and object (e.g. file, socket, IPC object, +etc) in the system is assigned a collection of security attributes, +known as a security context. A security context contains all of the +security attributes associated with a particular subject or object +that are relevant to the security policy. + + +In order to better encapsulate security contexts and to provide +greater efficiency, the policy enforcement code of SELinux typically +handles security identifiers (SIDs) rather than security contexts. A +SID is an integer that is mapped by the security server to a security +context at runtime. + + +When a security decision is required, the policy enforcement code +passes a pair of SIDs (typically the SID of a subject and the SID of +an object, but sometimes a pair of subject SIDs or a pair of object +SIDs), and an object security class to the security server. The object +security class indicates the kind of object, e.g. a process, a regular +file, a directory, a TCP socket, etc. + + +Access decisions specify whether or not a permission is granted for a +given pair of SIDs and class. Each object class has a set of +associated permissions defined to control operations on objects with +that class. + + +D-Bus performs SELinux security checks in two places. + + +First, any time a message is routed from one connection to another +connection, the bus daemon will check permissions with the security context of +the first connection as source, security context of the second connection +as target, object class "dbus" and requested permission "send_msg". + + +If a security context is not available for a connection +(impossible when using UNIX domain sockets), then the target +context used is the context of the bus daemon itself. +There is currently no way to change this default, because we're +assuming that only UNIX domain sockets will be used to +connect to the systemwide bus. If this changes, we'll +probably add a way to set the default connection context. + + +Second, any time a connection asks to own a name, +the bus daemon will check permissions with the security +context of the connection as source, the security context specified +for the name in the config file as target, object +class "dbus" and requested permission "acquire_svc". + + +The security context for a bus name is specified with the +<associate> element described earlier in this document. +If a name has no security context associated in the +configuration file, the security context of the bus daemon +itself will be used. + + + +AUTHOR +See http://www.freedesktop.org/software/dbus/doc/AUTHORS + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + diff --git a/doc/dbus-launch.1.xml b/doc/dbus-launch.1.xml new file mode 100644 index 00000000..dc34898f --- /dev/null +++ b/doc/dbus-launch.1.xml @@ -0,0 +1,240 @@ + + + + + + + + + +dbus-launch +1 + + +dbus-launch +Utility to start a message bus from a shell script + + + + + dbus-launch --version + --sh-syntax + --csh-syntax + --auto-syntax + --exit-with-session + --autolaunch=MACHINEID + --config-file=FILENAME + PROGRAM + ARGS + + + + + +DESCRIPTION +The dbus-launch command is used to start a session bus +instance of dbus-daemon from a shell script. +It would normally be called from a user's login +scripts. Unlike the daemon itself, dbus-launch exits, so +backticks or the $() construct can be used to read information from +dbus-launch. + +With no arguments, dbus-launch will launch a session bus +instance and print the address and pid of that instance to standard +output. + +You may specify a program to be run; in this case, dbus-launch +will launch a session bus instance, set the appropriate environment +variables so the specified program can find the bus, and then execute the +specified program, with the specified arguments. See below for +examples. + +If you launch a program, dbus-launch will not print the +information about the new bus to standard output. + +When dbus-launch prints bus information to standard output, by +default it is in a simple key-value pairs format. However, you may +request several alternate syntaxes using the --sh-syntax, --csh-syntax, +--binary-syntax, or +--auto-syntax options. Several of these cause dbus-launch to emit shell code +to set up the environment. + +With the --auto-syntax option, dbus-launch looks at the value +of the SHELL environment variable to determine which shell syntax +should be used. If SHELL ends in "csh", then csh-compatible code is +emitted; otherwise Bourne shell code is emitted. Instead of passing +--auto-syntax, you may explicity specify a particular one by using +--sh-syntax for Bourne syntax, or --csh-syntax for csh syntax. +In scripts, it's more robust to avoid --auto-syntax and you hopefully +know which shell your script is written in. + + +See http://www.freedesktop.org/software/dbus/ for more information +about D-Bus. See also the man page for dbus-daemon. + + +Here is an example of how to use dbus-launch with an +sh-compatible shell to start the per-session bus daemon: + + + ## test for an existing bus daemon, just to be safe + if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then + ## if not found, launch a new one + eval `dbus-launch --sh-syntax --exit-with-session` + echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" + fi + + +You might run something like that in your login scripts. + + +Another way to use dbus-launch is to run your main session +program, like so: + + +dbus-launch gnome-session + + +The above would likely be appropriate for ~/.xsession or ~/.Xclients. + + + +AUTOMATIC LAUNCHING +If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use +D-Bus, by default the process will attempt to invoke dbus-launch with +the --autolaunch option to start up a new session bus or find the +existing bus address on the X display or in a file in +~/.dbus/session-bus/ + + +Whenever an autolaunch occurs, the application that had to +start a new bus will be in its own little world; it can effectively +end up starting a whole new session if it tries to use a lot of +bus services. This can be suboptimal or even totally broken, depending +on the app and what it tries to do. + + +There are two common reasons for autolaunch. One is ssh to a remote +machine. The ideal fix for that would be forwarding of +DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded. +In the meantime, you can edit the session.conf config file to +have your session bus listen on TCP, and manually set +DBUS_SESSION_BUS_ADDRESS, if you like. + + +The second common reason for autolaunch is an su to another user, and +display of X applications running as the second user on the display +belonging to the first user. Perhaps the ideal fix in this case +would be to allow the second user to connect to the session bus of the +first user, just as they can connect to the first user's display. +However, a mechanism for that has not been coded. + + +You can always avoid autolaunch by manually setting +DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default +address if none is set is "autolaunch:", so if any other address is +set there will be no autolaunch. You can however include autolaunch in +an explicit session bus address as a fallback, for example +DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if +the first address doesn't work, processes will autolaunch. (The bus +address variable contains a comma-separated list of addresses to try.) + + +The --autolaunch option is considered an internal implementation +detail of libdbus, and in fact there are plans to change it. There's +no real reason to use it outside of the libdbus implementation anyhow. + + + +OPTIONS +The following options are supported: + + + + +Choose --csh-syntax or --sh-syntax based on the SHELL environment variable. + + +Write to stdout a nul-terminated bus address, then the bus PID as a +binary integer of size sizeof(pid_t), then the bus X window ID as a +binary integer of size sizeof(long). Integers are in the machine's +byte order, not network byte order or any other canonical byte order. + + + + + + +Close the standard error output stream before starting the D-Bus +daemon. This is useful if you want to capture dbus-launch error +messages but you don't want dbus-daemon to keep the stream open to +your application. + + + + + + +Pass --config-file=FILENAME to the bus daemon, instead of passing it +the --session argument. See the man page for dbus-daemon + + + + + + +Emit csh compatible code to set up environment variables. + + + + + + +If this option is provided, a persistent "babysitter" process will be +created that watches stdin for HUP and tries to connect to the X +server. If this process gets a HUP on stdin or loses its X connection, +it kills the message bus daemon. + + + + + + +This option implies that dbus-launch should scan for a +previously-started session and reuse the values found there. If no +session is found, it will start a new session. The +--exit-with-session option is implied if --autolaunch is given. +This option is for the exclusive use of libdbus, you do not want to +use it manually. It may change in the future. + + + + + + +Emit Bourne-shell compatible code to set up environment variables. + + + + + + +Print the version of dbus-launch + + + + + + +AUTHOR +See http://www.freedesktop.org/software/dbus/doc/AUTHORS + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + diff --git a/doc/dbus-monitor.1.xml b/doc/dbus-monitor.1.xml new file mode 100644 index 00000000..b41cace2 --- /dev/null +++ b/doc/dbus-monitor.1.xml @@ -0,0 +1,121 @@ + + + + + + + + + +dbus-monitor +1 + + +dbus-monitor +debug probe to print message bus messages + + + + + dbus-monitor + --system --session --address ADDRESS + --profile --monitor + watchexpressions + + + + + +DESCRIPTION +The dbus-monitor command is used to monitor messages going +through a D-Bus message bus. See +http://www.freedesktop.org/software/dbus/ for more information about +the big picture. + + +There are two well-known message buses: the systemwide message bus +(installed on many systems as the "messagebus" service) and the +per-user-login-session message bus (started each time a user logs in). +The --system and --session options direct dbus-monitor to +monitor the system or session buses respectively. If neither is +specified, dbus-monitor monitors the session bus. + + +dbus-monitor has two different output modes, the 'classic'-style +monitoring mode and profiling mode. The profiling format is a compact +format with a single line per message and microsecond-resolution timing +information. The --profile and --monitor options select the profiling +and monitoring output format respectively. If neither is specified, +dbus-monitor uses the monitoring output format. + + +In order to get dbus-monitor to see the messages you are interested +in, you should specify a set of watch expressions as you would expect to +be passed to the dbus_bus_add_match function. + + +The message bus configuration may keep dbus-monitor from seeing +all messages, especially if you run the monitor as a non-root user. + + + +OPTIONS + + + + +Monitor the system message bus. + + + + + +Monitor the session message bus. (This is the default.) + + + + + +Monitor an arbitrary message bus given at ADDRESS. + + + + + +Use the profiling output format. + + + + + +Use the monitoring output format. (This is the default.) + + + + + + +EXAMPLE +Here is an example of using dbus-monitor to watch for the gnome typing +monitor to say things + + + dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" + + + + + +AUTHOR +dbus-monitor was written by Philip Blundell. +The profiling output mode was added by Olli Salli. + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + diff --git a/doc/dbus-send.1.xml b/doc/dbus-send.1.xml new file mode 100644 index 00000000..7fefc03e --- /dev/null +++ b/doc/dbus-send.1.xml @@ -0,0 +1,143 @@ + + + + + + + + + +dbus-send +1 + + +dbus-send +Send a message to a message bus + + + + + dbus-send + --system --session + --dest=NAME + --print-reply + --type=TYPE + <destination + object + path> + <message + name> + contents + + + + + +DESCRIPTION +The dbus-send command is used to send a message to a D-Bus message +bus. See http://www.freedesktop.org/software/dbus/ for more +information about the big picture. + + +There are two well-known message buses: the systemwide message bus +(installed on many systems as the "messagebus" service) and the +per-user-login-session message bus (started each time a user logs in). +The --system and --session options direct dbus-send to send +messages to the system or session buses respectively. If neither is +specified, dbus-send sends to the session bus. + + +Nearly all uses of dbus-send must provide the --dest argument +which is the name of a connection on the bus to send the message to. If +--dest is omitted, no destination is set. + + +The object path and the name of the message to send must always be +specified. Following arguments, if any, are the message contents +(message arguments). These are given as type-specified values and +may include containers (arrays, dicts, and variants) as described below. + + +<contents> ::= <item> | <container> [ <item> | <container>...] +<item> ::= <type>:<value> +<container> ::= <array> | <dict> | <variant> +<array> ::= array:<type>:<value>[,<value>...] +<dict> ::= dict:<type>:<type>:<key>,<value>[,<key>,<value>...] +<variant> ::= variant:<type>:<value> +<type> ::= string | int16 | uint 16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath + + +D-Bus supports more types than these, but dbus-send currently +does not. Also, dbus-send does not permit empty containers +or nested containers (e.g. arrays of variants). + + +Here is an example invocation: + + + dbus-send --dest=org.freedesktop.ExampleName \ + /org/freedesktop/sample/object/name \ + org.freedesktop.ExampleInterface.ExampleMethod \ + int32:47 string:'hello world' double:65.32 \ + array:string:"1st item","next item","last item" \ + dict:string:int32:"one",1,"two",2,"three",3 \ + variant:int32:-8 \ + objpath:/org/freedesktop/sample/object/name + + + +Note that the interface is separated from a method or signal +name by a dot, though in the actual protocol the interface +and the interface member are separate fields. + + + +OPTIONS +The following options are supported: + + + + +Specify the name of the connection to receive the message. + + + + + +Block for a reply to the message sent, and print any reply received. + + + + + +Send to the system message bus. + + + + + +Send to the session message bus. (This is the default.) + + + + + +Specify "method_call" or "signal" (defaults to "signal"). + + + + + + +AUTHOR +dbus-send was written by Philip Blundell. + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + -- cgit v1.2.1 From 60cf73ce6482ae89fdf1777f3c7f8f767b36a278 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 5 Feb 2013 02:19:28 +0100 Subject: Updated man docbook xml sources from man page source using doclifter. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Simon McVittie --- cmake/doc/CMakeLists.txt | 2 + doc/dbus-cleanup-sockets.1.xml | 64 +++++ doc/dbus-daemon.1.xml.in | 582 +++++++++++++++++++++++++---------------- doc/dbus-launch.1.xml | 78 ++++-- doc/dbus-monitor.1.xml | 12 +- doc/dbus-send.1.xml | 72 +++-- doc/dbus-uuidgen.1.xml | 125 +++++++++ 7 files changed, 653 insertions(+), 282 deletions(-) create mode 100644 doc/dbus-cleanup-sockets.1.xml create mode 100644 doc/dbus-uuidgen.1.xml diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index 3c6d9525..a0bb361f 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -102,6 +102,8 @@ DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml html-nochunks) +DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml html-nochunks) +DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml html-nochunks) # # handle html index file diff --git a/doc/dbus-cleanup-sockets.1.xml b/doc/dbus-cleanup-sockets.1.xml new file mode 100644 index 00000000..190b68a0 --- /dev/null +++ b/doc/dbus-cleanup-sockets.1.xml @@ -0,0 +1,64 @@ + + + + + + + + +dbus-cleanup-sockets +1 + + +dbus-cleanup-sockets +clean up leftover sockets in a directory + + + + + dbus-cleanup-sockets DIRECTORY + + + + + +DESCRIPTION +The dbus-cleanup-sockets command cleans up unused D-Bus +connection sockets. See http://www.freedesktop.org/software/dbus/ for +more information about the big picture. + + +If given no arguments, dbus-cleanup-sockets cleans up sockets +in the standard default socket directory for the +per-user-login-session message bus; this is usually /tmp. +Optionally, you can pass a different directory on the command line. + + +On Linux, this program is essentially useless, because D-Bus defaults +to using "abstract sockets" that exist only in memory and don't have a +corresponding file in /tmp. + + +On most other flavors of UNIX, it's possible for the socket files to +leak when programs using D-Bus exit abnormally or without closing +their D-Bus connections. Thus, it might be interesting to run +dbus-cleanup-sockets in a cron job to mop up any leaked sockets. +Or you can just ignore the leaked sockets, they aren't really hurting +anything, other than cluttering the output of "ls /tmp" + + + +AUTHOR +dbus-cleanup-sockets was adapted by Havoc Pennington from +linc-cleanup-sockets written by Michael Meeks. + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index f331699c..bc602bbf 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -1,17 +1,17 @@ - + - - - - + + + dbus-daemon 1 - + dbus-daemon Message bus daemon @@ -41,35 +41,29 @@ application that uses this library to implement a message bus daemon. Multiple programs connect to the message bus daemon and can exchange messages with one another. - -There are two standard message bus instances: the systemwide message bus -(installed on many systems as the "messagebus" init service) and the +There are two standard message bus instances: the systemwide message bus +(installed on many systems as the "messagebus" init service) and the per-user-login-session message bus (started each time a user logs in). -dbus-daemon is used for both of these instances, but with +dbus-daemon is used for both of these instances, but with a different configuration file. - The --session option is equivalent to -"--config-file=/etc/dbus-1/session.conf" and the --system +"--config-file=@EXPANDED_SYSCONFDIR@/dbus-1/session.conf" and the --system option is equivalent to -"--config-file=/etc/dbus-1/system.conf". By creating +"--config-file=@EXPANDED_SYSCONFDIR@/dbus-1/system.conf". By creating additional configuration files and using the --config-file option, additional special-purpose message bus daemons could be created. +The systemwide daemon is normally launched by an init script, +standardly called simply "messagebus". -The systemwide daemon is normally launched by an init script, -standardly called simply "messagebus". - - -The systemwide daemon is largely used for broadcasting system events, +The systemwide daemon is largely used for broadcasting system events, such as changes to the printer queue, or adding/removing devices. - -The per-session daemon is used for various interprocess communication -among desktop applications (however, it is not tied to X or the GUI +The per-session daemon is used for various interprocess communication +among desktop applications (however, it is not tied to X or the GUI in any way). - SIGHUP will cause the D-Bus daemon to PARTIALLY reload its configuration file and to flush its user/group information caches. Some configuration changes would require kicking all apps off the bus; so they will @@ -90,25 +84,28 @@ with SIGHUP. -Force the message bus to fork and become a daemon, even if +Force the message bus to fork and become a daemon, even if the configuration file does not specify that it should. In most contexts the configuration file already gets this -right, though. +right, though. + +Force the message bus not to fork and become a daemon, even if +the configuration file specifies that it should. -Print the address of the message bus to standard output, or -to the given file descriptor. This is used by programs that +Print the address of the message bus to standard output, or +to the given file descriptor. This is used by programs that launch the message bus. -Print the process ID of the message bus to standard output, or -to the given file descriptor. This is used by programs that +Print the process ID of the message bus to standard output, or +to the given file descriptor. This is used by programs that launch the message bus. @@ -129,6 +126,33 @@ bus. Print the version of the daemon. + + + + + +Print the introspection information for all D-Bus internal interfaces. + + + + + +Set the address to listen on. This option overrides the address +configured in the configuration file. + + + + + +Enable systemd-style service activation. Only useful in conjunction +with the systemd system and session manager on Linux. + + + + + +Don't write a PID file even if one is configured in the configuration +files. @@ -137,23 +161,20 @@ bus. CONFIGURATION FILE A message bus daemon has a configuration file that specializes it -for a particular application. For example, one configuration -file might set up the message bus to be a systemwide message bus, +for a particular application. For example, one configuration +file might set up the message bus to be a systemwide message bus, while another might set it up to be a per-user-login-session bus. - The configuration file also establishes resource limits, security parameters, and so forth. - The configuration file is not part of any interoperability specification and its backward compatibility is not guaranteed; this document is documentation, not specification. - The standard systemwide and per-session message bus setups are -configured in the files "/etc/dbus-1/system.conf" and -"/etc/dbus-1/session.conf". These files normally +configured in the files "@EXPANDED_SYSCONFDIR@/dbus-1/system.conf" and +"@EXPANDED_SYSCONFDIR@/dbus-1/session.conf". These files normally <include> a system-local.conf or session-local.conf; you can put local overrides in those files to avoid modifying the primary configuration files. @@ -171,43 +192,50 @@ doctype declaration: The following elements may be present in the configuration file. - - - <busconfig> - - - - - + + + <busconfig> + + + Root element. - - - <type> - + - - - - + <type> + + + The well-known type of the message bus. Currently known values are "system" and "session"; if other values are set, they should be either added to the D-Bus specification, or namespaced. The last -<type> element "wins" (previous values are ignored). +<type> element "wins" (previous values are ignored). This element +only controls which message bus specific environment variables are +set in activated clients. Most of the policy that distinguishes a +session bus from the system bus is controlled from the other elements +in the configuration file. + + +If the well-known type of the message bus is "session", then the +DBUS_STARTER_BUS_TYPE environment variable will be set to "session" +and the DBUS_SESSION_BUS_ADDRESS environment variable will be set +to the address of the session bus. Likewise, if the type of the +message bus is "system", then the DBUS_STARTER_BUS_TYPE environment +variable will be set to "system" and the DBUS_SESSION_BUS_ADDRESS +environment variable will be set to the address of the system bus +(which is normally well known anyway). Example: <type>session</type> - - - <include> - - - - - + + + <include> + + + Include a file <include>filename.conf</include> at this point. If the filename is relative, it is located relative to the configuration file @@ -215,19 +243,16 @@ doing the including. <include> has an optional attribute "ignore_missing=(yes|no)" -which defaults to "no" if not provided. This attribute -controls whether it's a fatal error for the included file +which defaults to "no" if not provided. This attribute +controls whether it's a fatal error for the included file to be absent. - - - <includedir> - + - - - - + <includedir> + + + Include all files in <includedir>foo.d</includedir> at this point. Files in the directory are included in undefined order. @@ -237,18 +262,15 @@ Only files ending in ".conf" are included. This is intended to allow extension of the system bus by particular packages. For example, if CUPS wants to be able to send out notification of printer queue changes, it could install a file to -/etc/dbus-1/system.d that allowed all apps to receive +@EXPANDED_SYSCONFDIR@/dbus-1/system.d that allowed all apps to receive this message and allowed the printer daemon user to send it. - - - <user> - + - - - - + <user> + + + The user account the daemon should run as, as either a username or a UID. If the daemon cannot change to this UID on startup, it will exit. @@ -261,97 +283,127 @@ about its UID. The user is changed after the bus has completed initialization. So sockets etc. will be created before changing user, but no data will be -read from clients before changing user. This means that sockets -and PID files can be created in a location that requires root +read from clients before changing user. This means that sockets +and PID files can be created in a location that requires root privileges for writing. - - - <fork> - - - - - + -If present, the bus daemon becomes a real daemon (forks -into the background, etc.). This is generally used + <fork> + + + + +If present, the bus daemon becomes a real daemon (forks +into the background, etc.). This is generally used rather than the --fork command line option. - - - <listen> - + - - - - + <keep_umask> + + + + +If present, the bus daemon keeps its original umask when forking. +This may be useful to avoid affecting the behavior of child processes. + + -Add an address that the bus should listen on. The -address is in the standard D-Bus format that contains + <listen> + + + + +Add an address that the bus should listen on. The +address is in the standard D-Bus format that contains a transport name plus possible parameters/options. Example: <listen>unix:path=/tmp/foo</listen> -If there are multiple <listen> elements, then the bus listens -on multiple addresses. The bus will pass its address to -started services or other interested parties with -the last address given in <listen> first. That is, +Example: <listen>tcp:host=localhost,port=1234</listen> + + +If there are multiple <listen> elements, then the bus listens +on multiple addresses. The bus will pass its address to +started services or other interested parties with +the last address given in <listen> first. That is, apps will try to connect to the last <listen> address first. - - - <auth> - - - - - +tcp sockets can accept IPv4 addresses, IPv6 addresses or hostnames. +If a hostname resolves to multiple addresses, the server will bind +to all of them. The family=ipv4 or family=ipv6 options can be used +to force it to bind to a subset of addresses + + +Example: <listen>tcp:host=localhost,port=0,family=ipv4</listen> + + +A special case is using a port number of zero (or omitting the port), +which means to choose an available port selected by the operating +system. The port number chosen can be obtained with the +--print-address command line parameter and will be present in other +cases where the server reports its own address, such as when +DBUS_SESSION_BUS_ADDRESS is set. + + +Example: <listen>tcp:host=localhost,port=0</listen> + + +tcp addresses also allow a bind=hostname option, which will override +the host option specifying what address to bind to, without changing +the address reported by the bus. The bind option can also take a +special name '*' to cause the bus to listen on all local address +(INADDR_ANY). The specified host should be a valid name of the local +machine or weird stuff will happen. + + +Example: <listen>tcp:host=localhost,bind=*,port=0</listen> + + + + <auth> + + + Lists permitted authorization mechanisms. If this element doesn't exist, then all known mechanisms are allowed. If there are multiple <auth> elements, all the listed mechanisms are allowed. The order in which mechanisms are listed is not meaningful. - + Example: <auth>EXTERNAL</auth> Example: <auth>DBUS_COOKIE_SHA1</auth> - - - <servicedir> - + - - - - + <servicedir> + + + Adds a directory to scan for .service files. Directories are -scanned starting with the last to appear in the config file -(the first .service file found that provides a particular +scanned starting with the last to appear in the config file +(the first .service file found that provides a particular service will be used). Service files tell the bus how to automatically start a program. -They are primarily used with the per-user-session bus, +They are primarily used with the per-user-session bus, not the systemwide bus. - - - <standard_session_servicedirs/> - + - - - - + <standard_session_servicedirs/> + + + <standard_session_servicedirs/> is equivalent to specifying a series of <servicedir/> elements for each of the data directories in the "XDG @@ -367,18 +419,48 @@ otherwise try your favorite search engine. The <standard_session_servicedirs/> option is only relevant to the per-user-session bus daemon defined in -/etc/dbus-1/session.conf. Putting it in any other +@EXPANDED_SYSCONFDIR@/dbus-1/session.conf. Putting it in any other configuration file would probably be nonsense. - - - <limit> - + - - - - + <standard_system_servicedirs/> + + + + +<standard_system_servicedirs/> specifies the standard system-wide +activation directories that should be searched for service files. +This option defaults to @EXPANDED_DATADIR@/dbus-1/system-services. + + +The <standard_system_servicedirs/> option is only relevant to the +per-system bus daemon defined in +@EXPANDED_SYSCONFDIR@/dbus-1/system.conf. Putting it in any other +configuration file would probably be nonsense. + + + + <servicehelper/> + + + + +<servicehelper/> specifies the setuid helper that is used to launch +system daemons with an alternate user. Typically this should be +the dbus-daemon-launch-helper executable in located in libexec. + + +The <servicehelper/> option is only relevant to the per-system bus daemon +defined in @EXPANDED_SYSCONFDIR@/dbus-1/system.conf. Putting it in any other +configuration file would probably be nonsense. + + + + <limit> + + + <limit> establishes a resource limit. For example: @@ -392,31 +474,36 @@ Available limit names are: "max_incoming_bytes" : total size in bytes of messages incoming from a single connection + "max_incoming_unix_fds" : total number of unix fds of messages + incoming from a single connection "max_outgoing_bytes" : total size in bytes of messages queued up for a single connection + "max_outgoing_unix_fds" : total number of unix fds of messages + queued up for a single connection "max_message_size" : max size of a single message in bytes - "service_start_timeout" : milliseconds (thousandths) until + "max_message_unix_fds" : max unix fds of a single message + "service_start_timeout" : milliseconds (thousandths) until a started service has to connect "auth_timeout" : milliseconds (thousandths) a connection is given to authenticate - "max_completed_connections" : max number of authenticated connections + "max_completed_connections" : max number of authenticated connections "max_incomplete_connections" : max number of unauthenticated connections "max_connections_per_user" : max number of completed connections from the same user "max_pending_service_starts" : max number of service launches in progress at the same time - "max_names_per_connection" : max number of names a single + "max_names_per_connection" : max number of names a single connection can own - "max_match_rules_per_connection": max number of match rules for a single + "max_match_rules_per_connection": max number of match rules for a single connection - "max_replies_per_connection" : max number of pending method + "max_replies_per_connection" : max number of pending method replies per connection (number of calls-in-progress) - "reply_timeout" : milliseconds (thousandths) - until a method call times out + "reply_timeout" : milliseconds (thousandths) + until a method call times out @@ -430,49 +517,60 @@ number of users that can work together to denial-of-service all other users by u up all connections on the systemwide bus. -Limits are normally only of interest on the systemwide bus, not the user session +Limits are normally only of interest on the systemwide bus, not the user session buses. - - - <policy> - + - - - - + <policy> + + + The <policy> element defines a security policy to be applied to a particular set of connections to the bus. A policy is made up of <allow> and <deny> elements. Policies are normally used with the systemwide bus; -they are analogous to a firewall in that they allow expected traffic +they are analogous to a firewall in that they allow expected traffic and prevent unexpected traffic. -The <policy> element has one of three attributes: +Currently, the system bus has a default-deny policy for sending method calls +and owning bus names. Everything else, in particular reply messages, receive +checks, and signals has a default allow policy. + + +In general, it is best to keep system services as small, targeted programs which +run in their own process and provide a single bus name. Then, all that is needed +is an <allow> rule for the "own" permission to let the process claim the bus +name, and a "send_destination" rule to allow traffic from some or all uids to +your service. + + +The <policy> element has one of four attributes: context="(default|mandatory)" + at_console="(true|false)" user="username or userid" group="group name or gid" - -Policies are applied to a connection as follows: +Policies are applied to a connection as follows: - all context="default" policies are applied - all group="connection's user's group" policies are applied in undefined order - all user="connection's auth user" policies are applied in undefined order + - all at_console="true" policies are applied + - all at_console="false" policies are applied - all context="mandatory" policies are applied -Policies applied later will override those applied earlier, -when the policies overlap. Multiple policies with the same -user/group/context are applied in the order they appear +Policies applied later will override those applied earlier, +when the policies overlap. Multiple policies with the same +user/group/context are applied in the order they appear in the config file. @@ -493,16 +591,16 @@ statements, and works just like <deny> but with the inverse meaning.The possible attributes of these elements are: send_interface="interface_name" - send_member="method_or_signal_name" - send_error="error_name" - send_destination="name" - send_type="method_call" | "method_return" | "signal" | "error" + send_member="method_or_signal_name" + send_error="error_name" + send_destination="name" + send_type="method_call" | "method_return" | "signal" | "error" send_path="/path/name" receive_interface="interface_name" - receive_member="method_or_signal_name" - receive_error="error_name" - receive_sender="name" + receive_member="method_or_signal_name" + receive_error="error_name" + receive_sender="name" receive_type="method_call" | "method_return" | "signal" | "error" receive_path="/path/name" @@ -520,9 +618,7 @@ statements, and works just like <deny> but with the inverse meaning.Examples: - <deny send_interface="org.freedesktop.System" send_member="Reboot"/> - <deny receive_interface="org.freedesktop.System" receive_member="Reboot"/> - <deny own="org.freedesktop.System"/> + <deny send_destination="org.freedesktop.Service" send_interface="org.freedesktop.System" send_member="Reboot"/> <deny send_destination="org.freedesktop.System"/> <deny receive_sender="org.freedesktop.System"/> <deny user="john"/> @@ -534,34 +630,29 @@ statements, and works just like <deny> but with the inverse meaning. - send_destination and receive_sender rules mean that messages may not be sent to or received from the *owner* of the given name, not that they may not be sent *to that name*. That is, if a connection owns services A, B, C, and sending to A is denied, sending to B or C will not work either. - The other send_* and receive_* attributes are purely textual/by-value matches against the given field in the message header. - "Eavesdropping" occurs when an application receives a message that -was explicitly addressed to a name the application does not own. -Eavesdropping thus only applies to messages that are addressed to -services (i.e. it does not apply to signals). +was explicitly addressed to a name the application does not own, or +is a reply to such a message. Eavesdropping thus only applies to +messages that are addressed to services and replies to such messages +(i.e. it does not apply to signals). - -For <allow>, eavesdrop="true" indicates that the rule matches even -when eavesdropping. eavesdrop="false" is the default and means that +For <allow>, eavesdrop="true" indicates that the rule matches even +when eavesdropping. eavesdrop="false" is the default and means that the rule only allows messages to go to their specified recipient. -For <deny>, eavesdrop="true" indicates that the rule matches +For <deny>, eavesdrop="true" indicates that the rule matches only when eavesdropping. eavesdrop="false" is the default for <deny> -also, but here it means that the rule applies always, even when +also, but here it means that the rule applies always, even when not eavesdropping. The eavesdrop attribute can only be combined with -receive rules (with receive_* attributes). - - +send and receive rules (with send_* and receive_* attributes). The [send|receive]_requested_reply attribute works similarly to the eavesdrop attribute. It controls whether the <deny> or <allow> matches a reply @@ -582,7 +673,7 @@ requested. [send|receive]_requested_reply="true" indicates that the rule applies always, regardless of pending reply state. -user and group denials mean that the given user or group may +user and group denials mean that the given user or group may not connect to the message bus. @@ -591,6 +682,7 @@ the character "*" can be substituted, meaning "any." Complex globs like "foo.bar.*" aren't allowed for now because they'd be work to implement and maybe encourage sloppy security anyway. + <allow own_prefix="a.b"/> allows you to own the name "a.b" or any name whose first dot-separated elements are "a.b": in particular, you can own "a.b.c" or "a.b.c.d", but not "a.bc" or "a.c". @@ -599,6 +691,7 @@ define a meaning for subtrees of well-known names, such as org.freedesktop.Telepathy.ConnectionManager.(anything) and org.freedesktop.ReserveDevice1.(anything). + It does not make sense to deny a user or group inside a <policy> for a user or group; user/group denials can only be inside context="default" or context="mandatory" policies. @@ -617,42 +710,40 @@ rule, since "whether the message can be sent" and "whether it can be received" are evaluated separately. -Be careful with send_interface/receive_interface, because the -interface field in messages is optional. +Be careful with send_interface/receive_interface, because the +interface field in messages is optional. In particular, do NOT +specify <deny send_interface="org.foo.Bar"/>! This will cause +no-interface messages to be blocked for all services, which is +almost certainly not what you intended. Always use rules of +the form: <deny send_interface="org.foo.Bar" send_destination="org.foo.Service"/> - - - <selinux> - + - - - - + <selinux> + + + The <selinux> element contains settings related to Security Enhanced Linux. More details below. - - - <associate> - + - - - - + <associate> + + + An <associate> element appears below an <selinux> element and creates a mapping. Right now only one kind of association is possible: - <associate own="org.freedesktop.Foobar" context="foo_t"/> + <associate own="org.freedesktop.Foobar" context="foo_t"/> This means that if a connection asks to own the name "org.freedesktop.Foobar" then the source context will be the context -of the connection and the target context will be "foo_t" - see the +of the connection and the target context will be "foo_t" - see the short discussion of SELinux below. @@ -663,7 +754,7 @@ NOT the context of the connection owning the name. There's currently no way to set a default for owning any name, if we add this syntax it will look like: - <associate own="*" context="foo_t"/> + <associate own="*" context="foo_t"/> If you find a reason this is useful, let the developers know. Right now the default will be the security context of the bus itself. @@ -715,30 +806,75 @@ the first connection as source, security context of the second connection as target, object class "dbus" and requested permission "send_msg". -If a security context is not available for a connection -(impossible when using UNIX domain sockets), then the target +If a security context is not available for a connection +(impossible when using UNIX domain sockets), then the target context used is the context of the bus daemon itself. -There is currently no way to change this default, because we're -assuming that only UNIX domain sockets will be used to -connect to the systemwide bus. If this changes, we'll +There is currently no way to change this default, because we're +assuming that only UNIX domain sockets will be used to +connect to the systemwide bus. If this changes, we'll probably add a way to set the default connection context. -Second, any time a connection asks to own a name, -the bus daemon will check permissions with the security +Second, any time a connection asks to own a name, +the bus daemon will check permissions with the security context of the connection as source, the security context specified -for the name in the config file as target, object +for the name in the config file as target, object class "dbus" and requested permission "acquire_svc". -The security context for a bus name is specified with the +The security context for a bus name is specified with the <associate> element described earlier in this document. -If a name has no security context associated in the -configuration file, the security context of the bus daemon +If a name has no security context associated in the +configuration file, the security context of the bus daemon itself will be used. +DEBUGGING +If you're trying to figure out where your messages are going or why +you aren't getting messages, there are several things you can try. + +Remember that the system bus is heavily locked down and if you +haven't installed a security policy file to allow your message +through, it won't work. For the session bus, this is not a concern. + +The simplest way to figure out what's happening on the bus is to run +the dbus-monitor program, which comes with the D-Bus +package. You can also send test messages with dbus-send. These +programs have their own man pages. + +If you want to know what the daemon itself is doing, you might consider +running a separate copy of the daemon to test against. This will allow you +to put the daemon under a debugger, or run it with verbose output, without +messing up your real session and system daemons. + +To run a separate test copy of the daemon, for example you might open a terminal +and type: + + DBUS_VERBOSE=1 dbus-daemon --session --print-address + + +The test daemon address will be printed when the daemon starts. You will need +to copy-and-paste this address and use it as the value of the +DBUS_SESSION_BUS_ADDRESS environment variable when you launch the applications +you want to test. This will cause those applications to connect to your +test bus instead of the DBUS_SESSION_BUS_ADDRESS of your real session bus. + +DBUS_VERBOSE=1 will have NO EFFECT unless your copy of D-Bus +was compiled with verbose mode enabled. This is not recommended in +production builds due to performance impact. You may need to rebuild +D-Bus if your copy was not built with debugging in mind. (DBUS_VERBOSE +also affects the D-Bus library and thus applications using D-Bus; it may +be useful to see verbose output on both the client side and from the daemon.) + +If you want to get fancy, you can create a custom bus +configuration for your test bus (see the session.conf and system.conf +files that define the two default configurations for example). This +would allow you to specify a different directory for .service files, +for example. + + + AUTHOR See http://www.freedesktop.org/software/dbus/doc/AUTHORS diff --git a/doc/dbus-launch.1.xml b/doc/dbus-launch.1.xml index dc34898f..ab4d5edf 100644 --- a/doc/dbus-launch.1.xml +++ b/doc/dbus-launch.1.xml @@ -1,17 +1,17 @@ - + - - - + + dbus-launch 1 - + dbus-launch Utility to start a message bus from a shell script @@ -41,7 +41,7 @@ backticks or the $() construct can be used to read information from dbus-launch. With no arguments, dbus-launch will launch a session bus -instance and print the address and pid of that instance to standard +instance and print the address and PID of that instance to standard output. You may specify a program to be run; in this case, dbus-launch @@ -64,7 +64,7 @@ to set up the environment. of the SHELL environment variable to determine which shell syntax should be used. If SHELL ends in "csh", then csh-compatible code is emitted; otherwise Bourne shell code is emitted. Instead of passing ---auto-syntax, you may explicity specify a particular one by using +--auto-syntax, you may explicitly specify a particular one by using --sh-syntax for Bourne syntax, or --csh-syntax for csh syntax. In scripts, it's more robust to avoid --auto-syntax and you hopefully know which shell your script is written in. @@ -73,30 +73,46 @@ know which shell your script is written in. See http://www.freedesktop.org/software/dbus/ for more information about D-Bus. See also the man page for dbus-daemon. + -Here is an example of how to use dbus-launch with an -sh-compatible shell to start the per-session bus daemon: - +EXAMPLES +Distributions running +dbus-launch +as part of a standard X session should run +dbus-launch --exit-with-session +after the X server has started and become available, as a wrapper around +the "main" X client (typically a session manager or window manager), as in +these examples: - ## test for an existing bus daemon, just to be safe - if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then - ## if not found, launch a new one - eval `dbus-launch --sh-syntax --exit-with-session` - echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" - fi +
+dbus-launch --exit-with-session gnome-session - -You might run something like that in your login scripts. +dbus-launch --exit-with-session openbox +dbus-launch --exit-with-session ~/.xsession +
-Another way to use dbus-launch is to run your main session -program, like so: - +If your distribution does not do this, you can achieve similar results +by running your session or window manager in the same way in a script +run by your X session, such as +~/.xsession, +~/.xinitrc +or +~/.Xclients. -dbus-launch gnome-session +To start a D-Bus session within a text-mode session, you can run +dbus-launch in the background. For instance, in a sh-compatible shell: + + ## test for an existing bus daemon, just to be safe + if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then + ## if not found, launch a new one + eval `dbus-launch --sh-syntax` + echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" + fi -The above would likely be appropriate for ~/.xsession or ~/.Xclients. +Note that in this case, dbus-launch will exit, and dbus-daemon will not be +terminated automatically on logout.
@@ -227,6 +243,20 @@ use it manually. It may change in the future. +NOTES +If you run +dbus-launch myapp +(with any other options), dbus-daemon will +not +exit when +myapp +terminates: this is because +myapp +is assumed to be part of a larger session, rather than a session in its +own right. + + + AUTHOR See http://www.freedesktop.org/software/dbus/doc/AUTHORS diff --git a/doc/dbus-monitor.1.xml b/doc/dbus-monitor.1.xml index b41cace2..20e9301e 100644 --- a/doc/dbus-monitor.1.xml +++ b/doc/dbus-monitor.1.xml @@ -1,17 +1,17 @@ - + - - - + + dbus-monitor 1 - + dbus-monitor debug probe to print message bus messages diff --git a/doc/dbus-send.1.xml b/doc/dbus-send.1.xml index 7fefc03e..30d57c5b 100644 --- a/doc/dbus-send.1.xml +++ b/doc/dbus-send.1.xml @@ -1,17 +1,17 @@ - + - - - + + dbus-send 1 - + dbus-send Send a message to a message bus @@ -21,14 +21,12 @@ dbus-send --system --session --dest=NAME - --print-reply + --print-reply =literal + --reply-timeout=MSEC --type=TYPE - <destination - object - path> - <message - name> - contents + OBJECT_PATH + INTERFACE.MEMBER + CONTENTS @@ -43,14 +41,14 @@ information about the big picture. There are two well-known message buses: the systemwide message bus (installed on many systems as the "messagebus" service) and the per-user-login-session message bus (started each time a user logs in). -The --system and --session options direct dbus-send to send -messages to the system or session buses respectively. If neither is -specified, dbus-send sends to the session bus. +The and options direct +dbus-send to send messages to the system or session buses respectively. +If neither is specified, dbus-send sends to the session bus. -Nearly all uses of dbus-send must provide the --dest argument +Nearly all uses of dbus-send must provide the argument which is the name of a connection on the bus to send the message to. If ---dest is omitted, no destination is set. + is omitted, no destination is set. The object path and the name of the message to send must always be @@ -76,13 +74,13 @@ or nested containers (e.g. arrays of variants). Here is an example invocation: - dbus-send --dest=org.freedesktop.ExampleName \ - /org/freedesktop/sample/object/name \ - org.freedesktop.ExampleInterface.ExampleMethod \ - int32:47 string:'hello world' double:65.32 \ - array:string:"1st item","next item","last item" \ - dict:string:int32:"one",1,"two",2,"three",3 \ - variant:int32:-8 \ + dbus-send --dest=org.freedesktop.ExampleName \ + /org/freedesktop/sample/object/name \ + org.freedesktop.ExampleInterface.ExampleMethod \ + int32:47 string:'hello world' double:65.32 \ + array:string:"1st item","next item","last item" \ + dict:string:int32:"one",1,"two",2,"three",3 \ + variant:int32:-8 \ objpath:/org/freedesktop/sample/object/name @@ -97,7 +95,7 @@ and the interface member are separate fields. The following options are supported: - + NAME Specify the name of the connection to receive the message. @@ -105,7 +103,23 @@ and the interface member are separate fields. -Block for a reply to the message sent, and print any reply received. +Block for a reply to the message sent, and print any reply received +in a human-readable form. + + + + + +Block for a reply to the message sent, and print the body of the +reply. If the reply is an object path or a string, it is printed +literally, with no punctuation, escape characters etc. + + + + MSEC + +Wait for a reply for up to MSEC milliseconds. +The default is implementation‐defined, typically 25 seconds. @@ -121,9 +135,9 @@ and the interface member are separate fields.
- + TYPE -Specify "method_call" or "signal" (defaults to "signal"). +Specify method_call or signal (defaults to "signal"). diff --git a/doc/dbus-uuidgen.1.xml b/doc/dbus-uuidgen.1.xml new file mode 100644 index 00000000..3d99ef8e --- /dev/null +++ b/doc/dbus-uuidgen.1.xml @@ -0,0 +1,125 @@ + + + + + + + + +dbus-uuidgen +1 + + +dbus-uuidgen +Utility to generate UUIDs + + + + + dbus-uuidgen --version + --ensure =FILENAME + --get =FILENAME + + + + + +DESCRIPTION +The dbus-uuidgen command generates or reads a universally unique ID. + + +Note that the D-Bus UUID has no relationship to RFC 4122 and does not generate +UUIDs compatible with that spec. Many systems have a separate command +for that (often called "uuidgen"). + + +See http://www.freedesktop.org/software/dbus/ for more information +about D-Bus. + + +The primary usage of dbus-uuidgen is to run in the post-install +script of a D-Bus package like this: + + dbus-uuidgen --ensure + + + +This will ensure that /var/lib/dbus/machine-id exists and has the uuid in it. +It won't overwrite an existing uuid, since this id should remain fixed +for a single machine until the next reboot at least. + + +The important properties of the machine UUID are that 1) it remains +unchanged until the next reboot and 2) it is different for any two +running instances of the OS kernel. That is, if two processes see the +same UUID, they should also see the same shared memory, UNIX domain +sockets, local X displays, localhost.localdomain resolution, process +IDs, and so forth. + + +If you run dbus-uuidgen with no options it just prints a new uuid made +up out of thin air. + + +If you run it with --get, it prints the machine UUID by default, or +the UUID in the specified file if you specify a file. + + +If you try to change an existing machine-id on a running system, it will +probably result in bad things happening. Don't try to change this file. Also, +don't make it the same on two different systems; it needs to be different +anytime there are two different kernels running. + + +The UUID should be different on two different virtual machines, +because there are two different kernels. + + + +OPTIONS +The following options are supported: + + + + +If a filename is not given, defaults to localstatedir/lib/dbus/machine-id +(localstatedir is usually /var). If this file exists and is valid, the +uuid in the file is printed on stdout. Otherwise, the command exits +with a nonzero status. + + + + + + +If a filename is not given, defaults to localstatedir/lib/dbus/machine-id +(localstatedir is usually /var). If this file exists then it will be +validated, and a failure code returned if it contains the wrong thing. +If the file does not exist, it will be created with a new uuid in it. +On success, prints no output. + + + + + + +Print the version of dbus-uuidgen + + + + + + +AUTHOR +See http://www.freedesktop.org/software/dbus/doc/AUTHORS + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + -- cgit v1.2.1 From 6997f56168d35b0bf6f8ea7b1e832ca89c1553e1 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 5 Feb 2013 03:10:59 +0100 Subject: Generate man pages from xml docbook sources for cmake buildsystem. [removed commented line -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Simon McVittie --- cmake/doc/CMakeLists.txt | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index a0bb361f..e79429eb 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -42,28 +42,39 @@ endif () if (DBUS_ENABLE_XML_DOCS) -macro (DOCBOOK _sources _options) +macro (DOCBOOK _sources _format) get_filename_component(_infile ${_sources} ABSOLUTE) get_filename_component(_name ${_infile} NAME) - string(REPLACE ".xml" ".html" _outname ${_name}) - set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname}) + if (${_format} STREQUAL "man") + string(REPLACE ".xml" "" _outname ${_name}) + set(STYLESHEET "${DOCBOOKXSL_DIR}/manpages/docbook.xsl") + else() + string(REPLACE ".xml" ".html" _outname ${_name}) + set(STYLESHEET "${DOCBOOKXSL_DIR}/html/docbook.xsl") + endif () + + set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname}) if (EXISTS ${_sources}) if (MEINPROC4_EXECUTABLE) ADD_CUSTOM_TARGET(${_outname} ALL - ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} - DEPENDS ${_infile} + ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} + DEPENDS ${_infile} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif () if (XMLTO_EXECUTABLE) ADD_CUSTOM_TARGET(${_outname} ALL - ${XMLTO_EXECUTABLE} -vv ${_options} ${_infile} - DEPENDS ${_infile} + ${XMLTO_EXECUTABLE} -vv ${_format} ${_infile} + DEPENDS ${_infile} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif () - install(FILES ${_outfile} DESTINATION share/doc/dbus) + if (${_format} STREQUAL "man") + install(FILES ${_outfile} DESTINATION share/man/man1) + else () + install(FILES ${_outfile} DESTINATION share/doc/dbus) + endif () else () MESSAGE(STATUS "skipping xml doc generating for ${_infile}, file not found") endif () @@ -104,7 +115,14 @@ DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml html-nochunks) - +if (UNIX) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml man) + DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml man) + DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml man) + DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml man) + DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml man) + DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml man) +endif() # # handle html index file # -- cgit v1.2.1 From 644e466b36b623e28884fde1db994769477cf6ce Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Feb 2013 16:01:56 +0000 Subject: Fill in a manual and source for all man pages I only filled in a version for dbus-daemon, whose XML is already generated by configure. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Ralf Habacker Signed-off-by: Simon McVittie --- doc/dbus-cleanup-sockets.1.xml | 2 ++ doc/dbus-daemon.1.xml.in | 3 +++ doc/dbus-launch.1.xml | 2 ++ doc/dbus-monitor.1.xml | 2 ++ doc/dbus-send.1.xml | 2 ++ doc/dbus-uuidgen.1.xml | 2 ++ 6 files changed, 13 insertions(+) diff --git a/doc/dbus-cleanup-sockets.1.xml b/doc/dbus-cleanup-sockets.1.xml index 190b68a0..a147ad88 100644 --- a/doc/dbus-cleanup-sockets.1.xml +++ b/doc/dbus-cleanup-sockets.1.xml @@ -10,6 +10,8 @@ dbus-cleanup-sockets 1 +User Commands +D-Bus dbus-cleanup-sockets diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index bc602bbf..8380f215 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -10,6 +10,9 @@ dbus-daemon 1 +User Commands +D-Bus +@DBUS_VERSION@ dbus-daemon diff --git a/doc/dbus-launch.1.xml b/doc/dbus-launch.1.xml index ab4d5edf..6e6f4960 100644 --- a/doc/dbus-launch.1.xml +++ b/doc/dbus-launch.1.xml @@ -10,6 +10,8 @@ dbus-launch 1 +User Commands +D-Bus dbus-launch diff --git a/doc/dbus-monitor.1.xml b/doc/dbus-monitor.1.xml index 20e9301e..c3d1a972 100644 --- a/doc/dbus-monitor.1.xml +++ b/doc/dbus-monitor.1.xml @@ -10,6 +10,8 @@ dbus-monitor 1 +User Commands +D-Bus dbus-monitor diff --git a/doc/dbus-send.1.xml b/doc/dbus-send.1.xml index 30d57c5b..0988e19f 100644 --- a/doc/dbus-send.1.xml +++ b/doc/dbus-send.1.xml @@ -10,6 +10,8 @@ dbus-send 1 +User Commands +D-Bus dbus-send diff --git a/doc/dbus-uuidgen.1.xml b/doc/dbus-uuidgen.1.xml index 3d99ef8e..ee622353 100644 --- a/doc/dbus-uuidgen.1.xml +++ b/doc/dbus-uuidgen.1.xml @@ -10,6 +10,8 @@ dbus-uuidgen 1 +User Commands +D-Bus dbus-uuidgen -- cgit v1.2.1 From af96b13d57be2b5d2282f800ab04a5ce8f49f45f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Feb 2013 16:01:16 +0000 Subject: Use Docbook XML as the source for all man pages This means we no longer need man2html, which is nice. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Ralf Habacker Signed-off-by: Simon McVittie --- configure.ac | 12 +- doc/.gitignore | 3 +- doc/Makefile.am | 72 ++--- doc/dbus-cleanup-sockets.1 | 43 --- doc/dbus-daemon.1.in | 766 --------------------------------------------- doc/dbus-launch.1 | 211 ------------- doc/dbus-monitor.1 | 78 ----- doc/dbus-send.1 | 109 ------- doc/dbus-uuidgen.1 | 89 ------ 9 files changed, 41 insertions(+), 1342 deletions(-) delete mode 100644 doc/dbus-cleanup-sockets.1 delete mode 100644 doc/dbus-daemon.1.in delete mode 100644 doc/dbus-launch.1 delete mode 100644 doc/dbus-monitor.1 delete mode 100644 doc/dbus-send.1 delete mode 100644 doc/dbus-uuidgen.1 diff --git a/configure.ac b/configure.ac index 1c8b7058..37e33dc5 100644 --- a/configure.ac +++ b/configure.ac @@ -1488,13 +1488,8 @@ fi AM_CONDITIONAL(DBUS_XML_DOCS_ENABLED, test x$enable_xml_docs = xyes) AC_MSG_RESULT($enable_xml_docs) -AC_PATH_PROG([MAN2HTML], [man2html]) -AC_ARG_VAR([MAN2HTML], [Path to man2html (optional)]) -AM_CONDITIONAL(DBUS_HAVE_MAN2HTML, test x$MAN2HTML != x) - AM_CONDITIONAL(DBUS_CAN_UPLOAD_DOCS, - test x$enable_doxygen_docs = xyes -a x$enable_xml_docs = xyes -a \ - x$MAN2HTML != x) + [test x$enable_doxygen_docs = xyes && test x$enable_xml_docs = xyes]) #### Have to go $localstatedir->$prefix/var->/usr/local/var @@ -1815,7 +1810,7 @@ tools/Makefile test/Makefile test/name-test/Makefile doc/Makefile -doc/dbus-daemon.1 +doc/dbus-daemon.1.xml dbus-1.pc dbus-1-uninstalled.pc test/data/valid-config-files/debug-allow-all.conf @@ -1860,8 +1855,7 @@ echo " 32-bit int: ${DBUS_INT32_TYPE} 16-bit int: ${DBUS_INT16_TYPE} Doxygen: ${DOXYGEN:-not found} - xmlto: ${XMLTO:-not found} - man2html: ${MAN2HTML:-not found}" + xmlto: ${XMLTO:-not found}" echo " Rebuilding generated files: ${USE_MAINTAINER_MODE} diff --git a/doc/.gitignore b/doc/.gitignore index 1afe0141..d7c1236c 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -2,6 +2,7 @@ .libs Makefile Makefile.in +*.1 *.1.html *.lo *.la @@ -12,7 +13,7 @@ dbus-specification.html dbus-test-plan.html dbus-tutorial.html dbus-faq.html -dbus-daemon.1 +dbus-daemon.1.xml dbus-docs dbus-docs.tar.gz doxygen.stamp diff --git a/doc/Makefile.am b/doc/Makefile.am index 96f7bc38..4906724a 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,20 +1,27 @@ apidir = @htmldir@/api -# automake normally assumes that man pages are generated files; -# these ones aren't, so we need the dist_ prefix to say that they're -# their own source code -dist_man1_MANS = \ +MAN_XML_FILES = \ + dbus-daemon.1.xml \ + $(NULL) + +DIST_MAN_XML_FILES = \ + dbus-cleanup-sockets.1.xml \ + dbus-daemon.1.xml \ + dbus-launch.1.xml \ + dbus-monitor.1.xml \ + dbus-send.1.xml \ + dbus-uuidgen.1.xml \ + $(NULL) + +if DBUS_XML_DOCS_ENABLED +man1_MANS = \ dbus-cleanup-sockets.1 \ + dbus-daemon.1 \ dbus-launch.1 \ dbus-monitor.1 \ dbus-send.1 \ dbus-uuidgen.1 - -# on the other hand, this one is generated -man1_MANS = \ - dbus-daemon.1 - -MAN_IN_FILES = dbus-daemon.1.in +endif MAN_HTML_FILES = \ dbus-cleanup-sockets.1.html \ @@ -32,6 +39,7 @@ dist_doc_DATA = system-activation.txt # uploaded and distributed, but not installed STATIC_DOCS = \ + $(DIST_MAN_XML_FILES) \ dbus-faq.xml \ dbus-specification.xml \ dbus-test-plan.xml \ @@ -43,8 +51,7 @@ STATIC_DOCS = \ EXTRA_DIST = \ file-boilerplate.c \ doxygen_to_devhelp.xsl \ - $(STATIC_DOCS) \ - $(MAN_IN_FILES) + $(STATIC_DOCS) html_DATA = @@ -59,26 +66,22 @@ STATIC_HTML = \ dist_html_DATA += $(STATIC_HTML) -XMLTO_OUTPUT= \ +XMLTO_HTML = \ dbus-faq.html \ dbus-specification.html \ dbus-test-plan.html \ - dbus-tutorial.html + dbus-tutorial.html \ + $(MAN_HTML_FILES) \ + $(NULL) if DBUS_XML_DOCS_ENABLED -html_DATA += $(XMLTO_OUTPUT) +html_DATA += $(XMLTO_HTML) -dbus-specification.html: dbus-specification.xml +%.html: %.xml $(XMLTO) html-nochunks $< -dbus-test-plan.html: dbus-test-plan.xml - $(XMLTO) html-nochunks $< - -dbus-tutorial.html: dbus-tutorial.xml - $(XMLTO) html-nochunks $< - -dbus-faq.html: dbus-faq.xml - $(XMLTO) html-nochunks $< +%.1: %.1.xml + $(XMLTO) man $< endif if DBUS_DOXYGEN_DOCS_ENABLED @@ -114,13 +117,6 @@ uninstall-local:: rmdir $(DESTDIR)$(apidir) endif -if DBUS_HAVE_MAN2HTML -html_DATA += $(MAN_HTML_FILES) - -%.1.html: %.1 - $(AM_V_GEN)( $(MAN2HTML) < $< > $@.tmp && mv $@.tmp $@ ) -endif - if DBUS_CAN_UPLOAD_DOCS BONUS_FILES = \ $(top_srcdir)/README \ @@ -130,14 +126,15 @@ BONUS_FILES = \ $(top_srcdir)/COPYING \ $(top_srcdir)/ChangeLog -dbus-docs: $(STATIC_DOCS) $(dist_doc_DATA) $(dist_html_DATA) $(MAN_HTML_FILES) $(BONUS_FILES) doxygen.stamp $(XMLTO_OUTPUT) +dbus-docs: $(STATIC_DOCS) $(MAN_XML_FILES) $(dist_doc_DATA) $(dist_html_DATA) $(MAN_HTML_FILES) $(BONUS_FILES) doxygen.stamp $(XMLTO_HTML) $(AM_V_at)rm -rf $@ $@.tmp $(AM_V_GEN)$(MKDIR_P) $@.tmp/api $(AM_V_at)cd $(srcdir) && cp $(STATIC_DOCS) @abs_builddir@/$@.tmp $(AM_V_at)cd $(srcdir) && cp $(dist_doc_DATA) @abs_builddir@/$@.tmp $(AM_V_at)cd $(srcdir) && cp $(STATIC_HTML) @abs_builddir@/$@.tmp - $(AM_V_at)cp $(XMLTO_OUTPUT) @abs_builddir@/$@.tmp + $(AM_V_at)cp $(XMLTO_HTML) @abs_builddir@/$@.tmp $(AM_V_at)cp $(MAN_HTML_FILES) @abs_builddir@/$@.tmp + $(AM_V_at)cp $(MAN_XML_FILES) @abs_builddir@/$@.tmp $(AM_V_at)cp $(BONUS_FILES) @abs_builddir@/$@.tmp $(AM_V_at)cp -r api/html @abs_builddir@/$@.tmp/api $(AM_V_at)mv $@.tmp $@ @@ -164,12 +161,15 @@ maintainer-upload-docs: @false endif +CLEANFILES = \ + $(man1_MANS) \ + $(MAN_XML_FILES) \ + $(XMLTO_HTML) \ + $(NULL) + clean-local: rm -f $(html_DATA) rm -rf api rm -rf dbus-docs dbus-docs.tmp rm -f *.1.html rm -f doxygen.stamp - -maintainer-clean-local: - rm -f $(XMLTO_OUTPUT) diff --git a/doc/dbus-cleanup-sockets.1 b/doc/dbus-cleanup-sockets.1 deleted file mode 100644 index a062d498..00000000 --- a/doc/dbus-cleanup-sockets.1 +++ /dev/null @@ -1,43 +0,0 @@ -.\" -.\" dbus\-cleanup\-sockets manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus\-cleanup\-sockets 1 -.SH NAME -dbus\-cleanup\-sockets \- clean up leftover sockets in a directory -.SH SYNOPSIS -.PP -.B dbus\-cleanup\-sockets [DIRECTORY] - -.SH DESCRIPTION - -The \fIdbus\-cleanup\-sockets\fP command cleans up unused D\-Bus -connection sockets. See http://www.freedesktop.org/software/dbus/ for -more information about the big picture. - -.PP -If given no arguments, \fIdbus\-cleanup\-sockets\fP cleans up sockets -in the standard default socket directory for the -per\-user\-login\-session message bus; this is usually /tmp. -Optionally, you can pass a different directory on the command line. - -.PP -On Linux, this program is essentially useless, because D\-Bus defaults -to using "abstract sockets" that exist only in memory and don't have a -corresponding file in /tmp. - -.PP -On most other flavors of UNIX, it's possible for the socket files to -leak when programs using D\-Bus exit abnormally or without closing -their D\-Bus connections. Thus, it might be interesting to run -dbus\-cleanup\-sockets in a cron job to mop up any leaked sockets. -Or you can just ignore the leaked sockets, they aren't really hurting -anything, other than cluttering the output of "ls /tmp" - -.SH AUTHOR -dbus\-cleanup\-sockets was adapted by Havoc Pennington from -linc\-cleanup\-sockets written by Michael Meeks. - -.SH BUGS -Please send bug reports to the D\-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/doc/dbus-daemon.1.in b/doc/dbus-daemon.1.in deleted file mode 100644 index 53856e91..00000000 --- a/doc/dbus-daemon.1.in +++ /dev/null @@ -1,766 +0,0 @@ -.\" -.\" dbus\-daemon manual page. -.\" Copyright (C) 2003,2008 Red Hat, Inc. -.\" -.TH dbus\-daemon 1 -.SH NAME -dbus\-daemon \- Message bus daemon -.SH SYNOPSIS -.PP -.B dbus\-daemon -dbus\-daemon [\-\-version] [\-\-session] [\-\-system] [\-\-config\-file=FILE] -[\-\-print\-address[=DESCRIPTOR]] [\-\-print\-pid[=DESCRIPTOR]] [\-\-fork] - -.SH DESCRIPTION -\fIdbus\-daemon\fP is the D\-Bus message bus daemon. See -http://www.freedesktop.org/software/dbus/ for more information about -the big picture. D\-Bus is first a library that provides one\-to\-one -communication between any two applications; \fIdbus\-daemon\fP is an -application that uses this library to implement a message bus -daemon. Multiple programs connect to the message bus daemon and can -exchange messages with one another. -.PP -There are two standard message bus instances: the systemwide message bus -(installed on many systems as the "messagebus" init service) and the -per\-user\-login\-session message bus (started each time a user logs in). -\fIdbus\-daemon\fP is used for both of these instances, but with -a different configuration file. -.PP -The \-\-session option is equivalent to -"\-\-config\-file=@EXPANDED_SYSCONFDIR@/dbus\-1/session.conf" and the \-\-system -option is equivalent to -"\-\-config\-file=@EXPANDED_SYSCONFDIR@/dbus\-1/system.conf". By creating -additional configuration files and using the \-\-config\-file option, -additional special\-purpose message bus daemons could be created. -.PP -The systemwide daemon is normally launched by an init script, -standardly called simply "messagebus". -.PP -The systemwide daemon is largely used for broadcasting system events, -such as changes to the printer queue, or adding/removing devices. -.PP -The per\-session daemon is used for various interprocess communication -among desktop applications (however, it is not tied to X or the GUI -in any way). -.PP -SIGHUP will cause the D\-Bus daemon to PARTIALLY reload its -configuration file and to flush its user/group information caches. Some -configuration changes would require kicking all apps off the bus; so they will -only take effect if you restart the daemon. Policy changes should take effect -with SIGHUP. - -.SH OPTIONS -The following options are supported: -.TP -.I "\-\-config\-file=FILE" -Use the given configuration file. -.TP -.I "\-\-fork" -Force the message bus to fork and become a daemon, even if -the configuration file does not specify that it should. -In most contexts the configuration file already gets this -right, though. -.I "\-\-nofork" -Force the message bus not to fork and become a daemon, even if -the configuration file specifies that it should. -.TP -.I "\-\-print\-address[=DESCRIPTOR]" -Print the address of the message bus to standard output, or -to the given file descriptor. This is used by programs that -launch the message bus. -.TP -.I "\-\-print\-pid[=DESCRIPTOR]" -Print the process ID of the message bus to standard output, or -to the given file descriptor. This is used by programs that -launch the message bus. -.TP -.I "\-\-session" -Use the standard configuration file for the per\-login\-session message -bus. -.TP -.I "\-\-system" -Use the standard configuration file for the systemwide message bus. -.TP -.I "\-\-version" -Print the version of the daemon. -.TP -.I "\-\-introspect" -Print the introspection information for all D\-Bus internal interfaces. -.TP -.I "\-\-address[=ADDRESS]" -Set the address to listen on. This option overrides the address -configured in the configuration file. -.TP -.I "\-\-systemd\-activation" -Enable systemd\-style service activation. Only useful in conjunction -with the systemd system and session manager on Linux. -.TP -.I "\-\-nopidfile" -Don't write a PID file even if one is configured in the configuration -files. - -.SH CONFIGURATION FILE - -A message bus daemon has a configuration file that specializes it -for a particular application. For example, one configuration -file might set up the message bus to be a systemwide message bus, -while another might set it up to be a per\-user\-login\-session bus. -.PP -The configuration file also establishes resource limits, security -parameters, and so forth. -.PP -The configuration file is not part of any interoperability -specification and its backward compatibility is not guaranteed; this -document is documentation, not specification. -.PP -The standard systemwide and per\-session message bus setups are -configured in the files "@EXPANDED_SYSCONFDIR@/dbus\-1/system.conf" and -"@EXPANDED_SYSCONFDIR@/dbus\-1/session.conf". These files normally - a system\-local.conf or session\-local.conf; you can put local -overrides in those files to avoid modifying the primary configuration -files. - -.PP -The configuration file is an XML document. It must have the following -doctype declaration: -.nf - - - -.fi - -.PP -The following elements may be present in the configuration file. - -.TP -.I "" - -.PP -Root element. - -.TP -.I "" - -.PP -The well\-known type of the message bus. Currently known values are -"system" and "session"; if other values are set, they should be -either added to the D\-Bus specification, or namespaced. The last - element "wins" (previous values are ignored). This element -only controls which message bus specific environment variables are -set in activated clients. Most of the policy that distinguishes a -session bus from the system bus is controlled from the other elements -in the configuration file. - -.PP -If the well\-known type of the message bus is "session", then the -DBUS_STARTER_BUS_TYPE environment variable will be set to "session" -and the DBUS_SESSION_BUS_ADDRESS environment variable will be set -to the address of the session bus. Likewise, if the type of the -message bus is "system", then the DBUS_STARTER_BUS_TYPE environment -variable will be set to "system" and the DBUS_SESSION_BUS_ADDRESS -environment variable will be set to the address of the system bus -(which is normally well known anyway). - -.PP -Example: session - -.TP -.I "" - -.PP -Include a file filename.conf at this point. If the -filename is relative, it is located relative to the configuration file -doing the including. - -.PP - has an optional attribute "ignore_missing=(yes|no)" -which defaults to "no" if not provided. This attribute -controls whether it's a fatal error for the included file -to be absent. - -.TP -.I "" - -.PP -Include all files in foo.d at this -point. Files in the directory are included in undefined order. -Only files ending in ".conf" are included. - -.PP -This is intended to allow extension of the system bus by particular -packages. For example, if CUPS wants to be able to send out -notification of printer queue changes, it could install a file to -@EXPANDED_SYSCONFDIR@/dbus\-1/system.d that allowed all apps to receive -this message and allowed the printer daemon user to send it. - -.TP -.I "" - -.PP -The user account the daemon should run as, as either a username or a -UID. If the daemon cannot change to this UID on startup, it will exit. -If this element is not present, the daemon will not change or care -about its UID. - -.PP -The last entry in the file "wins", the others are ignored. - -.PP -The user is changed after the bus has completed initialization. So -sockets etc. will be created before changing user, but no data will be -read from clients before changing user. This means that sockets -and PID files can be created in a location that requires root -privileges for writing. - -.TP -.I "" - -.PP -If present, the bus daemon becomes a real daemon (forks -into the background, etc.). This is generally used -rather than the \-\-fork command line option. - -.TP -.I "" - -.PP -If present, the bus daemon keeps its original umask when forking. -This may be useful to avoid affecting the behavior of child processes. - -.TP -.I "" - -.PP -Add an address that the bus should listen on. The -address is in the standard D\-Bus format that contains -a transport name plus possible parameters/options. - -.PP -Example: unix:path=/tmp/foo - -.PP -Example: tcp:host=localhost,port=1234 - -.PP -If there are multiple elements, then the bus listens -on multiple addresses. The bus will pass its address to -started services or other interested parties with -the last address given in first. That is, -apps will try to connect to the last address first. - -.PP -tcp sockets can accept IPv4 addresses, IPv6 addresses or hostnames. -If a hostname resolves to multiple addresses, the server will bind -to all of them. The family=ipv4 or family=ipv6 options can be used -to force it to bind to a subset of addresses - -.PP -Example: tcp:host=localhost,port=0,family=ipv4 - -.PP -A special case is using a port number of zero (or omitting the port), -which means to choose an available port selected by the operating -system. The port number chosen can be obtained with the -\-\-print\-address command line parameter and will be present in other -cases where the server reports its own address, such as when -DBUS_SESSION_BUS_ADDRESS is set. - -.PP -Example: tcp:host=localhost,port=0 - -.PP -tcp addresses also allow a bind=hostname option, which will override -the host option specifying what address to bind to, without changing -the address reported by the bus. The bind option can also take a -special name '*' to cause the bus to listen on all local address -(INADDR_ANY). The specified host should be a valid name of the local -machine or weird stuff will happen. - -.PP -Example: tcp:host=localhost,bind=*,port=0 - -.TP -.I "" - -.PP -Lists permitted authorization mechanisms. If this element doesn't -exist, then all known mechanisms are allowed. If there are multiple - elements, all the listed mechanisms are allowed. The order in -which mechanisms are listed is not meaningful. - -.PP -Example: EXTERNAL - -.PP -Example: DBUS_COOKIE_SHA1 - -.TP -.I "" - -.PP -Adds a directory to scan for .service files. Directories are -scanned starting with the last to appear in the config file -(the first .service file found that provides a particular -service will be used). - -.PP -Service files tell the bus how to automatically start a program. -They are primarily used with the per\-user\-session bus, -not the systemwide bus. - -.TP -.I "" - -.PP - is equivalent to specifying a series -of elements for each of the data directories in the "XDG -Base Directory Specification" with the subdirectory "dbus\-1/services", -so for example "/usr/share/dbus\-1/services" would be among the -directories searched. - -.PP -The "XDG Base Directory Specification" can be found at -http://freedesktop.org/wiki/Standards/basedir\-spec if it hasn't moved, -otherwise try your favorite search engine. - -.PP -The option is only relevant to the -per\-user\-session bus daemon defined in -@EXPANDED_SYSCONFDIR@/dbus\-1/session.conf. Putting it in any other -configuration file would probably be nonsense. - -.TP -.I "" - -.PP - specifies the standard system\-wide -activation directories that should be searched for service files. -This option defaults to @EXPANDED_DATADIR@/dbus\-1/system\-services. - -.PP -The option is only relevant to the -per\-system bus daemon defined in -@EXPANDED_SYSCONFDIR@/dbus\-1/system.conf. Putting it in any other -configuration file would probably be nonsense. - -.TP -.I "" - -.PP - specifies the setuid helper that is used to launch -system daemons with an alternate user. Typically this should be -the dbus\-daemon\-launch\-helper executable in located in libexec. - -.PP -The option is only relevant to the per\-system bus daemon -defined in @EXPANDED_SYSCONFDIR@/dbus\-1/system.conf. Putting it in any other -configuration file would probably be nonsense. - -.TP -.I "" - -.PP - establishes a resource limit. For example: -.nf - 64 - 512 -.fi - -.PP -The name attribute is mandatory. -Available limit names are: -.nf - "max_incoming_bytes" : total size in bytes of messages - incoming from a single connection - "max_incoming_unix_fds" : total number of unix fds of messages - incoming from a single connection - "max_outgoing_bytes" : total size in bytes of messages - queued up for a single connection - "max_outgoing_unix_fds" : total number of unix fds of messages - queued up for a single connection - "max_message_size" : max size of a single message in - bytes - "max_message_unix_fds" : max unix fds of a single message - "service_start_timeout" : milliseconds (thousandths) until - a started service has to connect - "auth_timeout" : milliseconds (thousandths) a - connection is given to - authenticate - "max_completed_connections" : max number of authenticated connections - "max_incomplete_connections" : max number of unauthenticated - connections - "max_connections_per_user" : max number of completed connections from - the same user - "max_pending_service_starts" : max number of service launches in - progress at the same time - "max_names_per_connection" : max number of names a single - connection can own - "max_match_rules_per_connection": max number of match rules for a single - connection - "max_replies_per_connection" : max number of pending method - replies per connection - (number of calls\-in\-progress) - "reply_timeout" : milliseconds (thousandths) - until a method call times out -.fi - -.PP -The max incoming/outgoing queue sizes allow a new message to be queued -if one byte remains below the max. So you can in fact exceed the max -by max_message_size. - -.PP -max_completed_connections divided by max_connections_per_user is the -number of users that can work together to denial\-of\-service all other users by using -up all connections on the systemwide bus. - -.PP -Limits are normally only of interest on the systemwide bus, not the user session -buses. - -.TP -.I "" - -.PP -The element defines a security policy to be applied to a particular -set of connections to the bus. A policy is made up of - and elements. Policies are normally used with the systemwide bus; -they are analogous to a firewall in that they allow expected traffic -and prevent unexpected traffic. - -.PP -Currently, the system bus has a default\-deny policy for sending method calls -and owning bus names. Everything else, in particular reply messages, receive -checks, and signals has a default allow policy. - -.PP -In general, it is best to keep system services as small, targeted programs which -run in their own process and provide a single bus name. Then, all that is needed -is an rule for the "own" permission to let the process claim the bus -name, and a "send_destination" rule to allow traffic from some or all uids to -your service. - -.PP -The element has one of four attributes: -.nf - context="(default|mandatory)" - at_console="(true|false)" - user="username or userid" - group="group name or gid" -.fi - -.PP -Policies are applied to a connection as follows: -.nf - \- all context="default" policies are applied - \- all group="connection's user's group" policies are applied - in undefined order - \- all user="connection's auth user" policies are applied - in undefined order - \- all at_console="true" policies are applied - \- all at_console="false" policies are applied - \- all context="mandatory" policies are applied -.fi - -.PP -Policies applied later will override those applied earlier, -when the policies overlap. Multiple policies with the same -user/group/context are applied in the order they appear -in the config file. - -.TP -.I "" -.I "" - -.PP -A element appears below a element and prohibits some -action. The element makes an exception to previous -statements, and works just like but with the inverse meaning. - -.PP -The possible attributes of these elements are: -.nf - send_interface="interface_name" - send_member="method_or_signal_name" - send_error="error_name" - send_destination="name" - send_type="method_call" | "method_return" | "signal" | "error" - send_path="/path/name" - - receive_interface="interface_name" - receive_member="method_or_signal_name" - receive_error="error_name" - receive_sender="name" - receive_type="method_call" | "method_return" | "signal" | "error" - receive_path="/path/name" - - send_requested_reply="true" | "false" - receive_requested_reply="true" | "false" - - eavesdrop="true" | "false" - - own="name" - own_prefix="name" - user="username" - group="groupname" -.fi - -.PP -Examples: -.nf - - - - - -.fi - -.PP -The element's attributes determine whether the deny "matches" a -particular action. If it matches, the action is denied (unless later -rules in the config file allow it). -.PP -send_destination and receive_sender rules mean that messages may not be -sent to or received from the *owner* of the given name, not that -they may not be sent *to that name*. That is, if a connection -owns services A, B, C, and sending to A is denied, sending to B or C -will not work either. -.PP -The other send_* and receive_* attributes are purely textual/by\-value -matches against the given field in the message header. -.PP -"Eavesdropping" occurs when an application receives a message that -was explicitly addressed to a name the application does not own, or -is a reply to such a message. Eavesdropping thus only applies to -messages that are addressed to services and replies to such messages -(i.e. it does not apply to signals). -.PP -For , eavesdrop="true" indicates that the rule matches even -when eavesdropping. eavesdrop="false" is the default and means that -the rule only allows messages to go to their specified recipient. -For , eavesdrop="true" indicates that the rule matches -only when eavesdropping. eavesdrop="false" is the default for -also, but here it means that the rule applies always, even when -not eavesdropping. The eavesdrop attribute can only be combined with -send and receive rules (with send_* and receive_* attributes). -.PP -The [send|receive]_requested_reply attribute works similarly to the eavesdrop -attribute. It controls whether the or matches a reply -that is expected (corresponds to a previous method call message). -This attribute only makes sense for reply messages (errors and method -returns), and is ignored for other message types. - -.PP -For , [send|receive]_requested_reply="true" is the default and indicates that -only requested replies are allowed by the -rule. [send|receive]_requested_reply="false" means that the rule allows any reply -even if unexpected. - -.PP -For , [send|receive]_requested_reply="false" is the default but indicates that -the rule matches only when the reply was not -requested. [send|receive]_requested_reply="true" indicates that the rule applies -always, regardless of pending reply state. - -.PP -user and group denials mean that the given user or group may -not connect to the message bus. - -.PP -For "name", "username", "groupname", etc. -the character "*" can be substituted, meaning "any." Complex globs -like "foo.bar.*" aren't allowed for now because they'd be work to -implement and maybe encourage sloppy security anyway. - -.PP - allows you to own the name "a.b" or any -name whose first dot-separated elements are "a.b": in particular, -you can own "a.b.c" or "a.b.c.d", but not "a.bc" or "a.c". -This is useful when services like Telepathy and ReserveDevice -define a meaning for subtrees of well-known names, such as -org.freedesktop.Telepathy.ConnectionManager.(anything) -and org.freedesktop.ReserveDevice1.(anything). - -.PP -It does not make sense to deny a user or group inside a -for a user or group; user/group denials can only be inside -context="default" or context="mandatory" policies. - -.PP -A single rule may specify combinations of attributes such as -send_destination and send_interface and send_type. In this case, the -denial applies only if both attributes match the message being denied. -e.g. would -deny messages with the given interface AND the given bus name. -To get an OR effect you specify multiple rules. - -.PP -You can't include both send_ and receive_ attributes on the same -rule, since "whether the message can be sent" and "whether it can be -received" are evaluated separately. - -.PP -Be careful with send_interface/receive_interface, because the -interface field in messages is optional. In particular, do NOT -specify ! This will cause -no\-interface messages to be blocked for all services, which is -almost certainly not what you intended. Always use rules of -the form: - -.TP -.I "" - -.PP -The element contains settings related to Security Enhanced Linux. -More details below. - -.TP -.I "" - -.PP -An element appears below an element and -creates a mapping. Right now only one kind of association is possible: -.nf - -.fi - -.PP -This means that if a connection asks to own the name -"org.freedesktop.Foobar" then the source context will be the context -of the connection and the target context will be "foo_t" \- see the -short discussion of SELinux below. - -.PP -Note, the context here is the target context when requesting a name, -NOT the context of the connection owning the name. - -.PP -There's currently no way to set a default for owning any name, if -we add this syntax it will look like: -.nf - -.fi -If you find a reason this is useful, let the developers know. -Right now the default will be the security context of the bus itself. - -.PP -If two elements specify the same name, the element -appearing later in the configuration file will be used. - -.SH SELinux - -.PP -See http://www.nsa.gov/selinux/ for full details on SELinux. Some useful excerpts: - -.IP "" 8 -Every subject (process) and object (e.g. file, socket, IPC object, -etc) in the system is assigned a collection of security attributes, -known as a security context. A security context contains all of the -security attributes associated with a particular subject or object -that are relevant to the security policy. - -.IP "" 8 -In order to better encapsulate security contexts and to provide -greater efficiency, the policy enforcement code of SELinux typically -handles security identifiers (SIDs) rather than security contexts. A -SID is an integer that is mapped by the security server to a security -context at runtime. - -.IP "" 8 -When a security decision is required, the policy enforcement code -passes a pair of SIDs (typically the SID of a subject and the SID of -an object, but sometimes a pair of subject SIDs or a pair of object -SIDs), and an object security class to the security server. The object -security class indicates the kind of object, e.g. a process, a regular -file, a directory, a TCP socket, etc. - -.IP "" 8 -Access decisions specify whether or not a permission is granted for a -given pair of SIDs and class. Each object class has a set of -associated permissions defined to control operations on objects with -that class. - -.PP -D\-Bus performs SELinux security checks in two places. - -.PP -First, any time a message is routed from one connection to another -connection, the bus daemon will check permissions with the security context of -the first connection as source, security context of the second connection -as target, object class "dbus" and requested permission "send_msg". - -.PP -If a security context is not available for a connection -(impossible when using UNIX domain sockets), then the target -context used is the context of the bus daemon itself. -There is currently no way to change this default, because we're -assuming that only UNIX domain sockets will be used to -connect to the systemwide bus. If this changes, we'll -probably add a way to set the default connection context. - -.PP -Second, any time a connection asks to own a name, -the bus daemon will check permissions with the security -context of the connection as source, the security context specified -for the name in the config file as target, object -class "dbus" and requested permission "acquire_svc". - -.PP -The security context for a bus name is specified with the - element described earlier in this document. -If a name has no security context associated in the -configuration file, the security context of the bus daemon -itself will be used. - -.SH DEBUGGING - -.PP -If you're trying to figure out where your messages are going or why -you aren't getting messages, there are several things you can try. -.PP -Remember that the system bus is heavily locked down and if you -haven't installed a security policy file to allow your message -through, it won't work. For the session bus, this is not a concern. -.PP -The simplest way to figure out what's happening on the bus is to run -the \fIdbus\-monitor\fP program, which comes with the D\-Bus -package. You can also send test messages with \fIdbus\-send\fP. These -programs have their own man pages. -.PP -If you want to know what the daemon itself is doing, you might consider -running a separate copy of the daemon to test against. This will allow you -to put the daemon under a debugger, or run it with verbose output, without -messing up your real session and system daemons. -.PP -To run a separate test copy of the daemon, for example you might open a terminal -and type: -.nf - DBUS_VERBOSE=1 dbus\-daemon \-\-session \-\-print\-address -.fi -.PP -The test daemon address will be printed when the daemon starts. You will need -to copy\-and\-paste this address and use it as the value of the -DBUS_SESSION_BUS_ADDRESS environment variable when you launch the applications -you want to test. This will cause those applications to connect to your -test bus instead of the DBUS_SESSION_BUS_ADDRESS of your real session bus. -.PP -DBUS_VERBOSE=1 will have NO EFFECT unless your copy of D\-Bus -was compiled with verbose mode enabled. This is not recommended in -production builds due to performance impact. You may need to rebuild -D\-Bus if your copy was not built with debugging in mind. (DBUS_VERBOSE -also affects the D\-Bus library and thus applications using D\-Bus; it may -be useful to see verbose output on both the client side and from the daemon.) -.PP -If you want to get fancy, you can create a custom bus -configuration for your test bus (see the session.conf and system.conf -files that define the two default configurations for example). This -would allow you to specify a different directory for .service files, -for example. - -.SH AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - -.SH BUGS -Please send bug reports to the D\-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/doc/dbus-launch.1 b/doc/dbus-launch.1 deleted file mode 100644 index e22a3be0..00000000 --- a/doc/dbus-launch.1 +++ /dev/null @@ -1,211 +0,0 @@ -.\" -.\" dbus\-launch manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus\-launch 1 -.SH NAME -dbus\-launch \- Utility to start a message bus from a shell script -.SH SYNOPSIS -.PP -.B dbus\-launch [\-\-version] [\-\-sh\-syntax] [\-\-csh\-syntax] [\-\-auto\-syntax] [\-\-exit\-with\-session] [\-\-autolaunch=MACHINEID] [\-\-config\-file=FILENAME] [PROGRAM] [ARGS...] - -.SH DESCRIPTION - -The \fIdbus\-launch\fP command is used to start a session bus -instance of \fIdbus\-daemon\fP from a shell script. -It would normally be called from a user's login -scripts. Unlike the daemon itself, \fIdbus\-launch\fP exits, so -backticks or the $() construct can be used to read information from -\fIdbus\-launch\fP. - -With no arguments, \fIdbus\-launch\fP will launch a session bus -instance and print the address and PID of that instance to standard -output. - -You may specify a program to be run; in this case, \fIdbus\-launch\fP -will launch a session bus instance, set the appropriate environment -variables so the specified program can find the bus, and then execute the -specified program, with the specified arguments. See below for -examples. - -If you launch a program, \fIdbus\-launch\fP will not print the -information about the new bus to standard output. - -When \fIdbus\-launch\fP prints bus information to standard output, by -default it is in a simple key\-value pairs format. However, you may -request several alternate syntaxes using the \-\-sh\-syntax, \-\-csh\-syntax, -\-\-binary\-syntax, or -\-\-auto\-syntax options. Several of these cause \fIdbus\-launch\fP to emit shell code -to set up the environment. - -With the \-\-auto\-syntax option, \fIdbus\-launch\fP looks at the value -of the SHELL environment variable to determine which shell syntax -should be used. If SHELL ends in "csh", then csh\-compatible code is -emitted; otherwise Bourne shell code is emitted. Instead of passing -\-\-auto\-syntax, you may explicitly specify a particular one by using -\-\-sh\-syntax for Bourne syntax, or \-\-csh\-syntax for csh syntax. -In scripts, it's more robust to avoid \-\-auto\-syntax and you hopefully -know which shell your script is written in. - -.PP -See http://www.freedesktop.org/software/dbus/ for more information -about D\-Bus. See also the man page for \fIdbus\-daemon\fP. - -.SH EXAMPLES - -Distributions running -.B dbus\-launch -as part of a standard X session should run -.B "dbus\-launch \-\-exit\-with\-session" -after the X server has started and become available, as a wrapper around -the "main" X client (typically a session manager or window manager), as in -these examples: - -.RS -.B "dbus\-launch \-\-exit\-with\-session gnome\-session" - -.B "dbus\-launch \-\-exit\-with\-session openbox" - -.B "dbus\-launch \-\-exit\-with\-session ~/.xsession" -.RE - -If your distribution does not do this, you can achieve similar results -by running your session or window manager in the same way in a script -run by your X session, such as -.BR ~/.xsession , -.B ~/.xinitrc -or -.BR ~/.Xclients . - -To start a D-Bus session within a text-mode session, you can run -dbus-launch in the background. For instance, in a sh-compatible shell: - -.nf - ## test for an existing bus daemon, just to be safe - if test \-z "$DBUS_SESSION_BUS_ADDRESS" ; then - ## if not found, launch a new one - eval `dbus\-launch \-\-sh\-syntax` - echo "D\-Bus per\-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" - fi -.fi -Note that in this case, dbus-launch will exit, and dbus-daemon will not be -terminated automatically on logout. - -.SH AUTOMATIC LAUNCHING - -.PP -If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use -D\-Bus, by default the process will attempt to invoke dbus\-launch with -the \-\-autolaunch option to start up a new session bus or find the -existing bus address on the X display or in a file in -~/.dbus/session\-bus/ - -.PP -Whenever an autolaunch occurs, the application that had to -start a new bus will be in its own little world; it can effectively -end up starting a whole new session if it tries to use a lot of -bus services. This can be suboptimal or even totally broken, depending -on the app and what it tries to do. - -.PP -There are two common reasons for autolaunch. One is ssh to a remote -machine. The ideal fix for that would be forwarding of -DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded. -In the meantime, you can edit the session.conf config file to -have your session bus listen on TCP, and manually set -DBUS_SESSION_BUS_ADDRESS, if you like. - -.PP -The second common reason for autolaunch is an su to another user, and -display of X applications running as the second user on the display -belonging to the first user. Perhaps the ideal fix in this case -would be to allow the second user to connect to the session bus of the -first user, just as they can connect to the first user's display. -However, a mechanism for that has not been coded. - -.PP -You can always avoid autolaunch by manually setting -DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default -address if none is set is "autolaunch:", so if any other address is -set there will be no autolaunch. You can however include autolaunch in -an explicit session bus address as a fallback, for example -DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" \- in that case if -the first address doesn't work, processes will autolaunch. (The bus -address variable contains a comma\-separated list of addresses to try.) - -.PP -The \-\-autolaunch option is considered an internal implementation -detail of libdbus, and in fact there are plans to change it. There's -no real reason to use it outside of the libdbus implementation anyhow. - -.SH OPTIONS -The following options are supported: -.TP -.I "\-\-auto\-syntax" -Choose \-\-csh\-syntax or \-\-sh\-syntax based on the SHELL environment variable. - -.I "\-\-binary\-syntax" -Write to stdout a nul\-terminated bus address, then the bus PID as a -binary integer of size sizeof(pid_t), then the bus X window ID as a -binary integer of size sizeof(long). Integers are in the machine's -byte order, not network byte order or any other canonical byte order. - -.TP -.I "\-\-close\-stderr" -Close the standard error output stream before starting the D\-Bus -daemon. This is useful if you want to capture dbus\-launch error -messages but you don't want dbus\-daemon to keep the stream open to -your application. - -.TP -.I "\-\-config\-file=FILENAME" -Pass \-\-config\-file=FILENAME to the bus daemon, instead of passing it -the \-\-session argument. See the man page for dbus\-daemon - -.TP -.I "\-\-csh\-syntax" -Emit csh compatible code to set up environment variables. - -.TP -.I "\-\-exit\-with\-session" -If this option is provided, a persistent "babysitter" process will be -created that watches stdin for HUP and tries to connect to the X -server. If this process gets a HUP on stdin or loses its X connection, -it kills the message bus daemon. - -.TP -.I "\-\-autolaunch=MACHINEID" -This option implies that \fIdbus\-launch\fP should scan for a -previously\-started session and reuse the values found there. If no -session is found, it will start a new session. The -\-\-exit\-with\-session option is implied if \-\-autolaunch is given. -This option is for the exclusive use of libdbus, you do not want to -use it manually. It may change in the future. - -.TP -.I "\-\-sh\-syntax" -Emit Bourne\-shell compatible code to set up environment variables. - -.TP -.I "\-\-version" -Print the version of dbus\-launch - -.SH NOTES - -If you run -.B "dbus\-launch myapp" -(with any other options), dbus\-daemon will -.I not -exit when -.B myapp -terminates: this is because -.B myapp -is assumed to be part of a larger session, rather than a session in its -own right. - -.SH AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - -.SH BUGS -Please send bug reports to the D\-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/doc/dbus-monitor.1 b/doc/dbus-monitor.1 deleted file mode 100644 index 6282b9eb..00000000 --- a/doc/dbus-monitor.1 +++ /dev/null @@ -1,78 +0,0 @@ -.\" -.\" dbus\-monitor manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus\-monitor 1 -.SH NAME -dbus\-monitor \- debug probe to print message bus messages -.SH SYNOPSIS -.PP -.B dbus\-monitor -[\-\-system | \-\-session | \-\-address ADDRESS] [\-\-profile | \-\-monitor] -[watch expressions] - -.SH DESCRIPTION - -The \fIdbus\-monitor\fP command is used to monitor messages going -through a D\-Bus message bus. See -http://www.freedesktop.org/software/dbus/ for more information about -the big picture. - -.PP -There are two well\-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per\-user\-login\-session message bus (started each time a user logs in). -The \-\-system and \-\-session options direct \fIdbus\-monitor\fP to -monitor the system or session buses respectively. If neither is -specified, \fIdbus\-monitor\fP monitors the session bus. - -.PP -\fIdbus\-monitor\fP has two different output modes, the 'classic'\-style -monitoring mode and profiling mode. The profiling format is a compact -format with a single line per message and microsecond\-resolution timing -information. The \-\-profile and \-\-monitor options select the profiling -and monitoring output format respectively. If neither is specified, -\fIdbus\-monitor\fP uses the monitoring output format. - -.PP -In order to get \fIdbus\-monitor\fP to see the messages you are interested -in, you should specify a set of watch expressions as you would expect to -be passed to the \fIdbus_bus_add_match\fP function. - -.PP -The message bus configuration may keep \fIdbus\-monitor\fP from seeing -all messages, especially if you run the monitor as a non\-root user. - -.SH OPTIONS -.TP -.I "\-\-system" -Monitor the system message bus. -.TP -.I "\-\-session" -Monitor the session message bus. (This is the default.) -.TP -.I "\-\-address ADDRESS" -Monitor an arbitrary message bus given at ADDRESS. -.TP -.I "\-\-profile" -Use the profiling output format. -.TP -.I "\-\-monitor" -Use the monitoring output format. (This is the default.) - -.SH EXAMPLE -Here is an example of using dbus\-monitor to watch for the gnome typing -monitor to say things -.nf - - dbus\-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" - -.fi - -.SH AUTHOR -dbus\-monitor was written by Philip Blundell. -The profiling output mode was added by Olli Salli. - -.SH BUGS -Please send bug reports to the D\-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/doc/dbus-send.1 b/doc/dbus-send.1 deleted file mode 100644 index 131a60df..00000000 --- a/doc/dbus-send.1 +++ /dev/null @@ -1,109 +0,0 @@ -.\" -.\" dbus\-send manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus\-send 1 -.SH NAME -dbus\-send \- Send a message to a message bus -.SH SYNOPSIS -.PP -.B dbus\-send -[\fB\-\-system\fP | \fB\-\-session\fP] -[\fB\-\-dest=\fINAME\fP] -[\fB\-\-print\-reply\fP[\fB=literal\fP]] -[\fB\-\-reply\-timeout=\fIMSEC\fP] -[\fB\-\-type=\fITYPE\fP] -\fIOBJECT_PATH\fP \fIINTERFACE\fB.\fIMEMBER\fP [\fICONTENTS\fP ...] - -.SH DESCRIPTION - -The \fIdbus\-send\fP command is used to send a message to a D\-Bus message -bus. See http://www.freedesktop.org/software/dbus/ for more -information about the big picture. - -.PP -There are two well\-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per\-user\-login\-session message bus (started each time a user logs in). -The \fB\-\-system\fP and \fB\-\-session\fP options direct -\fBdbus\-send\fP to send messages to the system or session buses respectively. -If neither is specified, \fBdbus\-send\fP sends to the session bus. - -.PP -Nearly all uses of \fBdbus\-send\fP must provide the \fB\-\-dest\fP argument -which is the name of a connection on the bus to send the message to. If -\fB\-\-dest\fP is omitted, no destination is set. - -.PP -The object path and the name of the message to send must always be -specified. Following arguments, if any, are the message contents -(message arguments). These are given as type\-specified values and -may include containers (arrays, dicts, and variants) as described below. - -.nf - ::= | [ | ...] - ::= : - ::= | | - ::= array::[,...] - ::= dict:::,[,,...] - ::= variant:: - ::= string | int16 | uint 16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath -.fi - -D\-Bus supports more types than these, but \fBdbus\-send\fP currently -does not. Also, \fBdbus\-send\fP does not permit empty containers -or nested containers (e.g. arrays of variants). - -.PP -Here is an example invocation: -.nf - - dbus\-send \-\-dest=org.freedesktop.ExampleName \\ - /org/freedesktop/sample/object/name \\ - org.freedesktop.ExampleInterface.ExampleMethod \\ - int32:47 string:'hello world' double:65.32 \\ - array:string:"1st item","next item","last item" \\ - dict:string:int32:"one",1,"two",2,"three",3 \\ - variant:int32:\-8 \\ - objpath:/org/freedesktop/sample/object/name - -.fi - -Note that the interface is separated from a method or signal -name by a dot, though in the actual protocol the interface -and the interface member are separate fields. - -.SH OPTIONS -The following options are supported: -.TP -.BI \-\-dest= NAME -Specify the name of the connection to receive the message. -.TP -.B "\-\-print\-reply" -Block for a reply to the message sent, and print any reply received -in a human-readable form. -.TP -.B "\-\-print\-reply=literal" -Block for a reply to the message sent, and print the body of the -reply. If the reply is an object path or a string, it is printed -literally, with no punctuation, escape characters etc. -.TP -.BI \-\-reply\-timeout= MSEC -Wait for a reply for up to \fIMSEC\fP milliseconds. -The default is implementation\(hydefined, typically 25 seconds. -.TP -.B "\-\-system" -Send to the system message bus. -.TP -.B "\-\-session" -Send to the session message bus. (This is the default.) -.TP -.BI \-\-type= TYPE -Specify \fBmethod_call\fP or \fBsignal\fP (defaults to "\fBsignal\fP"). - -.SH AUTHOR -dbus\-send was written by Philip Blundell. - -.SH BUGS -Please send bug reports to the D\-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/doc/dbus-uuidgen.1 b/doc/dbus-uuidgen.1 deleted file mode 100644 index 8ed8dd20..00000000 --- a/doc/dbus-uuidgen.1 +++ /dev/null @@ -1,89 +0,0 @@ -.\" -.\" dbus\-uuidgen manual page. -.\" Copyright (C) 2006 Red Hat, Inc. -.\" -.TH dbus\-uuidgen 1 -.SH NAME -dbus\-uuidgen \- Utility to generate UUIDs -.SH SYNOPSIS -.PP -.B dbus\-uuidgen [\-\-version] [\-\-ensure[=FILENAME]] [\-\-get[=FILENAME]] - -.SH DESCRIPTION - -The \fIdbus\-uuidgen\fP command generates or reads a universally unique ID. - -.PP -Note that the D\-Bus UUID has no relationship to RFC 4122 and does not generate -UUIDs compatible with that spec. Many systems have a separate command -for that (often called "uuidgen"). - -.PP -See http://www.freedesktop.org/software/dbus/ for more information -about D\-Bus. - -.PP -The primary usage of \fIdbus\-uuidgen\fP is to run in the post\-install -script of a D\-Bus package like this: -.nf - dbus\-uuidgen \-\-ensure -.fi - -.PP -This will ensure that /var/lib/dbus/machine\-id exists and has the uuid in it. -It won't overwrite an existing uuid, since this id should remain fixed -for a single machine until the next reboot at least. - -.PP -The important properties of the machine UUID are that 1) it remains -unchanged until the next reboot and 2) it is different for any two -running instances of the OS kernel. That is, if two processes see the -same UUID, they should also see the same shared memory, UNIX domain -sockets, local X displays, localhost.localdomain resolution, process -IDs, and so forth. - -.PP -If you run \fIdbus\-uuidgen\fP with no options it just prints a new uuid made -up out of thin air. - -.PP -If you run it with \-\-get, it prints the machine UUID by default, or -the UUID in the specified file if you specify a file. - -.PP -If you try to change an existing machine\-id on a running system, it will -probably result in bad things happening. Don't try to change this file. Also, -don't make it the same on two different systems; it needs to be different -anytime there are two different kernels running. - -.PP -The UUID should be different on two different virtual machines, -because there are two different kernels. - -.SH OPTIONS -The following options are supported: -.TP -.I "\-\-get[=FILENAME]" -If a filename is not given, defaults to localstatedir/lib/dbus/machine\-id -(localstatedir is usually /var). If this file exists and is valid, the -uuid in the file is printed on stdout. Otherwise, the command exits -with a nonzero status. - -.TP -.I "\-\-ensure[=FILENAME]" -If a filename is not given, defaults to localstatedir/lib/dbus/machine\-id -(localstatedir is usually /var). If this file exists then it will be -validated, and a failure code returned if it contains the wrong thing. -If the file does not exist, it will be created with a new uuid in it. -On success, prints no output. - -.TP -.I "\-\-version" -Print the version of dbus\-uuidgen - -.SH AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - -.SH BUGS -Please send bug reports to the D\-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ -- cgit v1.2.1 From 3f2286f13ac900c0eaebd40058277910626aabc1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 14 Feb 2013 13:26:57 +0000 Subject: Turn all man pages' source into configure-generated files Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Ralf Habacker [dropped whitespace changes per Ralf's review -smcv] Signed-off-by: Simon McVittie --- cmake/doc/CMakeLists.txt | 15 ++- configure.ac | 5 + doc/.gitignore | 2 +- doc/Makefile.am | 5 - doc/dbus-cleanup-sockets.1.xml | 66 --------- doc/dbus-cleanup-sockets.1.xml.in | 66 +++++++++ doc/dbus-launch.1.xml | 272 -------------------------------------- doc/dbus-launch.1.xml.in | 272 ++++++++++++++++++++++++++++++++++++++ doc/dbus-monitor.1.xml | 123 ----------------- doc/dbus-monitor.1.xml.in | 123 +++++++++++++++++ doc/dbus-send.1.xml | 159 ---------------------- doc/dbus-send.1.xml.in | 159 ++++++++++++++++++++++ doc/dbus-uuidgen.1.xml | 127 ------------------ doc/dbus-uuidgen.1.xml.in | 127 ++++++++++++++++++ 14 files changed, 763 insertions(+), 758 deletions(-) delete mode 100644 doc/dbus-cleanup-sockets.1.xml create mode 100644 doc/dbus-cleanup-sockets.1.xml.in delete mode 100644 doc/dbus-launch.1.xml create mode 100644 doc/dbus-launch.1.xml.in delete mode 100644 doc/dbus-monitor.1.xml create mode 100644 doc/dbus-monitor.1.xml.in delete mode 100644 doc/dbus-send.1.xml create mode 100644 doc/dbus-send.1.xml.in delete mode 100644 doc/dbus-uuidgen.1.xml create mode 100644 doc/dbus-uuidgen.1.xml.in diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index e79429eb..15c05401 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -108,13 +108,18 @@ DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-test-plan.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-tutorial.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-specification.xml html-nochunks) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-faq.xml html-nochunks) +configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml) configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-daemon.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml) +configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml) +configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml) +configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml) +configure_file(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml.in ${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml) +DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml html-nochunks) DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml html-nochunks) -DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml html-nochunks) +DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml html-nochunks) +DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml html-nochunks) +DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml html-nochunks) +DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml html-nochunks) if (UNIX) DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml man) DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml man) diff --git a/configure.ac b/configure.ac index 37e33dc5..9b578ed4 100644 --- a/configure.ac +++ b/configure.ac @@ -1810,7 +1810,12 @@ tools/Makefile test/Makefile test/name-test/Makefile doc/Makefile +doc/dbus-cleanup-sockets.1.xml doc/dbus-daemon.1.xml +doc/dbus-launch.1.xml +doc/dbus-monitor.1.xml +doc/dbus-send.1.xml +doc/dbus-uuidgen.1.xml dbus-1.pc dbus-1-uninstalled.pc test/data/valid-config-files/debug-allow-all.conf diff --git a/doc/.gitignore b/doc/.gitignore index d7c1236c..708fe36f 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -3,6 +3,7 @@ Makefile Makefile.in *.1 +*.1.xml *.1.html *.lo *.la @@ -13,7 +14,6 @@ dbus-specification.html dbus-test-plan.html dbus-tutorial.html dbus-faq.html -dbus-daemon.1.xml dbus-docs dbus-docs.tar.gz doxygen.stamp diff --git a/doc/Makefile.am b/doc/Makefile.am index 4906724a..35725696 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,10 +1,6 @@ apidir = @htmldir@/api MAN_XML_FILES = \ - dbus-daemon.1.xml \ - $(NULL) - -DIST_MAN_XML_FILES = \ dbus-cleanup-sockets.1.xml \ dbus-daemon.1.xml \ dbus-launch.1.xml \ @@ -39,7 +35,6 @@ dist_doc_DATA = system-activation.txt # uploaded and distributed, but not installed STATIC_DOCS = \ - $(DIST_MAN_XML_FILES) \ dbus-faq.xml \ dbus-specification.xml \ dbus-test-plan.xml \ diff --git a/doc/dbus-cleanup-sockets.1.xml b/doc/dbus-cleanup-sockets.1.xml deleted file mode 100644 index a147ad88..00000000 --- a/doc/dbus-cleanup-sockets.1.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - -dbus-cleanup-sockets -1 -User Commands -D-Bus - - -dbus-cleanup-sockets -clean up leftover sockets in a directory - - - - - dbus-cleanup-sockets DIRECTORY - - - - - -DESCRIPTION -The dbus-cleanup-sockets command cleans up unused D-Bus -connection sockets. See http://www.freedesktop.org/software/dbus/ for -more information about the big picture. - - -If given no arguments, dbus-cleanup-sockets cleans up sockets -in the standard default socket directory for the -per-user-login-session message bus; this is usually /tmp. -Optionally, you can pass a different directory on the command line. - - -On Linux, this program is essentially useless, because D-Bus defaults -to using "abstract sockets" that exist only in memory and don't have a -corresponding file in /tmp. - - -On most other flavors of UNIX, it's possible for the socket files to -leak when programs using D-Bus exit abnormally or without closing -their D-Bus connections. Thus, it might be interesting to run -dbus-cleanup-sockets in a cron job to mop up any leaked sockets. -Or you can just ignore the leaked sockets, they aren't really hurting -anything, other than cluttering the output of "ls /tmp" - - - -AUTHOR -dbus-cleanup-sockets was adapted by Havoc Pennington from -linc-cleanup-sockets written by Michael Meeks. - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/doc/dbus-cleanup-sockets.1.xml.in b/doc/dbus-cleanup-sockets.1.xml.in new file mode 100644 index 00000000..a147ad88 --- /dev/null +++ b/doc/dbus-cleanup-sockets.1.xml.in @@ -0,0 +1,66 @@ + + + + + + + + +dbus-cleanup-sockets +1 +User Commands +D-Bus + + +dbus-cleanup-sockets +clean up leftover sockets in a directory + + + + + dbus-cleanup-sockets DIRECTORY + + + + + +DESCRIPTION +The dbus-cleanup-sockets command cleans up unused D-Bus +connection sockets. See http://www.freedesktop.org/software/dbus/ for +more information about the big picture. + + +If given no arguments, dbus-cleanup-sockets cleans up sockets +in the standard default socket directory for the +per-user-login-session message bus; this is usually /tmp. +Optionally, you can pass a different directory on the command line. + + +On Linux, this program is essentially useless, because D-Bus defaults +to using "abstract sockets" that exist only in memory and don't have a +corresponding file in /tmp. + + +On most other flavors of UNIX, it's possible for the socket files to +leak when programs using D-Bus exit abnormally or without closing +their D-Bus connections. Thus, it might be interesting to run +dbus-cleanup-sockets in a cron job to mop up any leaked sockets. +Or you can just ignore the leaked sockets, they aren't really hurting +anything, other than cluttering the output of "ls /tmp" + + + +AUTHOR +dbus-cleanup-sockets was adapted by Havoc Pennington from +linc-cleanup-sockets written by Michael Meeks. + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + diff --git a/doc/dbus-launch.1.xml b/doc/dbus-launch.1.xml deleted file mode 100644 index 6e6f4960..00000000 --- a/doc/dbus-launch.1.xml +++ /dev/null @@ -1,272 +0,0 @@ - - - - - - - - -dbus-launch -1 -User Commands -D-Bus - - -dbus-launch -Utility to start a message bus from a shell script - - - - - dbus-launch --version - --sh-syntax - --csh-syntax - --auto-syntax - --exit-with-session - --autolaunch=MACHINEID - --config-file=FILENAME - PROGRAM - ARGS - - - - - -DESCRIPTION -The dbus-launch command is used to start a session bus -instance of dbus-daemon from a shell script. -It would normally be called from a user's login -scripts. Unlike the daemon itself, dbus-launch exits, so -backticks or the $() construct can be used to read information from -dbus-launch. - -With no arguments, dbus-launch will launch a session bus -instance and print the address and PID of that instance to standard -output. - -You may specify a program to be run; in this case, dbus-launch -will launch a session bus instance, set the appropriate environment -variables so the specified program can find the bus, and then execute the -specified program, with the specified arguments. See below for -examples. - -If you launch a program, dbus-launch will not print the -information about the new bus to standard output. - -When dbus-launch prints bus information to standard output, by -default it is in a simple key-value pairs format. However, you may -request several alternate syntaxes using the --sh-syntax, --csh-syntax, ---binary-syntax, or ---auto-syntax options. Several of these cause dbus-launch to emit shell code -to set up the environment. - -With the --auto-syntax option, dbus-launch looks at the value -of the SHELL environment variable to determine which shell syntax -should be used. If SHELL ends in "csh", then csh-compatible code is -emitted; otherwise Bourne shell code is emitted. Instead of passing ---auto-syntax, you may explicitly specify a particular one by using ---sh-syntax for Bourne syntax, or --csh-syntax for csh syntax. -In scripts, it's more robust to avoid --auto-syntax and you hopefully -know which shell your script is written in. - - -See http://www.freedesktop.org/software/dbus/ for more information -about D-Bus. See also the man page for dbus-daemon. - - - -EXAMPLES -Distributions running -dbus-launch -as part of a standard X session should run -dbus-launch --exit-with-session -after the X server has started and become available, as a wrapper around -the "main" X client (typically a session manager or window manager), as in -these examples: - -
-dbus-launch --exit-with-session gnome-session - -dbus-launch --exit-with-session openbox - -dbus-launch --exit-with-session ~/.xsession -
- -If your distribution does not do this, you can achieve similar results -by running your session or window manager in the same way in a script -run by your X session, such as -~/.xsession, -~/.xinitrc -or -~/.Xclients. - -To start a D-Bus session within a text-mode session, you can run -dbus-launch in the background. For instance, in a sh-compatible shell: - - - ## test for an existing bus daemon, just to be safe - if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then - ## if not found, launch a new one - eval `dbus-launch --sh-syntax` - echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" - fi - -Note that in this case, dbus-launch will exit, and dbus-daemon will not be -terminated automatically on logout. - -
- -AUTOMATIC LAUNCHING -If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use -D-Bus, by default the process will attempt to invoke dbus-launch with -the --autolaunch option to start up a new session bus or find the -existing bus address on the X display or in a file in -~/.dbus/session-bus/ - - -Whenever an autolaunch occurs, the application that had to -start a new bus will be in its own little world; it can effectively -end up starting a whole new session if it tries to use a lot of -bus services. This can be suboptimal or even totally broken, depending -on the app and what it tries to do. - - -There are two common reasons for autolaunch. One is ssh to a remote -machine. The ideal fix for that would be forwarding of -DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded. -In the meantime, you can edit the session.conf config file to -have your session bus listen on TCP, and manually set -DBUS_SESSION_BUS_ADDRESS, if you like. - - -The second common reason for autolaunch is an su to another user, and -display of X applications running as the second user on the display -belonging to the first user. Perhaps the ideal fix in this case -would be to allow the second user to connect to the session bus of the -first user, just as they can connect to the first user's display. -However, a mechanism for that has not been coded. - - -You can always avoid autolaunch by manually setting -DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default -address if none is set is "autolaunch:", so if any other address is -set there will be no autolaunch. You can however include autolaunch in -an explicit session bus address as a fallback, for example -DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if -the first address doesn't work, processes will autolaunch. (The bus -address variable contains a comma-separated list of addresses to try.) - - -The --autolaunch option is considered an internal implementation -detail of libdbus, and in fact there are plans to change it. There's -no real reason to use it outside of the libdbus implementation anyhow. - - - -OPTIONS -The following options are supported: - - - - -Choose --csh-syntax or --sh-syntax based on the SHELL environment variable. - - -Write to stdout a nul-terminated bus address, then the bus PID as a -binary integer of size sizeof(pid_t), then the bus X window ID as a -binary integer of size sizeof(long). Integers are in the machine's -byte order, not network byte order or any other canonical byte order. - - - - - - -Close the standard error output stream before starting the D-Bus -daemon. This is useful if you want to capture dbus-launch error -messages but you don't want dbus-daemon to keep the stream open to -your application. - - - - - - -Pass --config-file=FILENAME to the bus daemon, instead of passing it -the --session argument. See the man page for dbus-daemon - - - - - - -Emit csh compatible code to set up environment variables. - - - - - - -If this option is provided, a persistent "babysitter" process will be -created that watches stdin for HUP and tries to connect to the X -server. If this process gets a HUP on stdin or loses its X connection, -it kills the message bus daemon. - - - - - - -This option implies that dbus-launch should scan for a -previously-started session and reuse the values found there. If no -session is found, it will start a new session. The ---exit-with-session option is implied if --autolaunch is given. -This option is for the exclusive use of libdbus, you do not want to -use it manually. It may change in the future. - - - - - - -Emit Bourne-shell compatible code to set up environment variables. - - - - - - -Print the version of dbus-launch - - - - - - -NOTES -If you run -dbus-launch myapp -(with any other options), dbus-daemon will -not -exit when -myapp -terminates: this is because -myapp -is assumed to be part of a larger session, rather than a session in its -own right. - - - -AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - -
- diff --git a/doc/dbus-launch.1.xml.in b/doc/dbus-launch.1.xml.in new file mode 100644 index 00000000..6e6f4960 --- /dev/null +++ b/doc/dbus-launch.1.xml.in @@ -0,0 +1,272 @@ + + + + + + + + +dbus-launch +1 +User Commands +D-Bus + + +dbus-launch +Utility to start a message bus from a shell script + + + + + dbus-launch --version + --sh-syntax + --csh-syntax + --auto-syntax + --exit-with-session + --autolaunch=MACHINEID + --config-file=FILENAME + PROGRAM + ARGS + + + + + +DESCRIPTION +The dbus-launch command is used to start a session bus +instance of dbus-daemon from a shell script. +It would normally be called from a user's login +scripts. Unlike the daemon itself, dbus-launch exits, so +backticks or the $() construct can be used to read information from +dbus-launch. + +With no arguments, dbus-launch will launch a session bus +instance and print the address and PID of that instance to standard +output. + +You may specify a program to be run; in this case, dbus-launch +will launch a session bus instance, set the appropriate environment +variables so the specified program can find the bus, and then execute the +specified program, with the specified arguments. See below for +examples. + +If you launch a program, dbus-launch will not print the +information about the new bus to standard output. + +When dbus-launch prints bus information to standard output, by +default it is in a simple key-value pairs format. However, you may +request several alternate syntaxes using the --sh-syntax, --csh-syntax, +--binary-syntax, or +--auto-syntax options. Several of these cause dbus-launch to emit shell code +to set up the environment. + +With the --auto-syntax option, dbus-launch looks at the value +of the SHELL environment variable to determine which shell syntax +should be used. If SHELL ends in "csh", then csh-compatible code is +emitted; otherwise Bourne shell code is emitted. Instead of passing +--auto-syntax, you may explicitly specify a particular one by using +--sh-syntax for Bourne syntax, or --csh-syntax for csh syntax. +In scripts, it's more robust to avoid --auto-syntax and you hopefully +know which shell your script is written in. + + +See http://www.freedesktop.org/software/dbus/ for more information +about D-Bus. See also the man page for dbus-daemon. + + + +EXAMPLES +Distributions running +dbus-launch +as part of a standard X session should run +dbus-launch --exit-with-session +after the X server has started and become available, as a wrapper around +the "main" X client (typically a session manager or window manager), as in +these examples: + +
+dbus-launch --exit-with-session gnome-session + +dbus-launch --exit-with-session openbox + +dbus-launch --exit-with-session ~/.xsession +
+ +If your distribution does not do this, you can achieve similar results +by running your session or window manager in the same way in a script +run by your X session, such as +~/.xsession, +~/.xinitrc +or +~/.Xclients. + +To start a D-Bus session within a text-mode session, you can run +dbus-launch in the background. For instance, in a sh-compatible shell: + + + ## test for an existing bus daemon, just to be safe + if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then + ## if not found, launch a new one + eval `dbus-launch --sh-syntax` + echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" + fi + +Note that in this case, dbus-launch will exit, and dbus-daemon will not be +terminated automatically on logout. + +
+ +AUTOMATIC LAUNCHING +If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use +D-Bus, by default the process will attempt to invoke dbus-launch with +the --autolaunch option to start up a new session bus or find the +existing bus address on the X display or in a file in +~/.dbus/session-bus/ + + +Whenever an autolaunch occurs, the application that had to +start a new bus will be in its own little world; it can effectively +end up starting a whole new session if it tries to use a lot of +bus services. This can be suboptimal or even totally broken, depending +on the app and what it tries to do. + + +There are two common reasons for autolaunch. One is ssh to a remote +machine. The ideal fix for that would be forwarding of +DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded. +In the meantime, you can edit the session.conf config file to +have your session bus listen on TCP, and manually set +DBUS_SESSION_BUS_ADDRESS, if you like. + + +The second common reason for autolaunch is an su to another user, and +display of X applications running as the second user on the display +belonging to the first user. Perhaps the ideal fix in this case +would be to allow the second user to connect to the session bus of the +first user, just as they can connect to the first user's display. +However, a mechanism for that has not been coded. + + +You can always avoid autolaunch by manually setting +DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default +address if none is set is "autolaunch:", so if any other address is +set there will be no autolaunch. You can however include autolaunch in +an explicit session bus address as a fallback, for example +DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if +the first address doesn't work, processes will autolaunch. (The bus +address variable contains a comma-separated list of addresses to try.) + + +The --autolaunch option is considered an internal implementation +detail of libdbus, and in fact there are plans to change it. There's +no real reason to use it outside of the libdbus implementation anyhow. + + + +OPTIONS +The following options are supported: + + + + +Choose --csh-syntax or --sh-syntax based on the SHELL environment variable. + + +Write to stdout a nul-terminated bus address, then the bus PID as a +binary integer of size sizeof(pid_t), then the bus X window ID as a +binary integer of size sizeof(long). Integers are in the machine's +byte order, not network byte order or any other canonical byte order. + + + + + + +Close the standard error output stream before starting the D-Bus +daemon. This is useful if you want to capture dbus-launch error +messages but you don't want dbus-daemon to keep the stream open to +your application. + + + + + + +Pass --config-file=FILENAME to the bus daemon, instead of passing it +the --session argument. See the man page for dbus-daemon + + + + + + +Emit csh compatible code to set up environment variables. + + + + + + +If this option is provided, a persistent "babysitter" process will be +created that watches stdin for HUP and tries to connect to the X +server. If this process gets a HUP on stdin or loses its X connection, +it kills the message bus daemon. + + + + + + +This option implies that dbus-launch should scan for a +previously-started session and reuse the values found there. If no +session is found, it will start a new session. The +--exit-with-session option is implied if --autolaunch is given. +This option is for the exclusive use of libdbus, you do not want to +use it manually. It may change in the future. + + + + + + +Emit Bourne-shell compatible code to set up environment variables. + + + + + + +Print the version of dbus-launch + + + + + + +NOTES +If you run +dbus-launch myapp +(with any other options), dbus-daemon will +not +exit when +myapp +terminates: this is because +myapp +is assumed to be part of a larger session, rather than a session in its +own right. + + + +AUTHOR +See http://www.freedesktop.org/software/dbus/doc/AUTHORS + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + +
+ diff --git a/doc/dbus-monitor.1.xml b/doc/dbus-monitor.1.xml deleted file mode 100644 index c3d1a972..00000000 --- a/doc/dbus-monitor.1.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - -dbus-monitor -1 -User Commands -D-Bus - - -dbus-monitor -debug probe to print message bus messages - - - - - dbus-monitor - --system --session --address ADDRESS - --profile --monitor - watchexpressions - - - - - -DESCRIPTION -The dbus-monitor command is used to monitor messages going -through a D-Bus message bus. See -http://www.freedesktop.org/software/dbus/ for more information about -the big picture. - - -There are two well-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per-user-login-session message bus (started each time a user logs in). -The --system and --session options direct dbus-monitor to -monitor the system or session buses respectively. If neither is -specified, dbus-monitor monitors the session bus. - - -dbus-monitor has two different output modes, the 'classic'-style -monitoring mode and profiling mode. The profiling format is a compact -format with a single line per message and microsecond-resolution timing -information. The --profile and --monitor options select the profiling -and monitoring output format respectively. If neither is specified, -dbus-monitor uses the monitoring output format. - - -In order to get dbus-monitor to see the messages you are interested -in, you should specify a set of watch expressions as you would expect to -be passed to the dbus_bus_add_match function. - - -The message bus configuration may keep dbus-monitor from seeing -all messages, especially if you run the monitor as a non-root user. - - - -OPTIONS - - - - -Monitor the system message bus. - - - - - -Monitor the session message bus. (This is the default.) - - - - - -Monitor an arbitrary message bus given at ADDRESS. - - - - - -Use the profiling output format. - - - - - -Use the monitoring output format. (This is the default.) - - - - - - -EXAMPLE -Here is an example of using dbus-monitor to watch for the gnome typing -monitor to say things - - - dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" - - - - - -AUTHOR -dbus-monitor was written by Philip Blundell. -The profiling output mode was added by Olli Salli. - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/doc/dbus-monitor.1.xml.in b/doc/dbus-monitor.1.xml.in new file mode 100644 index 00000000..c3d1a972 --- /dev/null +++ b/doc/dbus-monitor.1.xml.in @@ -0,0 +1,123 @@ + + + + + + + + +dbus-monitor +1 +User Commands +D-Bus + + +dbus-monitor +debug probe to print message bus messages + + + + + dbus-monitor + --system --session --address ADDRESS + --profile --monitor + watchexpressions + + + + + +DESCRIPTION +The dbus-monitor command is used to monitor messages going +through a D-Bus message bus. See +http://www.freedesktop.org/software/dbus/ for more information about +the big picture. + + +There are two well-known message buses: the systemwide message bus +(installed on many systems as the "messagebus" service) and the +per-user-login-session message bus (started each time a user logs in). +The --system and --session options direct dbus-monitor to +monitor the system or session buses respectively. If neither is +specified, dbus-monitor monitors the session bus. + + +dbus-monitor has two different output modes, the 'classic'-style +monitoring mode and profiling mode. The profiling format is a compact +format with a single line per message and microsecond-resolution timing +information. The --profile and --monitor options select the profiling +and monitoring output format respectively. If neither is specified, +dbus-monitor uses the monitoring output format. + + +In order to get dbus-monitor to see the messages you are interested +in, you should specify a set of watch expressions as you would expect to +be passed to the dbus_bus_add_match function. + + +The message bus configuration may keep dbus-monitor from seeing +all messages, especially if you run the monitor as a non-root user. + + + +OPTIONS + + + + +Monitor the system message bus. + + + + + +Monitor the session message bus. (This is the default.) + + + + + +Monitor an arbitrary message bus given at ADDRESS. + + + + + +Use the profiling output format. + + + + + +Use the monitoring output format. (This is the default.) + + + + + + +EXAMPLE +Here is an example of using dbus-monitor to watch for the gnome typing +monitor to say things + + + dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" + + + + + +AUTHOR +dbus-monitor was written by Philip Blundell. +The profiling output mode was added by Olli Salli. + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + diff --git a/doc/dbus-send.1.xml b/doc/dbus-send.1.xml deleted file mode 100644 index 0988e19f..00000000 --- a/doc/dbus-send.1.xml +++ /dev/null @@ -1,159 +0,0 @@ - - - - - - - - -dbus-send -1 -User Commands -D-Bus - - -dbus-send -Send a message to a message bus - - - - - dbus-send - --system --session - --dest=NAME - --print-reply =literal - --reply-timeout=MSEC - --type=TYPE - OBJECT_PATH - INTERFACE.MEMBER - CONTENTS - - - - - -DESCRIPTION -The dbus-send command is used to send a message to a D-Bus message -bus. See http://www.freedesktop.org/software/dbus/ for more -information about the big picture. - - -There are two well-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per-user-login-session message bus (started each time a user logs in). -The and options direct -dbus-send to send messages to the system or session buses respectively. -If neither is specified, dbus-send sends to the session bus. - - -Nearly all uses of dbus-send must provide the argument -which is the name of a connection on the bus to send the message to. If - is omitted, no destination is set. - - -The object path and the name of the message to send must always be -specified. Following arguments, if any, are the message contents -(message arguments). These are given as type-specified values and -may include containers (arrays, dicts, and variants) as described below. - - -<contents> ::= <item> | <container> [ <item> | <container>...] -<item> ::= <type>:<value> -<container> ::= <array> | <dict> | <variant> -<array> ::= array:<type>:<value>[,<value>...] -<dict> ::= dict:<type>:<type>:<key>,<value>[,<key>,<value>...] -<variant> ::= variant:<type>:<value> -<type> ::= string | int16 | uint 16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath - - -D-Bus supports more types than these, but dbus-send currently -does not. Also, dbus-send does not permit empty containers -or nested containers (e.g. arrays of variants). - - -Here is an example invocation: - - - dbus-send --dest=org.freedesktop.ExampleName \ - /org/freedesktop/sample/object/name \ - org.freedesktop.ExampleInterface.ExampleMethod \ - int32:47 string:'hello world' double:65.32 \ - array:string:"1st item","next item","last item" \ - dict:string:int32:"one",1,"two",2,"three",3 \ - variant:int32:-8 \ - objpath:/org/freedesktop/sample/object/name - - - -Note that the interface is separated from a method or signal -name by a dot, though in the actual protocol the interface -and the interface member are separate fields. - - - -OPTIONS -The following options are supported: - - - NAME - -Specify the name of the connection to receive the message. - - - - - -Block for a reply to the message sent, and print any reply received -in a human-readable form. - - - - - -Block for a reply to the message sent, and print the body of the -reply. If the reply is an object path or a string, it is printed -literally, with no punctuation, escape characters etc. - - - - MSEC - -Wait for a reply for up to MSEC milliseconds. -The default is implementation‐defined, typically 25 seconds. - - - - - -Send to the system message bus. - - - - - -Send to the session message bus. (This is the default.) - - - - TYPE - -Specify method_call or signal (defaults to "signal"). - - - - - - -AUTHOR -dbus-send was written by Philip Blundell. - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/doc/dbus-send.1.xml.in b/doc/dbus-send.1.xml.in new file mode 100644 index 00000000..0988e19f --- /dev/null +++ b/doc/dbus-send.1.xml.in @@ -0,0 +1,159 @@ + + + + + + + + +dbus-send +1 +User Commands +D-Bus + + +dbus-send +Send a message to a message bus + + + + + dbus-send + --system --session + --dest=NAME + --print-reply =literal + --reply-timeout=MSEC + --type=TYPE + OBJECT_PATH + INTERFACE.MEMBER + CONTENTS + + + + + +DESCRIPTION +The dbus-send command is used to send a message to a D-Bus message +bus. See http://www.freedesktop.org/software/dbus/ for more +information about the big picture. + + +There are two well-known message buses: the systemwide message bus +(installed on many systems as the "messagebus" service) and the +per-user-login-session message bus (started each time a user logs in). +The and options direct +dbus-send to send messages to the system or session buses respectively. +If neither is specified, dbus-send sends to the session bus. + + +Nearly all uses of dbus-send must provide the argument +which is the name of a connection on the bus to send the message to. If + is omitted, no destination is set. + + +The object path and the name of the message to send must always be +specified. Following arguments, if any, are the message contents +(message arguments). These are given as type-specified values and +may include containers (arrays, dicts, and variants) as described below. + + +<contents> ::= <item> | <container> [ <item> | <container>...] +<item> ::= <type>:<value> +<container> ::= <array> | <dict> | <variant> +<array> ::= array:<type>:<value>[,<value>...] +<dict> ::= dict:<type>:<type>:<key>,<value>[,<key>,<value>...] +<variant> ::= variant:<type>:<value> +<type> ::= string | int16 | uint 16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath + + +D-Bus supports more types than these, but dbus-send currently +does not. Also, dbus-send does not permit empty containers +or nested containers (e.g. arrays of variants). + + +Here is an example invocation: + + + dbus-send --dest=org.freedesktop.ExampleName \ + /org/freedesktop/sample/object/name \ + org.freedesktop.ExampleInterface.ExampleMethod \ + int32:47 string:'hello world' double:65.32 \ + array:string:"1st item","next item","last item" \ + dict:string:int32:"one",1,"two",2,"three",3 \ + variant:int32:-8 \ + objpath:/org/freedesktop/sample/object/name + + + +Note that the interface is separated from a method or signal +name by a dot, though in the actual protocol the interface +and the interface member are separate fields. + + + +OPTIONS +The following options are supported: + + + NAME + +Specify the name of the connection to receive the message. + + + + + +Block for a reply to the message sent, and print any reply received +in a human-readable form. + + + + + +Block for a reply to the message sent, and print the body of the +reply. If the reply is an object path or a string, it is printed +literally, with no punctuation, escape characters etc. + + + + MSEC + +Wait for a reply for up to MSEC milliseconds. +The default is implementation‐defined, typically 25 seconds. + + + + + +Send to the system message bus. + + + + + +Send to the session message bus. (This is the default.) + + + + TYPE + +Specify method_call or signal (defaults to "signal"). + + + + + + +AUTHOR +dbus-send was written by Philip Blundell. + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + diff --git a/doc/dbus-uuidgen.1.xml b/doc/dbus-uuidgen.1.xml deleted file mode 100644 index ee622353..00000000 --- a/doc/dbus-uuidgen.1.xml +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - -dbus-uuidgen -1 -User Commands -D-Bus - - -dbus-uuidgen -Utility to generate UUIDs - - - - - dbus-uuidgen --version - --ensure =FILENAME - --get =FILENAME - - - - - -DESCRIPTION -The dbus-uuidgen command generates or reads a universally unique ID. - - -Note that the D-Bus UUID has no relationship to RFC 4122 and does not generate -UUIDs compatible with that spec. Many systems have a separate command -for that (often called "uuidgen"). - - -See http://www.freedesktop.org/software/dbus/ for more information -about D-Bus. - - -The primary usage of dbus-uuidgen is to run in the post-install -script of a D-Bus package like this: - - dbus-uuidgen --ensure - - - -This will ensure that /var/lib/dbus/machine-id exists and has the uuid in it. -It won't overwrite an existing uuid, since this id should remain fixed -for a single machine until the next reboot at least. - - -The important properties of the machine UUID are that 1) it remains -unchanged until the next reboot and 2) it is different for any two -running instances of the OS kernel. That is, if two processes see the -same UUID, they should also see the same shared memory, UNIX domain -sockets, local X displays, localhost.localdomain resolution, process -IDs, and so forth. - - -If you run dbus-uuidgen with no options it just prints a new uuid made -up out of thin air. - - -If you run it with --get, it prints the machine UUID by default, or -the UUID in the specified file if you specify a file. - - -If you try to change an existing machine-id on a running system, it will -probably result in bad things happening. Don't try to change this file. Also, -don't make it the same on two different systems; it needs to be different -anytime there are two different kernels running. - - -The UUID should be different on two different virtual machines, -because there are two different kernels. - - - -OPTIONS -The following options are supported: - - - - -If a filename is not given, defaults to localstatedir/lib/dbus/machine-id -(localstatedir is usually /var). If this file exists and is valid, the -uuid in the file is printed on stdout. Otherwise, the command exits -with a nonzero status. - - - - - - -If a filename is not given, defaults to localstatedir/lib/dbus/machine-id -(localstatedir is usually /var). If this file exists then it will be -validated, and a failure code returned if it contains the wrong thing. -If the file does not exist, it will be created with a new uuid in it. -On success, prints no output. - - - - - - -Print the version of dbus-uuidgen - - - - - - -AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - - - -BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ - - - diff --git a/doc/dbus-uuidgen.1.xml.in b/doc/dbus-uuidgen.1.xml.in new file mode 100644 index 00000000..ee622353 --- /dev/null +++ b/doc/dbus-uuidgen.1.xml.in @@ -0,0 +1,127 @@ + + + + + + + + +dbus-uuidgen +1 +User Commands +D-Bus + + +dbus-uuidgen +Utility to generate UUIDs + + + + + dbus-uuidgen --version + --ensure =FILENAME + --get =FILENAME + + + + + +DESCRIPTION +The dbus-uuidgen command generates or reads a universally unique ID. + + +Note that the D-Bus UUID has no relationship to RFC 4122 and does not generate +UUIDs compatible with that spec. Many systems have a separate command +for that (often called "uuidgen"). + + +See http://www.freedesktop.org/software/dbus/ for more information +about D-Bus. + + +The primary usage of dbus-uuidgen is to run in the post-install +script of a D-Bus package like this: + + dbus-uuidgen --ensure + + + +This will ensure that /var/lib/dbus/machine-id exists and has the uuid in it. +It won't overwrite an existing uuid, since this id should remain fixed +for a single machine until the next reboot at least. + + +The important properties of the machine UUID are that 1) it remains +unchanged until the next reboot and 2) it is different for any two +running instances of the OS kernel. That is, if two processes see the +same UUID, they should also see the same shared memory, UNIX domain +sockets, local X displays, localhost.localdomain resolution, process +IDs, and so forth. + + +If you run dbus-uuidgen with no options it just prints a new uuid made +up out of thin air. + + +If you run it with --get, it prints the machine UUID by default, or +the UUID in the specified file if you specify a file. + + +If you try to change an existing machine-id on a running system, it will +probably result in bad things happening. Don't try to change this file. Also, +don't make it the same on two different systems; it needs to be different +anytime there are two different kernels running. + + +The UUID should be different on two different virtual machines, +because there are two different kernels. + + + +OPTIONS +The following options are supported: + + + + +If a filename is not given, defaults to localstatedir/lib/dbus/machine-id +(localstatedir is usually /var). If this file exists and is valid, the +uuid in the file is printed on stdout. Otherwise, the command exits +with a nonzero status. + + + + + + +If a filename is not given, defaults to localstatedir/lib/dbus/machine-id +(localstatedir is usually /var). If this file exists then it will be +validated, and a failure code returned if it contains the wrong thing. +If the file does not exist, it will be created with a new uuid in it. +On success, prints no output. + + + + + + +Print the version of dbus-uuidgen + + + + + + +AUTHOR +See http://www.freedesktop.org/software/dbus/doc/AUTHORS + + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + + -- cgit v1.2.1 From 80402f224561bbba513a2806101400b7bcf52164 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 14 Feb 2013 13:23:52 +0000 Subject: Add @DBUS_VERSION@ to the generated man pages Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Ralf Habacker [split out of previous patch -smcv] Signed-off-by: Simon McVittie --- doc/dbus-cleanup-sockets.1.xml.in | 1 + doc/dbus-launch.1.xml.in | 1 + doc/dbus-monitor.1.xml.in | 1 + doc/dbus-send.1.xml.in | 1 + doc/dbus-uuidgen.1.xml.in | 1 + 5 files changed, 5 insertions(+) diff --git a/doc/dbus-cleanup-sockets.1.xml.in b/doc/dbus-cleanup-sockets.1.xml.in index a147ad88..9a9ae7e0 100644 --- a/doc/dbus-cleanup-sockets.1.xml.in +++ b/doc/dbus-cleanup-sockets.1.xml.in @@ -12,6 +12,7 @@ 1 User Commands D-Bus +@DBUS_VERSION@ dbus-cleanup-sockets diff --git a/doc/dbus-launch.1.xml.in b/doc/dbus-launch.1.xml.in index 6e6f4960..c6ae0f14 100644 --- a/doc/dbus-launch.1.xml.in +++ b/doc/dbus-launch.1.xml.in @@ -12,6 +12,7 @@ 1 User Commands D-Bus +@DBUS_VERSION@ dbus-launch diff --git a/doc/dbus-monitor.1.xml.in b/doc/dbus-monitor.1.xml.in index c3d1a972..1c582595 100644 --- a/doc/dbus-monitor.1.xml.in +++ b/doc/dbus-monitor.1.xml.in @@ -12,6 +12,7 @@ 1 User Commands D-Bus +@DBUS_VERSION@ dbus-monitor diff --git a/doc/dbus-send.1.xml.in b/doc/dbus-send.1.xml.in index 0988e19f..b63d09cb 100644 --- a/doc/dbus-send.1.xml.in +++ b/doc/dbus-send.1.xml.in @@ -12,6 +12,7 @@ 1 User Commands D-Bus +@DBUS_VERSION@ dbus-send diff --git a/doc/dbus-uuidgen.1.xml.in b/doc/dbus-uuidgen.1.xml.in index ee622353..7693c24f 100644 --- a/doc/dbus-uuidgen.1.xml.in +++ b/doc/dbus-uuidgen.1.xml.in @@ -12,6 +12,7 @@ 1 User Commands D-Bus +@DBUS_VERSION@ dbus-uuidgen -- cgit v1.2.1 From 53c593b07df0f697933e379b3d365e9eec6ef6eb Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 14 Feb 2013 13:49:02 +0000 Subject: More NEWS --- NEWS | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS b/NEWS index 3295f903..0ed6533b 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,11 @@ Build-time configuration changes: supported; use the new DBUS_SESSION_BUS_LISTEN_ADDRESS and DBUS_SESSION_BUS_CONNECT_ADDRESS variables instead. +Requirements: + +• Man pages now require xmlto (or either xmlto or meinproc, if using CMake). +• man2html is no longer used. + Enhancements: • D-Bus Specification 0.21 @@ -21,6 +26,10 @@ Enhancements: · various reorganisation for better clarity (fd.o #38252, Simon McVittie) · stop claiming that all basic types work just like INT32 (strings don't!) +• The "source code" for the man pages is now Docbook XML, eliminating + the outdated duplicate copies used when building with CMake. + (fd.o #59805; Ralf Habacker, Simon McVittie) + Fixes: • In the activation helper, when compiled for tests, do not reset the system -- cgit v1.2.1 From 3b0b5c6b4a0dd2369f167f6b9f11a3dc59c4f8c5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 16 Feb 2013 11:06:43 +0100 Subject: Removed precarious cross compile shell script. CMake provides a standardized way to cross compile packages by using -DCMAKE_TOOLCHAIN_FILE at configure time. Also recent distributions like opensuse provides up to date native mingw binary packages and cross compile packages which reduces the cross compile setup to package installation and setup of a cross tool chain file as documented at http://www.vtk.org/Wiki/CMake_Cross_Compiling. https://bugs.freedesktop.org/show_bug.cgi?id=59733 Reviewed-by: Simon McVittie --- cmake/cross-compile.sh | 110 ------------------------------------------------- 1 file changed, 110 deletions(-) delete mode 100755 cmake/cross-compile.sh diff --git a/cmake/cross-compile.sh b/cmake/cross-compile.sh deleted file mode 100755 index 49e66e50..00000000 --- a/cmake/cross-compile.sh +++ /dev/null @@ -1,110 +0,0 @@ -#!/bin/sh -# -# cross compile script for cmake -# -# initial written by Fridrich Strba -# refactored to debian/lenny by Ralf Habacker -# -# reported to work at least on debian/lenny -# - -if test -f /usr/bin/i686-pc-mingw32-gcc; then - cross_cc=i686-pc-mingw32 -elif test -f /usr/bin/i586-mingw32msvc-gcc; then - cross_cc=i586-mingw32msvc -else - echo "could not determine mingw cross compiler" - exit 1 -fi - -if test -d ~/$cross_cc; then - cross_root=~/$cross_cc -elif test -d /usr/$cross_cc/sys-root/mingw; then - cross_root=/usr/$cross_cc/sys-root/mingw -elif test -d /usr/$cross_cc/lib; then - cross_root=/usr/$cross_cc -else - echo "could not determine mingw cross compiler sdk" - exit 1 -fi - -if ! TEMP=`mktemp --tmpdir -d dbus-cross-compile.XXXXXX`; then - echo "mktemp failed, try with coreutils 6.10 or later?" >&2 - exit 1 -fi - -# make cmake happy -export TEMP - -HOST_CC=gcc; export HOST_CC; - -if test -d $cross_root/lib/pkgconfig; then - PKG_CONFIG_PATH="$cross_root/lib/pkgconfig:$cross_root/share/pkgconfig"; export PKG_CONFIG_PATH; -fi - -if test -d "$MINGW32_CLASSPATH" || test -f "$cross_root/share/java/libgcj.jar"; then - CLASSPATH="$CLASSPATH:${MINGW32_CLASSPATH:-$cross_root/share/java/libgcj.jar:$cross_root/share/java/libgcj-tools.jar}"; export CLASSPATH; -fi - -_PREFIX="/usr/bin/$cross_cc-"; -for i in `ls -1 ${_PREFIX}* | grep -v 'gcc-'`; do - x=`echo $i|sed "s,${_PREFIX},,"|sed "s,\.awk*,,"|tr "a-z+-" "A-ZX_"`; - declare -x $x="$i" ; export $x; -done; -unset _PREFIX; - -CC="${MINGW32_CC:-$cross_cc-gcc}"; export CC; -CFLAGS="${MINGW32_CFLAGS:--O2 -g -pipe -Wall -fexceptions -fno-omit-frame-pointer -fno-optimize-sibling-calls --param=ssp-buffer-size=4 -mms-bitfields}"; export CFLAGS; -LDFLAGS="${MINGW32_LDFLAGS:--Wl,--exclude-libs=libintl.a -Wl,--exclude-libs=libiconv.a}"; export LDFLAGS; - -if [ -x "/usr/bin/$cross_cc-g++" ]; then - CXX="${MINGW32_CXX:-$cross_cc-g++}"; export CXX; - CXXFLAGS="${MINGW32_CXXFLAGS:--O2 -g -pipe -Wall -fexceptions -fno-omit-frame-pointer -fno-optimize-sibling-calls --param=ssp-buffer-size=4 -mms-bitfields}"; export CXXFLAGS; -else - CXX=; export CXX; - ac_cv_prog_CXX=no; export ac_cv_prog_CXX; - CXXFLAGS=; export CXXFLAGS; -fi; -for i in `ls $cross_root/bin/*|grep -- "-config$"` ; do - x=`basename $i|tr "a-z+-" "A-ZX_"|sed "s,\.,,"`; - declare -x $x="$i" ; export $x; -done; -unset x i ; - -if ! test -f "$cross_root/lib/libexpat.dll.a"; then - (cd $TEMP && wget http://www.winkde.org/pub/kde/ports/win32/repository/win32libs/expat-2.0.1-bin.zip) - (cd $TEMP && wget http://www.winkde.org/pub/kde/ports/win32/repository/win32libs/expat-2.0.1-lib.zip) - (cd $cross_root && unzip -x $TMP/expat-2.0.1-bin.zip) - (cd $cross_root && unzip -x $TMP/expat-2.0.1-lib.zip) -fi - -if test -f "$cross_root/lib/libexpat.dll.a"; then - xml_library=-DDBUS_USE_EXPAT=On -DLIBEXPAT_INCLUDE_DIR:PATH=$cross_root/include -DLIBEXPAT_LIBRARIES:PATH=$cross_root/lib/libexpat.dll.a -else - echo "could not find a cross compile xml libraray" - exit 1 -fi - -cmake \ - -DCMAKE_SYSTEM_NAME="Windows" \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_INSTALL_PREFIX:PATH=$cross_root \ - -DCMAKE_INSTALL_LIBDIR:PATH=$cross_root/lib \ - -DINCLUDE_INSTALL_DIR:PATH=$cross_root/include \ - -DLIB_INSTALL_DIR:PATH=$cross_root/lib \ - -DSYSCONF_INSTALL_DIR:PATH=$cross_root/etc \ - -DSHARE_INSTALL_PREFIX:PATH=$cross_root/share \ - -DBUILD_SHARED_LIBS:BOOL=ON \ - -DCMAKE_C_COMPILER="/usr/bin/$cross_cc-gcc" \ - -DCMAKE_CXX_COMPILER="/usr/bin/$cross_cc-g++" \ - -DCMAKE_FIND_ROOT_PATH="$cross_root" \ - -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ - -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ - -DCMAKE_CXX_COMPILER="/usr/bin/$cross_cc-g++" \ - -DCMAKE_FIND_ROOT_PATH="$cross_root" \ - -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \ - -DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \ - $xml_library \ - -DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \ - $* - -- cgit v1.2.1 From 4057fcb66f5b7820431b6569e6e48b771a79fa5f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 14 Feb 2013 13:39:15 +0000 Subject: Remove doclifter "signature" from Docbook man pages' source This no longer serves any purpose, and might mislead contributors into thinking that this XML is not the source for the man pages. (The man(7)-formatted man pages used to be the canonical source for the XML, but now it's the other way round.) Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker --- doc/dbus-cleanup-sockets.1.xml.in | 1 - doc/dbus-daemon.1.xml.in | 3 +-- doc/dbus-launch.1.xml.in | 1 - doc/dbus-monitor.1.xml.in | 1 - doc/dbus-send.1.xml.in | 1 - doc/dbus-uuidgen.1.xml.in | 1 - 6 files changed, 1 insertion(+), 7 deletions(-) diff --git a/doc/dbus-cleanup-sockets.1.xml.in b/doc/dbus-cleanup-sockets.1.xml.in index 9a9ae7e0..56574963 100644 --- a/doc/dbus-cleanup-sockets.1.xml.in +++ b/doc/dbus-cleanup-sockets.1.xml.in @@ -1,7 +1,6 @@ - - + diff --git a/doc/dbus-launch.1.xml.in b/doc/dbus-launch.1.xml.in index c6ae0f14..b9f07672 100644 --- a/doc/dbus-launch.1.xml.in +++ b/doc/dbus-launch.1.xml.in @@ -1,7 +1,6 @@ - - dbus-monitor + dbus-monitor --system --session --address ADDRESS --profile --monitor watchexpressions @@ -120,4 +120,3 @@ The profiling output mode was added by Olli Salli. see http://www.freedesktop.org/software/dbus/ - diff --git a/doc/dbus-send.1.xml.in b/doc/dbus-send.1.xml.in index af4f158d..78f1374b 100644 --- a/doc/dbus-send.1.xml.in +++ b/doc/dbus-send.1.xml.in @@ -20,7 +20,7 @@ - dbus-send + dbus-send --system --session --dest=NAME --print-reply =literal @@ -36,12 +36,12 @@ DESCRIPTION The dbus-send command is used to send a message to a D-Bus message -bus. See http://www.freedesktop.org/software/dbus/ for more +bus. See http://www.freedesktop.org/software/dbus/ for more information about the big picture. -There are two well-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the +There are two well-known message buses: the systemwide message bus +(installed on many systems as the "messagebus" service) and the per-user-login-session message bus (started each time a user logs in). The and options direct dbus-send to send messages to the system or session buses respectively. @@ -55,14 +55,14 @@ which is the name of a connection on the bus to send the message to. If The object path and the name of the message to send must always be specified. Following arguments, if any, are the message contents -(message arguments). These are given as type-specified values and +(message arguments). These are given as type-specified values and may include containers (arrays, dicts, and variants) as described below. <contents> ::= <item> | <container> [ <item> | <container>...] <item> ::= <type>:<value> <container> ::= <array> | <dict> | <variant> -<array> ::= array:<type>:<value>[,<value>...] +<array> ::= array:<type>:<value>[,<value>...] <dict> ::= dict:<type>:<type>:<key>,<value>[,<key>,<value>...] <variant> ::= variant:<type>:<value> <type> ::= string | int16 | uint 16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath @@ -83,11 +83,11 @@ or nested containers (e.g. arrays of variants). array:string:"1st item","next item","last item" \ dict:string:int32:"one",1,"two",2,"three",3 \ variant:int32:-8 \ - objpath:/org/freedesktop/sample/object/name + objpath:/org/freedesktop/sample/object/name -Note that the interface is separated from a method or signal +Note that the interface is separated from a method or signal name by a dot, though in the actual protocol the interface and the interface member are separate fields. @@ -156,4 +156,3 @@ The default is implementation‐defined, typically 25 seconds. see http://www.freedesktop.org/software/dbus/ - diff --git a/doc/dbus-uuidgen.1.xml.in b/doc/dbus-uuidgen.1.xml.in index 88e33add..fbd26812 100644 --- a/doc/dbus-uuidgen.1.xml.in +++ b/doc/dbus-uuidgen.1.xml.in @@ -54,8 +54,8 @@ for a single machine until the next reboot at least. The important properties of the machine UUID are that 1) it remains -unchanged until the next reboot and 2) it is different for any two -running instances of the OS kernel. That is, if two processes see the +unchanged until the next reboot and 2) it is different for any two +running instances of the OS kernel. That is, if two processes see the same UUID, they should also see the same shared memory, UNIX domain sockets, local X displays, localhost.localdomain resolution, process IDs, and so forth. @@ -88,7 +88,7 @@ because there are two different kernels. If a filename is not given, defaults to localstatedir/lib/dbus/machine-id (localstatedir is usually /var). If this file exists and is valid, the -uuid in the file is printed on stdout. Otherwise, the command exits +uuid in the file is printed on stdout. Otherwise, the command exits with a nonzero status. @@ -124,4 +124,3 @@ On success, prints no output. see http://www.freedesktop.org/software/dbus/ - -- cgit v1.2.1 From 16e69337a5a2fe6bb2ded42ed618ae55c92621a9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 18 Feb 2013 14:22:09 +0000 Subject: NEWS --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 0ed6533b..3708565f 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,12 @@ Build-time configuration changes: supported; use the new DBUS_SESSION_BUS_LISTEN_ADDRESS and DBUS_SESSION_BUS_CONNECT_ADDRESS variables instead. +• cmake/cross-compile.sh has been removed. Instead, please use a + cross-toolchain file (-DCMAKE_TOOLCHAIN_FILE) as documented at + ; or use Autotools + as documented in "info automake Cross-Compilation", and set + PKG_CONFIG_PATH appropriately. + Requirements: • Man pages now require xmlto (or either xmlto or meinproc, if using CMake). -- cgit v1.2.1 From 0484cf1a3cde1a5993425c938645f762db738033 Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Mon, 4 Feb 2013 18:30:14 -0600 Subject: Fix inotify usage for QNX QNX's copy of sys/inotify.h is broken, and doesn't include stdint.h even though it refers to types from it. Therefore, it must be included manually. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61176 Reviewed-by: Simon McVittie --- bus/dir-watch-inotify.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index 2e9be988..d684831d 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -22,11 +22,15 @@ * */ +/* Be careful, this file is not Linux-only: QNX also uses it */ + #include #include #include #include +/* QNX's inotify is broken, and requires stdint.h to be manually included first */ +#include #include #include #include -- cgit v1.2.1 From 0ebd4ae912568caa40b714ba166211fa31b82af8 Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Wed, 20 Feb 2013 15:27:20 -0600 Subject: Add support for systems without syslog.h This patch disables the use of syslog for systems which do not have it, such as QNX. Log messages are still printed to stderr. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61176 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-util-unix.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 6cff3fe2..7beab209 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -49,7 +49,10 @@ #include #include #include + +#ifdef HAVE_SYSLOG_H #include +#endif #ifdef HAVE_SYS_SYSLIMITS_H #include @@ -425,11 +428,15 @@ _dbus_request_file_descriptor_limit (unsigned int limit) void _dbus_init_system_log (void) { +#ifdef HAVE_SYSLOG_H + #if HAVE_DECL_LOG_PERROR openlog ("dbus", LOG_PID | LOG_PERROR, LOG_DAEMON); #else openlog ("dbus", LOG_PID, LOG_DAEMON); #endif + +#endif } /** @@ -465,6 +472,7 @@ _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) void _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args) { +#ifdef HAVE_SYSLOG_H int flags; switch (severity) { @@ -481,7 +489,10 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args return; } -#ifndef HAVE_DECL_LOG_PERROR + vsyslog (flags, msg, args); +#endif + +#if !defined(HAVE_SYSLOG_H) || !HAVE_DECL_LOG_PERROR { /* vsyslog() won't write to stderr, so we'd better do it */ va_list tmp; @@ -494,8 +505,6 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args } #endif - vsyslog (flags, msg, args); - if (severity == DBUS_SYSTEM_LOG_FATAL) exit (1); } -- cgit v1.2.1 From 0e90efd5b2c2e040763733761a8a320ccc8544c7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 18 Feb 2013 14:27:48 +0000 Subject: Don't warn for functions deprecated since GLib 2.26 Also warn if we inadvertently use a function introduced since then. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59971 Reviewed-by: Colin Walters --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index 9b578ed4..5c1a7e58 100644 --- a/configure.ac +++ b/configure.ac @@ -211,6 +211,9 @@ fi # default (unless you don't have GLib), because they don't bloat the library # or binaries. +AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_26], [Ignore post-2.26 deprecations]) +AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_26], [Prevent post-2.26 APIs]) + with_glib=yes if test "x$enable_modular_tests" != xno; then -- cgit v1.2.1 From 4a0b41ee31bdc67c56f672f6e0a64c42bf34c1ae Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 18 Feb 2013 14:30:22 +0000 Subject: Include config.h as the first thing in every .c file ...except for CheckForAbstractSockets.c, which runs before config.h is generated, and sd-daemon.c, which is externally-maintained. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59971 Signed-off-by: Simon McVittie Reviewed-by: Colin Walters --- test/name-test/test-autolaunch.c | 2 ++ test/test-exit.c | 2 ++ tools/strtoll.c | 1 + tools/strtoull.c | 1 + 4 files changed, 6 insertions(+) diff --git a/test/name-test/test-autolaunch.c b/test/name-test/test-autolaunch.c index 5e519895..adbeb185 100644 --- a/test/name-test/test-autolaunch.c +++ b/test/name-test/test-autolaunch.c @@ -1,3 +1,5 @@ +#include "config.h" + #include #include #include diff --git a/test/test-exit.c b/test/test-exit.c index f3358185..b4f967ae 100644 --- a/test/test-exit.c +++ b/test/test-exit.c @@ -1,3 +1,5 @@ +#include "config.h" + /* This is a process that just exits with a failure code */ int main (int argc, char **argv) diff --git a/tools/strtoll.c b/tools/strtoll.c index e4f57701..7360c630 100644 --- a/tools/strtoll.c +++ b/tools/strtoll.c @@ -27,6 +27,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include #ifdef HAVE_ERRNO_H diff --git a/tools/strtoull.c b/tools/strtoull.c index 459c5091..35595542 100644 --- a/tools/strtoull.c +++ b/tools/strtoull.c @@ -27,6 +27,7 @@ * SUCH DAMAGE. */ +#include "config.h" #include #ifdef HAVE_ERRNO_H -- cgit v1.2.1 From 60c1b41fbf7247eeb208dfe704fecb75efd8c824 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 22 Feb 2013 14:47:07 +0000 Subject: Prepare release 1.7.0 (and specification 0.20) --- NEWS | 16 ++++++++++++---- configure.ac | 10 +++++----- doc/dbus-specification.xml | 6 +++--- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 3708565f..db2260d1 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ -D-Bus 1.7.0 (UNRELEASED) +D-Bus 1.7.0 (2013-02-22) == +The "Disingenuous Assertions" release. + +This is a new development release, starting the 1.7.x branch. D-Bus 1.6 +remains the recommended version for long-term-supported distributions +or the upcoming GNOME 3.8 release. + Build-time configuration changes: • The --with-dbus-session-bus-default-address configure option is no longer @@ -9,7 +15,7 @@ Build-time configuration changes: usually want them to have the same argument; on Unix, the defaults are usually correct. -• Similarly, the DBUS_SESSION_BUS_DEFAULT_ADDRESS cmake variable is no longer +• Similarly, the DBUS_SESSION_BUS_DEFAULT_ADDRESS CMake variable is no longer supported; use the new DBUS_SESSION_BUS_LISTEN_ADDRESS and DBUS_SESSION_BUS_CONNECT_ADDRESS variables instead. @@ -26,7 +32,7 @@ Requirements: Enhancements: -• D-Bus Specification 0.21 +• D-Bus Specification 0.20 · actually say that /org/freedesktop/DBus is the object that implements o.fd.DBus (fd.o #51865, Colin Walters) · various reorganisation for better clarity (fd.o #38252, Simon McVittie) @@ -55,13 +61,15 @@ Fixes: • Don't assume CMake host and build system are the same (fd.o #59733, Ralf Habacker) +• Avoid deprecation warnings for GLib 2.35 (fd.o #59971, Simon McVittie) + • Unix-specific: · Check for functions in libpthread correctly, fixing compilation on (at least) OpenBSD (fd.o #47239, Simon) · Don't leak temporary fds pointing to /dev/null (fd.o #56927, Michel HERMIER) · Update sd-daemon.[ch] from systemd (fd.o #60681) - · Add partial support for QNX (fd.o #60339, Matt Fischer) + · Add partial support for QNX (fd.o #60339, fd.o #61176; Matt Fischer) • Windows-specific: · The default session bus listening and connecting address is now diff --git a/configure.ac b/configure.ac index 5c1a7e58..4554fcea 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ dnl -*- mode: m4 -*- AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) -m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [255]) +m4_define([dbus_minor_version], [7]) +m4_define([dbus_micro_version], [0]) 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]) @@ -33,16 +33,16 @@ AC_DEFINE_UNQUOTED(DBUS_DAEMON_NAME,"dbus-daemon",[Name of executable]) # ## increment if the interface has additions, changes, removals. -LT_CURRENT=10 +LT_CURRENT=11 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=2 +LT_REVISION=0 ## 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=7 +LT_AGE=8 AC_SUBST(LT_CURRENT) AC_SUBST(LT_REVISION) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 5d1cd106..8d348489 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -7,7 +7,7 @@ D-Bus Specification Version 0.20 - unreleased + 2013-02-22 Havoc @@ -72,8 +72,8 @@ - current - commit log + 0.20 + 22 February 2013 (commit log) smcv, walters reorganise for clarity, remove false claims about basic types, mention /o/fd/DBus -- cgit v1.2.1 From 4d41d120d8240cbf78cee5e0ab6bad79eab914c1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 22 Feb 2013 21:01:07 +0000 Subject: bump version to 1.7.1 --- NEWS | 3 +++ configure.ac | 2 +- doc/dbus-specification.xml | 12 +++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index db2260d1..442b38df 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +D-Bus 1.7.2 (UNRELEASED) +== + D-Bus 1.7.0 (2013-02-22) == diff --git a/configure.ac b/configure.ac index 4554fcea..ee89dcb4 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [0]) +m4_define([dbus_micro_version], [1]) 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]) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 8d348489..fdb247d9 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.20 - 2013-02-22 + Version 0.21 + (not yet released) Havoc @@ -71,9 +71,15 @@ + + 0.21 + not yet released (commit log) + + + 0.20 - 22 February 2013 (commit log) + 22 February 2013 smcv, walters reorganise for clarity, remove false claims about basic types, mention /o/fd/DBus -- cgit v1.2.1 From 88642f6fee46a4c6d1fde8ae221494a6b3188bd4 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 24 Feb 2013 08:46:48 -0500 Subject: sysdeps: Don't use LOG_PERROR if systemd is booted Otherwise we get duplicated log output, since stdout/stderr are connected to the journal by default. https://bugs.freedesktop.org/show_bug.cgi?id=61399 --- dbus/dbus-sysdeps-util-unix.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 7beab209..fe8843f1 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -429,13 +429,16 @@ void _dbus_init_system_log (void) { #ifdef HAVE_SYSLOG_H + int logopts = LOG_PID; -#if HAVE_DECL_LOG_PERROR - openlog ("dbus", LOG_PID | LOG_PERROR, LOG_DAEMON); -#else - openlog ("dbus", LOG_PID, LOG_DAEMON); +#ifdef HAVE_DECL_LOG_PERROR +#ifdef HAVE_SYSTEMD + if (sd_booted () <= 0) +#endif + logopts |= LOG_PERROR; #endif + openlog ("dbus", logopts, LOG_DAEMON); #endif } -- cgit v1.2.1 From ef72d5df98eb923d3e02dbe46e936c6ae99e086a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Feb 2013 19:32:15 +0000 Subject: include sd-daemon.h for sd_booted() --- dbus/dbus-sysdeps-util-unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index fe8843f1..81098caf 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -58,6 +58,8 @@ #include #endif +#include "sd-daemon.h" + #ifndef O_BINARY #define O_BINARY 0 #endif -- cgit v1.2.1 From 71a2028f4cdd2920ad56d93ce4f09fdb66cb7d53 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 28 Nov 2012 12:01:37 +0000 Subject: bus driver: factor out common code to get a named connection Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445 Reviewed-by: Thiago Macieira --- bus/driver.c | 159 +++++++++++++++++++++++------------------------------------ 1 file changed, 63 insertions(+), 96 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index 574e0f3d..01e56fb9 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -32,12 +32,55 @@ #include "signals.h" #include "stats.h" #include "utils.h" + #include #include #include #include #include +static DBusConnection * +bus_driver_get_conn_helper (DBusConnection *connection, + DBusMessage *message, + const char *what_we_want, + const char **name_p, + DBusError *error) +{ + const char *name; + BusRegistry *registry; + BusService *serv; + DBusString str; + DBusConnection *conn; + + if (!dbus_message_get_args (message, error, + DBUS_TYPE_STRING, &name, + DBUS_TYPE_INVALID)) + return NULL; + + _dbus_assert (name != NULL); + _dbus_verbose ("asked for %s of connection %s\n", what_we_want, name); + + registry = bus_connection_get_registry (connection); + _dbus_string_init_const (&str, name); + serv = bus_registry_lookup (registry, &str); + + if (serv == NULL) + { + dbus_set_error (error, DBUS_ERROR_NAME_HAS_NO_OWNER, + "Could not get %s of name '%s': no such name", + what_we_want, name); + return NULL; + } + + conn = bus_service_get_primary_owners_connection (serv); + _dbus_assert (conn != NULL); + + if (name_p != NULL) + *name_p = name; + + return conn; +} + static dbus_bool_t bus_driver_send_welcome_message (DBusConnection *connection, DBusMessage *hello_message, BusTransaction *transaction, @@ -1262,40 +1305,21 @@ bus_driver_handle_get_connection_unix_user (DBusConnection *connection, DBusMessage *message, DBusError *error) { - const char *service; - DBusString str; - BusRegistry *registry; - BusService *serv; DBusConnection *conn; DBusMessage *reply; unsigned long uid; dbus_uint32_t uid32; + const char *service; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - registry = bus_connection_get_registry (connection); - - service = NULL; reply = NULL; - if (! dbus_message_get_args (message, error, - DBUS_TYPE_STRING, &service, - DBUS_TYPE_INVALID)) - goto failed; - - _dbus_verbose ("asked for UID of connection %s\n", service); - - _dbus_string_init_const (&str, service); - serv = bus_registry_lookup (registry, &str); - if (serv == NULL) - { - dbus_set_error (error, - DBUS_ERROR_NAME_HAS_NO_OWNER, - "Could not get UID of name '%s': no such name", service); - goto failed; - } + conn = bus_driver_get_conn_helper (connection, message, "UID", &service, + error); - conn = bus_service_get_primary_owners_connection (serv); + if (conn == NULL) + goto failed; reply = dbus_message_new_method_return (message); if (reply == NULL) @@ -1338,40 +1362,21 @@ bus_driver_handle_get_connection_unix_process_id (DBusConnection *connection, DBusMessage *message, DBusError *error) { - const char *service; - DBusString str; - BusRegistry *registry; - BusService *serv; DBusConnection *conn; DBusMessage *reply; unsigned long pid; dbus_uint32_t pid32; + const char *service; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - registry = bus_connection_get_registry (connection); - - service = NULL; reply = NULL; - if (! dbus_message_get_args (message, error, - DBUS_TYPE_STRING, &service, - DBUS_TYPE_INVALID)) - goto failed; - - _dbus_verbose ("asked for PID of connection %s\n", service); - - _dbus_string_init_const (&str, service); - serv = bus_registry_lookup (registry, &str); - if (serv == NULL) - { - dbus_set_error (error, - DBUS_ERROR_NAME_HAS_NO_OWNER, - "Could not get PID of name '%s': no such name", service); - goto failed; - } + conn = bus_driver_get_conn_helper (connection, message, "PID", &service, + error); - conn = bus_service_get_primary_owners_connection (serv); + if (conn == NULL) + goto failed; reply = dbus_message_new_method_return (message); if (reply == NULL) @@ -1414,40 +1419,21 @@ bus_driver_handle_get_adt_audit_session_data (DBusConnection *connection, DBusMessage *message, DBusError *error) { - const char *service; - DBusString str; - BusRegistry *registry; - BusService *serv; DBusConnection *conn; DBusMessage *reply; void *data = NULL; dbus_uint32_t data_size; + const char *service; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - registry = bus_connection_get_registry (connection); - - service = NULL; reply = NULL; - if (! dbus_message_get_args (message, error, - DBUS_TYPE_STRING, &service, - DBUS_TYPE_INVALID)) - goto failed; - - _dbus_verbose ("asked for audit session data for connection %s\n", service); + conn = bus_driver_get_conn_helper (connection, message, + "audit session data", &service, error); - _dbus_string_init_const (&str, service); - serv = bus_registry_lookup (registry, &str); - if (serv == NULL) - { - dbus_set_error (error, - DBUS_ERROR_NAME_HAS_NO_OWNER, - "Could not get audit session data for name '%s': no such name", service); - goto failed; - } - - conn = bus_service_get_primary_owners_connection (serv); + if (conn == NULL) + goto failed; reply = dbus_message_new_method_return (message); if (reply == NULL) @@ -1489,39 +1475,20 @@ bus_driver_handle_get_connection_selinux_security_context (DBusConnection *conne DBusMessage *message, DBusError *error) { - const char *service; - DBusString str; - BusRegistry *registry; - BusService *serv; DBusConnection *conn; DBusMessage *reply; BusSELinuxID *context; + const char *service; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - registry = bus_connection_get_registry (connection); - - service = NULL; reply = NULL; - if (! dbus_message_get_args (message, error, - DBUS_TYPE_STRING, &service, - DBUS_TYPE_INVALID)) - goto failed; - - _dbus_verbose ("asked for security context of connection %s\n", service); + conn = bus_driver_get_conn_helper (connection, message, "security context", + &service, error); - _dbus_string_init_const (&str, service); - serv = bus_registry_lookup (registry, &str); - if (serv == NULL) - { - dbus_set_error (error, - DBUS_ERROR_NAME_HAS_NO_OWNER, - "Could not get security context of name '%s': no such name", service); - goto failed; - } - - conn = bus_service_get_primary_owners_connection (serv); + if (conn == NULL) + goto failed; reply = dbus_message_new_method_return (message); if (reply == NULL) -- cgit v1.2.1 From 76503373e6000c3eab72a252393f8e8c940bd89e Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 4 Mar 2013 15:24:19 +0100 Subject: Fix cmake linux build: dbus-1 and dbus-internal require to link to rt library Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61637 Reviewed-by: Simon McVittie --- cmake/dbus/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index d09e63df..8a401716 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -267,7 +267,7 @@ if(WIN32) target_link_libraries(dbus-1 ws2_32 advapi32 netapi32) endif(WINCE) else(WIN32) - target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT} rt) endif(WIN32) install_targets(/lib dbus-1 ) @@ -292,7 +292,7 @@ if(WIN32) target_link_libraries(dbus-internal ws2_32 advapi32 netapi32) endif(WINCE) else(WIN32) - target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT} rt) endif(WIN32) if (DBUS_BUILD_TESTS) -- cgit v1.2.1 From 57c35091a1ab228e4f36fab3aad592a34f8295c9 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 28 Feb 2013 12:22:33 +0000 Subject: CMake linux fixes when using meinproc4 doc generator. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61637 Reviewed-by: Simon McVittie --- cmake/doc/CMakeLists.txt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index 15c05401..dee9431b 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -28,16 +28,19 @@ if (XMLTO_EXECUTABLE) set(DBUS_XML_DOCS_ENABLED 1) set(MEINPROC4_EXECUTABLE 0) MESSAGE(STATUS "xmlto docbook generator found") + set(STYLESHEET_MAN "${DOCBOOKXSL_DIR}/manpages/docbook.xsl") + set(STYLESHEET_HTML "${DOCBOOKXSL_DIR}/html/docbook.xsl") + elseif (MEINPROC4_EXECUTABLE) set(DOCBOOK_GENERATOR_NAME "meinproc4" PARENT_SCOPE) set(DBUS_XML_DOCS_ENABLED 1) if(WIN32) get_filename_component(_a ${MEINPROC4_EXECUTABLE} PATH) get_filename_component(_meinproc_install_path ${_a} PATH) + set(STYLESHEET_HTML "${_meinproc_install_path}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl") else(WIN32) - set(_meinproc_install_path ${CMAKE_INSTALL_PREFIX}) + set(STYLESHEET_HTML file:///usr/share/kde4/apps/ksgmltools2/customization/kde-nochunk.xsl) endif(WIN32) - set(STYLESHEET "${_meinproc_install_path}/share/apps/ksgmltools2/docbook/xsl/html/docbook.xsl") endif () if (DBUS_ENABLE_XML_DOCS) @@ -48,10 +51,10 @@ macro (DOCBOOK _sources _format) if (${_format} STREQUAL "man") string(REPLACE ".xml" "" _outname ${_name}) - set(STYLESHEET "${DOCBOOKXSL_DIR}/manpages/docbook.xsl") + set(STYLESHEET ${STYLESHEET_MAN}) else() string(REPLACE ".xml" ".html" _outname ${_name}) - set(STYLESHEET "${DOCBOOKXSL_DIR}/html/docbook.xsl") + set(STYLESHEET ${STYLESHEET_HTML}) endif () set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname}) -- cgit v1.2.1 From e53229e42c24902b07cdbc325b5682b97f43c429 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 7 Mar 2013 10:42:26 +0100 Subject: Debug message eol fix. --- dbus/dbus-sysdeps-win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 5a2fb209..6e093c1f 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1690,7 +1690,7 @@ _dbus_read_credentials_socket (int handle, bytes_read = _dbus_read_socket(handle, &buf, 1 ); if (bytes_read > 0) - _dbus_verbose("got one zero byte from server"); + _dbus_verbose("got one zero byte from server\n"); _dbus_string_free(&buf); } -- cgit v1.2.1 From 73df9770b39ad486c6ed4d5a392d950c6eb065f5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 8 Mar 2013 10:44:30 +0100 Subject: Do not retrieve credential information from the wrong side of the connection. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61787 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 6e093c1f..f8189af7 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1695,8 +1695,7 @@ _dbus_read_credentials_socket (int handle, _dbus_string_free(&buf); } - _dbus_credentials_add_from_current_process (credentials); - _dbus_verbose("FIXME: get faked credentials from current process"); + _dbus_verbose("FIXME: fetch credentials from client connection\n"); return TRUE; } -- cgit v1.2.1 From 15b2d2bb258483c191efb51ee6366c26318fd9f9 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 8 Mar 2013 13:15:36 +0100 Subject: Rename the term 'unix_pid' to 'pid' in variables and functions. Windows also has numeric process IDs that fit in an unsigned long, so there's no reason this has to be Unix-specific. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61787 Reviewed-by: Simon McVittie --- dbus/dbus-auth-script.c | 2 +- dbus/dbus-credentials-util.c | 12 ++++++------ dbus/dbus-credentials.c | 32 ++++++++++++++++---------------- dbus/dbus-credentials.h | 4 ++-- dbus/dbus-sysdeps-unix.c | 4 ++-- dbus/dbus-sysdeps-win.c | 2 +- dbus/dbus-transport.c | 2 +- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 6285e3ba..cbdd748f 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -223,7 +223,7 @@ auth_set_unix_credentials(DBusAuth *auth, if (uid != DBUS_UID_UNSET) _dbus_credentials_add_unix_uid (credentials, uid); if (pid != DBUS_PID_UNSET) - _dbus_credentials_add_unix_pid (credentials, pid); + _dbus_credentials_add_pid (credentials, pid); _dbus_auth_set_credentials (auth, credentials); diff --git a/dbus/dbus-credentials-util.c b/dbus/dbus-credentials-util.c index 02771966..59cdcb83 100644 --- a/dbus/dbus-credentials-util.c +++ b/dbus/dbus-credentials-util.c @@ -40,7 +40,7 @@ static DBusCredentials* make_credentials(dbus_uid_t unix_uid, - dbus_pid_t unix_pid, + dbus_pid_t pid, const char *windows_sid) { DBusCredentials *credentials; @@ -56,9 +56,9 @@ make_credentials(dbus_uid_t unix_uid, } } - if (unix_pid != DBUS_PID_UNSET) + if (pid != DBUS_PID_UNSET) { - if (!_dbus_credentials_add_unix_pid (credentials, unix_pid)) + if (!_dbus_credentials_add_pid (credentials, pid)) { _dbus_credentials_unref (credentials); return NULL; @@ -102,7 +102,7 @@ _dbus_credentials_test (const char *test_data_dir) _dbus_assert (_dbus_credentials_include (creds, DBUS_CREDENTIAL_WINDOWS_SID)); _dbus_assert (_dbus_credentials_get_unix_uid (creds) == 12); - _dbus_assert (_dbus_credentials_get_unix_pid (creds) == 511); + _dbus_assert (_dbus_credentials_get_pid (creds) == 511); _dbus_assert (strcmp (_dbus_credentials_get_windows_sid (creds), SAMPLE_SID) == 0); _dbus_assert (!_dbus_credentials_are_empty (creds)); @@ -118,7 +118,7 @@ _dbus_credentials_test (const char *test_data_dir) _dbus_assert (_dbus_credentials_include (creds2, DBUS_CREDENTIAL_WINDOWS_SID)); _dbus_assert (_dbus_credentials_get_unix_uid (creds2) == 12); - _dbus_assert (_dbus_credentials_get_unix_pid (creds2) == 511); + _dbus_assert (_dbus_credentials_get_pid (creds2) == 511); _dbus_assert (strcmp (_dbus_credentials_get_windows_sid (creds2), SAMPLE_SID) == 0); _dbus_assert (_dbus_credentials_are_superset (creds, creds2)); @@ -192,7 +192,7 @@ _dbus_credentials_test (const char *test_data_dir) _dbus_assert (!_dbus_credentials_include (creds, DBUS_CREDENTIAL_WINDOWS_SID)); _dbus_assert (_dbus_credentials_get_unix_uid (creds) == DBUS_UID_UNSET); - _dbus_assert (_dbus_credentials_get_unix_pid (creds) == DBUS_PID_UNSET); + _dbus_assert (_dbus_credentials_get_pid (creds) == DBUS_PID_UNSET); _dbus_assert (_dbus_credentials_get_windows_sid (creds) == NULL); _dbus_assert (_dbus_credentials_are_empty (creds)); diff --git a/dbus/dbus-credentials.c b/dbus/dbus-credentials.c index ff69f3b0..7325125c 100644 --- a/dbus/dbus-credentials.c +++ b/dbus/dbus-credentials.c @@ -48,7 +48,7 @@ struct DBusCredentials { int refcount; dbus_uid_t unix_uid; - dbus_pid_t unix_pid; + dbus_pid_t pid; char *windows_sid; void *adt_audit_data; dbus_int32_t adt_audit_data_size; @@ -77,7 +77,7 @@ _dbus_credentials_new (void) creds->refcount = 1; creds->unix_uid = DBUS_UID_UNSET; - creds->unix_pid = DBUS_PID_UNSET; + creds->pid = DBUS_PID_UNSET; creds->windows_sid = NULL; creds->adt_audit_data = NULL; creds->adt_audit_data_size = 0; @@ -146,10 +146,10 @@ _dbus_credentials_unref (DBusCredentials *credentials) * @returns #FALSE if no memory */ dbus_bool_t -_dbus_credentials_add_unix_pid (DBusCredentials *credentials, - dbus_pid_t pid) +_dbus_credentials_add_pid (DBusCredentials *credentials, + dbus_pid_t pid) { - credentials->unix_pid = pid; + credentials->pid = pid; return TRUE; } @@ -231,7 +231,7 @@ _dbus_credentials_include (DBusCredentials *credentials, switch (type) { case DBUS_CREDENTIAL_UNIX_PROCESS_ID: - return credentials->unix_pid != DBUS_PID_UNSET; + return credentials->pid != DBUS_PID_UNSET; case DBUS_CREDENTIAL_UNIX_USER_ID: return credentials->unix_uid != DBUS_UID_UNSET; case DBUS_CREDENTIAL_WINDOWS_SID: @@ -252,9 +252,9 @@ _dbus_credentials_include (DBusCredentials *credentials, * @returns UNIX process ID */ dbus_pid_t -_dbus_credentials_get_unix_pid (DBusCredentials *credentials) +_dbus_credentials_get_pid (DBusCredentials *credentials) { - return credentials->unix_pid; + return credentials->pid; } /** @@ -322,8 +322,8 @@ _dbus_credentials_are_superset (DBusCredentials *credentials, DBusCredentials *possible_subset) { return - (possible_subset->unix_pid == DBUS_PID_UNSET || - possible_subset->unix_pid == credentials->unix_pid) && + (possible_subset->pid == DBUS_PID_UNSET || + possible_subset->pid == credentials->pid) && (possible_subset->unix_uid == DBUS_UID_UNSET || possible_subset->unix_uid == credentials->unix_uid) && (possible_subset->windows_sid == NULL || @@ -345,7 +345,7 @@ dbus_bool_t _dbus_credentials_are_empty (DBusCredentials *credentials) { return - credentials->unix_pid == DBUS_PID_UNSET && + credentials->pid == DBUS_PID_UNSET && credentials->unix_uid == DBUS_UID_UNSET && credentials->windows_sid == NULL && credentials->adt_audit_data == NULL; @@ -410,9 +410,9 @@ _dbus_credentials_add_credential (DBusCredentials *credentials, DBusCredentials *other_credentials) { if (which == DBUS_CREDENTIAL_UNIX_PROCESS_ID && - other_credentials->unix_pid != DBUS_PID_UNSET) + other_credentials->pid != DBUS_PID_UNSET) { - if (!_dbus_credentials_add_unix_pid (credentials, other_credentials->unix_pid)) + if (!_dbus_credentials_add_pid (credentials, other_credentials->pid)) return FALSE; } else if (which == DBUS_CREDENTIAL_UNIX_USER_ID && @@ -445,7 +445,7 @@ _dbus_credentials_add_credential (DBusCredentials *credentials, void _dbus_credentials_clear (DBusCredentials *credentials) { - credentials->unix_pid = DBUS_PID_UNSET; + credentials->pid = DBUS_PID_UNSET; credentials->unix_uid = DBUS_UID_UNSET; dbus_free (credentials->windows_sid); credentials->windows_sid = NULL; @@ -523,9 +523,9 @@ _dbus_credentials_to_string_append (DBusCredentials *credentials, goto oom; join = TRUE; } - if (credentials->unix_pid != DBUS_PID_UNSET) + if (credentials->pid != DBUS_PID_UNSET) { - if (!_dbus_string_append_printf (string, "%spid=" DBUS_PID_FORMAT, join ? " " : "", credentials->unix_pid)) + if (!_dbus_string_append_printf (string, "%spid=" DBUS_PID_FORMAT, join ? " " : "", credentials->pid)) goto oom; join = TRUE; } diff --git a/dbus/dbus-credentials.h b/dbus/dbus-credentials.h index ef6124fd..abcc4bb3 100644 --- a/dbus/dbus-credentials.h +++ b/dbus/dbus-credentials.h @@ -41,7 +41,7 @@ DBusCredentials* _dbus_credentials_new_from_current_process (void); DBusCredentials* _dbus_credentials_new (void); void _dbus_credentials_ref (DBusCredentials *credentials); void _dbus_credentials_unref (DBusCredentials *credentials); -dbus_bool_t _dbus_credentials_add_unix_pid (DBusCredentials *credentials, +dbus_bool_t _dbus_credentials_add_pid (DBusCredentials *credentials, dbus_pid_t pid); dbus_bool_t _dbus_credentials_add_unix_uid (DBusCredentials *credentials, dbus_uid_t uid); @@ -52,7 +52,7 @@ dbus_bool_t _dbus_credentials_add_adt_audit_data (DBusCredentials dbus_int32_t size); dbus_bool_t _dbus_credentials_include (DBusCredentials *credentials, DBusCredentialType type); -dbus_pid_t _dbus_credentials_get_unix_pid (DBusCredentials *credentials); +dbus_pid_t _dbus_credentials_get_pid (DBusCredentials *credentials); dbus_uid_t _dbus_credentials_get_unix_uid (DBusCredentials *credentials); const char* _dbus_credentials_get_windows_sid (DBusCredentials *credentials); void * _dbus_credentials_get_adt_audit_data (DBusCredentials *credentials); diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index a0310592..30606ff9 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1863,7 +1863,7 @@ _dbus_read_credentials_socket (int client_fd, if (pid_read != DBUS_PID_UNSET) { - if (!_dbus_credentials_add_unix_pid (credentials, pid_read)) + if (!_dbus_credentials_add_pid (credentials, pid_read)) { _DBUS_SET_OOM (error); return FALSE; @@ -2318,7 +2318,7 @@ _dbus_credentials_add_from_current_process (DBusCredentials *credentials) _dbus_assert (sizeof (uid_t) <= sizeof (dbus_uid_t)); _dbus_assert (sizeof (gid_t) <= sizeof (dbus_gid_t)); - if (!_dbus_credentials_add_unix_pid(credentials, _dbus_getpid())) + if (!_dbus_credentials_add_pid(credentials, _dbus_getpid())) return FALSE; if (!_dbus_credentials_add_unix_uid(credentials, _dbus_geteuid())) return FALSE; diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index f8189af7..ce60d29e 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -1794,7 +1794,7 @@ _dbus_credentials_add_from_current_process (DBusCredentials *credentials) if (!_dbus_getsid(&sid)) goto failed; - if (!_dbus_credentials_add_unix_pid(credentials, _dbus_getpid())) + if (!_dbus_credentials_add_pid (credentials, _dbus_getpid())) goto failed; if (!_dbus_credentials_add_windows_sid (credentials,sid)) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 6b58fda2..c483d764 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -1337,7 +1337,7 @@ _dbus_transport_get_unix_process_id (DBusTransport *transport, if (_dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID)) { - *pid = _dbus_credentials_get_unix_pid (auth_identity); + *pid = _dbus_credentials_get_pid (auth_identity); return TRUE; } else -- cgit v1.2.1 From e25938d52731e1dc59b4aeaaec186578f8cd16af Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 21 Mar 2013 09:24:21 +0100 Subject: Fix test for logind availability sd_booted() is not an appropriate check for whether we should talk to logind, test for /run/systemd/seats/ instead. For details, see: Bug: https://bugs.freedesktop.org/show_bug.cgi?id=62585 [trivial whitespace fix -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-userdb-util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c index 16bf2291..5af00922 100644 --- a/dbus/dbus-userdb-util.c +++ b/dbus/dbus-userdb-util.c @@ -21,6 +21,7 @@ * */ #include +#include #define DBUS_USERDB_INCLUDES_PRIVATE 1 #include "dbus-userdb.h" #include "dbus-test.h" @@ -29,7 +30,6 @@ #include #if HAVE_SYSTEMD -#include #include #endif @@ -55,7 +55,8 @@ _dbus_is_console_user (dbus_uid_t uid, dbus_bool_t result = FALSE; #ifdef HAVE_SYSTEMD - if (sd_booted () > 0) + /* check if we have logind */ + if (access ("/run/systemd/seats/", F_OK) >= 0) { int r; -- cgit v1.2.1 From 751f6783c4e185b05765e7217c782dcb6f0df3e9 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Thu, 21 Mar 2013 09:37:48 +0100 Subject: Update sd-daemon.[hc] from upstream This fixes sd_booted() to actually mean "have systemd init", which we need for _dbus_init_system_log() to decide whether systemd journal is being used. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=62585 Reviewed-by: Simon McVittie --- dbus/sd-daemon.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/dbus/sd-daemon.c b/dbus/sd-daemon.c index 80aadf7a..79d8ca37 100644 --- a/dbus/sd-daemon.c +++ b/dbus/sd-daemon.c @@ -25,7 +25,7 @@ ***/ #ifndef _GNU_SOURCE -#define _GNU_SOURCE +# define _GNU_SOURCE #endif #include @@ -33,9 +33,9 @@ #include #include #ifdef __BIONIC__ -#include +# include #else -#include +# include #endif #include #include @@ -48,21 +48,21 @@ #include #if defined(__linux__) -#include +# include #endif #include "sd-daemon.h" #if (__GNUC__ >= 4) -#ifdef SD_EXPORT_SYMBOLS +# ifdef SD_EXPORT_SYMBOLS /* Export symbols */ -#define _sd_export_ __attribute__ ((visibility("default"))) -#else +# define _sd_export_ __attribute__ ((visibility("default"))) +# else /* Don't export the symbols */ -#define _sd_export_ __attribute__ ((visibility("hidden"))) -#endif +# define _sd_export_ __attribute__ ((visibility("hidden"))) +# endif #else -#define _sd_export_ +# define _sd_export_ #endif _sd_export_ int sd_listen_fds(int unset_environment) { @@ -519,18 +519,15 @@ _sd_export_ int sd_booted(void) { #if defined(DISABLE_SYSTEMD) || !defined(__linux__) return 0; #else + struct stat st; - struct stat a, b; - - /* We simply test whether the systemd cgroup hierarchy is - * mounted */ - - if (lstat("/sys/fs/cgroup", &a) < 0) - return 0; + /* We test whether the runtime unit file directory has been + * created. This takes place in mount-setup.c, so is + * guaranteed to happen very early during boot. */ - if (lstat("/sys/fs/cgroup/systemd", &b) < 0) + if (lstat("/run/systemd/system/", &st) < 0) return 0; - return a.st_dev != b.st_dev; + return !!S_ISDIR(st.st_mode); #endif } -- cgit v1.2.1 From 3d86dbb173270fead07e15ff4adfced943a67c0e Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 15:32:22 -0400 Subject: dbus/dbus-object-tree.c (find_subtree_registered_or_unregistered): New function --- dbus/dbus-object-tree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 172c9d95..cc2560bf 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -1507,6 +1507,17 @@ run_decompose_tests (void) return TRUE; } +static DBusObjectSubtree* +find_subtree_registered_or_unregistered (DBusObjectTree *tree, + const char **path) +{ +#if VERBOSE_FIND + _dbus_verbose ("Looking for exact subtree, registered or unregistered\n"); +#endif + + return find_subtree_recurse (tree->root, path, FALSE, NULL, NULL); +} + static dbus_bool_t object_tree_test_iteration (void *data) { -- cgit v1.2.1 From 28088628f7f39abc1bfe7d9711d5ed5e9be3dfe7 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 15:42:02 -0400 Subject: dbus/dbus-object-tree.c: Add reproducer test case for parent removal FIXME --- dbus/dbus-object-tree.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index cc2560bf..94a11a43 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -1900,6 +1900,15 @@ object_tree_test_iteration (void *data) ++i; } + /* Test removal of newly-childless unregistered nodes */ + if (!do_register (tree, path2, TRUE, 2, tree_test_data)) + goto out; + + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From 22fb6673ff5694c3b8562aeb8fe95f20e09e9ed5 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 15:47:35 -0400 Subject: dbus/dbus-object-tree.c (unregister_subtree): New function --- dbus/dbus-object-tree.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 94a11a43..d496d219 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -433,6 +433,51 @@ _dbus_object_tree_register (DBusObjectTree *tree, return TRUE; } +/** + * Attempts to unregister the given subtree. If the subtree is registered, + * stores its unregister function and user data for later use and returns + * #TRUE. If subtree is not registered, simply returns #FALSE. Does not free + * subtree or remove it from the object tree. + * + * @param subtree the subtree to unregister + * @param unregister_function_out stores subtree's unregister_function + * @param user_data_out stores subtree's user_data + * @return #FALSE if the subtree was not registered, #TRUE on success + */ +static dbus_bool_t +unregister_subtree (DBusObjectSubtree *subtree, + DBusObjectPathUnregisterFunction *unregister_function_out, + void **user_data_out) +{ + _dbus_assert (subtree != NULL); + _dbus_assert (unregister_function_out != NULL); + _dbus_assert (user_data_out != NULL); + + /* Confirm subtree is registered */ + if (subtree->message_function != NULL) + { + subtree->message_function = NULL; + + *unregister_function_out = subtree->unregister_function; + *user_data_out = subtree->user_data; + + subtree->unregister_function = NULL; + subtree->user_data = NULL; + + return TRUE; + } + else + { + /* Assert that this unregistered subtree is either the root node or has + children, otherwise we have a dangling path which should never + happen */ + _dbus_assert (subtree->parent == NULL || subtree->n_subtrees > 0); + + /* The subtree is not registered */ + return FALSE; + } +} + /** * Unregisters an object subtree that was registered with the * same path. -- cgit v1.2.1 From 17fc1fdd34f8fc502427b3127ce9d5428178483f Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 15:49:06 -0400 Subject: dbus/dbus-object-tree.c (attempt_child_removal): New function --- dbus/dbus-object-tree.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index d496d219..56007f80 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -478,6 +478,52 @@ unregister_subtree (DBusObjectSubtree *subtree, } } +/** + * Attempts to remove a child subtree from its parent. If removal is + * successful, also frees the child. Returns #TRUE on success, #FALSE + * otherwise. A #FALSE return value tells unregister_and_free_path_recurse to + * stop attempting to remove ancestors, i.e., that no ancestors of the + * specified child are eligible for removal. + * + * @param parent parent from which to remove child + * @param child_index parent->subtrees index of child to remove + * @return #TRUE if removal and free succeed, #FALSE otherwise + */ +static dbus_bool_t +attempt_child_removal (DBusObjectSubtree *parent, + int child_index) +{ + /* Candidate for removal */ + DBusObjectSubtree* candidate; + + _dbus_assert (parent != NULL); + _dbus_assert (child_index >= 0 && child_index < parent->n_subtrees); + + candidate = parent->subtrees[child_index]; + _dbus_assert (candidate != NULL); + + if (candidate->n_subtrees == 0 && candidate->message_function == NULL) + { + /* The candidate node is childless and is not a registered + path, so... */ + + /* ... remove it from its parent... */ + /* Assumes a 0-byte memmove is OK */ + memmove (&parent->subtrees[child_index], + &parent->subtrees[child_index + 1], + (parent->n_subtrees - child_index - 1) + * sizeof (parent->subtrees[0])); + parent->n_subtrees -= 1; + + /* ... and free it */ + candidate->parent = NULL; + _dbus_object_subtree_unref (candidate); + + return TRUE; + } + return FALSE; +} + /** * Unregisters an object subtree that was registered with the * same path. -- cgit v1.2.1 From b45a5302e30596fb01a264948676e1939977e97e Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 15:50:25 -0400 Subject: dbus/dbus-object-tree.c (unregister_and_free_path_recurse): New function --- dbus/dbus-object-tree.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 56007f80..1c9b79d8 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -524,6 +524,94 @@ attempt_child_removal (DBusObjectSubtree *parent, return FALSE; } +/** + * Searches the object tree for a registered subtree node at the given path. + * If a registered node is found, it is removed from the tree and freed, and + * TRUE is returned. If a registered subtree node is not found at the given + * path, the tree is not modified and FALSE is returned. + * + * The found node's unregister_function and user_data are returned in the + * corresponding _out arguments. The caller should define these variables and + * pass their addresses as arguments. + * + * Likewise, the caller should define and set to TRUE a boolean variable, then + * pass its address as the continue_removal_attempts argument. + * + * Once a matching registered node is found, removed and freed, the recursive + * return path is traversed. Along the way, eligible ancestor nodes are + * removed and freed. An ancestor node is eligible for removal if and only if + * 1) it has no children, i.e., it has become childless and 2) it is not itself + * a registered handler. + * + * For example, suppose /A/B and /A/C are registered paths, and that these are + * the only paths in the tree. If B is removed and freed, C is still reachable + * through A, so A cannot be removed and freed. If C is subsequently removed + * and freed, then A becomes a childless node and it becomes eligible for + * removal, and will be removed and freed. + * + * Similarly, suppose /A is a registered path, and /A/B is also a registered + * path, and that these are the only paths in the tree. If B is removed and + * freed, then even though A has become childless, it can't be freed because it + * refers to a path that is still registered. + * + * @param subtree subtree from which to start the search, root for initial call + * @param path path to subtree (same as _dbus_object_tree_unregister_and_unlock) + * @param continue_removal_attempts pointer to a bool, #TRUE for initial call + * @param unregister_function_out returns the found node's unregister_function + * @param user_data_out returns the found node's user_data + * @returns #TRUE if a registered node was found at path, #FALSE otherwise + */ +static dbus_bool_t +unregister_and_free_path_recurse +(DBusObjectSubtree *subtree, + const char **path, + dbus_bool_t *continue_removal_attempts, + DBusObjectPathUnregisterFunction *unregister_function_out, + void **user_data_out) +{ + int i, j; + + _dbus_assert (continue_removal_attempts != NULL); + _dbus_assert (*continue_removal_attempts); + _dbus_assert (unregister_function_out != NULL); + _dbus_assert (user_data_out != NULL); + + if (path[0] == NULL) + return unregister_subtree (subtree, unregister_function_out, user_data_out); + + i = 0; + j = subtree->n_subtrees; + while (i < j) + { + int k, v; + + k = (i + j) / 2; + v = strcmp (path[0], subtree->subtrees[k]->name); + + if (v == 0) + { + dbus_bool_t freed; + freed = unregister_and_free_path_recurse (subtree->subtrees[k], + &path[1], + continue_removal_attempts, + unregister_function_out, + user_data_out); + if (freed && *continue_removal_attempts) + *continue_removal_attempts = attempt_child_removal (subtree, k); + return freed; + } + else if (v < 0) + { + j = k; + } + else + { + i = k + 1; + } + } + return FALSE; +} + /** * Unregisters an object subtree that was registered with the * same path. -- cgit v1.2.1 From 52ca558efaffe7ae93b7dae387fd14d94b2823a3 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 15:56:10 -0400 Subject: dbus/dbus-object-tree.c (_dbus_object_tree_unregister_and_unlock): Fix FIXME Call unregister_and_free_path_recurse instead of find_subtree. Delete subtree removal logic since it has been refactored into unregister_subtree and attempt_child_removal. --- dbus/dbus-object-tree.c | 46 +++++++++++----------------------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 1c9b79d8..9139b518 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -623,21 +623,27 @@ void _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, const char **path) { - int i; - DBusObjectSubtree *subtree; + dbus_bool_t found_subtree; + dbus_bool_t continue_removal_attempts; DBusObjectPathUnregisterFunction unregister_function; void *user_data; DBusConnection *connection; + _dbus_assert (tree != NULL); _dbus_assert (path != NULL); + continue_removal_attempts = TRUE; unregister_function = NULL; user_data = NULL; - subtree = find_subtree (tree, path, &i); + found_subtree = unregister_and_free_path_recurse (tree->root, + path, + &continue_removal_attempts, + &unregister_function, + &user_data); #ifndef DBUS_DISABLE_CHECKS - if (subtree == NULL) + if (found_subtree == FALSE) { _dbus_warn ("Attempted to unregister path (path[0] = %s path[1] = %s) which isn't registered\n", path[0] ? path[0] : "null", @@ -645,39 +651,9 @@ _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, goto unlock; } #else - _dbus_assert (subtree != NULL); + _dbus_assert (found_subtree == TRUE); #endif - _dbus_assert (subtree->parent == NULL || - (i >= 0 && subtree->parent->subtrees[i] == subtree)); - - subtree->message_function = NULL; - - unregister_function = subtree->unregister_function; - user_data = subtree->user_data; - - subtree->unregister_function = NULL; - subtree->user_data = NULL; - - /* If we have no subtrees of our own, remove from - * our parent (FIXME could also be more aggressive - * and remove our parent if it becomes empty) - */ - if (subtree->parent && subtree->n_subtrees == 0) - { - /* assumes a 0-byte memmove is OK */ - memmove (&subtree->parent->subtrees[i], - &subtree->parent->subtrees[i+1], - (subtree->parent->n_subtrees - i - 1) * - sizeof (subtree->parent->subtrees[0])); - subtree->parent->n_subtrees -= 1; - - subtree->parent = NULL; - - _dbus_object_subtree_unref (subtree); - } - subtree = NULL; - unlock: connection = tree->connection; -- cgit v1.2.1 From a2963d23a62582cd26aa8c9a12b7c7062670f278 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 16:12:21 -0400 Subject: dbus/dbus-object-tree.c: Add test case for parent removal fix --- dbus/dbus-object-tree.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 9139b518..4d1e4988 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -2064,6 +2064,30 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Test that unregistered parents cannot be freed out from under their + children */ + if (!do_register (tree, path2, TRUE, 2, tree_test_data)) + goto out; + + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + +#if 0 + /* This triggers the "Attempted to unregister path ..." warning message */ + _dbus_object_tree_unregister_and_unlock (tree, path1); +#endif + _dbus_assert (find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From 74801782893043d354cdbb6bd1d645e712bc0d58 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 16:13:16 -0400 Subject: dbus/dbus-object-tree.c: Add test case for parent removal fix --- dbus/dbus-object-tree.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 4d1e4988..95d5234d 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -2088,6 +2088,30 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Test that registered parents cannot be freed out from under their + children, and that if they are unregistered before their children, they + are still freed when their children are unregistered */ + if (!do_register (tree, path1, TRUE, 1, tree_test_data)) + goto out; + if (!do_register (tree, path2, TRUE, 2, tree_test_data)) + goto out; + + _dbus_assert (find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree (tree, path2, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path1); + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree (tree, path2, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (!find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From 8f03f7f3d815ca02a75b40ffbd1886d4c36fea15 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 16:14:16 -0400 Subject: dbus/dbus-object-tree.c: Add test case for parent removal fix --- dbus/dbus-object-tree.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 95d5234d..14061e8a 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -1685,6 +1685,7 @@ object_tree_test_iteration (void *data) const char *path6[] = { "blah", "boof", NULL }; const char *path7[] = { "blah", "boof", "this", "is", "really", "long", NULL }; const char *path8[] = { "childless", NULL }; + DBusObjectPathVTable test_vtable = { NULL, test_message_function, NULL }; DBusObjectTree *tree; TreeTestData tree_test_data[9]; int i; @@ -2112,6 +2113,20 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Test with NULL unregister_function and user_data */ + if (!_dbus_object_tree_register (tree, TRUE, path2, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path2) == NULL); + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From d4afe1b80fda8657a8166f0ca6b985afdeb46f33 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 16:14:57 -0400 Subject: dbus/dbus-object-tree.c: Add test case for parent removal fix --- dbus/dbus-object-tree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 14061e8a..8ae0f239 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -2127,6 +2127,17 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Test freeing a long path */ + if (!do_register (tree, path3, TRUE, 3, tree_test_data)) + goto out; + + _dbus_object_tree_unregister_and_unlock (tree, path3); + _dbus_assert (!find_subtree (tree, path3, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path3)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From 6d482371afd95bc09ef7697b1d924775138e1263 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 16:16:24 -0400 Subject: dbus/dbus-object-tree.c: Add test case for parent removal fix --- dbus/dbus-object-tree.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 8ae0f239..325bc89a 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -2138,6 +2138,31 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + /* Test freeing multiple children from the same path */ + if (!do_register (tree, path3, TRUE, 3, tree_test_data)) + goto out; + if (!do_register (tree, path4, TRUE, 4, tree_test_data)) + goto out; + + _dbus_assert (find_subtree (tree, path3, NULL)); + _dbus_assert (find_subtree (tree, path4, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path3); + _dbus_assert (!find_subtree (tree, path3, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path3)); + _dbus_assert (find_subtree (tree, path4, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path4)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + + _dbus_object_tree_unregister_and_unlock (tree, path4); + _dbus_assert (!find_subtree (tree, path4, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path4)); + _dbus_assert (!find_subtree (tree, path3, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path3)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From e650c1cb2c698230a7baa9e1b0447e96a1eada57 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 16:17:46 -0400 Subject: dbus/dbus-object-tree.c: Add test case for parent removal fix --- dbus/dbus-object-tree.c | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 325bc89a..49987f59 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -1685,6 +1685,12 @@ object_tree_test_iteration (void *data) const char *path6[] = { "blah", "boof", NULL }; const char *path7[] = { "blah", "boof", "this", "is", "really", "long", NULL }; const char *path8[] = { "childless", NULL }; + const char *path9[] = { "blah", "a", NULL }; + const char *path10[] = { "blah", "b", NULL }; + const char *path11[] = { "blah", "c", NULL }; + const char *path12[] = { "blah", "a", "d", NULL }; + const char *path13[] = { "blah", "b", "d", NULL }; + const char *path14[] = { "blah", "c", "d", NULL }; DBusObjectPathVTable test_vtable = { NULL, test_message_function, NULL }; DBusObjectTree *tree; TreeTestData tree_test_data[9]; @@ -2163,6 +2169,83 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + /* Test subtree removal */ + if (!_dbus_object_tree_register (tree, TRUE, path12, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path12, NULL)); + + if (!_dbus_object_tree_register (tree, TRUE, path13, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path13, NULL)); + + if (!_dbus_object_tree_register (tree, TRUE, path14, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path14, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path12); + + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path12)); + _dbus_assert (find_subtree (tree, path13, NULL)); + _dbus_assert (find_subtree (tree, path14, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path9)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + if (!_dbus_object_tree_register (tree, TRUE, path12, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path12, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path13); + + _dbus_assert (find_subtree (tree, path12, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path13)); + _dbus_assert (find_subtree (tree, path14, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path10)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + if (!_dbus_object_tree_register (tree, TRUE, path13, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path13, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path14); + + _dbus_assert (find_subtree (tree, path12, NULL)); + _dbus_assert (find_subtree (tree, path13, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path14)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path11)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + _dbus_object_tree_unregister_and_unlock (tree, path12); + + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path12)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path9)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + _dbus_object_tree_unregister_and_unlock (tree, path13); + + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path13)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path10)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path5)); + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From 89d4644ee53dea16b8448270e159d8c31acaea93 Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Wed, 27 Mar 2013 16:20:36 -0400 Subject: dbus/dbus-object-tree.c: Add test case for parent removal fix --- dbus/dbus-object-tree.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 49987f59..eba22d14 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -2246,6 +2246,16 @@ object_tree_test_iteration (void *data) _dbus_assert (!find_subtree_registered_or_unregistered (tree, path10)); _dbus_assert (!find_subtree_registered_or_unregistered (tree, path5)); +#if 0 + /* Test attempting to unregister non-existent paths. These trigger + "Attempted to unregister path ..." warning messages */ + _dbus_object_tree_unregister_and_unlock (tree, path0); + _dbus_object_tree_unregister_and_unlock (tree, path1); + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_object_tree_unregister_and_unlock (tree, path3); + _dbus_object_tree_unregister_and_unlock (tree, path4); +#endif + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) -- cgit v1.2.1 From 0b6f144f1cc40980eded278cec0892078da6657a Mon Sep 17 00:00:00 2001 From: Thomas Fitzsimmons Date: Mon, 1 Apr 2013 13:10:16 -0400 Subject: Don't reference path[1] in warning message if path[0] is NULL --- dbus/dbus-object-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index eba22d14..642d67c3 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -647,7 +647,7 @@ _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, { _dbus_warn ("Attempted to unregister path (path[0] = %s path[1] = %s) which isn't registered\n", path[0] ? path[0] : "null", - path[1] ? path[1] : "null"); + (path[0] && path[1]) ? path[1] : "null"); goto unlock; } #else -- cgit v1.2.1 From ee49d0672a04c68850c7d48988d0373caa3077ab Mon Sep 17 00:00:00 2001 From: Dagobert Michelsen Date: Wed, 3 Apr 2013 12:38:38 +0200 Subject: HAVE_DECL_LOG_PERROR is 0 when unavailable Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39987 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-util-unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 81098caf..99888f01 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -433,7 +433,7 @@ _dbus_init_system_log (void) #ifdef HAVE_SYSLOG_H int logopts = LOG_PID; -#ifdef HAVE_DECL_LOG_PERROR +#if HAVE_DECL_LOG_PERROR #ifdef HAVE_SYSTEMD if (sd_booted () <= 0) #endif -- cgit v1.2.1 From 6485fafbca1dbdb0907713d2b325b63926f83fe2 Mon Sep 17 00:00:00 2001 From: Dagobert Michelsen Date: Wed, 3 Apr 2013 10:38:51 +0200 Subject: If alloca.h is available it is required (e.g. on Solaris 10) Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63071 Reviewed-by: Simon McVittie --- configure.ac | 2 ++ dbus/dbus-sysdeps-unix.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 5490cf02..dc083bb6 100644 --- a/configure.ac +++ b/configure.ac @@ -686,6 +686,8 @@ AC_CHECK_HEADERS(ws2tcpip.h) AC_CHECK_HEADERS(wspiapi.h) +AC_CHECK_HEADERS(alloca.h) + # Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris # case $host_os in diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index b4ecc96e..fc677990 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -71,6 +71,9 @@ #ifdef HAVE_GETPEERUCRED #include #endif +#ifdef HAVE_ALLOCA_H +#include +#endif #ifdef HAVE_ADT #include -- cgit v1.2.1 From aa8dcc13a6f0e8711940fae247d1b8064104f893 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 3 Apr 2013 12:20:57 +0100 Subject: NEWS for 1.6 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 061ca186..86b497d6 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,10 @@ D-Bus 1.6.10 (UNRELEASED) • Create session.d, system.d directories under CMake (fd.o #41319, Ralf Habacker) +• Unix-specific: + · Include alloca.h for alloca() if available, fixing compilation on + Solaris 10 (fd.o #63071, Dagobert Michelsen) + D-Bus 1.6.8 (2012-09-28) == -- cgit v1.2.1 From 8159956ed4d34ff217f67758a72005fe4362aa45 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 8 Mar 2013 13:55:32 +0100 Subject: Add function _dbus_get_peer_pid_from_tcp_handle() which returns pid and sid from tcp connection peer. This function is called by _dbus_read_credentials_socket() to fetch client credentials. Because Wine is used to check cross compiled dbus for windows, in calls to GetExtendedTcpTable() we use table class TCP_TABLE_OWNER_PID_ALL instead of TCP_TABLE_OWNER_PID_CONNECTIONS. This class is the only one which is available since wine 1.5.3. https://bugs.freedesktop.org/show_bug.cgi?id=61787 Reviewed-by: Simon McVittie --- cmake/dbus/CMakeLists.txt | 4 +- configure.ac | 2 +- dbus/dbus-sysdeps-win.c | 144 ++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 130 insertions(+), 20 deletions(-) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 8a401716..66772c58 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -264,7 +264,7 @@ if(WIN32) if(WINCE) target_link_libraries(dbus-1 ws2) else(WINCE) - target_link_libraries(dbus-1 ws2_32 advapi32 netapi32) + target_link_libraries(dbus-1 ws2_32 advapi32 netapi32 iphlpapi) endif(WINCE) else(WIN32) target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT} rt) @@ -289,7 +289,7 @@ if(WIN32) if(WINCE) target_link_libraries(dbus-internal ws2) else(WINCE) - target_link_libraries(dbus-internal ws2_32 advapi32 netapi32) + target_link_libraries(dbus-internal ws2_32 advapi32 netapi32 iphlpapi) endif(WINCE) else(WIN32) target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT} rt) diff --git a/configure.ac b/configure.ac index 3bd2405e..b6430c52 100644 --- a/configure.ac +++ b/configure.ac @@ -1279,7 +1279,7 @@ if test x$dbus_win = xyes ; then if test x$dbus_wince = xyes ; then NETWORK_libs="-lws2" else - NETWORK_libs="-lws2_32" + NETWORK_libs="-lws2_32 -liphlpapi" fi fi diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index ce60d29e..66d6b767 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -6,7 +6,7 @@ * Copyright (C) 2005 Novell, Inc. * Copyright (C) 2006 Peter Kümmel * Copyright (C) 2006 Christian Ehrlicher - * Copyright (C) 2006-2010 Ralf Habacker + * Copyright (C) 2006-2013 Ralf Habacker * * Licensed under the Academic Free License version 2.1 * @@ -54,8 +54,9 @@ #include #include #include +#include -/* Declarations missing in mingw's headers */ +/* Declarations missing in mingw's and windows sdk 7.0 headers */ extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR StringSid, PSID *Sid); extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); @@ -103,6 +104,93 @@ _dbus_win_set_errno (int err) #endif } +/** + * @brief return peer process id from tcp handle for localhost connections + * @param handle tcp socket descriptor + * @return process id or 0 in case the process id could not be fetched + */ +static dbus_pid_t +_dbus_get_peer_pid_from_tcp_handle (int handle) +{ + struct sockaddr_storage addr; + socklen_t len = sizeof (addr); + int peer_port; + + dbus_pid_t result; + DWORD size; + MIB_TCPTABLE_OWNER_PID *tcp_table; + DWORD i; + dbus_bool_t is_localhost = FALSE; + + getpeername (handle, (struct sockaddr *) &addr, &len); + + if (addr.ss_family == AF_INET) + { + struct sockaddr_in *s = (struct sockaddr_in *) &addr; + peer_port = ntohs (s->sin_port); + is_localhost = (htonl (s->sin_addr.s_addr) == INADDR_LOOPBACK); + } + else if (addr.ss_family == AF_INET6) + { + _dbus_verbose ("FIXME [61922]: IPV6 support not working on windows\n"); + return 0; + /* + struct sockaddr_in6 *s = (struct sockaddr_in6 * )&addr; + peer_port = ntohs (s->sin6_port); + is_localhost = (memcmp(s->sin6_addr.s6_addr, in6addr_loopback.s6_addr, 16) == 0); + _dbus_verbose ("IPV6 %08x %08x\n", s->sin6_addr.s6_addr, in6addr_loopback.s6_addr); + */ + } + else + { + _dbus_verbose ("no idea what address family %d is\n", addr.ss_family); + return 0; + } + + if (!is_localhost) + { + _dbus_verbose ("could not fetch process id from remote process\n"); + return 0; + } + + if (peer_port == 0) + { + _dbus_verbose + ("Error not been able to fetch tcp peer port from connection\n"); + return 0; + } + + if ((result = + GetExtendedTcpTable (NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) == ERROR_INSUFFICIENT_BUFFER) + { + tcp_table = (MIB_TCPTABLE_OWNER_PID *) dbus_malloc (size); + if (tcp_table == NULL) + { + _dbus_verbose ("Error allocating memory\n"); + return 0; + } + } + + if ((result = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) + { + _dbus_verbose ("Error fetching tcp table %d\n", result); + dbus_free (tcp_table); + return 0; + } + + result = 0; + for (i = 0; i < tcp_table->dwNumEntries; i++) + { + MIB_TCPROW_OWNER_PID *p = &tcp_table->table[i]; + int local_port = ntohs (p->dwLocalPort); + if (p->dwState == MIB_TCP_STATE_ESTAB && local_port == peer_port) + result = p->dwOwningPid; + } + + _dbus_verbose ("got pid %d\n", result); + dbus_free (tcp_table); + return result; +} /* Convert GetLastError() to a dbus error. */ const char* @@ -738,22 +826,23 @@ _dbus_pid_for_log (void) return _dbus_getpid (); } - #ifndef DBUS_WINCE /** Gets our SID - * @param points to sid buffer, need to be freed with LocalFree() + * @param sid points to sid buffer, need to be freed with LocalFree() + * @param process_id the process id for which the sid should be returned * @returns process sid */ static dbus_bool_t -_dbus_getsid(char **sid) +_dbus_getsid(char **sid, dbus_pid_t process_id) { HANDLE process_token = INVALID_HANDLE_VALUE; TOKEN_USER *token_user = NULL; DWORD n; PSID psid; int retval = FALSE; - - if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &process_token)) + HANDLE process_handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); + + if (!OpenProcessToken (process_handle, TOKEN_QUERY, &process_token)) { _dbus_win_warn_win_error ("OpenProcessToken failed", GetLastError ()); goto failed; @@ -781,6 +870,7 @@ _dbus_getsid(char **sid) retval = TRUE; failed: + CloseHandle (process_handle); if (process_token != INVALID_HANDLE_VALUE) CloseHandle (process_token); @@ -1665,7 +1755,7 @@ again: * a byte was read, not whether we got valid credentials. On some * systems, such as Linux, reading/writing the byte isn't actually * required, but we do it anyway just to avoid multiple codepaths. - * + * * Fails if no byte is available, so you must select() first. * * The point of the byte is that on some systems we have to @@ -1683,21 +1773,41 @@ _dbus_read_credentials_socket (int handle, { int bytes_read = 0; DBusString buf; - + + char *sid = NULL; + dbus_pid_t pid; + int retval = FALSE; + // could fail due too OOM - if (_dbus_string_init(&buf)) + if (_dbus_string_init (&buf)) { - bytes_read = _dbus_read_socket(handle, &buf, 1 ); + bytes_read = _dbus_read_socket (handle, &buf, 1 ); if (bytes_read > 0) - _dbus_verbose("got one zero byte from server\n"); + _dbus_verbose ("got one zero byte from server\n"); - _dbus_string_free(&buf); + _dbus_string_free (&buf); } - _dbus_verbose("FIXME: fetch credentials from client connection\n"); + pid = _dbus_get_peer_pid_from_tcp_handle (handle); + if (pid == 0) + return TRUE; - return TRUE; + _dbus_credentials_add_pid (credentials, pid); + + if (_dbus_getsid (&sid, pid)) + { + if (!_dbus_credentials_add_windows_sid (credentials, sid)) + goto out; + } + + retval = TRUE; + +out: + if (sid) + LocalFree (sid); + + return retval; } /** @@ -1791,7 +1901,7 @@ _dbus_credentials_add_from_current_process (DBusCredentials *credentials) dbus_bool_t retval = FALSE; char *sid = NULL; - if (!_dbus_getsid(&sid)) + if (!_dbus_getsid(&sid, _dbus_getpid())) goto failed; if (!_dbus_credentials_add_pid (credentials, _dbus_getpid())) @@ -1829,7 +1939,7 @@ _dbus_append_user_from_current_process (DBusString *str) dbus_bool_t retval = FALSE; char *sid = NULL; - if (!_dbus_getsid(&sid)) + if (!_dbus_getsid(&sid, _dbus_getpid())) return FALSE; retval = _dbus_string_append (str,sid); -- cgit v1.2.1 From 1495c207b4c76e306a3fe666fffe2b95e0326f3e Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 4 Apr 2013 10:49:18 -0500 Subject: Don't access random memory if data slot isn't allocated yet If DBUS_DISABLE_ASSERTS was turned on, and a buggy program called dbus_connection_get_data() with a slot number less than zero (eg, before even allocating the data slot), random memory would be accessed and a random value returned. Anything less than zero is not a valid slot number and should be rejected by libdbus. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63127 Signed-off-by: Dan Williams Reviewed-by: Simon McVittie --- dbus/dbus-connection.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index ee33b6cc..66315b3f 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -5974,7 +5974,8 @@ dbus_connection_get_data (DBusConnection *connection, void *res; _dbus_return_val_if_fail (connection != NULL, NULL); - + _dbus_return_val_if_fail (slot >= 0, NULL); + SLOTS_LOCK (connection); res = _dbus_data_slot_list_get (&slot_allocator, -- cgit v1.2.1 From 02be6d055348ee0013cf744ecf518bbbe5cadedf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Apr 2013 12:47:07 +0100 Subject: NEWS for 1.6 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 86b497d6..96e10146 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ D-Bus 1.6.10 (UNRELEASED) == +• Diagnose incorrect use of dbus_connection_get_data() with negative slot + (i.e. before allocating the slot) rather than returning junk + (fd.o #63127, Dan Williams) + • In the activation helper, when compiled for tests, do not reset the system bus address, fixing the regression tests. (fd.o #52202, Simon) -- cgit v1.2.1 From c052230fffb444ff15667bb07411397ce77fb08c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 18 Feb 2013 14:27:48 +0000 Subject: Don't warn for functions deprecated since GLib 2.26 Also warn if we inadvertently use a function introduced since then. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59971 Reviewed-by: Colin Walters --- configure.ac | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure.ac b/configure.ac index dc083bb6..edd599cd 100644 --- a/configure.ac +++ b/configure.ac @@ -212,6 +212,9 @@ fi # default (unless you don't have GLib), because they don't bloat the library # or binaries. +AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_26], [Ignore post-2.26 deprecations]) +AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_26], [Prevent post-2.26 APIs]) + with_glib=yes if test "x$enable_modular_tests" != xno; then -- cgit v1.2.1 From 540e5692e07d48fb41a4e977e0c9078fa19bd677 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Apr 2013 12:54:57 +0100 Subject: Allow use of GLib 2.32 functionality, which we do conditionally --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index edd599cd..6762808c 100644 --- a/configure.ac +++ b/configure.ac @@ -213,7 +213,7 @@ fi # or binaries. AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_26], [Ignore post-2.26 deprecations]) -AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_26], [Prevent post-2.26 APIs]) +AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevent post-2.32 APIs]) with_glib=yes -- cgit v1.2.1 From 71fc71fe5552c8292564ea0662b30fd535d8565f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Apr 2013 12:57:56 +0100 Subject: NEWS for 1.7 --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 93a968f2..8b4fe0d4 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,8 @@ D-Bus 1.7.2 (UNRELEASED) • Windows-specific: · Do not claim that all bus clients have the dbus-daemon's credentials (fd.o #61787, Ralf Habacker) + · Pick up local TCPv4 clients' credentials (process ID and session ID) + using GetExtendedTcpTable() (fd.o #61787, Ralf Habacker) D-Bus 1.7.0 (2013-02-22) == -- cgit v1.2.1 From 60511bb9951c210b82e14f8b5b1a10a744acf6bc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Apr 2013 17:01:29 +0100 Subject: fix NEWS: a Windows "sid" is a security ID, not a session ID --- NEWS | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index c7d6500a..6bd2e0da 100644 --- a/NEWS +++ b/NEWS @@ -16,10 +16,10 @@ D-Bus 1.7.2 (UNRELEASED) meinproc's XSLT stylesheets (fd.o #61637, Ralf Habacker) • Windows-specific: - · Do not claim that all bus clients have the dbus-daemon's credentials - (fd.o #61787, Ralf Habacker) - · Pick up local TCPv4 clients' credentials (process ID and session ID) - using GetExtendedTcpTable() (fd.o #61787, Ralf Habacker) + · Do not claim that all bus clients have the dbus-daemon's credentials; + pick up local TCPv4 clients' credentials (process ID and security + identifier, i.e. user) using GetExtendedTcpTable() (fd.o #61787, + Ralf Habacker) D-Bus 1.7.0 (2013-02-22) == -- cgit v1.2.1 From 2ab900b678abb6df62790549b55230215f20a8a4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 5 Apr 2013 13:28:54 +0100 Subject: Do not suppress syslog test's stderr just because init is systemd This causes the test to fail. The assumption implicitly being made was "if pid 1 is systemd, then every caller of _dbus_init_system_log() is a systemd service" which is not valid for the regression test. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63163 Signed-off-by: Simon McVittie Reviewed-by: Colin Walters --- bus/bus.c | 2 +- dbus/dbus-sysdeps-util-unix.c | 4 ++-- dbus/dbus-sysdeps-util-win.c | 2 +- dbus/dbus-sysdeps.h | 2 +- test/internals/syslog.c | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bus/bus.c b/bus/bus.c index e80e7080..307c1586 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -287,7 +287,7 @@ process_config_first_time_only (BusContext *context, auth_mechanisms = NULL; pidfile = NULL; - _dbus_init_system_log (); + _dbus_init_system_log (TRUE); if (flags & BUS_CONTEXT_FLAG_SYSTEMD_ACTIVATION) context->systemd_activation = TRUE; diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 99888f01..789729c7 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -428,14 +428,14 @@ _dbus_request_file_descriptor_limit (unsigned int limit) } void -_dbus_init_system_log (void) +_dbus_init_system_log (dbus_bool_t is_daemon) { #ifdef HAVE_SYSLOG_H int logopts = LOG_PID; #if HAVE_DECL_LOG_PERROR #ifdef HAVE_SYSTEMD - if (sd_booted () <= 0) + if (!is_daemon || sd_booted () <= 0) #endif logopts |= LOG_PERROR; #endif diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 111db9ea..abb10f70 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -262,7 +262,7 @@ _dbus_request_file_descriptor_limit (unsigned int limit) } void -_dbus_init_system_log (void) +_dbus_init_system_log (dbus_bool_t is_daemon) { /* OutputDebugStringA doesn't need any special initialization, do nothing */ } diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index f4b0ac97..a3205cfe 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -450,7 +450,7 @@ void _dbus_set_signal_handler (int sig, dbus_bool_t _dbus_user_at_console (const char *username, DBusError *error); -void _dbus_init_system_log (void); +void _dbus_init_system_log (dbus_bool_t is_daemon); typedef enum { DBUS_SYSTEM_LOG_INFO, diff --git a/test/internals/syslog.c b/test/internals/syslog.c index 4f6b7c22..658281cb 100644 --- a/test/internals/syslog.c +++ b/test/internals/syslog.c @@ -54,7 +54,7 @@ test_syslog (Fixture *f, { if (g_test_trap_fork (0, 0)) { - _dbus_init_system_log (); + _dbus_init_system_log (FALSE); _dbus_system_log (DBUS_SYSTEM_LOG_FATAL, MESSAGE "%d", 23); /* should not be reached: exit 0 so the assertion in the main process * will fail */ @@ -66,7 +66,7 @@ test_syslog (Fixture *f, if (g_test_trap_fork (0, 0)) { - _dbus_init_system_log (); + _dbus_init_system_log (FALSE); _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); exit (0); @@ -76,7 +76,7 @@ test_syslog (Fixture *f, g_test_trap_assert_stderr ("*" MESSAGE "42\n*" MESSAGE "666\n*"); /* manual test (this is the best we can do on Windows) */ - _dbus_init_system_log (); + _dbus_init_system_log (FALSE); _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); _dbus_system_log (DBUS_SYSTEM_LOG_SECURITY, MESSAGE "%d", 666); } -- cgit v1.2.1 From 977293549d909c50490f0376bc90ec3c93cb2ad5 Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Wed, 20 Feb 2013 15:23:42 -0600 Subject: Set default maximum number of Unix fds according to OS QNX has an arbitrary limit to the number of file descriptors which may be passed in a message, which is smaller than the current default. This patch therefore changes the default from a hardcoded constant to a macro, which is determined at configure time by looking at the host operating system. [This reduces the limit from 4096 (session)/1024 (system) to 128 fds per message on QNX, and 1024 fds per message on other operating systems. I think the reduced session bus limit on other OSs is a reasonable change too, given that the default hard/soft ulimits in Linux are only 4096/1024 fds per process. -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61176 Reviewed-by: Simon McVittie --- bus/config-parser.c | 6 +++--- bus/session.conf.in | 2 +- cmake/config.h.cmake | 2 ++ configure.ac | 11 +++++++++++ dbus/dbus-message.c | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/bus/config-parser.c b/bus/config-parser.c index 1d1b8bf0..ff73ed03 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -420,9 +420,9 @@ bus_config_parser_new (const DBusString *basedir, maximum number of file descriptors we can receive. Picking a high value here thus translates directly to more memory allocation. */ - parser->limits.max_incoming_unix_fds = 1024*4; - parser->limits.max_outgoing_unix_fds = 1024*4; - parser->limits.max_message_unix_fds = 1024; + parser->limits.max_incoming_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS*4; + parser->limits.max_outgoing_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS*4; + parser->limits.max_message_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS; /* Making this long means the user has to wait longer for an error * message if something screws up, but making it too short means diff --git a/bus/session.conf.in b/bus/session.conf.in index 716b5e79..bb6f70bc 100644 --- a/bus/session.conf.in +++ b/bus/session.conf.in @@ -49,7 +49,7 @@ 1000000000 250000000 1000000000 - 4096 + @default_message_unix_fds@ 120000 240000 100000 diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 76ccb866..b0dde3dd 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -82,6 +82,8 @@ # define DBUS_ENABLE_X11_AUTOLAUNCH 1 #endif +#define DBUS_DEFAULT_MESSAGE_UNIX_FDS 1024 + #define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; } #cmakedefine DBUS_VA_COPY_FUNC diff --git a/configure.ac b/configure.ac index aff812e6..c55ced7d 100644 --- a/configure.ac +++ b/configure.ac @@ -1296,6 +1296,17 @@ if test x$with_valgrind != xno; then AC_DEFINE([WITH_VALGRIND], [1], [Define to add Valgrind instrumentation]) fi +# Determine maximum number of Unix fds which may be passed +AS_CASE([$host_os], + [*qnx*], + [default_message_unix_fds=256], + [*], + [default_message_unix_fds=1024]) +AC_DEFINE_UNQUOTED([DBUS_DEFAULT_MESSAGE_UNIX_FDS], + [$default_message_unix_fds], + [Default for dbus_connection_get_max_message_unix_fds()]) +AC_SUBST([default_message_unix_fds]) + #### Set up final flags LIBDBUS_LIBS="$THREAD_LIBS $NETWORK_libs" AC_SUBST([LIBDBUS_LIBS]) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 71bcee60..619bc695 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -3802,7 +3802,7 @@ _dbus_message_loader_new (void) SCM_RIGHTS works we need to preallocate an fd array of the maximum number of unix fds we want to receive in advance. A try-and-reallocate loop is not possible. */ - loader->max_message_unix_fds = 1024; + loader->max_message_unix_fds = DBUS_DEFAULT_MESSAGE_UNIX_FDS; if (!_dbus_string_init (&loader->data)) { -- cgit v1.2.1 From 1aaeb6afd0d6dcc02497e6f952f88e94e05b04b9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 11 Apr 2013 14:00:15 +0100 Subject: NEWS for 1.7 --- NEWS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/NEWS b/NEWS index 6bd2e0da..a47f8495 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,15 @@ D-Bus 1.7.2 (UNRELEASED) == +Configuration changes: + +• On non-QNX Unix platforms, the default limit on fds per message in the + session bus configuration has reduced from 4096 to 1024. The default + limit used on the system bus was already 1024. On QNX, both limits are + reduced further, to 128. + +Fixes: + • Diagnose incorrect use of dbus_connection_get_data() with negative slot (i.e. before allocating the slot) rather than returning junk (fd.o #63127, Dan Williams) @@ -14,6 +23,8 @@ D-Bus 1.7.2 (UNRELEASED) (fd.o #62585, Martin Pitt) · When built with CMake, link to librt and use the right path for meinproc's XSLT stylesheets (fd.o #61637, Ralf Habacker) + · Reduce the default limit on number of fds per message to 128 under + QNX, working around an arbitrary OS limit (fd.o #61176, Matt Fischer) • Windows-specific: · Do not claim that all bus clients have the dbus-daemon's credentials; -- cgit v1.2.1 From 68c1a26d1e740e2500001b4a28d91d5753fc99dc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 17:40:41 +0100 Subject: sd-daemon.c: update from systemd for better portability --- dbus/sd-daemon.c | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/dbus/sd-daemon.c b/dbus/sd-daemon.c index 79d8ca37..485b3010 100644 --- a/dbus/sd-daemon.c +++ b/dbus/sd-daemon.c @@ -32,11 +32,7 @@ #include #include #include -#ifdef __BIONIC__ -# include -#else -# include -#endif +#include #include #include #include @@ -47,7 +43,7 @@ #include #include -#if defined(__linux__) +#if defined(__linux__) && !defined(SD_DAEMON_DISABLE_MQ) # include #endif @@ -84,7 +80,7 @@ _sd_export_ int sd_listen_fds(int unset_environment) { errno = 0; l = strtoul(e, &p, 10); - if (errno != 0) { + if (errno > 0) { r = -errno; goto finish; } @@ -109,7 +105,7 @@ _sd_export_ int sd_listen_fds(int unset_environment) { errno = 0; l = strtoul(e, &p, 10); - if (errno != 0) { + if (errno > 0) { r = -errno; goto finish; } @@ -278,11 +274,8 @@ _sd_export_ int sd_is_socket(int fd, int family, int type, int listening) { return r; if (family > 0) { - union sockaddr_union sockaddr; - socklen_t l; - - memset(&sockaddr, 0, sizeof(sockaddr)); - l = sizeof(sockaddr); + union sockaddr_union sockaddr = {}; + socklen_t l = sizeof(sockaddr); if (getsockname(fd, &sockaddr.sa, &l) < 0) return -errno; @@ -297,8 +290,8 @@ _sd_export_ int sd_is_socket(int fd, int family, int type, int listening) { } _sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, uint16_t port) { - union sockaddr_union sockaddr; - socklen_t l; + union sockaddr_union sockaddr = {}; + socklen_t l = sizeof(sockaddr); int r; if (family != 0 && family != AF_INET && family != AF_INET6) @@ -308,9 +301,6 @@ _sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, u if (r <= 0) return r; - memset(&sockaddr, 0, sizeof(sockaddr)); - l = sizeof(sockaddr); - if (getsockname(fd, &sockaddr.sa, &l) < 0) return -errno; @@ -343,17 +333,14 @@ _sd_export_ int sd_is_socket_inet(int fd, int family, int type, int listening, u } _sd_export_ int sd_is_socket_unix(int fd, int type, int listening, const char *path, size_t length) { - union sockaddr_union sockaddr; - socklen_t l; + union sockaddr_union sockaddr = {}; + socklen_t l = sizeof(sockaddr); int r; r = sd_is_socket_internal(fd, type, listening); if (r <= 0) return r; - memset(&sockaddr, 0, sizeof(sockaddr)); - l = sizeof(sockaddr); - if (getsockname(fd, &sockaddr.sa, &l) < 0) return -errno; @@ -387,7 +374,7 @@ _sd_export_ int sd_is_socket_unix(int fd, int type, int listening, const char *p } _sd_export_ int sd_is_mq(int fd, const char *path) { -#if !defined(__linux__) +#if !defined(__linux__) || defined(SD_DAEMON_DISABLE_MQ) return 0; #else struct mq_attr attr; -- cgit v1.2.1 From 1502908465491df129ca2b101bf528e0a9a6fb57 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 18 Apr 2013 12:21:58 +0100 Subject: cmake: define default_message_unix_fds so it can be substituted in session.conf This fixes a regression since 1.7.0: session.conf would be invalid when generated by cmake. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63682 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker --- cmake/CMakeLists.txt | 4 ++++ cmake/config.h.cmake | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9a37e40f..c7f9939e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -435,6 +435,10 @@ endif (WIN32) set (DBUS_USER ) +# In Autotools this has a different default on QNX, but there seems little +# point in replicating that here; if you're on an unusual Unix, use Autotools. +set (default_message_unix_fds 1024) + # This won't work on Windows. It's not meant to - the system bus is # meaningless on Windows anyway. # diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index b0dde3dd..3c7cb966 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -82,7 +82,7 @@ # define DBUS_ENABLE_X11_AUTOLAUNCH 1 #endif -#define DBUS_DEFAULT_MESSAGE_UNIX_FDS 1024 +#define DBUS_DEFAULT_MESSAGE_UNIX_FDS @default_message_unix_fds@ #define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; } -- cgit v1.2.1 From 287242271844b27149459b1448dedebf167a3024 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 18 Apr 2013 12:35:07 +0100 Subject: Rename default_message_unix_fds to DEFAULT_MESSAGE_UNIX_FDS As Ralf pointed out, we usually use upper-case when substituting variables (apart from "somethingdir", which Autoconf conventionally makes lower-case for some reason). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63682 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker --- bus/session.conf.in | 2 +- cmake/CMakeLists.txt | 2 +- cmake/config.h.cmake | 2 +- configure.ac | 8 ++++---- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bus/session.conf.in b/bus/session.conf.in index bb6f70bc..74d9d1fd 100644 --- a/bus/session.conf.in +++ b/bus/session.conf.in @@ -49,7 +49,7 @@ 1000000000 250000000 1000000000 - @default_message_unix_fds@ + @DEFAULT_MESSAGE_UNIX_FDS@ 120000 240000 100000 diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c7f9939e..45d7fb8a 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -437,7 +437,7 @@ set (DBUS_USER ) # In Autotools this has a different default on QNX, but there seems little # point in replicating that here; if you're on an unusual Unix, use Autotools. -set (default_message_unix_fds 1024) +set (DEFAULT_MESSAGE_UNIX_FDS 1024) # This won't work on Windows. It's not meant to - the system bus is # meaningless on Windows anyway. diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 3c7cb966..91cf0806 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -82,7 +82,7 @@ # define DBUS_ENABLE_X11_AUTOLAUNCH 1 #endif -#define DBUS_DEFAULT_MESSAGE_UNIX_FDS @default_message_unix_fds@ +#define DBUS_DEFAULT_MESSAGE_UNIX_FDS @DEFAULT_MESSAGE_UNIX_FDS@ #define _DBUS_VA_COPY_ASSIGN(a1,a2) { a1 = a2; } diff --git a/configure.ac b/configure.ac index c55ced7d..21df9507 100644 --- a/configure.ac +++ b/configure.ac @@ -1299,13 +1299,13 @@ fi # Determine maximum number of Unix fds which may be passed AS_CASE([$host_os], [*qnx*], - [default_message_unix_fds=256], + [DEFAULT_MESSAGE_UNIX_FDS=256], [*], - [default_message_unix_fds=1024]) + [DEFAULT_MESSAGE_UNIX_FDS=1024]) AC_DEFINE_UNQUOTED([DBUS_DEFAULT_MESSAGE_UNIX_FDS], - [$default_message_unix_fds], + [$DEFAULT_MESSAGE_UNIX_FDS], [Default for dbus_connection_get_max_message_unix_fds()]) -AC_SUBST([default_message_unix_fds]) +AC_SUBST([DEFAULT_MESSAGE_UNIX_FDS]) #### Set up final flags LIBDBUS_LIBS="$THREAD_LIBS $NETWORK_libs" -- cgit v1.2.1 From c27d913789333997f4224e951c0024e31f273168 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 18 Apr 2013 19:26:59 +0100 Subject: NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index a47f8495..2f85aa64 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ Fixes: (i.e. before allocating the slot) rather than returning junk (fd.o #63127, Dan Williams) +• Fix a cmake build regression since 1.7.0 (fd.o #63682; Ralf Habacker, + Simon McVittie) + • Unix-specific:   · Under systemd, log to syslog only, not stderr, avoiding duplication (fd.o #61399, #39987; Colin Walters, Dagobert Michelsen) -- cgit v1.2.1 From 7467a410ef74ac121cb4aa75948c580f6ad30d6d Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 22 Feb 2013 17:32:18 +0100 Subject: Unify docbook dtd version to 4.4. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59805 Reviewed-by: Simon McVittie --- doc/dbus-faq.xml | 4 ++-- doc/dbus-specification.xml | 4 ++-- doc/dbus-test-plan.xml | 4 ++-- doc/dbus-tutorial.xml | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/doc/dbus-faq.xml b/doc/dbus-faq.xml index 69ac3f15..0d296d92 100644 --- a/doc/dbus-faq.xml +++ b/doc/dbus-faq.xml @@ -1,6 +1,6 @@ - diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index fdb247d9..8316764b 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -1,6 +1,6 @@ -
diff --git a/doc/dbus-test-plan.xml b/doc/dbus-test-plan.xml index e6aafb9a..ee911149 100644 --- a/doc/dbus-test-plan.xml +++ b/doc/dbus-test-plan.xml @@ -1,6 +1,6 @@ - diff --git a/doc/dbus-tutorial.xml b/doc/dbus-tutorial.xml index 5c385f0e..c7580d15 100644 --- a/doc/dbus-tutorial.xml +++ b/doc/dbus-tutorial.xml @@ -1,6 +1,6 @@ - -- cgit v1.2.1 From 6b2add5e70252c513f506f84cc386f47953df48d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 22 Apr 2013 15:36:32 +0100 Subject: Accept non-characters when validating Unicode Unicode Corrigendum #9 clarifies that the non-characters U+nFFFE (for n in the range 0 to 0x10), U+nFFFF (for n in the same range), and U+FDD0..U+FDEF are valid for interchange, and their presence does not make a string ill-formed. GLib 2.36 made the corresponding change in its definition of UTF-8 as used by g_utf8_validate() and similar functions. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63072 Signed-off-by: Simon McVittie --- dbus/dbus-string.c | 10 +--------- test/syntax.c | 6 ++++-- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 9accdb19..e3766aad 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -1577,19 +1577,11 @@ _dbus_string_split_on_byte (DBusString *source, * * The second check covers surrogate pairs (category Cs). * - * The last two checks cover "Noncharacter": defined as: - * "A code point that is permanently reserved for - * internal use, and that should never be interchanged. In - * Unicode 3.1, these consist of the values U+nFFFE and U+nFFFF - * (where n is from 0 to 10_16) and the values U+FDD0..U+FDEF." - * * @param Char the character */ #define UNICODE_VALID(Char) \ ((Char) < 0x110000 && \ - (((Char) & 0xFFFFF800) != 0xD800) && \ - ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \ - ((Char) & 0xFFFE) != 0xFFFE) + (((Char) & 0xFFFFF800) != 0xD800)) /** * Finds the given substring in the string, diff --git a/test/syntax.c b/test/syntax.c index 88db9638..e26b3643 100644 --- a/test/syntax.c +++ b/test/syntax.c @@ -178,12 +178,14 @@ const char * const invalid_single_signatures[] = { const char * const valid_strings[] = { "", - "\xc2\xa9", + "\xc2\xa9", /* UTF-8 (c) symbol */ + "\xef\xbf\xbe", /* U+FFFE is reserved but Corrigendum 9 says it's OK */ NULL }; const char * const invalid_strings[] = { - "\xa9", + "\xa9", /* Latin-1 (c) symbol */ + "\xed\xa0\x80", /* UTF-16 surrogates are not valid in UTF-8 */ NULL }; -- cgit v1.2.1 From 6d7782659aff46544bbb9177bf09753fdb454fac Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 22 Apr 2013 16:15:34 +0100 Subject: NEWS for 1.6 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 96e10146..a3c4ad5b 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ D-Bus 1.6.10 (UNRELEASED) == +• Following Unicode Corrigendum #9, the noncharacters U+nFFFE, U+nFFFF, + U+FDD0..U+FDEF are allowed in UTF-8 strings again. + (fd.o #63072, Simon McVittie) + • Diagnose incorrect use of dbus_connection_get_data() with negative slot (i.e. before allocating the slot) rather than returning junk (fd.o #63127, Dan Williams) -- cgit v1.2.1 From 0c97243219978e449943c6b4dbc2bb28f34111ca Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 22 Apr 2013 15:30:33 +0100 Subject: Specification: explicitly allow the Unicode noncharacters This follows Unicode Corrigendum #9. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63072 Signed-off-by: Simon McVittie --- doc/dbus-specification.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 8316764b..f18327ac 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -454,8 +454,15 @@ are basic types with a variable length. The value of any string-like type is conceptually 0 or more Unicode codepoints encoded in UTF-8, none of which may be U+0000. The UTF-8 text must be validated - strictly: in particular, it must not contain overlong sequences, - noncharacters such as U+FFFE, or codepoints above U+10FFFF. + strictly: in particular, it must not contain overlong sequences + or codepoints above U+10FFFF. + + + + Since D-Bus Specification version 0.21, in accordance with Unicode + Corrigendum #9, the "noncharacters" U+FDD0..U+FDEF, U+nFFFE and + U+nFFFF are allowed in UTF-8 strings (but note that older versions of + D-Bus rejected these noncharacters). -- cgit v1.2.1 From 235fd739a4c54843c5939230039f980ddff15a89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= Date: Sun, 14 Apr 2013 03:57:40 -0300 Subject: dbus.service.in: Do not order after syslog.target It is no longer required or recommended in fact it no longer exists since http://cgit.freedesktop.org/systemd/systemd/commit/?id=5d4caf565471ff3401bd9b53aa814c8545a18a93 [Clarification: there are two reasons why we do not need that dependency. First, we do not have DefaultDependencies=no, so we only get run after sockets.target. Second, syslog.socket doesn't provide /dev/log, which is part of systemd-journald.socket. -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63531 Reviewed-by: Simon McVittie --- bus/dbus.service.in | 1 - 1 file changed, 1 deletion(-) diff --git a/bus/dbus.service.in b/bus/dbus.service.in index 160947c7..1b0bbb29 100644 --- a/bus/dbus.service.in +++ b/bus/dbus.service.in @@ -1,7 +1,6 @@ [Unit] Description=D-Bus System Message Bus Requires=dbus.socket -After=syslog.target [Service] ExecStart=@EXPANDED_BINDIR@/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation -- cgit v1.2.1 From 9e04ddba7d3168901ccb0dda20775446fea4ea0b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 22 Apr 2013 16:21:02 +0100 Subject: NEWS for 1.7 --- NEWS | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 4fd09775..a9e752dd 100644 --- a/NEWS +++ b/NEWS @@ -8,11 +8,14 @@ Configuration changes: limit used on the system bus was already 1024. On QNX, both limits are reduced further, to 128. -Fixes: +Enhancements: -• Following Unicode Corrigendum #9, the noncharacters U+nFFFE, U+nFFFF, - U+FDD0..U+FDEF are allowed in UTF-8 strings again. - (fd.o #63072, Simon McVittie) +• D-Bus Specification 0.21 + · Following Unicode Corrigendum #9, the noncharacters U+nFFFE, U+nFFFF, + U+FDD0..U+FDEF are allowed in UTF-8 strings again. (fd.o #63072, + Simon McVittie) + +Fixes: • Diagnose incorrect use of dbus_connection_get_data() with negative slot (i.e. before allocating the slot) rather than returning junk @@ -24,6 +27,8 @@ Fixes: • Unix-specific:   · Under systemd, log to syslog only, not stderr, avoiding duplication (fd.o #61399, #39987; Colin Walters, Dagobert Michelsen) + · Under systemd, remove unnecessary dependency on syslog.socket + (fd.o #63531, Cristian Rodríguez) · Include alloca.h for alloca() if available, fixing compilation on Solaris 10 (fd.o #63071, Dagobert Michelsen) · Allow use of systemd-logind without the rest of systemd -- cgit v1.2.1 From 684916fb67f9b573aacc57f18a6928042462a733 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 17:45:36 +0100 Subject: Disable sd-daemon.c's support for POSIX message queues This fixes build failures with recent glibc while avoiding an otherwise useless librt dependency. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63166 Reviewed-by: Thiago Macieira --- dbus/Makefile.am | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 3679e3f9..87e818a6 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -12,6 +12,10 @@ AM_CPPFLAGS = \ -DDBUS_SESSION_CONFIG_FILE=\""$(configdir)/session.conf"\" \ $(NULL) +# On Linux with glibc 2.17, sd-daemon.c support for POSIX message queues +# results in an otherwise unnecessary dependency on librt. Disable it. +AM_CPPFLAGS += -DSD_DAEMON_DISABLE_MQ + # if assertions are enabled, improve backtraces AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ -- cgit v1.2.1 From 79c150c51983431fe978cfec8f4fcd3cac8f07a0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Apr 2013 19:16:23 +0100 Subject: NEWS for 1.7 --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index a9e752dd..b0ad5a8c 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,7 @@ Fixes: Simon McVittie) • Unix-specific: + · On Linux, link successfully with glibc 2.17 (fd.o #63166, Simon McVittie)   · Under systemd, log to syslog only, not stderr, avoiding duplication (fd.o #61399, #39987; Colin Walters, Dagobert Michelsen) · Under systemd, remove unnecessary dependency on syslog.socket -- cgit v1.2.1 From a1883ddcacabc8f6d661c95f0935e7c08424e06b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 24 Apr 2013 12:14:57 +0100 Subject: Prepare release 1.6.10 --- NEWS | 4 +++- configure.ac | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index a3c4ad5b..3ea75053 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ -D-Bus 1.6.10 (UNRELEASED) +D-Bus 1.6.10 (2013-04-24) == +The “little-known facts about bananas” release. + • Following Unicode Corrigendum #9, the noncharacters U+nFFFE, U+nFFFF, U+FDD0..U+FDEF are allowed in UTF-8 strings again. (fd.o #63072, Simon McVittie) diff --git a/configure.ac b/configure.ac index 6762808c..f860232e 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [9]) +m4_define([dbus_micro_version], [10]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=2 +LT_REVISION=3 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From 1d560ff7f98880d06e4667936611beca802bd651 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 24 Apr 2013 20:30:00 +0100 Subject: development version --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3ea75053..8dd994a5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.6.12 (UNRELEASED) +== + +... + D-Bus 1.6.10 (2013-04-24) == diff --git a/configure.ac b/configure.ac index f860232e..1f0597bd 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [10]) +m4_define([dbus_micro_version], [11]) 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]) -- cgit v1.2.1 From 7ff0cd0640b906821f9b222924e2545b25d28c0f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 25 Apr 2013 13:12:15 +0100 Subject: prepare version 1.7.2 and spec 0.21 --- NEWS | 4 +++- configure.ac | 4 ++-- doc/dbus-specification.xml | 9 +++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index b0ad5a8c..06599794 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ -D-Bus 1.7.2 (UNRELEASED) +D-Bus 1.7.2 (2013-04-25) == +The “only partially opaque” release. + Configuration changes: • On non-QNX Unix platforms, the default limit on fds per message in the diff --git a/configure.ac b/configure.ac index 21df9507..47254a69 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [1]) +m4_define([dbus_micro_version], [2]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=11 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=0 +LT_REVISION=1 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index f18327ac..ec8afde8 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -7,7 +7,7 @@ D-Bus Specification Version 0.21 - (not yet released) + 2013-04-25 Havoc @@ -73,9 +73,10 @@ 0.21 - not yet released (commit log) - - + 2013-04-25 + smcv + allow Unicode noncharacters in UTF-8 (Unicode + Corrigendum #9) 0.20 -- cgit v1.2.1 From 286923789ebe5c85b1f89b0b8279c498a968cb78 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 29 Apr 2013 20:27:12 +0200 Subject: Fixed cmake windows build system bug not installing runtime part of shared libraries into bin dir. This patch also take care of different install directories on unix like os. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=59733 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 6 ++++++ cmake/dbus/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 45d7fb8a..9c1ef2ec 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -70,6 +70,12 @@ set(DBUS_DAEMONDIR ${EXPANDED_BINDIR}) #enable building of shared library SET(BUILD_SHARED_LIBS ON) +if(WIN32) + set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "bin" LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib") +else() + set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${EXPANDED_LIBDIR}" LIBRARY DESTINATION "${EXPANDED_LIBDIR}" ARCHIVE DESTINATION "${EXPANDED_LIBDIR}") +endif() + if (CYGWIN) set (WIN32) endif (CYGWIN) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 66772c58..f70711af 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -270,7 +270,7 @@ else(WIN32) target_link_libraries(dbus-1 ${CMAKE_THREAD_LIBS_INIT} rt) endif(WIN32) -install_targets(/lib dbus-1 ) +install(TARGETS dbus-1 ${INSTALL_TARGETS_DEFAULT_ARGS}) install_files(/include/dbus FILES ${dbusinclude_HEADERS}) ### Internal library, used for the daemon, tools and tests, compiled statically. -- cgit v1.2.1 From 657a589a98ced570145a2892f7dafdd5b4b98248 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 2 May 2013 14:50:16 +0100 Subject: start 1.7.4 development --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 06599794..da6b97f7 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.7.4 (UNRELEASED) +== + +... + D-Bus 1.7.2 (2013-04-25) == diff --git a/configure.ac b/configure.ac index 47254a69..f351fde1 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [2]) +m4_define([dbus_micro_version], [3]) 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]) -- cgit v1.2.1 From 82b3d94ab10f16e6c6c18eb3bc76594cd63e3854 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 2 May 2013 14:50:24 +0100 Subject: start spec 0.22 development --- doc/dbus-specification.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index ec8afde8..a6bedfae 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.21 - 2013-04-25 + Version 0.22 + (not yet released) Havoc @@ -71,6 +71,12 @@ + + 0.22 + not yet released (commit log) + + + 0.21 2013-04-25 -- cgit v1.2.1 From bd5cec18cdc3c1ae66b9875695901cb4b3e063d3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 8 May 2013 14:30:46 +0100 Subject: NEWS --- NEWS | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index da6b97f7..831b8dc4 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,11 @@ D-Bus 1.7.4 (UNRELEASED) == -... +Fixes: + +• Windows-specific: + · Under cmake, install runtime libraries (DLLs) into bin/ instead of lib/ + so that Windows finds them (fd.o #59733, Ralf Habacker) D-Bus 1.7.2 (2013-04-25) == -- cgit v1.2.1 From 7ac9b68220a2f48bc2942aaa909d6ba1f4605f73 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 15 Apr 2013 20:40:21 +0100 Subject: Add _DBUS_GNUC_WARN_UNUSED_RESULT, similar to GLib's Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Ralf Habacker Reviewed-by: Alban Crequy --- dbus/dbus-macros.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-macros.h b/dbus/dbus-macros.h index dcd3eebd..cae4100e 100644 --- a/dbus/dbus-macros.h +++ b/dbus/dbus-macros.h @@ -88,13 +88,21 @@ #define DBUS_ALLOC_SIZE2(x,y) #endif +#if (__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +#define _DBUS_GNUC_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) +#else +#define _DBUS_GNUC_WARN_UNUSED_RESULT +#endif + /** @def _DBUS_GNUC_PRINTF * used to tell gcc about printf format strings */ /** @def _DBUS_GNUC_NORETURN * used to tell gcc about functions that never return, such as _dbus_abort() */ - +/** @def _DBUS_GNUC_WARN_UNUSED_RESULT + * used to tell gcc about functions whose result must be used + */ /* Normally docs are in .c files, but there isn't a .c file for this. */ /** -- cgit v1.2.1 From c36f21a2e91730e9ae52e8945305aa3072f0e508 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 15 Apr 2013 13:51:19 +0100 Subject: DBusAtomic: on Unix, use pthreads mutexes for fallback On pthreads platforms, POSIX guarantees that we can "allocate" mutexes as library-global variables, without involving malloc. This means we don't need to error-check their allocation - if the dynamic linker succeeds, then we have enough memory for all our globals - which is an important step towards being thread-safe by default. In particular, making atomic operations never rely on DBusMutex means that we are free to implement parts of DBusMutex in terms of DBusAtomic, if it would help. We do not currently support any non-Windows platform that does not have pthreads. This is unlikely to change. On Windows, we already used real atomic operations; we can just delete the unused global variable. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Ralf Habacker --- dbus/dbus-internals.h | 5 ----- dbus/dbus-sysdeps-unix.c | 27 ++++++++++++++++++++------- dbus/dbus-sysdeps-win.c | 2 -- dbus/dbus-threads.c | 3 --- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 80376ad5..28486a81 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -323,12 +323,7 @@ _DBUS_DECLARE_GLOBAL_LOCK (win_fds); _DBUS_DECLARE_GLOBAL_LOCK (sid_atom_cache); _DBUS_DECLARE_GLOBAL_LOCK (machine_uuid); -#if !DBUS_USE_SYNC -_DBUS_DECLARE_GLOBAL_LOCK (atomic); -#define _DBUS_N_GLOBAL_LOCKS (15) -#else #define _DBUS_N_GLOBAL_LOCKS (14) -#endif dbus_bool_t _dbus_threads_init_debug (void); diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 88db4153..34dfbe7d 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -82,6 +82,10 @@ #include "sd-daemon.h" +#if !DBUS_USE_SYNC +#include +#endif + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -2428,7 +2432,12 @@ _dbus_parse_uid (const DBusString *uid_str, } #if !DBUS_USE_SYNC -_DBUS_DEFINE_GLOBAL_LOCK (atomic); +/* To be thread-safe by default on platforms that don't necessarily have + * atomic operations (notably Debian armel, which is armv4t), we must + * use a mutex that can be initialized statically, like this. + * GLib >= 2.32 uses a similar system. + */ +static pthread_mutex_t atomic_mutex = PTHREAD_MUTEX_INITIALIZER; #endif /** @@ -2444,10 +2453,12 @@ _dbus_atomic_inc (DBusAtomic *atomic) return __sync_add_and_fetch(&atomic->value, 1)-1; #else dbus_int32_t res; - _DBUS_LOCK (atomic); + + pthread_mutex_lock (&atomic_mutex); res = atomic->value; atomic->value += 1; - _DBUS_UNLOCK (atomic); + pthread_mutex_unlock (&atomic_mutex); + return res; #endif } @@ -2466,10 +2477,11 @@ _dbus_atomic_dec (DBusAtomic *atomic) #else dbus_int32_t res; - _DBUS_LOCK (atomic); + pthread_mutex_lock (&atomic_mutex); res = atomic->value; atomic->value -= 1; - _DBUS_UNLOCK (atomic); + pthread_mutex_unlock (&atomic_mutex); + return res; #endif } @@ -2490,9 +2502,10 @@ _dbus_atomic_get (DBusAtomic *atomic) #else dbus_int32_t res; - _DBUS_LOCK (atomic); + pthread_mutex_lock (&atomic_mutex); res = atomic->value; - _DBUS_UNLOCK (atomic); + pthread_mutex_unlock (&atomic_mutex); + return res; #endif } diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 66d6b767..4a549817 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3188,8 +3188,6 @@ _dbus_get_standard_system_servicedirs (DBusList **dirs) return TRUE; } -_DBUS_DEFINE_GLOBAL_LOCK (atomic); - /** * Atomically increments an integer * diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index bb1169db..b464629a 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -496,9 +496,6 @@ init_locks (void) LOCK_ADDR (pending_call_slots), LOCK_ADDR (server_slots), LOCK_ADDR (message_slots), -#if !DBUS_USE_SYNC - LOCK_ADDR (atomic), -#endif LOCK_ADDR (bus), LOCK_ADDR (bus_datas), LOCK_ADDR (shutdown_funcs), -- cgit v1.2.1 From eabf6c42a1b779f57f2c08d35772035788657579 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 15 Apr 2013 13:54:39 +0100 Subject: dbus_threads_init: call _dbus_threads_init_platform_specific() This reverses the relationship between these two functions. Previously, dbus_threads_init() wouldn't allocate dbus_cond_event_tls on Windows, call check_monotonic_clock on Unix, or call _dbus_check_setuid on Unix. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-pthread.c | 3 ++- dbus/dbus-sysdeps-thread-win.c | 2 +- dbus/dbus-threads.c | 7 ++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 439c9c62..1344074e 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -283,5 +283,6 @@ _dbus_threads_init_platform_specific (void) */ check_monotonic_clock (); (void) _dbus_check_setuid (); - return dbus_threads_init (NULL); + + return TRUE; } diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c index e30e7b87..4c4442a6 100644 --- a/dbus/dbus-sysdeps-thread-win.c +++ b/dbus/dbus-sysdeps-thread-win.c @@ -269,6 +269,6 @@ _dbus_threads_init_platform_specific (void) return FALSE; } - return dbus_threads_init (NULL); + return TRUE; } diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index b464629a..e7f2eb74 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -584,7 +584,8 @@ dbus_threads_init (const DBusThreadFunctions *functions) if (thread_init_generation == _dbus_current_generation) return TRUE; - if (!init_locks ()) + if (!_dbus_threads_init_platform_specific() || + !init_locks ()) return FALSE; thread_init_generation = _dbus_current_generation; @@ -613,7 +614,7 @@ dbus_threads_init (const DBusThreadFunctions *functions) dbus_bool_t dbus_threads_init_default (void) { - return _dbus_threads_init_platform_specific (); + return dbus_threads_init (NULL); } @@ -624,7 +625,7 @@ dbus_threads_init_default (void) dbus_bool_t _dbus_threads_init_debug (void) { - return _dbus_threads_init_platform_specific(); + return dbus_threads_init (NULL); } #endif /* DBUS_BUILD_TESTS */ -- cgit v1.2.1 From 863c989bb631d7063597db30fe8add3233cca7fd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 8 May 2013 15:26:14 +0100 Subject: Fix compiler warnings when X11 autolaunch and launchd are both disabled From the department of "if it isn't tested, it doesn't work". I tried compiling dbus without an assortment of optional features: in_builddir ~/build/dbus/legacy ${MR_REPO}/configure \ --enable-developer --enable-maintainer-mode --enable-tests \ dbus_cv_sync_sub_and_fetch=no \ --disable-selinux \ --disable-inotify \ --disable-dnotify \ --disable-epoll \ --disable-kqueue \ --disable-launchd \ --disable-systemd \ --disable-libaudit \ --without-valgrind \ --disable-x11-autolaunch \ && ... and it resulted in -Wunused warnings. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=64362 Signed-off-by: Simon McVittie Reviewed-by: Thiago Macieira --- dbus/dbus-sysdeps-unix.c | 2 ++ tools/dbus-launch.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 34dfbe7d..d3dd6001 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3220,6 +3220,7 @@ _dbus_get_tmpdir(void) return tmpdir; } +#if defined(DBUS_ENABLE_X11_AUTOLAUNCH) || defined(DBUS_ENABLE_LAUNCHD) /** * Execute a subprocess, returning up to 1024 bytes of output * into @p result. @@ -3421,6 +3422,7 @@ _read_subprocess_line_argv (const char *progpath, return retval; } +#endif /** * Returns the address of a new session bus. diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 2a9dabfa..b2ffe41d 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -1162,7 +1162,6 @@ main (int argc, char **argv) char *end; long wid = 0; long val; - int ret2; verbose ("=== Parent dbus-launch continues\n"); @@ -1236,6 +1235,8 @@ main (int argc, char **argv) #ifdef DBUS_ENABLE_X11_AUTOLAUNCH if (xdisplay != NULL) { + int ret2; + verbose("Saving x11 address\n"); ret2 = x11_save_address (bus_address, bus_pid, &wid); /* Only get an existing dbus session when autolaunching */ -- cgit v1.2.1 From 17a23d08b51cf21a2110047649a86445e99e2b3f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 12:07:23 +0100 Subject: dbus_threads_init_default, dbus_threads_init: be safe to call at any time On Unix, we use a pthreads mutex, which can be allocated and initialized in global memory. On Windows, we use a CRITICAL_SECTION, together with a call to InitializeCriticalSection() from the constructor of a global static C++ object (thanks to Ralf Habacker for suggesting this approach). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Ralf Habacker --- cmake/dbus/CMakeLists.txt | 1 + dbus/Makefile.am | 1 + dbus/dbus-init-win.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-memory.c | 7 ++++++ dbus/dbus-sysdeps-pthread.c | 14 ++++++++++++ dbus/dbus-sysdeps-thread-win.c | 28 +++++++++++++++++++++++ dbus/dbus-sysdeps-win.h | 3 +++ dbus/dbus-sysdeps.h | 12 ++++++++++ dbus/dbus-threads.c | 28 +++++++++++++++++------ 9 files changed, 139 insertions(+), 7 deletions(-) create mode 100644 dbus/dbus-init-win.cpp diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index f70711af..6b2d0635 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -186,6 +186,7 @@ set (DBUS_UTIL_HEADERS if (WIN32) set (DBUS_SHARED_SOURCES ${DBUS_SHARED_SOURCES} ${DBUS_DIR}/dbus-file-win.c + ${DBUS_DIR}/dbus-init-win.cpp ${DBUS_DIR}/dbus-sysdeps-win.c ${DBUS_DIR}/dbus-pipe-win.c ${DBUS_DIR}/dbus-sysdeps-thread-win.c diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 87e818a6..fe9c93f2 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -72,6 +72,7 @@ endif DBUS_SHARED_arch_sources = \ $(wince_source) \ dbus-file-win.c \ + dbus-init-win.cpp \ dbus-pipe-win.c \ dbus-sockets-win.h \ dbus-sysdeps-win.c \ diff --git a/dbus/dbus-init-win.cpp b/dbus/dbus-init-win.cpp new file mode 100644 index 00000000..687f248c --- /dev/null +++ b/dbus/dbus-init-win.cpp @@ -0,0 +1,52 @@ +/* + * dbus-init-win.cpp - once-per-process initialization + * + * Copyright © 2013 Intel Corporation + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +extern "C" +{ +#include "dbus-sysdeps-win.h" +} + +class DBusInternalInit + { + public: + DBusInternalInit () + { + _dbus_threads_windows_init_global (); + } + + void must_not_be_omitted () + { + } + }; + +static DBusInternalInit init; + +extern "C" void +_dbus_threads_windows_ensure_ctor_linked () +{ + /* Do nothing significant, just ensure that the global initializer gets + * linked in. */ + init.must_not_be_omitted (); +} diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index a033b540..317e37ee 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -26,6 +26,7 @@ #include "dbus-internals.h" #include "dbus-sysdeps.h" #include "dbus-list.h" +#include "dbus-threads.h" #include /** @@ -890,7 +891,13 @@ dbus_shutdown (void) dbus_free (c); } + /* We wrap this in the thread-initialization lock because + * dbus_threads_init() uses the current generation to tell whether + * we're initialized, so we need to make sure that un-initializing + * propagates into all threads. */ + _dbus_threads_lock_platform_specific (); _dbus_current_generation += 1; + _dbus_threads_unlock_platform_specific (); } /** @} */ /** End of public API docs block */ diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 1344074e..1300ec35 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -286,3 +286,17 @@ _dbus_threads_init_platform_specific (void) return TRUE; } + +static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; + +void +_dbus_threads_lock_platform_specific (void) +{ + pthread_mutex_lock (&init_mutex); +} + +void +_dbus_threads_unlock_platform_specific (void) +{ + pthread_mutex_unlock (&init_mutex); +} diff --git a/dbus/dbus-sysdeps-thread-win.c b/dbus/dbus-sysdeps-thread-win.c index 4c4442a6..0887a549 100644 --- a/dbus/dbus-sysdeps-thread-win.c +++ b/dbus/dbus-sysdeps-thread-win.c @@ -30,6 +30,21 @@ #include +static dbus_bool_t global_init_done = FALSE; +static CRITICAL_SECTION init_lock; + +/* Called from C++ code in dbus-init-win.cpp. */ +void +_dbus_threads_windows_init_global (void) +{ + /* this ensures that the object that acts as our global constructor + * actually gets linked in when we're linked statically */ + _dbus_threads_windows_ensure_ctor_linked (); + + InitializeCriticalSection (&init_lock); + global_init_done = TRUE; +} + struct DBusCondVar { DBusList *list; /**< list thread-local-stored events waiting on the cond variable */ CRITICAL_SECTION lock; /**< lock protecting the list */ @@ -272,3 +287,16 @@ _dbus_threads_init_platform_specific (void) return TRUE; } +void +_dbus_threads_lock_platform_specific (void) +{ + _dbus_assert (global_init_done); + EnterCriticalSection (&init_lock); +} + +void +_dbus_threads_unlock_platform_specific (void) +{ + _dbus_assert (global_init_done); + LeaveCriticalSection (&init_lock); +} diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 74624b75..5e7f1e46 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -85,6 +85,9 @@ dbus_bool_t _dbus_get_config_file_name(DBusString *config_file, dbus_bool_t _dbus_get_install_root(char *prefix, int len); +void _dbus_threads_windows_init_global (void); +void _dbus_threads_windows_ensure_ctor_linked (void); + #endif /** @} end of sysdeps-win.h */ diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index a3205cfe..d92325ca 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -520,6 +520,18 @@ dbus_bool_t _dbus_read_local_machine_uuid (DBusGUID *machine_id, */ dbus_bool_t _dbus_threads_init_platform_specific (void); +/** + * Lock a static mutex used to protect _dbus_threads_init_platform_specific(). + * + * On Windows, this is currently unimplemented and does nothing. + */ +void _dbus_threads_lock_platform_specific (void); + +/** + * Undo _dbus_threads_lock_platform_specific(). + */ +void _dbus_threads_unlock_platform_specific (void); + dbus_bool_t _dbus_split_paths_and_append (DBusString *dirs, const char *suffix, DBusList **dir_list); diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index e7f2eb74..9a505def 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -581,15 +581,24 @@ init_locks (void) dbus_bool_t dbus_threads_init (const DBusThreadFunctions *functions) { + _dbus_threads_lock_platform_specific (); + if (thread_init_generation == _dbus_current_generation) - return TRUE; + { + _dbus_threads_unlock_platform_specific (); + return TRUE; + } if (!_dbus_threads_init_platform_specific() || !init_locks ()) - return FALSE; + { + _dbus_threads_unlock_platform_specific (); + return FALSE; + } thread_init_generation = _dbus_current_generation; - + + _dbus_threads_unlock_platform_specific (); return TRUE; } @@ -600,11 +609,16 @@ dbus_threads_init (const DBusThreadFunctions *functions) /** * Initializes threads. If this function is not called, the D-Bus * library will not lock any data structures. If it is called, D-Bus - * will do locking, at some cost in efficiency. Note that this - * function must be called BEFORE the second thread is started. + * will do locking, at some cost in efficiency. + * + * Since D-Bus 1.7 it is safe to call this function from any thread, + * any number of times (but it must be called before any other + * libdbus API is used). * - * It's safe to call dbus_threads_init_default() as many times as you - * want, but only the first time will have an effect. + * In D-Bus 1.6 or older, this function must be called in the main thread + * before any other thread starts. As a result, it is not sufficient to + * call this function in a library or plugin, unless the library or plugin + * imposes a similar requirement on its callers. * * dbus_shutdown() reverses the effects of this function when it * resets all global state in libdbus. -- cgit v1.2.1 From e8136f0d30d4a203ef75fe28b91b9203b45cd5b6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 10 May 2013 12:59:35 +0100 Subject: NEWS for part 1 of fd.o#54972 --- NEWS | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/NEWS b/NEWS index 831b8dc4..fa5160f0 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,19 @@ D-Bus 1.7.4 (UNRELEASED) == +Dependencies: + +• The Windows version of libdbus now contains a C++ source file, used + to provide global initialization when the library is loaded. + gcc (mingw*) users should ensure that g++ is also installed. + +Enhancements: + +• It should now be safe to call dbus_threads_init_default() from any thread, + at any time. Authors of loadable modules and plugins that use libdbus + should consider doing so during initialization. + (fd.o #54972, Simon McVittie) + Fixes: • Windows-specific: -- cgit v1.2.1 From 24a9b93021908b6f2b20eaacc1b36fa8fb24edb4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 12:14:14 +0100 Subject: Turn a runtime assertion into a compile-time assertion Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Ralf Habacker --- dbus/dbus-threads.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 9a505def..249f53fe 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -506,8 +506,7 @@ init_locks (void) #undef LOCK_ADDR }; - _dbus_assert (_DBUS_N_ELEMENTS (global_locks) == - _DBUS_N_GLOBAL_LOCKS); + _DBUS_STATIC_ASSERT (_DBUS_N_ELEMENTS (global_locks) == _DBUS_N_GLOBAL_LOCKS); i = 0; -- cgit v1.2.1 From d35f64339e401a7a47c1b088ef26e3dcb202cb9d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 12:14:02 +0100 Subject: Remove unused global mutexes for win_fds, sid_atom_cache Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Ralf Habacker --- dbus/dbus-internals.h | 10 ++++------ dbus/dbus-sysdeps.c | 2 -- dbus/dbus-threads.c | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 28486a81..382630da 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -305,25 +305,23 @@ extern int _dbus_current_generation; #define _DBUS_LOCK(name) _dbus_rmutex_lock (_dbus_lock_##name) #define _DBUS_UNLOCK(name) _dbus_rmutex_unlock (_dbus_lock_##name) -/* 1-5 */ +/* index 0-4 */ _DBUS_DECLARE_GLOBAL_LOCK (list); _DBUS_DECLARE_GLOBAL_LOCK (connection_slots); _DBUS_DECLARE_GLOBAL_LOCK (pending_call_slots); _DBUS_DECLARE_GLOBAL_LOCK (server_slots); _DBUS_DECLARE_GLOBAL_LOCK (message_slots); -/* 5-10 */ +/* index 5-9 */ _DBUS_DECLARE_GLOBAL_LOCK (bus); _DBUS_DECLARE_GLOBAL_LOCK (bus_datas); _DBUS_DECLARE_GLOBAL_LOCK (shutdown_funcs); _DBUS_DECLARE_GLOBAL_LOCK (system_users); _DBUS_DECLARE_GLOBAL_LOCK (message_cache); -/* 10-14 */ +/* index 10-11 */ _DBUS_DECLARE_GLOBAL_LOCK (shared_connections); -_DBUS_DECLARE_GLOBAL_LOCK (win_fds); -_DBUS_DECLARE_GLOBAL_LOCK (sid_atom_cache); _DBUS_DECLARE_GLOBAL_LOCK (machine_uuid); -#define _DBUS_N_GLOBAL_LOCKS (14) +#define _DBUS_N_GLOBAL_LOCKS (12) dbus_bool_t _dbus_threads_init_debug (void); diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 04fb8d76..4e14ac38 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -46,8 +46,6 @@ #include #endif -_DBUS_DEFINE_GLOBAL_LOCK (win_fds); -_DBUS_DEFINE_GLOBAL_LOCK (sid_atom_cache); _DBUS_DEFINE_GLOBAL_LOCK (system_users); #ifdef DBUS_WIN diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 249f53fe..43676bc1 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -489,8 +489,6 @@ init_locks (void) DBusRMutex ***dynamic_global_locks; DBusRMutex **global_locks[] = { #define LOCK_ADDR(name) (& _dbus_lock_##name) - LOCK_ADDR (win_fds), - LOCK_ADDR (sid_atom_cache), LOCK_ADDR (list), LOCK_ADDR (connection_slots), LOCK_ADDR (pending_call_slots), -- cgit v1.2.1 From 8b3681e35d1a4496c5e465caeddb520e6bb797be Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 29 May 2013 20:50:21 +0800 Subject: When "activating" systemd, handle its special case better When dbus-daemon receives a request to activate a systemd service before systemd has connected to it, it enqueues a fake request to "activate" systemd itself (as a way to get a BusPendingActivationEntry to track the process of waiting for systemd). When systemd later joins the bus, dbus-daemon sends the actual activation message; any future activation messages are sent directly to systemd. In the "pending" code path, the activation messages are currently dispatched as though they had been sent by the same process that sent the original activation request, which is wrong: the bus security policy probably doesn't allow that process to talk to systemd directly. They should be dispatched as though they had been sent by the dbus-daemon itself (connection == NULL), the same as in the non-pending code path. In the worst case, if the attempt to activate systemd timed out, the dbus-daemon would crash with a (fatal) warning, because in this special case, activation_message is a signal with no serial number, whereas the code to send an error reply is expecting a method call with a serial number. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=50199 Signed-off-by: Chengwei Yang Tested-by: Ma Yu Reviewed-by: Simon McVittie --- bus/activation.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index 3dfba787..fcb71337 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -80,7 +80,14 @@ typedef struct BusPendingActivationEntry BusPendingActivationEntry; struct BusPendingActivationEntry { + /* Normally a method call, but if connection is NULL, this is a signal + * instead. + */ DBusMessage *activation_message; + /* NULL if this activation entry is for the dbus-daemon itself, + * waiting for systemd to start. In this case, auto_activation is always + * TRUE. + */ DBusConnection *connection; dbus_bool_t auto_activation; @@ -1106,7 +1113,8 @@ bus_activation_service_created (BusActivation *activation, BusPendingActivationEntry *entry = link->data; DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link); - if (dbus_connection_get_is_connected (entry->connection)) + /* entry->connection is NULL for activating systemd */ + if (entry->connection && dbus_connection_get_is_connected (entry->connection)) { /* Only send activation replies to regular activation requests. */ if (!entry->auto_activation) @@ -1175,7 +1183,7 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation BusPendingActivationEntry *entry = link->data; DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link); - if (entry->auto_activation && dbus_connection_get_is_connected (entry->connection)) + if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection))) { DBusConnection *addressed_recipient; @@ -1233,7 +1241,7 @@ try_send_activation_failure (BusPendingActivation *pending_activation, BusPendingActivationEntry *entry = link->data; DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link); - if (dbus_connection_get_is_connected (entry->connection)) + if (entry->connection && dbus_connection_get_is_connected (entry->connection)) { if (!bus_transaction_send_error_reply (transaction, entry->connection, @@ -1759,7 +1767,8 @@ bus_activation_activate_service (BusActivation *activation, pending_activation_entry->activation_message = activation_message; dbus_message_ref (activation_message); pending_activation_entry->connection = connection; - dbus_connection_ref (connection); + if (connection) + dbus_connection_ref (connection); /* Check if the service is being activated */ pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations, service_name); @@ -1972,7 +1981,7 @@ bus_activation_activate_service (BusActivation *activation, service_name, entry->systemd_service); /* systemd is not around, let's "activate" it. */ - retval = bus_activation_activate_service (activation, connection, activation_transaction, TRUE, + retval = bus_activation_activate_service (activation, NULL, activation_transaction, TRUE, message, "org.freedesktop.systemd1", error); } -- cgit v1.2.1 From 371e7b000db2b30f297730259c1fd1705b6979da Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 31 May 2013 17:36:04 +0800 Subject: doc: fix a little bit for dbus-send Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- doc/dbus-send.1.xml.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/dbus-send.1.xml.in b/doc/dbus-send.1.xml.in index 78f1374b..67b6dfd2 100644 --- a/doc/dbus-send.1.xml.in +++ b/doc/dbus-send.1.xml.in @@ -21,7 +21,7 @@ dbus-send - --system --session + --system --session --address=ADDRESS --dest=NAME --print-reply =literal --reply-timeout=MSEC @@ -106,7 +106,7 @@ and the interface member are separate fields. Block for a reply to the message sent, and print any reply received -in a human-readable form. +in a human-readable form. It also means the message type () is method_call. @@ -134,6 +134,12 @@ The default is implementation‐defined, typically 25 seconds. Send to the session message bus. (This is the default.) + + + + ADDRESS + +Send to ADDRESS. -- cgit v1.2.1 From eba9402951c3873c7dfab061b7f85d9a41c328e8 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 31 May 2013 15:02:45 +0800 Subject: Fix build error: unused-result Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- bus/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bus/main.c b/bus/main.c index ca0be3ce..970c1def 100644 --- a/bus/main.c +++ b/bus/main.c @@ -91,7 +91,10 @@ signal_handler (int sig) static const char message[] = "Unable to write to reload pipe - buffer full?\n"; - write (STDERR_FILENO, message, strlen (message)); + if (write (STDERR_FILENO, message, strlen (message)) != strlen (message)) + { + /* ignore failure to write out a warning */ + } } } break; @@ -113,7 +116,10 @@ signal_handler (int sig) "Unable to write termination signal to pipe - buffer full?\n" "Will exit instead.\n"; - write (STDERR_FILENO, message, strlen (message)); + if (write (STDERR_FILENO, message, strlen (message)) != strlen (message)) + { + /* ignore failure to write out a warning */ + } _exit (1); } } -- cgit v1.2.1 From 108ea348d844ec138588690ad5f17b87839ce1f4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Jun 2013 17:00:40 +0100 Subject: NEWS --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index fa5160f0..de7f3b61 100644 --- a/NEWS +++ b/NEWS @@ -14,8 +14,16 @@ Enhancements: should consider doing so during initialization. (fd.o #54972, Simon McVittie) +• Improve dbus-send documentation (Chengwei Yang) + Fixes: +• Unix-specific: + · Fix an assertion failure if we try to activate systemd services before + systemd connects to the bus (fd.o #50199, Chengwei Yang) + · Avoid compiler warnings for ignoring the return from write() + (Chengwei Yang) + • Windows-specific: · Under cmake, install runtime libraries (DLLs) into bin/ instead of lib/ so that Windows finds them (fd.o #59733, Ralf Habacker) -- cgit v1.2.1 From b434238c346a356b7aee4e43a9b88c1df1d4aef5 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 29 May 2013 20:50:21 +0800 Subject: When "activating" systemd, handle its special case better When dbus-daemon receives a request to activate a systemd service before systemd has connected to it, it enqueues a fake request to "activate" systemd itself (as a way to get a BusPendingActivationEntry to track the process of waiting for systemd). When systemd later joins the bus, dbus-daemon sends the actual activation message; any future activation messages are sent directly to systemd. In the "pending" code path, the activation messages are currently dispatched as though they had been sent by the same process that sent the original activation request, which is wrong: the bus security policy probably doesn't allow that process to talk to systemd directly. They should be dispatched as though they had been sent by the dbus-daemon itself (connection == NULL), the same as in the non-pending code path. In the worst case, if the attempt to activate systemd timed out, the dbus-daemon would crash with a (fatal) warning, because in this special case, activation_message is a signal with no serial number, whereas the code to send an error reply is expecting a method call with a serial number. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=50199 Signed-off-by: Chengwei Yang Tested-by: Ma Yu Reviewed-by: Simon McVittie --- bus/activation.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index 3dfba787..fcb71337 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -80,7 +80,14 @@ typedef struct BusPendingActivationEntry BusPendingActivationEntry; struct BusPendingActivationEntry { + /* Normally a method call, but if connection is NULL, this is a signal + * instead. + */ DBusMessage *activation_message; + /* NULL if this activation entry is for the dbus-daemon itself, + * waiting for systemd to start. In this case, auto_activation is always + * TRUE. + */ DBusConnection *connection; dbus_bool_t auto_activation; @@ -1106,7 +1113,8 @@ bus_activation_service_created (BusActivation *activation, BusPendingActivationEntry *entry = link->data; DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link); - if (dbus_connection_get_is_connected (entry->connection)) + /* entry->connection is NULL for activating systemd */ + if (entry->connection && dbus_connection_get_is_connected (entry->connection)) { /* Only send activation replies to regular activation requests. */ if (!entry->auto_activation) @@ -1175,7 +1183,7 @@ bus_activation_send_pending_auto_activation_messages (BusActivation *activation BusPendingActivationEntry *entry = link->data; DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link); - if (entry->auto_activation && dbus_connection_get_is_connected (entry->connection)) + if (entry->auto_activation && (entry->connection == NULL || dbus_connection_get_is_connected (entry->connection))) { DBusConnection *addressed_recipient; @@ -1233,7 +1241,7 @@ try_send_activation_failure (BusPendingActivation *pending_activation, BusPendingActivationEntry *entry = link->data; DBusList *next = _dbus_list_get_next_link (&pending_activation->entries, link); - if (dbus_connection_get_is_connected (entry->connection)) + if (entry->connection && dbus_connection_get_is_connected (entry->connection)) { if (!bus_transaction_send_error_reply (transaction, entry->connection, @@ -1759,7 +1767,8 @@ bus_activation_activate_service (BusActivation *activation, pending_activation_entry->activation_message = activation_message; dbus_message_ref (activation_message); pending_activation_entry->connection = connection; - dbus_connection_ref (connection); + if (connection) + dbus_connection_ref (connection); /* Check if the service is being activated */ pending_activation = _dbus_hash_table_lookup_string (activation->pending_activations, service_name); @@ -1972,7 +1981,7 @@ bus_activation_activate_service (BusActivation *activation, service_name, entry->systemd_service); /* systemd is not around, let's "activate" it. */ - retval = bus_activation_activate_service (activation, connection, activation_transaction, TRUE, + retval = bus_activation_activate_service (activation, NULL, activation_transaction, TRUE, message, "org.freedesktop.systemd1", error); } -- cgit v1.2.1 From 634dc5d8a02c4de31c146e845e908f01d803d411 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 31 May 2013 15:02:45 +0800 Subject: Fix build error: unused-result Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- bus/main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bus/main.c b/bus/main.c index ca0be3ce..970c1def 100644 --- a/bus/main.c +++ b/bus/main.c @@ -91,7 +91,10 @@ signal_handler (int sig) static const char message[] = "Unable to write to reload pipe - buffer full?\n"; - write (STDERR_FILENO, message, strlen (message)); + if (write (STDERR_FILENO, message, strlen (message)) != strlen (message)) + { + /* ignore failure to write out a warning */ + } } } break; @@ -113,7 +116,10 @@ signal_handler (int sig) "Unable to write termination signal to pipe - buffer full?\n" "Will exit instead.\n"; - write (STDERR_FILENO, message, strlen (message)); + if (write (STDERR_FILENO, message, strlen (message)) != strlen (message)) + { + /* ignore failure to write out a warning */ + } _exit (1); } } -- cgit v1.2.1 From f691c24dd1bff1c6cd38fe3b5f2f2831e175464c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 7 Feb 2012 17:45:16 +0000 Subject: Add dbus-run-session Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196 Reviewed-by: Colin Walters --- doc/Makefile.am | 2 + doc/dbus-run-session.1 | 100 ++++++++++ tools/Makefile.am | 4 + tools/dbus-run-session.c | 477 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 583 insertions(+) create mode 100644 doc/dbus-run-session.1 create mode 100644 tools/dbus-run-session.c diff --git a/doc/Makefile.am b/doc/Makefile.am index 35725696..0c6b6fdf 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -15,6 +15,7 @@ man1_MANS = \ dbus-daemon.1 \ dbus-launch.1 \ dbus-monitor.1 \ + dbus-run-session.1 \ dbus-send.1 \ dbus-uuidgen.1 endif @@ -24,6 +25,7 @@ MAN_HTML_FILES = \ dbus-daemon.1.html \ dbus-launch.1.html \ dbus-monitor.1.html \ + dbus-run-session.1.html \ dbus-send.1.html \ dbus-uuidgen.1.html diff --git a/doc/dbus-run-session.1 b/doc/dbus-run-session.1 new file mode 100644 index 00000000..8b270ebe --- /dev/null +++ b/doc/dbus-run-session.1 @@ -0,0 +1,100 @@ +.TH dbus\-run\-session 1 +.SH NAME +dbus\-run\-session \- start a process as a new D-Bus session +.SH SYNOPSIS +.B dbus\-run\-session +.RB [ \-\-config\-file +.IR FILENAME ] +.RB [ \-\-dbus\-daemon +.IR BINARY ] +.RB [ \-\- ] +.IR PROGRAM " [" ARGUMENTS ...] +.P +.B dbus\-run\-session \-\-help +.P +.B dbus\-run\-session \-\-version +.SH DESCRIPTION +.B dbus\-run\-session +is used to start a session bus instance of +.B dbus\-daemon +from a shell script, and start a specified program in that session. The +.B dbus\-daemon +will run for as long as the program does, after which it will terminate. +.P +One use is to run a shell with its own +.B dbus\-daemon +in a text\(hymode or SSH session, and have the +.B dbus\-daemon +terminate automatically on leaving the sub\(hyshell, like this: +.P + dbus\-run\-session \-\- bash +.P +or to replace the login shell altogether, by combining \fBdbus\-run\-session\fR +with the \fBexec\fR builtin: +.P + exec dbus\-run\-session \-\- bash +.P +Another use is to run regression tests and similar things in an isolated +D-Bus session, to avoid either interfering with the "real" D-Bus session +or relying on there already being a D-Bus session active, for instance: +.P + dbus\-run\-session \-\- make check +.P +or (in +.BR automake (1)): +.P +.nf + TESTS_ENVIRONMENT = MY_DEBUG=all dbus\-run\-session \-\- +.fi +.P +.SH OPTIONS +.TP +\fB\-\-config\-file=\fIFILENAME\fR, \fB\-\-config\-file\fR \fIFILENAME\fR +Pass +.BI \-\-config-file= FILENAME +to the bus daemon, instead of passing it the +.B \-\-session +argument. See +.BR dbus-daemon (1). +.TP +\fB\-\-dbus\-daemon=\fIBINARY\fR, \fB\-\-dbus\-daemon\fR \fIBINARY\fR +Run \fIBINARY\fR as \fBdbus\-daemon\fR(1), instead of searching the \fBPATH\fR +in the usual way for an executable called \fBdbus\-daemon\fR. +.TP +.B \-\-help +Print usage information and exit. +.TP +.B \-\-version +Print the version of dbus\-run\-session and exit. +.SH EXIT STATUS +.B dbus\-run\-session +exits with the exit status of +.IR PROGRAM , +0 if the +.BR \-\-help " or " \-\-version +options were used, 127 on an error within +.B dbus\-run\-session +itself, or +.RI 128+ n +if the +.I PROGRAM +was killed by signal +.IR n . +.SH ENVIRONMENT +.B PATH +is searched to find +.IR PROGRAM , +and (if the \-\-dbus\-daemon option is not used or its argument does not +contain a +.BR / " character) to find " dbus\-daemon . +.P +The session bus' address is made available to +.I PROGRAM +in the environment variable +.BR DBUS_SESSION_BUS_ADDRESS . +.SH BUGS +Please send bug reports to the D\-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ +.SH SEE ALSO +.BR dbus\-daemon (1), +.BR dbus\-launch (1) diff --git a/tools/Makefile.am b/tools/Makefile.am index cfd54b8b..464a8050 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -20,6 +20,7 @@ bin_PROGRAMS = \ if DBUS_UNIX bin_PROGRAMS += \ dbus-cleanup-sockets \ + dbus-run-session \ dbus-uuidgen \ $(NULL) endif @@ -43,6 +44,9 @@ dbus_launch_SOURCES= \ dbus-launch.c \ dbus-launch-x11.c \ dbus-launch.h + +dbus_run_session_SOURCES = \ + dbus-run-session.c endif dbus_cleanup_sockets_SOURCES= \ diff --git a/tools/dbus-run-session.c b/tools/dbus-run-session.c new file mode 100644 index 00000000..4f0b32b5 --- /dev/null +++ b/tools/dbus-run-session.c @@ -0,0 +1,477 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-run-session.c - run a child process in its own session + * + * Copyright © 2003-2006 Red Hat, Inc. + * Copyright © 2006 Thiago Macieira + * Copyright © 2011-2012 Nokia Corporation + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include + +#define MAX_ADDR_LEN 512 +#define PIPE_READ_END 0 +#define PIPE_WRITE_END 1 + +/* PROCESSES + * + * If you are in a shell and run "dbus-run-session myapp", here is what + * happens (compare and contrast with dbus-launch): + * + * shell + * \- dbus-run-session myapp + * \- dbus-daemon --nofork --print-address --session + * \- myapp + * + * All processes are long-running. + * + * When myapp exits, dbus-run-session kills dbus-daemon and terminates. + * + * If dbus-daemon exits, dbus-run-session warns and continues to run. + * + * PIPES + * + * dbus-daemon --print-address -> bus_address_pipe -> d-r-s + */ + +static const char me[] = "dbus-run-session"; + +static void +usage (int ecode) +{ + fprintf (stderr, + "%s [OPTIONS] [--] PROGRAM [ARGUMENTS]\n" + "%s --version\n" + "%s --help\n" + "\n" + "Options:\n" + "--dbus-daemon=BINARY run BINARY instead of dbus-daemon\n" + "--config-file=FILENAME pass to dbus-daemon instead of --session\n" + "\n", + me, me, me); + exit (ecode); +} + +static void +version (void) +{ + printf ("%s %s\n" + "Copyright (C) 2003-2006 Red Hat, Inc.\n" + "Copyright (C) 2006 Thiago Macieira\n" + "Copyright © 2011-2012 Nokia Corporation\n" + "\n" + "This is free software; see the source for copying conditions.\n" + "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n", + me, VERSION); + exit (0); +} + +static void +oom (void) +{ + fprintf (stderr, "%s: out of memory\n", me); + exit (1); +} + +static void * +xmalloc (size_t bytes) +{ + void *ret; + + if (bytes == 0) + bytes = 1; + + ret = malloc (bytes); + + if (ret == NULL) + oom (); + + return ret; +} + +typedef enum +{ + READ_STATUS_OK, /**< Read succeeded */ + READ_STATUS_ERROR, /**< Some kind of error */ + READ_STATUS_EOF /**< EOF returned */ +} ReadStatus; + +static ReadStatus +read_line (int fd, + char *buf, + size_t maxlen) +{ + size_t bytes = 0; + ReadStatus retval; + + memset (buf, '\0', maxlen); + maxlen -= 1; /* ensure nul term */ + + retval = READ_STATUS_OK; + + while (1) + { + ssize_t chunk; + size_t to_read; + + again: + to_read = maxlen - bytes; + + if (to_read == 0) + break; + + chunk = read (fd, + buf + bytes, + to_read); + if (chunk < 0 && errno == EINTR) + goto again; + + if (chunk < 0) + { + retval = READ_STATUS_ERROR; + break; + } + else if (chunk == 0) + { + retval = READ_STATUS_EOF; + break; /* EOF */ + } + else /* chunk > 0 */ + bytes += chunk; + } + + if (retval == READ_STATUS_EOF && + bytes > 0) + retval = READ_STATUS_OK; + + /* whack newline */ + if (retval != READ_STATUS_ERROR && + bytes > 0 && + buf[bytes-1] == '\n') + buf[bytes-1] = '\0'; + + return retval; +} + +static void +exec_dbus_daemon (const char *dbus_daemon, + int bus_address_pipe[2], + const char *config_file) +{ + /* Child process, which execs dbus-daemon or dies trying */ +#define MAX_FD_LEN 64 + char write_address_fd_as_string[MAX_FD_LEN]; + + close (bus_address_pipe[PIPE_READ_END]); + + sprintf (write_address_fd_as_string, "%d", bus_address_pipe[PIPE_WRITE_END]); + + execlp (dbus_daemon, + dbus_daemon, + "--nofork", + "--print-address", write_address_fd_as_string, + config_file ? "--config-file" : "--session", + config_file, /* has to be last in this varargs list */ + NULL); + + fprintf (stderr, "%s: failed to execute message bus daemon '%s': %s\n", + me, dbus_daemon, strerror (errno)); +} + +static void +exec_app (int prog_arg, char **argv) +{ + execvp (argv[prog_arg], argv + prog_arg); + + fprintf (stderr, "%s: failed to exec '%s': %s\n", me, argv[prog_arg], + strerror (errno)); + exit (1); +} + +int +main (int argc, char **argv) +{ + int prog_arg = 0; + int bus_address_pipe[2] = { 0, 0 }; + const char *config_file = NULL; + const char *dbus_daemon = NULL; + char bus_address[MAX_ADDR_LEN] = { 0 }; + const char *prev_arg = NULL; + int i = 1; + int requires_arg = 0; + pid_t bus_pid; + pid_t app_pid; + char *envvar; + + while (i < argc) + { + const char *arg = argv[i]; + + if (requires_arg) + { + const char **arg_dest; + + assert (prev_arg != NULL); + + if (strcmp (prev_arg, "--config-file") == 0) + { + arg_dest = &config_file; + } + else if (strcmp (prev_arg, "--dbus-daemon") == 0) + { + arg_dest = &dbus_daemon; + } + else + { + /* shouldn't happen */ + fprintf (stderr, "%s: internal error: %s not fully implemented\n", + me, prev_arg); + return 127; + } + + if (*arg_dest != NULL) + { + fprintf (stderr, "%s: %s given twice\n", me, prev_arg); + return 127; + } + + *arg_dest = arg; + requires_arg = 0; + prev_arg = arg; + ++i; + continue; + } + + if (strcmp (arg, "--help") == 0 || + strcmp (arg, "-h") == 0 || + strcmp (arg, "-?") == 0) + { + usage (0); + } + else if (strcmp (arg, "--version") == 0) + { + version (); + } + else if (strstr (arg, "--config-file=") == arg) + { + const char *file; + + if (config_file != NULL) + { + fprintf (stderr, "%s: --config-file given twice\n", me); + return 127; + } + + file = strchr (arg, '='); + ++file; + + config_file = file; + } + else if (strstr (arg, "--dbus-daemon=") == arg) + { + const char *file; + + if (dbus_daemon != NULL) + { + fprintf (stderr, "%s: --dbus-daemon given twice\n", me); + return 127; + } + + file = strchr (arg, '='); + ++file; + + dbus_daemon = file; + } + else if (strcmp (arg, "--config-file") == 0 || + strcmp (arg, "--dbus-daemon") == 0) + { + requires_arg = 1; + } + else if (arg[0] == '-') + { + if (strcmp (arg, "--") != 0) + { + fprintf (stderr, "%s: option '%s' is unknown\n", me, arg); + return 127; + } + else + { + prog_arg = i + 1; + break; + } + } + else + { + prog_arg = i; + break; + } + + prev_arg = arg; + ++i; + } + + /* "dbus-run-session" and "dbus-run-session ... --" are not allowed: + * there must be something to run */ + if (prog_arg < 1 || prog_arg >= argc) + { + fprintf (stderr, "%s: a non-option argument is required\n", me); + return 127; + } + + if (requires_arg) + { + fprintf (stderr, "%s: option '%s' requires an argument\n", me, prev_arg); + return 127; + } + + if (dbus_daemon == NULL) + dbus_daemon = "dbus-daemon"; + + if (pipe (bus_address_pipe) < 0) + { + fprintf (stderr, "%s: failed to create pipe: %s\n", me, strerror (errno)); + return 127; + } + + bus_pid = fork (); + + if (bus_pid < 0) + { + fprintf (stderr, "%s: failed to fork: %s\n", me, strerror (errno)); + return 127; + } + + if (bus_pid == 0) + { + /* child */ + exec_dbus_daemon (dbus_daemon, bus_address_pipe, config_file); + /* not reached */ + return 127; + } + + close (bus_address_pipe[PIPE_WRITE_END]); + + switch (read_line (bus_address_pipe[PIPE_READ_END], bus_address, MAX_ADDR_LEN)) + { + case READ_STATUS_OK: + break; + + case READ_STATUS_EOF: + fprintf (stderr, "%s: EOF reading address from bus daemon\n", me); + return 127; + break; + + case READ_STATUS_ERROR: + fprintf (stderr, "%s: error reading address from bus daemon: %s\n", + me, strerror (errno)); + return 127; + break; + } + + close (bus_address_pipe[PIPE_READ_END]); + + envvar = xmalloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") + + strlen (bus_address) + 1); + strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); + strcat (envvar, bus_address); + putenv (envvar); + + app_pid = fork (); + + if (app_pid < 0) + { + fprintf (stderr, "%s: failed to fork: %s\n", me, strerror (errno)); + return 127; + } + + if (app_pid == 0) + { + /* child */ + exec_app (prog_arg, argv); + /* not reached */ + return 127; + } + + while (1) + { + int child_status; + pid_t child_pid = waitpid (-1, &child_status, 0); + + if (child_pid == (pid_t) -1) + { + int errsv = errno; + + if (errsv == EINTR) + continue; + + /* shouldn't happen: the only other documented errors are ECHILD, + * which shouldn't happen because we terminate when all our children + * have died, and EINVAL, which would indicate programming error */ + fprintf (stderr, "%s: waitpid() failed: %s\n", me, strerror (errsv)); + return 127; + } + else if (child_pid == bus_pid) + { + /* no need to kill it, now */ + bus_pid = 0; + + if (WIFEXITED (child_status)) + fprintf (stderr, "%s: dbus-daemon exited with code %d\n", + me, WEXITSTATUS (child_status)); + else if (WIFSIGNALED (child_status)) + fprintf (stderr, "%s: dbus-daemon terminated by signal %d\n", + me, WTERMSIG (child_status)); + else + fprintf (stderr, "%s: dbus-daemon died or something\n", me); + } + else if (child_pid == app_pid) + { + if (bus_pid != 0) + kill (bus_pid, SIGTERM); + + if (WIFEXITED (child_status)) + return WEXITSTATUS (child_status); + + /* if it died from a signal, behave like sh(1) */ + if (WIFSIGNALED (child_status)) + return 128 + WTERMSIG (child_status); + + /* I give up (this should never be reached) */ + fprintf (stderr, "%s: child process died or something\n", me); + return 127; + } + else + { + fprintf (stderr, "%s: ignoring unknown child process %ld\n", me, + (long) child_pid); + } + } + + return 0; +} -- cgit v1.2.1 From 59acbc4854ac7edb463a8b0c6e9b5844e16e1e47 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Jun 2013 17:55:03 +0100 Subject: Put dbus-run-session through doclifter and adjust to match other man pages --- configure.ac | 1 + doc/Makefile.am | 1 + doc/dbus-run-session.1 | 100 ----------------------------- doc/dbus-run-session.1.xml.in | 144 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 100 deletions(-) delete mode 100644 doc/dbus-run-session.1 create mode 100644 doc/dbus-run-session.1.xml.in diff --git a/configure.ac b/configure.ac index f351fde1..008d0d52 100644 --- a/configure.ac +++ b/configure.ac @@ -1830,6 +1830,7 @@ doc/dbus-cleanup-sockets.1.xml doc/dbus-daemon.1.xml doc/dbus-launch.1.xml doc/dbus-monitor.1.xml +doc/dbus-run-session.1.xml doc/dbus-send.1.xml doc/dbus-uuidgen.1.xml dbus-1.pc diff --git a/doc/Makefile.am b/doc/Makefile.am index 0c6b6fdf..aa5c7e1f 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -5,6 +5,7 @@ MAN_XML_FILES = \ dbus-daemon.1.xml \ dbus-launch.1.xml \ dbus-monitor.1.xml \ + dbus-run-session.1.xml \ dbus-send.1.xml \ dbus-uuidgen.1.xml \ $(NULL) diff --git a/doc/dbus-run-session.1 b/doc/dbus-run-session.1 deleted file mode 100644 index 8b270ebe..00000000 --- a/doc/dbus-run-session.1 +++ /dev/null @@ -1,100 +0,0 @@ -.TH dbus\-run\-session 1 -.SH NAME -dbus\-run\-session \- start a process as a new D-Bus session -.SH SYNOPSIS -.B dbus\-run\-session -.RB [ \-\-config\-file -.IR FILENAME ] -.RB [ \-\-dbus\-daemon -.IR BINARY ] -.RB [ \-\- ] -.IR PROGRAM " [" ARGUMENTS ...] -.P -.B dbus\-run\-session \-\-help -.P -.B dbus\-run\-session \-\-version -.SH DESCRIPTION -.B dbus\-run\-session -is used to start a session bus instance of -.B dbus\-daemon -from a shell script, and start a specified program in that session. The -.B dbus\-daemon -will run for as long as the program does, after which it will terminate. -.P -One use is to run a shell with its own -.B dbus\-daemon -in a text\(hymode or SSH session, and have the -.B dbus\-daemon -terminate automatically on leaving the sub\(hyshell, like this: -.P - dbus\-run\-session \-\- bash -.P -or to replace the login shell altogether, by combining \fBdbus\-run\-session\fR -with the \fBexec\fR builtin: -.P - exec dbus\-run\-session \-\- bash -.P -Another use is to run regression tests and similar things in an isolated -D-Bus session, to avoid either interfering with the "real" D-Bus session -or relying on there already being a D-Bus session active, for instance: -.P - dbus\-run\-session \-\- make check -.P -or (in -.BR automake (1)): -.P -.nf - TESTS_ENVIRONMENT = MY_DEBUG=all dbus\-run\-session \-\- -.fi -.P -.SH OPTIONS -.TP -\fB\-\-config\-file=\fIFILENAME\fR, \fB\-\-config\-file\fR \fIFILENAME\fR -Pass -.BI \-\-config-file= FILENAME -to the bus daemon, instead of passing it the -.B \-\-session -argument. See -.BR dbus-daemon (1). -.TP -\fB\-\-dbus\-daemon=\fIBINARY\fR, \fB\-\-dbus\-daemon\fR \fIBINARY\fR -Run \fIBINARY\fR as \fBdbus\-daemon\fR(1), instead of searching the \fBPATH\fR -in the usual way for an executable called \fBdbus\-daemon\fR. -.TP -.B \-\-help -Print usage information and exit. -.TP -.B \-\-version -Print the version of dbus\-run\-session and exit. -.SH EXIT STATUS -.B dbus\-run\-session -exits with the exit status of -.IR PROGRAM , -0 if the -.BR \-\-help " or " \-\-version -options were used, 127 on an error within -.B dbus\-run\-session -itself, or -.RI 128+ n -if the -.I PROGRAM -was killed by signal -.IR n . -.SH ENVIRONMENT -.B PATH -is searched to find -.IR PROGRAM , -and (if the \-\-dbus\-daemon option is not used or its argument does not -contain a -.BR / " character) to find " dbus\-daemon . -.P -The session bus' address is made available to -.I PROGRAM -in the environment variable -.BR DBUS_SESSION_BUS_ADDRESS . -.SH BUGS -Please send bug reports to the D\-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ -.SH SEE ALSO -.BR dbus\-daemon (1), -.BR dbus\-launch (1) diff --git a/doc/dbus-run-session.1.xml.in b/doc/dbus-run-session.1.xml.in new file mode 100644 index 00000000..693c5e4e --- /dev/null +++ b/doc/dbus-run-session.1.xml.in @@ -0,0 +1,144 @@ + + + + +dbus-run-session +1 +User Commands +D-Bus +@DBUS_VERSION@ + + +dbus-run-session +start a process as a new D-Bus session + + + + + dbus-run-session + --config-file FILENAME + --dbus-daemon BINARY + -- + PROGRAM + ARGUMENTS + + + dbus-run-session --help + + + dbus-run-session --version + + + + +DESCRIPTION +dbus-run-session +is used to start a session bus instance of +dbus-daemon +from a shell script, and start a specified program in that session. The +dbus-daemon +will run for as long as the program does, after which it will terminate. + +One use is to run a shell with its own +dbus-daemon +in a text‐mode or SSH session, and have the +dbus-daemon +terminate automatically on leaving the sub‐shell, like this: + + dbus-run-session -- bash + +or to replace the login shell altogether, by combining dbus-run-session +with the exec builtin: + + exec dbus-run-session -- bash + +Another use is to run regression tests and similar things in an isolated +D-Bus session, to avoid either interfering with the "real" D-Bus session +or relying on there already being a D-Bus session active, for instance: + + dbus-run-session -- make check + +or (in +automake1): + + + TESTS_ENVIRONMENT = MY_DEBUG=all dbus-run-session -- + + + +OPTIONS + + + FILENAME, FILENAME + +Pass +FILENAME +to the bus daemon, instead of passing it the + +argument. See +dbus-daemon1. + + + + BINARY, BINARY + +Run BINARY as dbus-daemon1, instead of searching the PATH +in the usual way for an executable called dbus-daemon. + + + + + +Print usage information and exit. + + + + + +Print the version of dbus-run-session and exit. + + + + + +EXIT STATUS +dbus-run-session +exits with the exit status of +PROGRAM, +0 if the + or +options were used, 127 on an error within +dbus-run-session +itself, or +128+n +if the +PROGRAM +was killed by signal +n. + + +ENVIRONMENT +PATH +is searched to find +PROGRAM, +and (if the --dbus-daemon option is not used or its argument does not +contain a +/ character) to find dbus-daemon. + +The session bus' address is made available to +PROGRAM +in the environment variable +DBUS_SESSION_BUS_ADDRESS. + + +BUGS +Please send bug reports to the D-Bus mailing list or bug tracker, +see http://www.freedesktop.org/software/dbus/ + + +SEE ALSO +dbus-daemon1, +dbus-launch1 + + -- cgit v1.2.1 From 9c0ef7028893e4db18fe901ed749784c99a8839f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Jun 2013 17:51:55 +0100 Subject: Recomend dbus-run-session over dbus-launch for starting text-mode sessions Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196 Reviewed-by: Colin Walters [reformatted from roff to Docbook -smcv] --- doc/dbus-launch.1.xml.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/dbus-launch.1.xml.in b/doc/dbus-launch.1.xml.in index fde439da..727495b7 100644 --- a/doc/dbus-launch.1.xml.in +++ b/doc/dbus-launch.1.xml.in @@ -102,8 +102,10 @@ run by your X session, such as or ~/.Xclients. -To start a D-Bus session within a text-mode session, you can run -dbus-launch in the background. For instance, in a sh-compatible shell: +To start a D-Bus session within a text\(hymode session, + do not use dbus-launch. + Instead, see dbus-run-session1. + ## test for an existing bus daemon, just to be safe -- cgit v1.2.1 From 9760bdf393211a9bc79432de54cb4252f8724723 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 7 Feb 2012 19:58:44 +0000 Subject: massively simplify run-with-tmp-session-bus.sh by using dbus-run-session It turns out that if you don't second-guess the system by catching SIGINT, the right things happen: it's received by every program in the foreground process group, including dbus-run-session and dbus-daemon. Neither of those catch SIGINT (unlike dbus-launch) so they'll exit gracefully without the wrapper script needing to do anything special. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196 Reviewed-by: Colin Walters --- tools/run-with-tmp-session-bus.sh | 45 +++++++++++---------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh index c39999fb..3245652e 100755 --- a/tools/run-with-tmp-session-bus.sh +++ b/tools/run-with-tmp-session-bus.sh @@ -1,16 +1,12 @@ #! /bin/sh -SCRIPTNAME=$0 -WRAPPED_SCRIPT=$1 +SCRIPTNAME="$0" +WRAPPED_SCRIPT="$1" shift -die() +die () { - if ! test -z "$DBUS_SESSION_BUS_PID" ; then - echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 - kill -9 $DBUS_SESSION_BUS_PID - fi - echo $SCRIPTNAME: $* >&2 + echo "$SCRIPTNAME: $*" >&2 exit 1 } @@ -18,9 +14,6 @@ if test -z "$DBUS_TOP_BUILDDIR" ; then die "Must set DBUS_TOP_BUILDDIR" fi -## convenient to be able to ctrl+C without leaking the message bus process -trap 'die "Received SIGINT"' INT - CONFIG_FILE=./run-with-tmp-session-bus.conf SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files" ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'` @@ -50,27 +43,13 @@ export LD_LIBRARY_PATH unset DBUS_SESSION_BUS_ADDRESS unset DBUS_SESSION_BUS_PID -echo "Running $DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE" >&2 - -DBUS_USE_TEST_BINARY=1 +# this does not actually affect dbus-run-session any more, but could be +# significant for dbus-launch as used by the autolaunch test +DBUS_USE_TEST_BINARY=1 export DBUS_USE_TEST_BINARY -eval `$DBUS_TOP_BUILDDIR/tools/dbus-launch --sh-syntax --config-file=$CONFIG_FILE` - -if test -z "$DBUS_SESSION_BUS_PID" ; then - die "Failed to launch message bus for test script to run" -fi - -echo "Started bus pid $DBUS_SESSION_BUS_PID at $DBUS_SESSION_BUS_ADDRESS" >&2 - -# Execute wrapped script -echo "Running $WRAPPED_SCRIPT $@" >&2 -$WRAPPED_SCRIPT "$@" || die "script \"$WRAPPED_SCRIPT\" failed" - -kill -TERM $DBUS_SESSION_BUS_PID || die "Message bus vanished! should not have happened" && echo "Killed daemon $DBUS_SESSION_BUS_PID" >&2 - -sleep 2 - -## be sure it really died -kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true -exit 0 +exec $DBUS_TOP_BUILDDIR/tools/dbus-run-session \ + --config-file="$CONFIG_FILE" \ + --dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \ + -- \ + "$WRAPPED_SCRIPT" "$@" -- cgit v1.2.1 From ff641bdb2f87188c16c24cee729b210cc827c4c7 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 11:36:22 +0800 Subject: Do not suggest user to do 'make' if configure failed Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65415 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index 15581120..b049f4ef 100755 --- a/autogen.sh +++ b/autogen.sh @@ -101,7 +101,7 @@ else fi if $run_configure; then - $srcdir/configure --enable-developer --config-cache "$@" + $srcdir/configure --enable-developer --config-cache "$@" || exit $? echo echo "Now type 'make' to compile $PROJECT." else -- cgit v1.2.1 From 0a76508672de5c879c14c343f8e6cc041c1843d9 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 13:25:10 +0800 Subject: Fix dbus-daemon crash due to invalid service file dbus-daemon will crash due to invalid service file which key/value starts before section. In that situation, new_line() will try to access invalid address. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60853 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- bus/desktop-file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bus/desktop-file.c b/bus/desktop-file.c index ae441c5e..bfeb72e2 100644 --- a/bus/desktop-file.c +++ b/bus/desktop-file.c @@ -688,6 +688,12 @@ bus_desktop_file_load (DBusString *filename, else if (is_blank_line (&parser) || _dbus_string_get_byte (&parser.data, parser.pos) == '#') parse_comment_or_blank (&parser); + else if (parser.current_section < 0) + { + dbus_set_error(error, DBUS_ERROR_FAILED, + "invalid service file: key=value before [Section]"); + return NULL; + } else { if (!parse_key_value (&parser, error)) -- cgit v1.2.1 From 46602768c537bfa51af80ba2c67857f3a30c0e67 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 15:59:20 +0800 Subject: XML: hard depends on expat and delete libxml [The libxml code path has been broken for at least 2.5 years, and Expat is tiny, so there seems no point in supporting both. -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=20253 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- README.cmake | 3 - bus/Makefile.am | 5 - bus/config-loader-libxml.c | 324 --------------------------------- cmake/CMakeLists.txt | 21 +-- cmake/bus/CMakeLists.txt | 6 +- cmake/modules/CPackInstallConfig.cmake | 9 +- configure.ac | 52 +----- 7 files changed, 11 insertions(+), 409 deletions(-) delete mode 100644 bus/config-loader-libxml.c diff --git a/README.cmake b/README.cmake index 0c30ba66..9415a82d 100644 --- a/README.cmake +++ b/README.cmake @@ -141,9 +141,6 @@ DBUS_SYSTEM_BUS_DEFAULT_ADDRESS:STRING=unix:path=/var/run/dbus/system_bus_socket // Use atomic integer implementation for 486 DBUS_USE_ATOMIC_INT_486:BOOL=OFF -// Use expat (== ON) or libxml2 (==OFF) -DBUS_USE_EXPAT:BOOL=ON - win32 only: // enable win32 debug port for message output DBUS_USE_OUTPUT_DEBUG_STRING:BOOL=OFF diff --git a/bus/Makefile.am b/bus/Makefile.am index 6cbc09a6..74c62e74 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -42,12 +42,7 @@ agentdir=$(LAUNCHD_AGENT_DIR) agent_DATA=org.freedesktop.dbus-session.plist endif -if DBUS_USE_LIBXML -XML_SOURCES=config-loader-libxml.c -endif -if DBUS_USE_EXPAT XML_SOURCES=config-loader-expat.c -endif if DBUS_BUS_ENABLE_KQUEUE DIR_WATCH_SOURCE=dir-watch-kqueue.c diff --git a/bus/config-loader-libxml.c b/bus/config-loader-libxml.c deleted file mode 100644 index c73a1815..00000000 --- a/bus/config-loader-libxml.c +++ /dev/null @@ -1,324 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* config-loader-libxml.c libxml2 XML loader - * - * Copyright (C) 2003 Red Hat, Inc. - * - * Licensed under the Academic Free License version 2.1 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include -#include "config-parser.h" -#include -#include -#include -#include -#include -#ifdef HAVE_ERRNO_H -#include -#endif -#include - -/* About the error handling: - * - setup a "structured" error handler that catches structural - * errors and some oom errors - * - assume that a libxml function returning an error code means - * out-of-memory - */ -#define _DBUS_MAYBE_SET_OOM(e) (dbus_error_is_set(e) ? (void)0 : _DBUS_SET_OOM(e)) - - -static dbus_bool_t -xml_text_start_element (BusConfigParser *parser, - xmlTextReader *reader, - DBusError *error) -{ - const char *name; - int n_attributes; - const char **attribute_names, **attribute_values; - dbus_bool_t ret; - int i, status, is_empty; - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - ret = FALSE; - attribute_names = NULL; - attribute_values = NULL; - - name = xmlTextReaderConstName (reader); - n_attributes = xmlTextReaderAttributeCount (reader); - is_empty = xmlTextReaderIsEmptyElement (reader); - - if (name == NULL || n_attributes < 0 || is_empty == -1) - { - _DBUS_MAYBE_SET_OOM (error); - goto out; - } - - attribute_names = dbus_new0 (const char *, n_attributes + 1); - attribute_values = dbus_new0 (const char *, n_attributes + 1); - if (attribute_names == NULL || attribute_values == NULL) - { - _DBUS_SET_OOM (error); - goto out; - } - i = 0; - while ((status = xmlTextReaderMoveToNextAttribute (reader)) == 1) - { - _dbus_assert (i < n_attributes); - attribute_names[i] = xmlTextReaderConstName (reader); - attribute_values[i] = xmlTextReaderConstValue (reader); - if (attribute_names[i] == NULL || attribute_values[i] == NULL) - { - _DBUS_MAYBE_SET_OOM (error); - goto out; - } - i++; - } - if (status == -1) - { - _DBUS_MAYBE_SET_OOM (error); - goto out; - } - _dbus_assert (i == n_attributes); - - ret = bus_config_parser_start_element (parser, name, - attribute_names, attribute_values, - error); - if (ret && is_empty == 1) - ret = bus_config_parser_end_element (parser, name, error); - - out: - dbus_free (attribute_names); - dbus_free (attribute_values); - - return ret; -} - -static void xml_shut_up (void *ctx, const char *msg, ...) -{ - return; -} - -static void -xml_text_reader_error (void *arg, xmlErrorPtr xml_error) -{ - DBusError *error = arg; - -#if 0 - _dbus_verbose ("XML_ERROR level=%d, domain=%d, code=%d, msg=%s\n", - xml_error->level, xml_error->domain, - xml_error->code, xml_error->message); -#endif - - if (!dbus_error_is_set (error)) - { - if (xml_error->code == XML_ERR_NO_MEMORY) - _DBUS_SET_OOM (error); - else if (xml_error->level == XML_ERR_ERROR || - xml_error->level == XML_ERR_FATAL) - dbus_set_error (error, DBUS_ERROR_FAILED, - "Error loading config file: '%s'", - xml_error->message); - } -} - - -BusConfigParser* -bus_config_load (const DBusString *file, - dbus_bool_t is_toplevel, - const BusConfigParser *parent, - DBusError *error) - -{ - xmlTextReader *reader; - BusConfigParser *parser; - DBusString dirname, data; - DBusError tmp_error; - int ret; - - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - - parser = NULL; - reader = NULL; - - if (!_dbus_string_init (&dirname)) - { - _DBUS_SET_OOM (error); - return NULL; - } - - if (!_dbus_string_init (&data)) - { - _DBUS_SET_OOM (error); - _dbus_string_free (&dirname); - return NULL; - } - - if (is_toplevel) - { - /* xmlMemSetup only fails if one of the functions is NULL */ - xmlMemSetup (dbus_free, - dbus_malloc, - dbus_realloc, - _dbus_strdup); - xmlInitParser (); - xmlSetGenericErrorFunc (NULL, xml_shut_up); - } - - if (!_dbus_string_get_dirname (file, &dirname)) - { - _DBUS_SET_OOM (error); - goto failed; - } - - parser = bus_config_parser_new (&dirname, is_toplevel, parent); - if (parser == NULL) - { - _DBUS_SET_OOM (error); - goto failed; - } - - if (!_dbus_file_get_contents (&data, file, error)) - goto failed; - - reader = xmlReaderForMemory (_dbus_string_get_const_data (&data), - _dbus_string_get_length (&data), - NULL, NULL, 0); - if (reader == NULL) - { - _DBUS_SET_OOM (error); - goto failed; - } - - xmlTextReaderSetParserProp (reader, XML_PARSER_SUBST_ENTITIES, 1); - - dbus_error_init (&tmp_error); - xmlTextReaderSetStructuredErrorHandler (reader, xml_text_reader_error, &tmp_error); - - while ((ret = xmlTextReaderRead (reader)) == 1) - { - int type; - - if (dbus_error_is_set (&tmp_error)) - goto reader_out; - - type = xmlTextReaderNodeType (reader); - if (type == -1) - { - _DBUS_MAYBE_SET_OOM (&tmp_error); - goto reader_out; - } - - switch ((xmlReaderTypes) type) { - case XML_READER_TYPE_ELEMENT: - xml_text_start_element (parser, reader, &tmp_error); - break; - - case XML_READER_TYPE_TEXT: - case XML_READER_TYPE_CDATA: - { - DBusString content; - const char *value; - value = xmlTextReaderConstValue (reader); - if (value != NULL) - { - _dbus_string_init_const (&content, value); - bus_config_parser_content (parser, &content, &tmp_error); - } - else - _DBUS_MAYBE_SET_OOM (&tmp_error); - break; - } - - case XML_READER_TYPE_DOCUMENT_TYPE: - { - const char *name; - name = xmlTextReaderConstName (reader); - if (name != NULL) - bus_config_parser_check_doctype (parser, name, &tmp_error); - else - _DBUS_MAYBE_SET_OOM (&tmp_error); - break; - } - - case XML_READER_TYPE_END_ELEMENT: - { - const char *name; - name = xmlTextReaderConstName (reader); - if (name != NULL) - bus_config_parser_end_element (parser, name, &tmp_error); - else - _DBUS_MAYBE_SET_OOM (&tmp_error); - break; - } - - case XML_READER_TYPE_DOCUMENT: - case XML_READER_TYPE_DOCUMENT_FRAGMENT: - case XML_READER_TYPE_PROCESSING_INSTRUCTION: - case XML_READER_TYPE_COMMENT: - case XML_READER_TYPE_ENTITY: - case XML_READER_TYPE_NOTATION: - case XML_READER_TYPE_WHITESPACE: - case XML_READER_TYPE_SIGNIFICANT_WHITESPACE: - case XML_READER_TYPE_END_ENTITY: - case XML_READER_TYPE_XML_DECLARATION: - /* nothing to do, just read on */ - break; - - case XML_READER_TYPE_NONE: - case XML_READER_TYPE_ATTRIBUTE: - case XML_READER_TYPE_ENTITY_REFERENCE: - _dbus_assert_not_reached ("unexpected nodes in XML"); - } - - if (dbus_error_is_set (&tmp_error)) - goto reader_out; - } - - if (ret == -1) - _DBUS_MAYBE_SET_OOM (&tmp_error); - - reader_out: - xmlFreeTextReader (reader); - reader = NULL; - if (dbus_error_is_set (&tmp_error)) - { - dbus_move_error (&tmp_error, error); - goto failed; - } - - if (!bus_config_parser_finished (parser, error)) - goto failed; - _dbus_string_free (&dirname); - _dbus_string_free (&data); - if (is_toplevel) - xmlCleanupParser(); - _DBUS_ASSERT_ERROR_IS_CLEAR (error); - return parser; - - failed: - _DBUS_ASSERT_ERROR_IS_SET (error); - _dbus_string_free (&dirname); - _dbus_string_free (&data); - if (is_toplevel) - xmlCleanupParser(); - if (parser) - bus_config_parser_unref (parser); - _dbus_assert (reader == NULL); /* must go to reader_out first */ - return NULL; -} diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9c1ef2ec..ed1df562 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -89,8 +89,6 @@ if (WIN32) addExplorerWrapper(${CMAKE_PROJECT_NAME}) endif (WIN32) -option (DBUS_USE_EXPAT "Use expat (== ON) or libxml2 (==OFF)" ON) - if(NOT WIN32) option (DBUS_ENABLE_ABSTRACT_SOCKETS "enable support for abstract sockets" ON) set (CMAKE_THREAD_PREFER_PTHREAD ON) @@ -104,11 +102,7 @@ option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) -if (DBUS_USE_EXPAT) - find_package(EXPAT) -else () - find_package(LibXml2) -endif () +find_package(EXPAT) find_package(X11) # analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac @@ -309,16 +303,9 @@ if(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) message(FATAL "Neither expat nor libxml2 found!") endif(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) -if(DBUS_USE_EXPAT) - SET(XML_LIB "Expat") - SET(XML_LIBRARY ${EXPAT_LIBRARIES}) - SET(XML_INCLUDE_DIR ${EXPAT_INCLUDE_DIR}) -else(DBUS_USE_EXPAT) - SET(XML_LIB "LibXML2") - SET(XML_LIBRARY ${LIBXML2_LIBRARIES}) - SET(XML_INCLUDE_DIR ${LIBXML2_INCLUDE_DIR}) -endif(DBUS_USE_EXPAT) - +SET(XML_LIB "Expat") +SET(XML_LIBRARY ${EXPAT_LIBRARIES}) +SET(XML_INCLUDE_DIR ${EXPAT_INCLUDE_DIR}) #AC_ARG_WITH(init-scripts, AS_HELP_STRING([--with-init-scripts=[redhat]],[Style of init scripts to install])) #AC_ARG_WITH(session-socket-dir, AS_HELP_STRING([--with-session-socket-dir=[dirname]],[Where to put sockets for the per-login-session message bus])) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 2657605e..f2ea55eb 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -29,11 +29,7 @@ FOREACH(FILE ${FILES}) configure_file(${FILE} ${TARGET} ) ENDFOREACH(FILE) -if(DBUS_USE_EXPAT) - SET (XML_SOURCES ${BUS_DIR}/config-loader-expat.c) -else(DBUS_USE_EXPAT) - SET (XML_SOURCES ${BUS_DIR}/config-loader-libxml.c) -endif (DBUS_USE_EXPAT) +SET (XML_SOURCES ${BUS_DIR}/config-loader-expat.c) # after next cvs update #set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-default.c) diff --git a/cmake/modules/CPackInstallConfig.cmake b/cmake/modules/CPackInstallConfig.cmake index f8073a25..74b66898 100644 --- a/cmake/modules/CPackInstallConfig.cmake +++ b/cmake/modules/CPackInstallConfig.cmake @@ -1,14 +1,7 @@ if (DBUS_INSTALL_SYSTEM_LIBS) if (MINGW) - if (DBUS_USE_EXPAT) - # expat - install_files(/bin FILES ${LIBEXPAT_LIBRARIES}) - else (DBUS_USE_EXPAT) - # xml2 - install_files(/bin FILES ${LIBXML2_LIBRARIES}) - install_files(/bin FILES ${LIBICONV_LIBRARIES}) - endif (DBUS_USE_EXPAT) + install_files(/bin FILES ${LIBEXPAT_LIBRARIES}) else (MINGW) INCLUDE(InstallRequiredSystemLibraries) endif (MINGW) diff --git a/configure.ac b/configure.ac index 008d0d52..f6335f7d 100644 --- a/configure.ac +++ b/configure.ac @@ -158,7 +158,6 @@ AC_ARG_ENABLE(userdb-cache, AS_HELP_STRING([--enable-userdb-cache],[build with u AC_ARG_ENABLE(launchd, AS_HELP_STRING([--enable-launchd],[build with launchd auto-launch support]),enable_launchd=$enableval,enable_launchd=auto) AC_ARG_ENABLE(systemd, AS_HELP_STRING([--enable-systemd],[build with systemd at_console support]),enable_systemd=$enableval,enable_systemd=auto) -AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use (libxml may be named libxml2 on some systems)])) AC_ARG_WITH(init-scripts, AS_HELP_STRING([--with-init-scripts=[redhat]],[Style of init scripts to install])) AC_ARG_WITH(session-socket-dir, AS_HELP_STRING([--with-session-socket-dir=[dirname]],[Where to put sockets for the per-login-session message bus])) AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check])) @@ -910,49 +909,13 @@ PKG_PROG_PKG_CONFIG #### Sort out XML library -# see what we have AC_CHECK_LIB(expat, XML_ParserCreate_MM, - [ AC_CHECK_HEADERS(expat.h, have_expat=true, have_expat=false) ], - have_expat=false) - -# see what we want to use -dbus_use_libxml=false -dbus_use_expat=false -if test x$with_xml = xexpat; then - if ! $have_expat ; then - AC_MSG_ERROR([Explicitly requested expat but expat not found]) - fi - dbus_use_expat=true -elif test x$with_xml = xlibxml; then - PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= 2.6.0, have_libxml=true, have_libxml=false) - if ! $have_libxml ; then - AC_MSG_ERROR([Explicitly requested libxml but libxml not found]) - fi - dbus_use_libxml=true -else - ### expat is the default because libxml can't currently survive - ### our brutal OOM-handling unit test setup. - ### http://bugzilla.gnome.org/show_bug.cgi?id=109368 - if test x$have_expat = xfalse; then - AC_MSG_ERROR([Could not find expat.h, check config.log for failed attempts]) - fi - ### By default, only use Expat since it's tested and known to work. If you're a - ### general-purpose OS vendor, please don't enable libxml. For embedded use - ### if your OS is built around libxml, that's another case. - dbus_use_expat=true -fi + [ AC_CHECK_HEADERS(expat.h, [], + [AC_MSG_ERROR([Could not find expat.h, check config.log for failed attempts])]) ], + [ AC_MSG_ERROR([Explicitly requested expat but expat not found]) ]) -AM_CONDITIONAL(DBUS_USE_EXPAT, $dbus_use_expat) -AM_CONDITIONAL(DBUS_USE_LIBXML, $dbus_use_libxml) - -if $dbus_use_expat; then - XML_LIBS=-lexpat - XML_CFLAGS= -fi -if $dbus_use_libxml; then - XML_LIBS=$LIBXML_LIBS - XML_CFLAGS=$LIBXML_CFLAGS -fi +XML_LIBS=-lexpat +XML_CFLAGS= AC_SUBST([XML_CFLAGS]) AC_SUBST([XML_LIBS]) @@ -1899,7 +1862,6 @@ echo " Building XML docs: ${enable_xml_docs} Building cache support: ${enable_userdb_cache} Building launchd support: ${have_launchd} - Using XML parser: ${with_xml} Init scripts style: ${with_init_scripts} Abstract socket names: ${ac_cv_have_abstract_sockets} System bus socket: ${DBUS_SYSTEM_SOCKET} @@ -1937,10 +1899,6 @@ fi if test x$enable_checks = xno; then echo "NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance." fi -if test x$dbus_use_libxml = xtrue; then - 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. -- cgit v1.2.1 From 049a132b86eb6ee74edd8e090037b20845ae06a0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 16:12:01 +0800 Subject: Fix a typo: enable_x11 -> have_x11 From git history, enable_x11 was used to track have_x11, but it's useless now. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65443 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f6335f7d..5d243764 100644 --- a/configure.ac +++ b/configure.ac @@ -1857,7 +1857,7 @@ echo " Building dnotify support: ${have_dnotify} Building kqueue support: ${have_kqueue} Building systemd support: ${have_systemd} - Building X11 code: ${enable_x11} + Building X11 code: ${have_x11} Building Doxygen docs: ${enable_doxygen_docs} Building XML docs: ${enable_xml_docs} Building cache support: ${enable_userdb_cache} -- cgit v1.2.1 From c9b942e56f5b0a166cfc7ab4f53c54449a9db8de Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 16:11:16 +0800 Subject: Assign default value to enable compiler coverage Signed-off-by: Chengwei Yang Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65424 Reviewed-by: Simon McVittie --- m4/compiler.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/compiler.m4 b/m4/compiler.m4 index 5aff5d81..5a197ada 100644 --- a/m4/compiler.m4 +++ b/m4/compiler.m4 @@ -63,5 +63,5 @@ AC_DEFUN([COMPILER_COVERAGE], if test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage" fi -fi])dnl +fi],[enable_compiler_coverage=no])dnl ])# COMPILER_COVERAGE -- cgit v1.2.1 From c690ee4351f99ed5e629ffcf5f4a2edcd418d103 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 16:58:11 +0800 Subject: dbus-send: check usage a bit strictly This commit does several more strictly check for dbus-send as its usage suggested. * now --address is an invalid option but --address=, this just like the others, say --reply-timeout=, --dest=, --type= * --print-reply= only take an optional argument "=literal" * --print-reply= will cause error with missing MSEC and invalid MSEC will cause invalid value error * --dest= will cause error with missing a NAME and also call dbus_validate_bus_name to verify the NAME Signed-off-by: Chengwei Yang Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65424 Reviewed-by: Simon McVittie --- tools/dbus-send.c | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/tools/dbus-send.c b/tools/dbus-send.c index e403a587..ca5dd5c6 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -266,34 +266,52 @@ main (int argc, char *argv[]) type = DBUS_BUS_SESSION; session_or_system = TRUE; } - else if (strstr (arg, "--address") == arg) + else if (strstr (arg, "--address=") == arg) { - address = strchr (arg, '='); - - if (address == NULL) + if (*(strchr (arg, '=') + 1) == '\0') { fprintf (stderr, "\"--address=\" requires an ADDRESS\n"); usage (1); } - else - { - address = address + 1; - } + address = strchr (arg, '=') + 1; } else if (strncmp (arg, "--print-reply", 13) == 0) { print_reply = TRUE; message_type = DBUS_MESSAGE_TYPE_METHOD_CALL; - if (*(arg + 13) != '\0') + if (strcmp (arg + 13, "=literal") == 0) print_reply_literal = TRUE; + else if (*(arg + 13) != '\0') + { + fprintf (stderr, "invalid value (%s) of \"--print-reply\"\n", arg + 13); + usage (1); + } } else if (strstr (arg, "--reply-timeout=") == arg) { + if (*(strchr (arg, '=') + 1) == '\0') + { + fprintf (stderr, "\"--reply-timeout=\" requires an MSEC\n"); + usage (1); + } reply_timeout = strtol (strchr (arg, '=') + 1, NULL, 10); + if (reply_timeout <= 0) + { + fprintf (stderr, "invalid value (%s) of \"--reply-timeout\"\n", + strchr (arg, '=') + 1); + usage (1); + } } else if (strstr (arg, "--dest=") == arg) - dest = strchr (arg, '=') + 1; + { + if (*(strchr (arg, '=') + 1) == '\0') + { + fprintf (stderr, "\"--dest=\" requires an NAME\n"); + usage (1); + } + dest = strchr (arg, '=') + 1; + } else if (strstr (arg, "--type=") == arg) type_str = strchr (arg, '=') + 1; else if (!strcmp(arg, "--help")) @@ -330,6 +348,12 @@ main (int argc, char *argv[]) dbus_error_init (&error); + if (!dbus_validate_bus_name (dest, &error)) + { + fprintf (stderr, "invalid value (%s) of \"--dest\"\n", dest); + usage (1); + } + if (address != NULL) { connection = dbus_connection_open (address, &error); -- cgit v1.2.1 From 9e800cbb0028d3674ba357570ff4109dfb99801f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 6 Jun 2013 13:18:06 +0100 Subject: NEWS Also update README to not mention libxml2. --- INSTALL | 5 +---- NEWS | 10 +++++++++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/INSTALL b/INSTALL index e182f985..4e905c58 100644 --- a/INSTALL +++ b/INSTALL @@ -51,10 +51,7 @@ Core library Requisite: - Gettext - - expat or libxml-2 - - NB, expat is the recommended XML parser because it has more robust - handling of OOM conditions. + - expat Optional: diff --git a/NEWS b/NEWS index de7f3b61..75641f0a 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,10 @@ Dependencies: to provide global initialization when the library is loaded. gcc (mingw*) users should ensure that g++ is also installed. +• The libxml2-based configuration reader (which hasn't worked for 2.5 years, + and was never the recommended option) has been removed. Expat is now a + hard dependency. + Enhancements: • It should now be safe to call dbus_threads_init_default() from any thread, @@ -14,10 +18,14 @@ Enhancements: should consider doing so during initialization. (fd.o #54972, Simon McVittie) -• Improve dbus-send documentation (Chengwei Yang) +• Improve dbus-send documentation and command-line parsing (fd.o #65424, + Chengwei Yang) Fixes: +• In dbus-daemon, don't crash if a .service file starts with key=value + (fd.o #60853, Chengwei Yang) + • Unix-specific: · Fix an assertion failure if we try to activate systemd services before systemd connects to the bus (fd.o #50199, Chengwei Yang) -- cgit v1.2.1 From 16f3b1246c134a4ed72779ce248902e9b03d38f6 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 6 Jun 2013 13:25:10 +0800 Subject: Fix dbus-daemon crash due to invalid service file dbus-daemon will crash due to invalid service file which key/value starts before section. In that situation, new_line() will try to access invalid address. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60853 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- bus/desktop-file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bus/desktop-file.c b/bus/desktop-file.c index ae441c5e..bfeb72e2 100644 --- a/bus/desktop-file.c +++ b/bus/desktop-file.c @@ -688,6 +688,12 @@ bus_desktop_file_load (DBusString *filename, else if (is_blank_line (&parser) || _dbus_string_get_byte (&parser.data, parser.pos) == '#') parse_comment_or_blank (&parser); + else if (parser.current_section < 0) + { + dbus_set_error(error, DBUS_ERROR_FAILED, + "invalid service file: key=value before [Section]"); + return NULL; + } else { if (!parse_key_value (&parser, error)) -- cgit v1.2.1 From 355b470da78e25cb451eab0c49f30437b2c5ccb9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 13:42:58 +0100 Subject: NEWS for 1.6.x --- NEWS | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 8dd994a5..f084c8ab 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,16 @@ D-Bus 1.6.12 (UNRELEASED) == -... +Fixes: + +• In dbus-daemon, don't crash if a .service file starts with key=value + (fd.o #60853, Chengwei Yang) + +• Unix-specific: + · Fix an assertion failure if we try to activate systemd services before + systemd connects to the bus (fd.o #50199, Chengwei Yang) + · Avoid compiler warnings for ignoring the return from write() + (Chengwei Yang) D-Bus 1.6.10 (2013-04-24) == -- cgit v1.2.1 From 954d75b2b64e4799f360d2a6bf9cff6d9fee37e7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 10 Jun 2013 18:06:47 +0100 Subject: CVE-2013-2168: _dbus_printf_string_upper_bound: copy the va_list for each use Using a va_list more than once is non-portable: it happens to work under the ABI of (for instance) x86 Linux, but not x86-64 Linux. This led to _dbus_printf_string_upper_bound() crashing if it should have returned exactly 1024 bytes. Many system services can be induced to process a caller-controlled string in ways that end up using _dbus_printf_string_upper_bound(), so this is a denial of service. Reviewed-by: Thiago Macieira --- dbus/dbus-sysdeps-unix.c | 16 +++++++++++++--- dbus/dbus-sysdeps-win.c | 9 +++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index fc677990..e31c7355 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3121,8 +3121,11 @@ _dbus_printf_string_upper_bound (const char *format, char static_buf[1024]; int bufsize = sizeof (static_buf); int len; + va_list args_copy; - len = vsnprintf (static_buf, bufsize, format, args); + DBUS_VA_COPY (args_copy, args); + len = vsnprintf (static_buf, bufsize, format, args_copy); + va_end (args_copy); /* If vsnprintf() returned non-negative, then either the string fits in * static_buf, or this OS has the POSIX and C99 behaviour where vsnprintf @@ -3138,8 +3141,12 @@ _dbus_printf_string_upper_bound (const char *format, * 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) + DBUS_VA_COPY (args_copy, args); + + if (vsnprintf (static_buf, 1, format, args_copy) == 1) len = -1; + + va_end (args_copy); } /* If vsnprintf() returned negative, we have to do more work. @@ -3155,7 +3162,10 @@ _dbus_printf_string_upper_bound (const char *format, if (buf == NULL) return -1; - len = vsnprintf (buf, bufsize, format, args); + DBUS_VA_COPY (args_copy, args); + len = vsnprintf (buf, bufsize, format, args_copy); + va_end (args_copy); + dbus_free (buf); /* If the reported length is exactly the buffer size, round up to the diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index bc4951b5..c42316f1 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -538,9 +538,12 @@ int _dbus_printf_string_upper_bound (const char *format, char buf[1024]; int bufsize; int len; + va_list args_copy; bufsize = sizeof (buf); - len = _vsnprintf (buf, bufsize - 1, format, args); + DBUS_VA_COPY (args_copy, args); + len = _vsnprintf (buf, bufsize - 1, format, args_copy); + va_end (args_copy); while (len == -1) /* try again */ { @@ -553,7 +556,9 @@ int _dbus_printf_string_upper_bound (const char *format, if (p == NULL) return -1; - len = _vsnprintf (p, bufsize - 1, format, args); + DBUS_VA_COPY (args_copy, args); + len = _vsnprintf (p, bufsize - 1, format, args_copy); + va_end (args_copy); free (p); } -- cgit v1.2.1 From 2420f7ae8b72405de1a41760b213e2e0849b2b8d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 13:56:39 +0100 Subject: Add a test-case for CVE-2013-2168 Reviewed-by: Thiago Macieira [build system adjusted to compile it even if we don't have GLib -smcv] --- test/Makefile.am | 5 +++ test/internals/printf.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 test/internals/printf.c diff --git a/test/Makefile.am b/test/Makefile.am index e9448998..6f0e6e10 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -81,6 +81,10 @@ shell_test_LDADD = libdbus-testutils.la spawn_test_CPPFLAGS = $(static_cppflags) spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la +test_printf_SOURCES = internals/printf.c +test_printf_CPPFLAGS = $(static_cppflags) +test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la + test_refs_SOURCES = internals/refs.c test_refs_CPPFLAGS = $(static_cppflags) test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) @@ -97,6 +101,7 @@ testexec_PROGRAMS = installable_tests = \ shell-test \ + test-printf \ $(NULL) if DBUS_WITH_GLIB diff --git a/test/internals/printf.c b/test/internals/printf.c new file mode 100644 index 00000000..2d2fff8d --- /dev/null +++ b/test/internals/printf.c @@ -0,0 +1,89 @@ +/* Regression test for _dbus_printf_string_upper_bound + * + * Author: Simon McVittie + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +#define DBUS_COMPILATION /* this test uses libdbus-internal */ +#include +#include +#include +#include "test-utils.h" + +#include +#include + +static void +do_test (int minimum, + const char *format, + ...) +{ + va_list ap; + int result; + + va_start (ap, format); + result = _dbus_printf_string_upper_bound (format, ap); + va_end (ap); + + if (result < minimum) + { + fprintf (stderr, "expected at least %d, got %d\n", minimum, result); + abort (); + } +} + +#define X_TIMES_8 "XXXXXXXX" +#define X_TIMES_16 X_TIMES_8 X_TIMES_8 +#define X_TIMES_32 X_TIMES_16 X_TIMES_16 +#define X_TIMES_64 X_TIMES_32 X_TIMES_32 +#define X_TIMES_128 X_TIMES_64 X_TIMES_64 +#define X_TIMES_256 X_TIMES_128 X_TIMES_128 +#define X_TIMES_512 X_TIMES_256 X_TIMES_256 +#define X_TIMES_1024 X_TIMES_512 X_TIMES_512 + +int +main (int argc, + char **argv) +{ + char buf[] = X_TIMES_1024 X_TIMES_1024 X_TIMES_1024 X_TIMES_1024; + int i; + + do_test (1, "%d", 0); + do_test (7, "%d", 1234567); + do_test (3, "%f", 3.5); + + do_test (0, "%s", ""); + do_test (1024, "%s", X_TIMES_1024); + do_test (1025, "%s", X_TIMES_1024 "Y"); + + for (i = 4096; i > 0; i--) + { + buf[i] = '\0'; + do_test (i, "%s", buf); + do_test (i + 3, "%s:%d", buf, 42); + } + + return 0; +} -- cgit v1.2.1 From 159fdbf680d2dcdd5f80568c3305e93114caddfa Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 14:02:31 +0100 Subject: Prepare embargoed release for tomorrow --- NEWS | 6 +++++- configure.ac | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index f084c8ab..9a577c36 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,12 @@ -D-Bus 1.6.12 (UNRELEASED) +D-Bus 1.6.12 (2013-06-13) == Fixes: +• CVE-2013-2168: Fix misuse of va_list that could be used as a denial + of service for system services. Vulnerability reported by Alexandru Cornea. + (Simon) + • In dbus-daemon, don't crash if a .service file starts with key=value (fd.o #60853, Chengwei Yang) diff --git a/configure.ac b/configure.ac index 1f0597bd..a963d4d5 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [11]) +m4_define([dbus_micro_version], [12]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=3 +LT_REVISION=4 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From 22fd9df043aab7e1e344909c45cde472e93bd152 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 14:46:24 +0100 Subject: Start 1.6.13 --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 9a577c36..46cf8b32 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.6.14 (UNRELEASED) +== + +... + D-Bus 1.6.12 (2013-06-13) == diff --git a/configure.ac b/configure.ac index a963d4d5..dab29ee4 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [12]) +m4_define([dbus_micro_version], [13]) 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]) -- cgit v1.2.1 From 0553e53de04685588efacb961ae48384956db31d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 11 Jun 2013 19:20:55 +0100 Subject: _dbus_system_logv: copy the va_list here too This would crash if HAVE_SYSLOG_H is defined, HAVE_DECL_LOG_PERROR is false, and the platform calling convention is that va_list is a struct. Verified on Linux by undefining HAVE_DECL_LOG_PERROR. Reviewed-by: Colin Walters --- dbus/dbus-sysdeps-util-unix.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 789729c7..6265e2b5 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -477,6 +477,7 @@ _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) void _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args) { + va_list tmp; #ifdef HAVE_SYSLOG_H int flags; switch (severity) @@ -494,14 +495,14 @@ _dbus_system_logv (DBusSystemLogSeverity severity, const char *msg, va_list args return; } - vsyslog (flags, msg, args); + DBUS_VA_COPY (tmp, args); + vsyslog (flags, msg, tmp); + va_end (tmp); #endif #if !defined(HAVE_SYSLOG_H) || !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); -- cgit v1.2.1 From b54067510f80d2e570c1afdb4b17ee4d0b7c57ed Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 17:25:29 +0100 Subject: Revert "start spec 0.22 development" This reverts commit 82b3d94ab10f16e6c6c18eb3bc76594cd63e3854. --- doc/dbus-specification.xml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index a6bedfae..ec8afde8 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.22 - (not yet released) + Version 0.21 + 2013-04-25 Havoc @@ -71,12 +71,6 @@ - - 0.22 - not yet released (commit log) - - - 0.21 2013-04-25 -- cgit v1.2.1 From 7385459f89d8efc21659f4fee7f89fec26bb1773 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 17:27:54 +0100 Subject: Fix an incorrect comment _dbus_threads_lock_platform_specific() is implemented on Windows now. --- dbus/dbus-sysdeps.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index d92325ca..1053303a 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -522,8 +522,6 @@ dbus_bool_t _dbus_threads_init_platform_specific (void); /** * Lock a static mutex used to protect _dbus_threads_init_platform_specific(). - * - * On Windows, this is currently unimplemented and does nothing. */ void _dbus_threads_lock_platform_specific (void); -- cgit v1.2.1 From dab4284a24da2b6c015fd89fa953f177af7867b4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 19:01:07 +0100 Subject: NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 5491e663..a8d66a66 100644 --- a/NEWS +++ b/NEWS @@ -33,6 +33,9 @@ Other fixes: (fd.o #60853, Chengwei Yang) • Unix-specific: + · Fix a crash similar to CVE-2013-2168 the first time we try to use syslog + on a platform not defining LOG_PERROR, such as Solaris or QNX. + This regressed in 1.7.0. (Simon) · Fix an assertion failure if we try to activate systemd services before systemd connects to the bus (fd.o #50199, Chengwei Yang) · Avoid compiler warnings for ignoring the return from write() -- cgit v1.2.1 From 74651d3b1788a755ad78ec41d80612d50123db4d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 19:14:40 +0100 Subject: Move libdbus-init-win.cpp to its own convenience library Otherwise libdbus-1 ends up linked as if it contained C++, even on Unix, where it doesn't; in turn, that makes it export all the underscore-prefixed symbols that aren't meant to be exported. Reviewed-by: Thiago Macieira Reviewed-by: David Zeuthen --- dbus/Makefile.am | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index fe9c93f2..90c2c901 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -72,7 +72,6 @@ endif DBUS_SHARED_arch_sources = \ $(wince_source) \ dbus-file-win.c \ - dbus-init-win.cpp \ dbus-pipe-win.c \ dbus-sockets-win.h \ dbus-sysdeps-win.c \ @@ -296,6 +295,17 @@ libdbus_internal_la_CPPFLAGS = \ $(NULL) libdbus_internal_la_LIBADD=$(LIBDBUS_LIBS) $(SYSTEMD_LIBS) +if DBUS_WIN +# This must be a separate convenience library, otherwise libtool notices +# that libdbus-1 might contain C++, links it with g++ and links in libstdc++, +# even on Unix where in fact it doesn't contain any C++. For Windows, where +# this code is used, we don't actually need libstdc++. +noinst_LTLIBRARIES += libdbus-init-win.la +libdbus_init_win_la_SOURCES = dbus-init-win.cpp +libdbus_1_la_LIBADD += libdbus-init-win.la +libdbus_internal_la_LIBADD += libdbus-init-win.la +endif + noinst_PROGRAMS = if DBUS_BUILD_TESTS -- cgit v1.2.1 From 46d73712ab0750f995f0ec89f4d28b09dbba8c29 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 12 Jun 2013 19:49:44 +0100 Subject: Prepare 1.7.4 for tomorrow --- NEWS | 2 +- configure.ac | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index a8d66a66..59d38503 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -D-Bus 1.7.4 (UNRELEASED) +D-Bus 1.7.4 (2013-06-13) == Security fixes: diff --git a/configure.ac b/configure.ac index 5d243764..8edbf18d 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [3]) +m4_define([dbus_micro_version], [4]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=11 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=1 +LT_REVISION=2 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From ba0f90c16fa502e81e74db7d2834c27e239b45ba Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 13 Jun 2013 13:46:33 +0100 Subject: Add release name for 1.6.12 --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 46cf8b32..4fec6324 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ D-Bus 1.6.14 (UNRELEASED) D-Bus 1.6.12 (2013-06-13) == +The “does this unit have a soul?” release. + Fixes: • CVE-2013-2168: Fix misuse of va_list that could be used as a denial -- cgit v1.2.1 From 1a69f641fbf8afc7ca46dcbe00981faa4bb9822a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 13 Jun 2013 13:47:19 +0100 Subject: Start on 1.7.5, add release name for 1.7.4 --- NEWS | 7 +++++++ configure.ac | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 59d38503..cf24c116 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,13 @@ +D-Bus 1.7.6 (UNRELEASED) +== + +... + D-Bus 1.7.4 (2013-06-13) == +The “but is your thread-safety thread-safe?” release. + Security fixes: • CVE-2013-2168: Fix misuse of va_list that could be used as a denial diff --git a/configure.ac b/configure.ac index 8edbf18d..4c63f982 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [4]) +m4_define([dbus_micro_version], [5]) 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]) -- cgit v1.2.1 From 57db30169fc9fd55e54f09fe7f22f6961859545f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 13 Jun 2013 16:18:30 +0100 Subject: Fix Werror=unused-function if build without X11 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65712 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- tools/dbus-launch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index b2ffe41d..632a0042 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -105,6 +105,7 @@ save_machine_uuid (const char *uuid_arg) machine_uuid = xstrdup (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 */ @@ -146,7 +147,7 @@ out: fclose(f); return ret; } - +#endif /* DBUS_BUILD_X11 */ void verbose (const char *format, -- cgit v1.2.1 From 7e9ee6c82e42ffa3f6e4e69e077f72df6f4107db Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 2 May 2013 14:50:24 +0100 Subject: start spec 0.22 development --- doc/dbus-specification.xml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index ec8afde8..a6bedfae 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.21 - 2013-04-25 + Version 0.22 + (not yet released) Havoc @@ -71,6 +71,12 @@ + + 0.22 + not yet released (commit log) + + + 0.21 2013-04-25 -- cgit v1.2.1 From c80c20af46c5f43dcbe672f2c6d8aec0e7f2bbd6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 15:39:54 +0100 Subject: Replace individual global-lock variables with an array of DBusRMutex * This means we can use a much simpler code structure in data-slot allocators: instead of giving them a DBusRMutex ** at first-allocation, we can just give them an index into the array, which can be done statically. It doesn't make us any more thread-safe-by-default - the mutexes will only actually be used if threads were already initialized - but it's substantially better than nothing. These locks really do have to be recursive: for instance, internal_bus_get() calls dbus_bus_register() under the bus lock, and dbus_bus_register() can call _dbus_connection_close_possibly_shared(), which takes the bus lock. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Ralf Habacker Reviewed-by: Anas Nashif --- Doxyfile.in | 1 - cmake/Doxyfile.cmake | 1 - dbus/dbus-bus.c | 13 ------ dbus/dbus-connection.c | 7 ++-- dbus/dbus-dataslot.c | 62 +++++++++-------------------- dbus/dbus-dataslot.h | 8 ++-- dbus/dbus-internals.c | 19 +-------- dbus/dbus-internals.h | 59 ++++++++++++++++------------ dbus/dbus-list.c | 2 +- dbus/dbus-memory.c | 18 ++++++--- dbus/dbus-message.c | 7 ++-- dbus/dbus-pending-call.c | 5 +-- dbus/dbus-server.c | 6 +-- dbus/dbus-sysdeps.c | 2 - dbus/dbus-threads.c | 100 +++++++++++++++++++++-------------------------- 15 files changed, 126 insertions(+), 184 deletions(-) diff --git a/Doxyfile.in b/Doxyfile.in index afac639b..f0a37eda 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -147,7 +147,6 @@ PREDEFINED = "DBUS_BEGIN_DECLS=" \ "DBUS_END_DECLS=" \ "DOXYGEN_SHOULD_SKIP_THIS" \ "DBUS_GNUC_DEPRECATED=" \ - "_DBUS_DEFINE_GLOBAL_LOCK(name)=" \ "_DBUS_GNUC_PRINTF(from,to)=" SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- diff --git a/cmake/Doxyfile.cmake b/cmake/Doxyfile.cmake index e00984e7..3c63d95a 100644 --- a/cmake/Doxyfile.cmake +++ b/cmake/Doxyfile.cmake @@ -147,7 +147,6 @@ PREDEFINED = "DBUS_BEGIN_DECLS=" \ "DBUS_END_DECLS=" \ "DOXYGEN_SHOULD_SKIP_THIS" \ "DBUS_GNUC_DEPRECATED=" \ - "_DBUS_DEFINE_GLOBAL_LOCK(name)=" \ "_DBUS_GNUC_PRINTF(from,to)=" \ "DBUS_EXPORT=" SKIP_FUNCTION_MACROS = YES diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 6f81c74a..4a6ffb1e 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -95,19 +95,6 @@ static DBusBusType activation_bus_type = DBUS_BUS_STARTER; static dbus_bool_t initialized = FALSE; -/** - * Lock for globals in this file - */ -_DBUS_DEFINE_GLOBAL_LOCK (bus); - -/** - * Global lock covering all BusData on any connection. The bet is - * that some lock contention is better than more memory - * for a per-connection lock, but it's tough to imagine it mattering - * either way. - */ -_DBUS_DEFINE_GLOBAL_LOCK (bus_datas); - static void addresses_shutdown_func (void *data) { diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 66315b3f..03ee0667 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -1531,7 +1531,7 @@ _dbus_connection_handle_watch (DBusWatch *watch, return retval; } -_DBUS_DEFINE_GLOBAL_LOCK (shared_connections); +/* Protected by _DBUS_LOCK (shared_connections) */ static DBusHashTable *shared_connections = NULL; static DBusList *shared_connections_no_guid = NULL; @@ -5852,8 +5852,8 @@ dbus_connection_list_registered (DBusConnection *connection, return retval; } -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (connection_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (connection_slots)); /** * Allocates an integer ID to be used for storing application-specific @@ -5873,7 +5873,6 @@ dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t *slot_p) { return _dbus_data_slot_allocator_alloc (&slot_allocator, - &_DBUS_LOCK_NAME (connection_slots), slot_p); } diff --git a/dbus/dbus-dataslot.c b/dbus/dbus-dataslot.c index 0369612e..b3c80909 100644 --- a/dbus/dbus-dataslot.c +++ b/dbus/dbus-dataslot.c @@ -43,13 +43,14 @@ * @param allocator the allocator to initialize */ dbus_bool_t -_dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator) +_dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator, + DBusGlobalLock lock) { allocator->allocated_slots = NULL; allocator->n_allocated_slots = 0; allocator->n_used_slots = 0; - allocator->lock_loc = NULL; - + allocator->lock = lock; + return TRUE; } @@ -61,29 +62,16 @@ _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator) * is allocated and stored at *slot_id_p. * * @param allocator the allocator - * @param mutex_loc the location lock for this allocator * @param slot_id_p address to fill with the slot ID * @returns #TRUE on success */ dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, - DBusRMutex **mutex_loc, dbus_int32_t *slot_id_p) { dbus_int32_t slot; - _dbus_rmutex_lock (*mutex_loc); - - if (allocator->n_allocated_slots == 0) - { - _dbus_assert (allocator->lock_loc == NULL); - allocator->lock_loc = mutex_loc; - } - else if (allocator->lock_loc != mutex_loc) - { - _dbus_warn_check_failed ("D-Bus threads were initialized after first using the D-Bus library. If your application does not directly initialize threads or use D-Bus, keep in mind that some library or plugin may have used D-Bus or initialized threads behind your back. You can often fix this problem by calling dbus_init_threads() or dbus_g_threads_init() early in your main() method, before D-Bus is used.\n"); - _dbus_assert_not_reached ("exiting"); - } + _dbus_lock (allocator->lock); if (*slot_id_p >= 0) { @@ -146,7 +134,7 @@ _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, slot, allocator, allocator->n_allocated_slots, allocator->n_used_slots); out: - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); return slot >= 0; } @@ -165,7 +153,7 @@ void _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p) { - _dbus_rmutex_lock (*(allocator->lock_loc)); + _dbus_lock (allocator->lock); _dbus_assert (*slot_id_p < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[*slot_id_p].slot_id == *slot_id_p); @@ -175,7 +163,7 @@ _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, if (allocator->allocated_slots[*slot_id_p].refcount > 0) { - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); return; } @@ -190,19 +178,12 @@ _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, if (allocator->n_used_slots == 0) { - DBusRMutex **mutex_loc = allocator->lock_loc; - dbus_free (allocator->allocated_slots); allocator->allocated_slots = NULL; allocator->n_allocated_slots = 0; - allocator->lock_loc = NULL; - - _dbus_rmutex_unlock (*mutex_loc); - } - else - { - _dbus_rmutex_unlock (*(allocator->lock_loc)); } + + _dbus_unlock (allocator->lock); } /** @@ -247,10 +228,10 @@ _dbus_data_slot_list_set (DBusDataSlotAllocator *allocator, * be e.g. realloc()ing allocated_slots. We avoid doing this if asserts * are disabled, since then the asserts are empty. */ - _dbus_rmutex_lock (*(allocator->lock_loc)); + _dbus_lock (allocator->lock); _dbus_assert (slot < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[slot].slot_id == slot); - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); #endif if (slot >= list->n_slots) @@ -304,11 +285,11 @@ _dbus_data_slot_list_get (DBusDataSlotAllocator *allocator, * be e.g. realloc()ing allocated_slots. We avoid doing this if asserts * are disabled, since then the asserts are empty. */ - _dbus_rmutex_lock (*(allocator->lock_loc)); + _dbus_lock (allocator->lock); _dbus_assert (slot >= 0); _dbus_assert (slot < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[slot].slot_id == slot); - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); #endif if (slot >= list->n_slots) @@ -384,17 +365,12 @@ _dbus_data_slot_test (void) int i; DBusFreeFunction old_free_func; void *old_data; - DBusRMutex *mutex; - - if (!_dbus_data_slot_allocator_init (&allocator)) + + if (!_dbus_data_slot_allocator_init (&allocator, _DBUS_LOCK_server_slots)) _dbus_assert_not_reached ("no memory for allocator"); _dbus_data_slot_list_init (&list); - _dbus_rmutex_new_at_location (&mutex); - if (mutex == NULL) - _dbus_assert_not_reached ("failed to alloc mutex"); - #define N_SLOTS 100 i = 0; @@ -405,8 +381,8 @@ _dbus_data_slot_test (void) * here. */ dbus_int32_t tmp = -1; - - _dbus_data_slot_allocator_alloc (&allocator, &mutex, &tmp); + + _dbus_data_slot_allocator_alloc (&allocator, &tmp); if (tmp != i) _dbus_assert_not_reached ("did not allocate slots in numeric order\n"); @@ -471,8 +447,6 @@ _dbus_data_slot_test (void) ++i; } - _dbus_rmutex_free_at_location (&mutex); - return TRUE; } diff --git a/dbus/dbus-dataslot.h b/dbus/dbus-dataslot.h index 3d9d5edd..1e04fcbc 100644 --- a/dbus/dbus-dataslot.h +++ b/dbus/dbus-dataslot.h @@ -57,9 +57,11 @@ struct DBusDataSlotAllocator DBusAllocatedSlot *allocated_slots; /**< Allocated slots */ int n_allocated_slots; /**< number of slots malloc'd */ int n_used_slots; /**< number of slots used */ - DBusRMutex **lock_loc; /**< location of thread lock */ + DBusGlobalLock lock; /**< index of thread lock */ }; +#define _DBUS_DATA_SLOT_ALLOCATOR_INIT(x) { NULL, 0, 0, x } + /** * Data structure that stores the actual user data set at a given * slot. @@ -70,9 +72,9 @@ struct DBusDataSlotList int n_slots; /**< Slots we have storage for in data_slots */ }; -dbus_bool_t _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator); +dbus_bool_t _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator, + DBusGlobalLock lock); dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, - DBusRMutex **mutex_loc, int *slot_id_p); void _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, int *slot_id_p); diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 0e5d807e..1a367344 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -162,23 +162,6 @@ * Expands to name of a global lock variable. */ -/** - * @def _DBUS_DEFINE_GLOBAL_LOCK - * - * Defines a global lock variable with the given name. - * The lock must be added to the list to initialize - * in dbus_threads_init(). - */ - -/** - * @def _DBUS_DECLARE_GLOBAL_LOCK - * - * Expands to declaration of a global lock defined - * with _DBUS_DEFINE_GLOBAL_LOCK. - * The lock must be added to the list to initialize - * in dbus_threads_init(). - */ - /** * @def _DBUS_LOCK * @@ -847,7 +830,7 @@ _dbus_read_uuid_file (const DBusString *filename, } } -_DBUS_DEFINE_GLOBAL_LOCK (machine_uuid); +/* Protected by _DBUS_LOCK (machine_uuid) */ static int machine_uuid_initialized_generation = 0; static DBusGUID machine_uuid; diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 382630da..d0a10899 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -293,35 +293,42 @@ dbus_bool_t _dbus_test_oom_handling (const char *description, #endif /* !DBUS_BUILD_TESTS */ typedef void (* DBusShutdownFunction) (void *data); -dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction function, - void *data); +dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction function, + void *data); +dbus_bool_t _dbus_register_shutdown_func_unlocked (DBusShutdownFunction function, + void *data); extern int _dbus_current_generation; -/* Thread initializers */ -#define _DBUS_LOCK_NAME(name) _dbus_lock_##name -#define _DBUS_DECLARE_GLOBAL_LOCK(name) extern DBusRMutex *_dbus_lock_##name -#define _DBUS_DEFINE_GLOBAL_LOCK(name) DBusRMutex *_dbus_lock_##name -#define _DBUS_LOCK(name) _dbus_rmutex_lock (_dbus_lock_##name) -#define _DBUS_UNLOCK(name) _dbus_rmutex_unlock (_dbus_lock_##name) - -/* index 0-4 */ -_DBUS_DECLARE_GLOBAL_LOCK (list); -_DBUS_DECLARE_GLOBAL_LOCK (connection_slots); -_DBUS_DECLARE_GLOBAL_LOCK (pending_call_slots); -_DBUS_DECLARE_GLOBAL_LOCK (server_slots); -_DBUS_DECLARE_GLOBAL_LOCK (message_slots); -/* index 5-9 */ -_DBUS_DECLARE_GLOBAL_LOCK (bus); -_DBUS_DECLARE_GLOBAL_LOCK (bus_datas); -_DBUS_DECLARE_GLOBAL_LOCK (shutdown_funcs); -_DBUS_DECLARE_GLOBAL_LOCK (system_users); -_DBUS_DECLARE_GLOBAL_LOCK (message_cache); -/* index 10-11 */ -_DBUS_DECLARE_GLOBAL_LOCK (shared_connections); -_DBUS_DECLARE_GLOBAL_LOCK (machine_uuid); - -#define _DBUS_N_GLOBAL_LOCKS (12) +/* The weird case convention is to avoid having to change all the callers, + * which would be quite a mega-patch. */ +typedef enum +{ + /* index 0-4 */ + _DBUS_LOCK_list, + _DBUS_LOCK_connection_slots, + _DBUS_LOCK_pending_call_slots, + _DBUS_LOCK_server_slots, + _DBUS_LOCK_message_slots, + /* index 5-9 */ + _DBUS_LOCK_bus, + _DBUS_LOCK_bus_datas, + _DBUS_LOCK_shutdown_funcs, + _DBUS_LOCK_system_users, + _DBUS_LOCK_message_cache, + /* index 10-11 */ + _DBUS_LOCK_shared_connections, + _DBUS_LOCK_machine_uuid, + + _DBUS_N_GLOBAL_LOCKS +} DBusGlobalLock; + +void _dbus_lock (DBusGlobalLock lock); +void _dbus_unlock (DBusGlobalLock lock); + +#define _DBUS_LOCK_NAME(name) _DBUS_LOCK_##name +#define _DBUS_LOCK(name) _dbus_lock (_DBUS_LOCK_##name) +#define _DBUS_UNLOCK(name) _dbus_unlock (_DBUS_LOCK_##name) dbus_bool_t _dbus_threads_init_debug (void); diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index 7e11cc8d..e5a49408 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -35,8 +35,8 @@ * Types and functions related to DBusList. */ +/* Protected by _DBUS_LOCK (list) */ static DBusMemPool *list_pool; -_DBUS_DEFINE_GLOBAL_LOCK (list); /** * @defgroup DBusListInternals Linked list implementation details diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index 317e37ee..a13b9516 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -795,7 +795,7 @@ struct ShutdownClosure void *data; /**< Data for function */ }; -_DBUS_DEFINE_GLOBAL_LOCK (shutdown_funcs); +/* Protected by _DBUS_LOCK (shutdown_funcs) */ static ShutdownClosure *registered_globals = NULL; /** @@ -809,6 +809,18 @@ static ShutdownClosure *registered_globals = NULL; dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction func, void *data) +{ + dbus_bool_t ok; + + _DBUS_LOCK (shutdown_funcs); + ok = _dbus_register_shutdown_func_unlocked (func, data); + _DBUS_UNLOCK (shutdown_funcs); + return ok; +} + +dbus_bool_t +_dbus_register_shutdown_func_unlocked (DBusShutdownFunction func, + void *data) { ShutdownClosure *c; @@ -820,13 +832,9 @@ _dbus_register_shutdown_func (DBusShutdownFunction func, c->func = func; c->data = data; - _DBUS_LOCK (shutdown_funcs); - c->next = registered_globals; registered_globals = c; - _DBUS_UNLOCK (shutdown_funcs); - return TRUE; } diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 619bc695..bc2380f8 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -506,7 +506,7 @@ _dbus_message_set_signature (DBusMessage *message, /** Avoid caching too many messages */ #define MAX_MESSAGE_CACHE_SIZE 5 -_DBUS_DEFINE_GLOBAL_LOCK (message_cache); +/* Protected by _DBUS_LOCK (message_cache) */ static DBusMessage *message_cache[MAX_MESSAGE_CACHE_SIZE]; static int message_cache_count = 0; static dbus_bool_t message_cache_shutdown_registered = FALSE; @@ -4423,8 +4423,8 @@ _dbus_message_loader_get_max_message_unix_fds (DBusMessageLoader *loader) return loader->max_message_unix_fds; } -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (message_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (message_slots)); /** * Allocates an integer ID to be used for storing application-specific @@ -4444,7 +4444,6 @@ dbus_bool_t dbus_message_allocate_data_slot (dbus_int32_t *slot_p) { return _dbus_data_slot_allocator_alloc (&slot_allocator, - &_DBUS_LOCK_NAME (message_slots), slot_p); } diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index 62c6c748..16044087 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -489,8 +489,8 @@ _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending) return pending->completed; } -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (pending_call_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (pending_call_slots)); /** * Stores a pointer on a #DBusPendingCall, along @@ -768,7 +768,6 @@ dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p) _dbus_return_val_if_fail (slot_p != NULL, FALSE); return _dbus_data_slot_allocator_alloc (&slot_allocator, - &_DBUS_LOCK_NAME (pending_call_slots), slot_p); } diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index b62c2b40..e0212662 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -1071,9 +1071,8 @@ dbus_server_set_auth_mechanisms (DBusServer *server, return TRUE; } - -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (server_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (server_slots)); /** * Allocates an integer ID to be used for storing application-specific @@ -1093,7 +1092,6 @@ dbus_bool_t dbus_server_allocate_data_slot (dbus_int32_t *slot_p) { return _dbus_data_slot_allocator_alloc (&slot_allocator, - (DBusRMutex **)&_DBUS_LOCK_NAME (server_slots), slot_p); } diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 4e14ac38..0fbf9e71 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -46,8 +46,6 @@ #include #endif -_DBUS_DEFINE_GLOBAL_LOCK (system_users); - #ifdef DBUS_WIN #include #elif (defined __APPLE__) diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 43676bc1..297a7e4e 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -343,23 +343,19 @@ _dbus_condvar_wake_one (DBusCondVar *cond) _dbus_platform_condvar_wake_one (cond); } +static DBusRMutex *global_locks[_DBUS_N_GLOBAL_LOCKS] = { NULL }; + static void -shutdown_global_locks (void *data) +shutdown_global_locks (void *nil) { - DBusRMutex ***locks = data; int i; - i = 0; - while (i < _DBUS_N_GLOBAL_LOCKS) + for (i = 0; i < _DBUS_N_GLOBAL_LOCKS; i++) { - if (*(locks[i]) != NULL) - _dbus_platform_rmutex_free (*(locks[i])); - - *(locks[i]) = NULL; - ++i; + _dbus_assert (global_locks[i] != NULL); + _dbus_platform_rmutex_free (global_locks[i]); + global_locks[i] = NULL; } - - dbus_free (locks); } static void @@ -483,67 +479,60 @@ init_uninitialized_locks (void) } static dbus_bool_t -init_locks (void) +init_global_locks (void) { int i; - DBusRMutex ***dynamic_global_locks; - DBusRMutex **global_locks[] = { -#define LOCK_ADDR(name) (& _dbus_lock_##name) - LOCK_ADDR (list), - LOCK_ADDR (connection_slots), - LOCK_ADDR (pending_call_slots), - LOCK_ADDR (server_slots), - LOCK_ADDR (message_slots), - LOCK_ADDR (bus), - LOCK_ADDR (bus_datas), - LOCK_ADDR (shutdown_funcs), - LOCK_ADDR (system_users), - LOCK_ADDR (message_cache), - LOCK_ADDR (shared_connections), - LOCK_ADDR (machine_uuid) -#undef LOCK_ADDR - }; - - _DBUS_STATIC_ASSERT (_DBUS_N_ELEMENTS (global_locks) == _DBUS_N_GLOBAL_LOCKS); - - i = 0; - - dynamic_global_locks = dbus_new (DBusRMutex**, _DBUS_N_GLOBAL_LOCKS); - if (dynamic_global_locks == NULL) - goto failed; - - while (i < _DBUS_N_ELEMENTS (global_locks)) + dbus_bool_t ok; + + for (i = 0; i < _DBUS_N_GLOBAL_LOCKS; i++) { - *global_locks[i] = _dbus_platform_rmutex_new (); + _dbus_assert (global_locks[i] == NULL); + + global_locks[i] = _dbus_platform_rmutex_new (); - if (*global_locks[i] == NULL) + if (global_locks[i] == NULL) goto failed; + } - dynamic_global_locks[i] = global_locks[i]; + _dbus_lock (_DBUS_LOCK_NAME (shutdown_funcs)); + ok = _dbus_register_shutdown_func_unlocked (shutdown_global_locks, NULL); + _dbus_unlock (_DBUS_LOCK_NAME (shutdown_funcs)); - ++i; - } - - if (!_dbus_register_shutdown_func (shutdown_global_locks, - dynamic_global_locks)) + if (!ok) goto failed; - if (!init_uninitialized_locks ()) - goto failed; - return TRUE; failed: - dbus_free (dynamic_global_locks); - for (i = i - 1; i >= 0; i--) { - _dbus_platform_rmutex_free (*global_locks[i]); - *global_locks[i] = NULL; + _dbus_platform_rmutex_free (global_locks[i]); + global_locks[i] = NULL; } + return FALSE; } +void +_dbus_lock (DBusGlobalLock lock) +{ + _dbus_assert (lock >= 0); + _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); + + if (thread_init_generation == _dbus_current_generation) + _dbus_platform_rmutex_lock (global_locks[lock]); +} + +void +_dbus_unlock (DBusGlobalLock lock) +{ + _dbus_assert (lock >= 0); + _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); + + if (thread_init_generation == _dbus_current_generation) + _dbus_platform_rmutex_unlock (global_locks[lock]); +} + /** @} */ /* end of internals */ /** @@ -587,7 +576,8 @@ dbus_threads_init (const DBusThreadFunctions *functions) } if (!_dbus_threads_init_platform_specific() || - !init_locks ()) + !init_global_locks () || + !init_uninitialized_locks ()) { _dbus_threads_unlock_platform_specific (); return FALSE; -- cgit v1.2.1 From 2b3272c75ae48c93911bd6f656965cf77d6de3e8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 16:28:44 +0100 Subject: Make taking a global lock automatically initialize locking if needed This lets them be thread-safe by default, at the cost that they can now fail. init_uninitialized_locks() and init_global_locks() must now both reimplement the equivalent of _dbus_register_shutdown_func(), by using _dbus_platform_rmutex_lock() on the same underlying mutex around a call to _dbus_register_shutdown_func_unlocked(). This is because if they used the usual _DBUS_LOCK() API (as _dbus_register_shutdown_func() does), it would automatically try to initialize global locking, leading to infinite recursion. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Anas Nashif --- bus/stats.c | 4 +-- dbus/dbus-bus.c | 52 ++++++++++++++++++++++++++++++-------- dbus/dbus-connection.c | 50 ++++++++++++++++++++++++++---------- dbus/dbus-dataslot.c | 19 ++++++++++---- dbus/dbus-internals.c | 8 ++++-- dbus/dbus-internals.h | 4 +-- dbus/dbus-list.c | 17 ++++++++++--- dbus/dbus-memory.c | 4 ++- dbus/dbus-message.c | 19 +++++++++++--- dbus/dbus-threads.c | 28 +++++++++++++------- dbus/dbus-userdb-util.c | 20 ++++++++++++--- dbus/dbus-userdb.c | 43 +++++++++++++++++++++++-------- dbus/dbus-userdb.h | 2 +- test/name-test/test-threads-init.c | 14 ++++++---- 14 files changed, 213 insertions(+), 71 deletions(-) diff --git a/bus/stats.c b/bus/stats.c index 28fd49ba..45531910 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -203,8 +203,8 @@ bus_stats_handle_get_stats (DBusConnection *connection, if (!asv_add_uint32 (&iter, &arr_iter, "Serial", stats_serial++)) goto oom; - _dbus_list_get_stats (&in_use, &in_free_list, &allocated); - if (!asv_add_uint32 (&iter, &arr_iter, "ListMemPoolUsedBytes", in_use) || + if (!_dbus_list_get_stats (&in_use, &in_free_list, &allocated) || + !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolUsedBytes", in_use) || !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolCachedBytes", in_free_list) || !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolAllocatedBytes", diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 4a6ffb1e..7b5f09af 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -317,7 +317,11 @@ bus_data_free (void *data) if (bd->is_well_known) { int i; - _DBUS_LOCK (bus); + + if (!_DBUS_LOCK (bus)) + _dbus_assert_not_reached ("global locks should have been initialized " + "when we attached bus data"); + /* We may be stored in more than one slot */ /* This should now be impossible - these slots are supposed to * be cleared on disconnect, so should not need to be cleared on @@ -388,8 +392,13 @@ void _dbus_bus_notify_shared_connection_disconnected_unlocked (DBusConnection *connection) { int i; - - _DBUS_LOCK (bus); + + if (!_DBUS_LOCK (bus)) + { + /* If it was in bus_connections, we would have initialized global locks + * when we added it. So, it can't be. */ + return; + } /* We are expecting to have the connection saved in only one of these * slots, but someone could in a pathological case set system and session @@ -423,7 +432,12 @@ internal_bus_get (DBusBusType type, connection = NULL; - _DBUS_LOCK (bus); + if (!_DBUS_LOCK (bus)) + { + _DBUS_SET_OOM (error); + /* do not "goto out", that would try to unlock */ + return NULL; + } if (!init_connections_unlocked ()) { @@ -493,8 +507,10 @@ internal_bus_get (DBusBusType type, */ dbus_connection_set_exit_on_disconnect (connection, TRUE); - - _DBUS_LOCK (bus_datas); + + if (!_DBUS_LOCK (bus_datas)) + _dbus_assert_not_reached ("global locks were initialized already"); + bd = ensure_bus_data (connection); _dbus_assert (bd != NULL); /* it should have been created on register, so OOM not possible */ @@ -647,7 +663,12 @@ dbus_bus_register (DBusConnection *connection, message = NULL; reply = NULL; - _DBUS_LOCK (bus_datas); + if (!_DBUS_LOCK (bus_datas)) + { + _DBUS_SET_OOM (error); + /* do not "goto out", that would try to unlock */ + return FALSE; + } bd = ensure_bus_data (connection); if (bd == NULL) @@ -756,8 +777,12 @@ dbus_bus_set_unique_name (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (unique_name != NULL, FALSE); - _DBUS_LOCK (bus_datas); - + if (!_DBUS_LOCK (bus_datas)) + { + /* do not "goto out", that would try to unlock */ + return FALSE; + } + bd = ensure_bus_data (connection); if (bd == NULL) goto out; @@ -799,8 +824,13 @@ dbus_bus_get_unique_name (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, NULL); - _DBUS_LOCK (bus_datas); - + if (!_DBUS_LOCK (bus_datas)) + { + /* We'd have initialized locks when we gave it its unique name, if it + * had one. Don't "goto out", that would try to unlock. */ + return NULL; + } + bd = ensure_bus_data (connection); if (bd == NULL) goto out; diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 03ee0667..87cfeb03 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -1555,9 +1555,14 @@ static void shared_connections_shutdown (void *data) { int n_entries; - - _DBUS_LOCK (shared_connections); - + + if (!_DBUS_LOCK (shared_connections)) + { + /* We'd have initialized locks before adding anything, so there + * can't be anything there. */ + return; + } + /* This is a little bit unpleasant... better ideas? */ while ((n_entries = _dbus_hash_table_get_n_entries (shared_connections)) > 0) { @@ -1571,7 +1576,8 @@ shared_connections_shutdown (void *data) _DBUS_UNLOCK (shared_connections); close_connection_on_shutdown (connection); - _DBUS_LOCK (shared_connections); + if (!_DBUS_LOCK (shared_connections)) + _dbus_assert_not_reached ("global locks were already initialized"); /* The connection should now be dead and not in our hash ... */ _dbus_assert (_dbus_hash_table_get_n_entries (shared_connections) < n_entries); @@ -1590,7 +1596,8 @@ shared_connections_shutdown (void *data) { _DBUS_UNLOCK (shared_connections); close_connection_on_shutdown (connection); - _DBUS_LOCK (shared_connections); + if (!_DBUS_LOCK (shared_connections)) + _dbus_assert_not_reached ("global locks were already initialized"); connection = _dbus_list_pop_first (&shared_connections_no_guid); } } @@ -1607,8 +1614,13 @@ connection_lookup_shared (DBusAddressEntry *entry, _dbus_verbose ("checking for existing connection\n"); *result = NULL; - - _DBUS_LOCK (shared_connections); + + if (!_DBUS_LOCK (shared_connections)) + { + /* If it was shared, we'd have initialized global locks when we put + * it in shared_connections. */ + return FALSE; + } if (shared_connections == NULL) { @@ -1706,7 +1718,8 @@ connection_record_shared_unlocked (DBusConnection *connection, if (guid == NULL) { - _DBUS_LOCK (shared_connections); + if (!_DBUS_LOCK (shared_connections)) + return FALSE; if (!_dbus_list_prepend (&shared_connections_no_guid, connection)) { @@ -1733,8 +1746,14 @@ connection_record_shared_unlocked (DBusConnection *connection, dbus_free (guid_key); return FALSE; } - - _DBUS_LOCK (shared_connections); + + if (!_DBUS_LOCK (shared_connections)) + { + dbus_free (guid_in_connection); + dbus_free (guid_key); + return FALSE; + } + _dbus_assert (shared_connections != NULL); if (!_dbus_hash_table_insert_string (shared_connections, @@ -1765,9 +1784,14 @@ connection_forget_shared_unlocked (DBusConnection *connection) if (!connection->shareable) return; - - _DBUS_LOCK (shared_connections); - + + if (!_DBUS_LOCK (shared_connections)) + { + /* If it was shared, we'd have initialized global locks when we put + * it in the table; so it can't be there. */ + return; + } + if (connection->server_guid != NULL) { _dbus_verbose ("dropping connection to %s out of the shared table\n", diff --git a/dbus/dbus-dataslot.c b/dbus/dbus-dataslot.c index b3c80909..412e7f4f 100644 --- a/dbus/dbus-dataslot.c +++ b/dbus/dbus-dataslot.c @@ -71,7 +71,8 @@ _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, { dbus_int32_t slot; - _dbus_lock (allocator->lock); + if (!_dbus_lock (allocator->lock)) + return FALSE; if (*slot_id_p >= 0) { @@ -153,8 +154,10 @@ void _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p) { - _dbus_lock (allocator->lock); - + if (!_dbus_lock (allocator->lock)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated this slot"); + _dbus_assert (*slot_id_p < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[*slot_id_p].slot_id == *slot_id_p); _dbus_assert (allocator->allocated_slots[*slot_id_p].refcount > 0); @@ -228,7 +231,10 @@ _dbus_data_slot_list_set (DBusDataSlotAllocator *allocator, * be e.g. realloc()ing allocated_slots. We avoid doing this if asserts * are disabled, since then the asserts are empty. */ - _dbus_lock (allocator->lock); + if (!_dbus_lock (allocator->lock)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated this slot"); + _dbus_assert (slot < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[slot].slot_id == slot); _dbus_unlock (allocator->lock); @@ -285,7 +291,10 @@ _dbus_data_slot_list_get (DBusDataSlotAllocator *allocator, * be e.g. realloc()ing allocated_slots. We avoid doing this if asserts * are disabled, since then the asserts are empty. */ - _dbus_lock (allocator->lock); + if (!_dbus_lock (allocator->lock)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated this slot"); + _dbus_assert (slot >= 0); _dbus_assert (slot < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[slot].slot_id == slot); diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 1a367344..63559be9 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -165,7 +165,9 @@ /** * @def _DBUS_LOCK * - * Locks a global lock + * Locks a global lock, initializing it first if necessary. + * + * @returns #FALSE if not enough memory */ /** @@ -849,7 +851,9 @@ _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str) { dbus_bool_t ok; - _DBUS_LOCK (machine_uuid); + if (!_DBUS_LOCK (machine_uuid)) + return FALSE; + if (machine_uuid_initialized_generation != _dbus_current_generation) { DBusError error = DBUS_ERROR_INIT; diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index d0a10899..ca011a51 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -323,8 +323,8 @@ typedef enum _DBUS_N_GLOBAL_LOCKS } DBusGlobalLock; -void _dbus_lock (DBusGlobalLock lock); -void _dbus_unlock (DBusGlobalLock lock); +dbus_bool_t _dbus_lock (DBusGlobalLock lock) _DBUS_GNUC_WARN_UNUSED_RESULT; +void _dbus_unlock (DBusGlobalLock lock); #define _DBUS_LOCK_NAME(name) _DBUS_LOCK_##name #define _DBUS_LOCK(name) _dbus_lock (_DBUS_LOCK_##name) diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index e5a49408..525e0678 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -56,7 +56,8 @@ alloc_link (void *data) { DBusList *link; - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + return FALSE; if (list_pool == NULL) { @@ -93,7 +94,10 @@ alloc_link (void *data) static void free_link (DBusList *link) { - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated a linked-list link"); + if (_dbus_mem_pool_dealloc (list_pool, link)) { _dbus_mem_pool_free (list_pool); @@ -152,7 +156,14 @@ _dbus_list_get_stats (dbus_uint32_t *in_use_p, dbus_uint32_t *in_free_list_p, dbus_uint32_t *allocated_p) { - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + { + *in_use_p = 0; + *in_free_list_p = 0; + *allocated_p = 0; + return; + } + _dbus_mem_pool_get_stats (list_pool, in_use_p, in_free_list_p, allocated_p); _DBUS_UNLOCK (list); } diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index a13b9516..6cf04498 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -812,7 +812,9 @@ _dbus_register_shutdown_func (DBusShutdownFunction func, { dbus_bool_t ok; - _DBUS_LOCK (shutdown_funcs); + if (!_DBUS_LOCK (shutdown_funcs)) + return FALSE; + ok = _dbus_register_shutdown_func_unlocked (func, data); _DBUS_UNLOCK (shutdown_funcs); return ok; diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index bc2380f8..696991f6 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -516,7 +516,9 @@ dbus_message_cache_shutdown (void *data) { int i; - _DBUS_LOCK (message_cache); + if (!_DBUS_LOCK (message_cache)) + _dbus_assert_not_reached ("we would have initialized global locks " + "before registering a shutdown function"); i = 0; while (i < MAX_MESSAGE_CACHE_SIZE) @@ -548,7 +550,12 @@ dbus_message_get_cached (void) message = NULL; - _DBUS_LOCK (message_cache); + if (!_DBUS_LOCK (message_cache)) + { + /* we'd have initialized global locks before caching anything, + * so there can't be anything in the cache */ + return NULL; + } _dbus_assert (message_cache_count >= 0); @@ -660,7 +667,13 @@ dbus_message_cache_or_finalize (DBusMessage *message) was_cached = FALSE; - _DBUS_LOCK (message_cache); + if (!_DBUS_LOCK (message_cache)) + { + /* The only way to get a non-null message goes through + * dbus_message_get_cached() which takes the lock. */ + _dbus_assert_not_reached ("we would have initialized global locks " + "the first time we constructed a message"); + } if (!message_cache_shutdown_registered) { diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 297a7e4e..2c2a8166 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -366,10 +366,12 @@ shutdown_uninitialized_locks (void *data) _dbus_list_clear (&uninitialized_condvar_list); } +/* init_global_locks() must be called first. */ static dbus_bool_t init_uninitialized_locks (void) { DBusList *link; + dbus_bool_t ok; _dbus_assert (thread_init_generation != _dbus_current_generation); @@ -422,8 +424,12 @@ init_uninitialized_locks (void) _dbus_list_clear (&uninitialized_cmutex_list); _dbus_list_clear (&uninitialized_condvar_list); - if (!_dbus_register_shutdown_func (shutdown_uninitialized_locks, - NULL)) + /* This assumes that init_global_locks() has already been called. */ + _dbus_platform_rmutex_lock (global_locks[_DBUS_LOCK_shutdown_funcs]); + ok = _dbus_register_shutdown_func_unlocked (shutdown_uninitialized_locks, NULL); + _dbus_platform_rmutex_unlock (global_locks[_DBUS_LOCK_shutdown_funcs]); + + if (!ok) goto fail_condvar; return TRUE; @@ -494,9 +500,9 @@ init_global_locks (void) goto failed; } - _dbus_lock (_DBUS_LOCK_NAME (shutdown_funcs)); + _dbus_platform_rmutex_lock (global_locks[_DBUS_LOCK_shutdown_funcs]); ok = _dbus_register_shutdown_func_unlocked (shutdown_global_locks, NULL); - _dbus_unlock (_DBUS_LOCK_NAME (shutdown_funcs)); + _dbus_platform_rmutex_unlock (global_locks[_DBUS_LOCK_shutdown_funcs]); if (!ok) goto failed; @@ -513,14 +519,18 @@ init_global_locks (void) return FALSE; } -void +dbus_bool_t _dbus_lock (DBusGlobalLock lock) { _dbus_assert (lock >= 0); _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); - if (thread_init_generation == _dbus_current_generation) - _dbus_platform_rmutex_lock (global_locks[lock]); + if (thread_init_generation != _dbus_current_generation && + !dbus_threads_init_default ()) + return FALSE; + + _dbus_platform_rmutex_lock (global_locks[lock]); + return TRUE; } void @@ -529,8 +539,7 @@ _dbus_unlock (DBusGlobalLock lock) _dbus_assert (lock >= 0); _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); - if (thread_init_generation == _dbus_current_generation) - _dbus_platform_rmutex_unlock (global_locks[lock]); + _dbus_platform_rmutex_unlock (global_locks[lock]); } /** @} */ /* end of internals */ @@ -576,6 +585,7 @@ dbus_threads_init (const DBusThreadFunctions *functions) } if (!_dbus_threads_init_platform_specific() || + /* init_global_locks() must be called before init_uninitialized_locks. */ !init_global_locks () || !init_uninitialized_locks ()) { diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c index 5af00922..38ea4ef0 100644 --- a/dbus/dbus-userdb-util.c +++ b/dbus/dbus-userdb-util.c @@ -104,7 +104,11 @@ _dbus_is_console_user (dbus_uid_t uid, #endif /* HAVE_CONSOLE_OWNER_FILE */ - _dbus_user_database_lock_system (); + if (!_dbus_user_database_lock_system ()) + { + _DBUS_SET_OOM (error); + return FALSE; + } db = _dbus_user_database_get_system (); if (db == NULL) @@ -158,7 +162,10 @@ _dbus_get_group_id (const DBusString *groupname, { DBusUserDatabase *db; const DBusGroupInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -195,7 +202,10 @@ _dbus_get_user_id_and_primary_group (const DBusString *username, { DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -388,7 +398,9 @@ _dbus_groups_from_uid (dbus_uid_t uid, *group_ids = NULL; *n_group_ids = 0; - _dbus_user_database_lock_system (); + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 4e8b39aa..73f8fcef 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -306,11 +306,18 @@ init_system_db (void) /** * Locks global system user database. */ -void +dbus_bool_t _dbus_user_database_lock_system (void) { - _DBUS_LOCK (system_users); - database_locked = TRUE; + if (_DBUS_LOCK (system_users)) + { + database_locked = TRUE; + return TRUE; + } + else + { + return FALSE; + } } /** @@ -345,8 +352,12 @@ _dbus_user_database_get_system (void) void _dbus_user_database_flush_system (void) { - _dbus_user_database_lock_system (); - + if (!_dbus_user_database_lock_system ()) + { + /* nothing to flush */ + return; + } + if (system_db != NULL) _dbus_user_database_flush (system_db); @@ -363,7 +374,9 @@ _dbus_user_database_flush_system (void) dbus_bool_t _dbus_username_from_current_process (const DBusString **username) { - _dbus_user_database_lock_system (); + if (!_dbus_user_database_lock_system ()) + return FALSE; + if (!init_system_db ()) { _dbus_user_database_unlock_system (); @@ -385,7 +398,9 @@ _dbus_username_from_current_process (const DBusString **username) dbus_bool_t _dbus_homedir_from_current_process (const DBusString **homedir) { - _dbus_user_database_lock_system (); + if (!_dbus_user_database_lock_system ()) + return FALSE; + if (!init_system_db ()) { _dbus_user_database_unlock_system (); @@ -410,7 +425,10 @@ _dbus_homedir_from_username (const DBusString *username, { DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -449,7 +467,10 @@ _dbus_homedir_from_uid (dbus_uid_t uid, { DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -496,7 +517,9 @@ _dbus_credentials_add_from_user (DBusCredentials *credentials, DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) diff --git a/dbus/dbus-userdb.h b/dbus/dbus-userdb.h index cb49d9e7..d6b72d8c 100644 --- a/dbus/dbus-userdb.h +++ b/dbus/dbus-userdb.h @@ -86,7 +86,7 @@ void _dbus_group_info_free_allocated (DBusGroupInfo *info); #endif /* DBUS_USERDB_INCLUDES_PRIVATE */ DBusUserDatabase* _dbus_user_database_get_system (void); -void _dbus_user_database_lock_system (void); +dbus_bool_t _dbus_user_database_lock_system (void) _DBUS_GNUC_WARN_UNUSED_RESULT; void _dbus_user_database_unlock_system (void); void _dbus_user_database_flush_system (void); diff --git a/test/name-test/test-threads-init.c b/test/name-test/test-threads-init.c index 5e22852a..580ffe14 100644 --- a/test/name-test/test-threads-init.c +++ b/test/name-test/test-threads-init.c @@ -149,11 +149,15 @@ main (int argc, char *argv[]) &dispatch_cond1, &io_path_cond1); - check_mutex_lock (mutex1, mutex2, FALSE); - check_mutex_lock (dispatch_mutex1, dispatch_mutex2, FALSE); - check_mutex_lock (io_path_mutex1, io_path_mutex2, FALSE); - check_condvar_lock (dispatch_cond1, dispatch_cond2, FALSE); - check_condvar_lock (io_path_cond1, io_path_cond2, FALSE); + /* Since 1.7 it is no longer the case that mutex1 != mutex2, because + * initializing global locks automatically initializes locks + * in general. However, it is true that the mutex is not the dummy + * implementation, which is what we really wanted to check here. */ + _dbus_assert (mutex1 != (DBusMutex *) 0xABCDEF); + _dbus_assert (dispatch_mutex1 != (DBusMutex *) 0xABCDEF); + _dbus_assert (dispatch_cond1 != (DBusCondVar *) 0xABCDEF2); + _dbus_assert (io_path_mutex1 != (DBusMutex *) 0xABCDEF); + _dbus_assert (io_path_cond1 != (DBusCondVar *) 0xABCDEF2); _run_iteration (conn); _dbus_connection_test_get_locks (conn, &mutex2, -- cgit v1.2.1 From 08391b14616c248458e838691d068aa48dc70d18 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 16:37:51 +0100 Subject: Always initialize threading before allocating a dynamic mutex Dynamic allocation of mutexes can fail anyway, so this is easy. Justification for not keeping the dummy mutex code-paths, even as an opt-in thing for processes known to be high-performance and single-threaded: real mutexes only cut the throughput of test/dbus-daemon.c by a couple of percent on my laptop (from around 6700 to around 6600 messages per second), and libdbus crashes caused by not calling dbus_threads_init_default() are sufficiently widespread that they're wasting a lot of everyone's time. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Anas Nashif --- dbus/dbus-threads.c | 300 ++++++++++------------------------------------------ 1 file changed, 56 insertions(+), 244 deletions(-) diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 2c2a8166..29462ebd 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -27,18 +27,6 @@ #include "dbus-list.h" static int thread_init_generation = 0; - -static DBusList *uninitialized_rmutex_list = NULL; -static DBusList *uninitialized_cmutex_list = NULL; -static DBusList *uninitialized_condvar_list = NULL; - -/** This is used for the no-op default mutex pointer, just to be distinct from #NULL */ -#define _DBUS_DUMMY_MUTEX ((DBusMutex*)0xABCDEF) -#define _DBUS_DUMMY_RMUTEX ((DBusRMutex *) _DBUS_DUMMY_MUTEX) -#define _DBUS_DUMMY_CMUTEX ((DBusCMutex *) _DBUS_DUMMY_MUTEX) - -/** This is used for the no-op default mutex pointer, just to be distinct from #NULL */ -#define _DBUS_DUMMY_CONDVAR ((DBusCondVar*)0xABCDEF2) /** * @defgroup DBusThreadsInternals Thread functions @@ -59,11 +47,6 @@ static DBusList *uninitialized_condvar_list = NULL; * If possible, the mutex returned by this function is recursive, to * avoid deadlocks. However, that cannot be relied on. * - * The extra level of indirection given by allocating a pointer - * to point to the mutex location allows the threading - * module to swap out dummy mutexes for a real mutex so libraries - * can initialize threads even after the D-Bus API has been used. - * * @param location_p the location of the new mutex, can return #NULL on OOM */ void @@ -71,17 +54,13 @@ _dbus_rmutex_new_at_location (DBusRMutex **location_p) { _dbus_assert (location_p != NULL); - if (thread_init_generation == _dbus_current_generation) + if (!dbus_threads_init_default ()) { - *location_p = _dbus_platform_rmutex_new (); + *location_p = NULL; + return; } - else - { - *location_p = _DBUS_DUMMY_RMUTEX; - if (!_dbus_list_append (&uninitialized_rmutex_list, location_p)) - *location_p = NULL; - } + *location_p = _dbus_platform_rmutex_new (); } /** @@ -92,11 +71,6 @@ _dbus_rmutex_new_at_location (DBusRMutex **location_p) * * The returned mutex is suitable for use with condition variables. * - * The extra level of indirection given by allocating a pointer - * to point to the mutex location allows the threading - * module to swap out dummy mutexes for a real mutex so libraries - * can initialize threads even after the D-Bus API has been used. - * * @param location_p the location of the new mutex, can return #NULL on OOM */ void @@ -104,22 +78,17 @@ _dbus_cmutex_new_at_location (DBusCMutex **location_p) { _dbus_assert (location_p != NULL); - if (thread_init_generation == _dbus_current_generation) + if (!dbus_threads_init_default ()) { - *location_p = _dbus_platform_cmutex_new (); + *location_p = NULL; + return; } - else - { - *location_p = _DBUS_DUMMY_CMUTEX; - if (!_dbus_list_append (&uninitialized_cmutex_list, location_p)) - *location_p = NULL; - } + *location_p = _dbus_platform_cmutex_new (); } /** - * Frees a DBusRMutex or removes it from the uninitialized mutex list; - * does nothing if passed a #NULL pointer. + * Frees a DBusRMutex; does nothing if passed a #NULL pointer. */ void _dbus_rmutex_free_at_location (DBusRMutex **location_p) @@ -127,23 +96,12 @@ _dbus_rmutex_free_at_location (DBusRMutex **location_p) if (location_p == NULL) return; - if (thread_init_generation == _dbus_current_generation) - { - if (*location_p != NULL) - _dbus_platform_rmutex_free (*location_p); - } - else - { - _dbus_assert (*location_p == NULL || *location_p == _DBUS_DUMMY_RMUTEX); - - _dbus_list_remove (&uninitialized_rmutex_list, location_p); - } + if (*location_p != NULL) + _dbus_platform_rmutex_free (*location_p); } /** - * Frees a DBusCMutex and removes it from the - * uninitialized mutex list; - * does nothing if passed a #NULL pointer. + * Frees a DBusCMutex; does nothing if passed a #NULL pointer. */ void _dbus_cmutex_free_at_location (DBusCMutex **location_p) @@ -151,17 +109,8 @@ _dbus_cmutex_free_at_location (DBusCMutex **location_p) if (location_p == NULL) return; - if (thread_init_generation == _dbus_current_generation) - { - if (*location_p != NULL) - _dbus_platform_cmutex_free (*location_p); - } - else - { - _dbus_assert (*location_p == NULL || *location_p == _DBUS_DUMMY_CMUTEX); - - _dbus_list_remove (&uninitialized_cmutex_list, location_p); - } + if (*location_p != NULL) + _dbus_platform_cmutex_free (*location_p); } /** @@ -172,8 +121,10 @@ _dbus_cmutex_free_at_location (DBusCMutex **location_p) void _dbus_rmutex_lock (DBusRMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_rmutex_lock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_rmutex_lock (mutex); } /** @@ -184,8 +135,10 @@ _dbus_rmutex_lock (DBusRMutex *mutex) void _dbus_cmutex_lock (DBusCMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_cmutex_lock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_cmutex_lock (mutex); } /** @@ -196,8 +149,10 @@ _dbus_cmutex_lock (DBusCMutex *mutex) void _dbus_rmutex_unlock (DBusRMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_rmutex_unlock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_rmutex_unlock (mutex); } /** @@ -208,8 +163,10 @@ _dbus_rmutex_unlock (DBusRMutex *mutex) void _dbus_cmutex_unlock (DBusCMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_cmutex_unlock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_cmutex_unlock (mutex); } /** @@ -223,19 +180,17 @@ _dbus_cmutex_unlock (DBusCMutex *mutex) DBusCondVar * _dbus_condvar_new (void) { - if (thread_init_generation == _dbus_current_generation) - return _dbus_platform_condvar_new (); - else - return _DBUS_DUMMY_CONDVAR; + if (!dbus_threads_init_default ()) + return NULL; + + return _dbus_platform_condvar_new (); } /** * This does the same thing as _dbus_condvar_new. It however * gives another level of indirection by allocating a pointer - * to point to the condvar location. This allows the threading - * module to swap out dummy condvars for a real condvar so libraries - * can initialize threads even after the D-Bus API has been used. + * to point to the condvar location; this used to be useful. * * @returns the location of a new condvar or #NULL on OOM */ @@ -245,17 +200,7 @@ _dbus_condvar_new_at_location (DBusCondVar **location_p) { _dbus_assert (location_p != NULL); - if (thread_init_generation == _dbus_current_generation) - { - *location_p = _dbus_condvar_new(); - } - else - { - *location_p = _DBUS_DUMMY_CONDVAR; - - if (!_dbus_list_append (&uninitialized_condvar_list, location_p)) - *location_p = NULL; - } + *location_p = _dbus_condvar_new(); } @@ -266,14 +211,14 @@ _dbus_condvar_new_at_location (DBusCondVar **location_p) void _dbus_condvar_free (DBusCondVar *cond) { - if (cond && thread_init_generation == _dbus_current_generation) - _dbus_platform_condvar_free (cond); + if (cond == NULL) + return; + + _dbus_platform_condvar_free (cond); } /** - * Frees a conditional variable and removes it from the - * uninitialized_condvar_list; - * does nothing if passed a #NULL pointer. + * Frees a condition variable; does nothing if passed a #NULL pointer. */ void _dbus_condvar_free_at_location (DBusCondVar **location_p) @@ -281,17 +226,8 @@ _dbus_condvar_free_at_location (DBusCondVar **location_p) if (location_p == NULL) return; - if (thread_init_generation == _dbus_current_generation) - { - if (*location_p != NULL) - _dbus_platform_condvar_free (*location_p); - } - else - { - _dbus_assert (*location_p == NULL || *location_p == _DBUS_DUMMY_CONDVAR); - - _dbus_list_remove (&uninitialized_condvar_list, location_p); - } + if (*location_p != NULL) + _dbus_platform_condvar_free (*location_p); } /** @@ -304,8 +240,10 @@ void _dbus_condvar_wait (DBusCondVar *cond, DBusCMutex *mutex) { - if (cond && mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_condvar_wait (cond, mutex); + if (cond == NULL || mutex == NULL) + return; + + _dbus_platform_condvar_wait (cond, mutex); } /** @@ -324,11 +262,11 @@ _dbus_condvar_wait_timeout (DBusCondVar *cond, DBusCMutex *mutex, int timeout_milliseconds) { - if (cond && mutex && thread_init_generation == _dbus_current_generation) - return _dbus_platform_condvar_wait_timeout (cond, mutex, - timeout_milliseconds); - else + if (cond == NULL || mutex == NULL) return TRUE; + + return _dbus_platform_condvar_wait_timeout (cond, mutex, + timeout_milliseconds); } /** @@ -339,8 +277,10 @@ _dbus_condvar_wait_timeout (DBusCondVar *cond, void _dbus_condvar_wake_one (DBusCondVar *cond) { - if (cond && thread_init_generation == _dbus_current_generation) - _dbus_platform_condvar_wake_one (cond); + if (cond == NULL) + return; + + _dbus_platform_condvar_wake_one (cond); } static DBusRMutex *global_locks[_DBUS_N_GLOBAL_LOCKS] = { NULL }; @@ -358,132 +298,6 @@ shutdown_global_locks (void *nil) } } -static void -shutdown_uninitialized_locks (void *data) -{ - _dbus_list_clear (&uninitialized_rmutex_list); - _dbus_list_clear (&uninitialized_cmutex_list); - _dbus_list_clear (&uninitialized_condvar_list); -} - -/* init_global_locks() must be called first. */ -static dbus_bool_t -init_uninitialized_locks (void) -{ - DBusList *link; - dbus_bool_t ok; - - _dbus_assert (thread_init_generation != _dbus_current_generation); - - link = uninitialized_rmutex_list; - while (link != NULL) - { - DBusRMutex **mp; - - mp = link->data; - _dbus_assert (*mp == _DBUS_DUMMY_RMUTEX); - - *mp = _dbus_platform_rmutex_new (); - if (*mp == NULL) - goto fail_mutex; - - link = _dbus_list_get_next_link (&uninitialized_rmutex_list, link); - } - - link = uninitialized_cmutex_list; - while (link != NULL) - { - DBusCMutex **mp; - - mp = link->data; - _dbus_assert (*mp == _DBUS_DUMMY_CMUTEX); - - *mp = _dbus_platform_cmutex_new (); - if (*mp == NULL) - goto fail_mutex; - - link = _dbus_list_get_next_link (&uninitialized_cmutex_list, link); - } - - link = uninitialized_condvar_list; - while (link != NULL) - { - DBusCondVar **cp; - - cp = (DBusCondVar **)link->data; - _dbus_assert (*cp == _DBUS_DUMMY_CONDVAR); - - *cp = _dbus_platform_condvar_new (); - if (*cp == NULL) - goto fail_condvar; - - link = _dbus_list_get_next_link (&uninitialized_condvar_list, link); - } - - _dbus_list_clear (&uninitialized_rmutex_list); - _dbus_list_clear (&uninitialized_cmutex_list); - _dbus_list_clear (&uninitialized_condvar_list); - - /* This assumes that init_global_locks() has already been called. */ - _dbus_platform_rmutex_lock (global_locks[_DBUS_LOCK_shutdown_funcs]); - ok = _dbus_register_shutdown_func_unlocked (shutdown_uninitialized_locks, NULL); - _dbus_platform_rmutex_unlock (global_locks[_DBUS_LOCK_shutdown_funcs]); - - if (!ok) - goto fail_condvar; - - return TRUE; - - fail_condvar: - link = uninitialized_condvar_list; - while (link != NULL) - { - DBusCondVar **cp; - - cp = link->data; - - if (*cp != _DBUS_DUMMY_CONDVAR && *cp != NULL) - _dbus_platform_condvar_free (*cp); - - *cp = _DBUS_DUMMY_CONDVAR; - - link = _dbus_list_get_next_link (&uninitialized_condvar_list, link); - } - - fail_mutex: - link = uninitialized_rmutex_list; - while (link != NULL) - { - DBusRMutex **mp; - - mp = link->data; - - if (*mp != _DBUS_DUMMY_RMUTEX && *mp != NULL) - _dbus_platform_rmutex_free (*mp); - - *mp = _DBUS_DUMMY_RMUTEX; - - link = _dbus_list_get_next_link (&uninitialized_rmutex_list, link); - } - - link = uninitialized_cmutex_list; - while (link != NULL) - { - DBusCMutex **mp; - - mp = link->data; - - if (*mp != _DBUS_DUMMY_CMUTEX && *mp != NULL) - _dbus_platform_cmutex_free (*mp); - - *mp = _DBUS_DUMMY_CMUTEX; - - link = _dbus_list_get_next_link (&uninitialized_cmutex_list, link); - } - - return FALSE; -} - static dbus_bool_t init_global_locks (void) { @@ -585,9 +399,7 @@ dbus_threads_init (const DBusThreadFunctions *functions) } if (!_dbus_threads_init_platform_specific() || - /* init_global_locks() must be called before init_uninitialized_locks. */ - !init_global_locks () || - !init_uninitialized_locks ()) + !init_global_locks ()) { _dbus_threads_unlock_platform_specific (); return FALSE; -- cgit v1.2.1 From 83aaa9f359e90d3b8cae5d17f6d9ba4600cff68b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 16 Apr 2013 16:48:11 +0100 Subject: Add a statically-initialized implementation of _dbus_lock() on glibc systems Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54972 Signed-off-by: Simon McVittie Reviewed-by: Alban Crequy Reviewed-by: Anas Nashif --- dbus/dbus-sysdeps-pthread.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-threads-internal.h | 6 ++++++ dbus/dbus-threads.c | 14 +++++++++++++ 3 files changed, 67 insertions(+) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 1300ec35..2180c37b 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -300,3 +300,50 @@ _dbus_threads_unlock_platform_specific (void) { pthread_mutex_unlock (&init_mutex); } + +#ifdef DBUS_HAVE_STATIC_RECURSIVE_MUTEXES + +static pthread_mutex_t global_locks[] = { + /* 0-4 */ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + /* 5-9 */ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + /* 10-11 */ + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, + PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP +}; + +_DBUS_STATIC_ASSERT (_DBUS_N_ELEMENTS (global_locks) == _DBUS_N_GLOBAL_LOCKS); + +dbus_bool_t +_dbus_lock (DBusGlobalLock lock) +{ + /* No initialization is needed. */ + _dbus_assert (lock >= 0); + _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); + + PTHREAD_CHECK ("pthread_mutex_lock", + pthread_mutex_lock (&(global_locks[lock]))); + return TRUE; +} + +void +_dbus_unlock (DBusGlobalLock lock) +{ + /* No initialization is needed. */ + _dbus_assert (lock >= 0); + _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); + + PTHREAD_CHECK ("pthread_mutex_unlock", + pthread_mutex_unlock (&(global_locks[lock]))); +} + +#endif diff --git a/dbus/dbus-threads-internal.h b/dbus/dbus-threads-internal.h index 64e8bac0..228a8c05 100644 --- a/dbus/dbus-threads-internal.h +++ b/dbus/dbus-threads-internal.h @@ -32,6 +32,12 @@ * @{ */ +/* glibc can implement global locks without needing an initialization step, + * which improves our thread-safety-by-default further. */ +#if defined(__GLIBC__) && defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) +# define DBUS_HAVE_STATIC_RECURSIVE_MUTEXES 1 +#endif + /** * A mutex which is recursive if possible, else non-recursive. * This is typically recursive, but that cannot be relied upon. diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 29462ebd..1781bdaf 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -283,6 +283,18 @@ _dbus_condvar_wake_one (DBusCondVar *cond) _dbus_platform_condvar_wake_one (cond); } +#ifdef DBUS_HAVE_STATIC_RECURSIVE_MUTEXES + +static dbus_bool_t +init_global_locks (void) +{ + return TRUE; +} + +/* implementations in dbus-sysdeps-pthread.c */ + +#else /* !defined(DBUS_HAVE_STATIC_RECURSIVE_MUTEXES) */ + static DBusRMutex *global_locks[_DBUS_N_GLOBAL_LOCKS] = { NULL }; static void @@ -356,6 +368,8 @@ _dbus_unlock (DBusGlobalLock lock) _dbus_platform_rmutex_unlock (global_locks[lock]); } +#endif /* !defined(DBUS_HAVE_STATIC_RECURSIVE_MUTEXES) */ + /** @} */ /* end of internals */ /** -- cgit v1.2.1 From ab786800d585e028a030109be4d169224ad08c66 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 18 Jun 2013 13:42:34 +0200 Subject: Fixed wrong path for generated xml files when creating man pages with cmake. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=64058 Reviewed-by: Simon McVittie --- cmake/doc/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index dee9431b..ae037561 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -125,11 +125,11 @@ DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml html-nochunks) DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml html-nochunks) if (UNIX) DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml man) endif() # # handle html index file -- cgit v1.2.1 From 9ddf5fb757b47ff093ebf86394ccf9f4ea1d1691 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 18 Jun 2013 14:07:38 +0200 Subject: Fix of cmake xmldoc dependencies chain. This patch fixes an issues that xml documentation is generated on all builds regardless if related files has been changed or not. The patch adds a global xmldoc make target to which all generated html or man files are added as build dependency. Each dependency itself depends on related CMakeLists.txt and the xml file generated from the related xml.in file. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=64058 Reviewed-by: Simon McVittie --- cmake/doc/CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index ae037561..bd1af17d 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -21,6 +21,7 @@ find_program(XMLTO_EXECUTABLE xmlto) if (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) OPTION(DBUS_ENABLE_XML_DOCS "build XML documentation (requires xmlto or meinproc4)" ON) + ADD_CUSTOM_TARGET(xmldoc ALL) endif (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) if (XMLTO_EXECUTABLE) @@ -48,6 +49,7 @@ if (DBUS_ENABLE_XML_DOCS) macro (DOCBOOK _sources _format) get_filename_component(_infile ${_sources} ABSOLUTE) get_filename_component(_name ${_infile} NAME) + set(_deps ${CMAKE_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) if (${_format} STREQUAL "man") string(REPLACE ".xml" "" _outname ${_name}) @@ -60,16 +62,18 @@ macro (DOCBOOK _sources _format) set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname}) if (EXISTS ${_sources}) if (MEINPROC4_EXECUTABLE) - ADD_CUSTOM_TARGET(${_outname} ALL - ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} - DEPENDS ${_infile} + ADD_CUSTOM_COMMAND( + OUTPUT ${_outfile} + COMMAND ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} + DEPENDS ${_infile} ${STYLESHEET} ${_deps} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif () if (XMLTO_EXECUTABLE) - ADD_CUSTOM_TARGET(${_outname} ALL - ${XMLTO_EXECUTABLE} -vv ${_format} ${_infile} - DEPENDS ${_infile} + ADD_CUSTOM_COMMAND( + OUTPUT ${_outfile} + COMMAND ${XMLTO_EXECUTABLE} -vv ${_format} ${_infile} + DEPENDS ${_infile} ${_deps} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif () @@ -81,7 +85,8 @@ macro (DOCBOOK _sources _format) else () MESSAGE(STATUS "skipping xml doc generating for ${_infile}, file not found") endif () - + ADD_CUSTOM_TARGET(${_outname} DEPENDS ${_outfile}) + ADD_DEPENDENCIES(xmldoc ${_outname}) endmacro (DOCBOOK) ### copy tests to builddir so that generated tests and static tests -- cgit v1.2.1 From 7e1820aa89f6242fdf96e96352e4f27cbd8ccf60 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sat, 15 Jun 2013 15:42:19 +0800 Subject: Doc: fix invalid usage of doxygen @param command Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65755 --- dbus/dbus-connection.c | 2 +- dbus/dbus-shell.c | 12 ++++++------ dbus/dbus-sysdeps-unix.c | 2 +- dbus/dbus-sysdeps-util-unix.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 87cfeb03..1bc033e8 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2174,7 +2174,7 @@ _dbus_connection_close_if_only_one_ref (DBusConnection *connection) * relatively long time for memory, if they were only willing to block * briefly then we retry for memory at a rapid rate. * - * @timeout_milliseconds the timeout requested for blocking + * @param timeout_milliseconds the timeout requested for blocking */ static void _dbus_memory_pause_based_on_timeout (int timeout_milliseconds) diff --git a/dbus/dbus-shell.c b/dbus/dbus-shell.c index 111d39df..2384961c 100644 --- a/dbus/dbus-shell.c +++ b/dbus/dbus-shell.c @@ -150,7 +150,7 @@ unquote_string_inplace (char* str, char** end) * through literally instead of being expanded). This function is * guaranteed to succeed if applied to the result of * _dbus_shell_quote(). If it fails, it returns %NULL. - * The @quoted_string need not actually contain quoted or + * The @p quoted_string need not actually contain quoted or * escaped text; _dbus_shell_unquote() simply goes through the string and * unquotes/unescapes anything that the shell would. Both single and * double quotes are handled, as are escapes including escaped @@ -163,7 +163,7 @@ unquote_string_inplace (char* str, char** end) * be escaped with backslash. Otherwise double quotes preserve things * literally. * - * @quoted_string: shell-quoted string + * @param quoted_string shell-quoted string **/ char* _dbus_shell_unquote (const char *quoted_string) @@ -544,10 +544,10 @@ tokenize_command_line (const char *command_line, DBusError *error) * does contain such expansions, they are passed through * literally. Free the returned vector with dbus_free_string_array(). * - * @command_line: command line to parse - * @argcp: return location for number of args - * @argvp: return location for array of args - * @error: error information + * @param command_line command line to parse + * @param argcp return location for number of args + * @param argvp return location for array of args + * @param error error information **/ dbus_bool_t _dbus_shell_parse_argv (const char *command_line, diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 07b761b4..4a586c72 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1153,7 +1153,7 @@ _dbus_listen_unix_socket (const char *path, * * This will set FD_CLOEXEC for the sockets returned. * - * @oaram fds the file descriptors + * @param fds the file descriptors * @param error return location for errors * @returns the number of file descriptors */ diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 6265e2b5..6053265b 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -381,13 +381,13 @@ _dbus_change_to_daemon_user (const char *user, /** * Attempt to ensure that the current process can open - * at least @limit file descriptors. + * at least @p limit file descriptors. * - * If @limit is lower than the current, it will not be + * If @p limit is lower than the current, it will not be * lowered. No error is returned if the request can * not be satisfied. * - * @limit Number of file descriptors + * @param limit number of file descriptors */ void _dbus_request_file_descriptor_limit (unsigned int limit) -- cgit v1.2.1 From 8eb29fda102be3bd27b04a0b2d7f53a4dfb01f62 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 20 Jun 2013 17:24:04 +0800 Subject: DBusString: fix may crash if try to free an uninitialized str If the str will be freed hasn't been initialized by _dbus_string_init correctly, _dbus_string_free may crash due to trying to free an undefined memory. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65959 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- dbus/dbus-string.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index e3766aad..52eb0f23 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -246,6 +246,14 @@ _dbus_string_free (DBusString *str) if (real->constant) return; + + /* so it's safe if @p str returned by a failed + * _dbus_string_init call + * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65959 + */ + if (real->str == NULL) + return; + dbus_free (real->str - real->align_offset); real->invalid = TRUE; -- cgit v1.2.1 From 931c9663b714d1db0e0dfcf13034e0b83450f3cf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 20 Jun 2013 13:20:08 +0100 Subject: NEWS for #65959 --- NEWS | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 4fec6324..96d4b0c2 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,10 @@ D-Bus 1.6.14 (UNRELEASED) == -... +Fixes: + +• If malloc() returns NULL in _dbus_string_init() or similar, don't free + an invalid pointer if the string is later freed (fd.o #65959, Chengwei Yang) D-Bus 1.6.12 (2013-06-13) == -- cgit v1.2.1 From dd2ca80e3fb0413090136443aa79fe1dba4e6b19 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 19 Jun 2013 16:35:43 +0800 Subject: dbus-send: Fix fail to run without "--dest" option Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65923 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- tools/dbus-send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dbus-send.c b/tools/dbus-send.c index ca5dd5c6..2e37b089 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -348,7 +348,7 @@ main (int argc, char *argv[]) dbus_error_init (&error); - if (!dbus_validate_bus_name (dest, &error)) + if (dest && !dbus_validate_bus_name (dest, &error)) { fprintf (stderr, "invalid value (%s) of \"--dest\"\n", dest); usage (1); -- cgit v1.2.1 From 8b774c5f3baa82da1122a9280fef63083cf85607 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 20 Jun 2013 13:32:20 +0100 Subject: NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 3fe6c0e4..42081d56 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ D-Bus 1.7.6 (UNRELEASED) Fixes: +• Don't crash on "dbus-send --session / x.y.z" which regressed in 1.7.4. + (fd.o #65923, Chengwei Yang) + • If malloc() returns NULL in _dbus_string_init() or similar, don't free an invalid pointer if the string is later freed (fd.o #65959, Chengwei Yang) -- cgit v1.2.1 From 3a43d4aef2ddb2d5cdfb5c411b01840289203d49 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 2 Apr 2013 16:20:45 -0400 Subject: connection: Add incoming message serials to verbose mode logging This helps pair up messages with verbose mode output from the other side of a connection. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=63047 Reviewed-by: Simon McVittie --- dbus/dbus-connection.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 1bc033e8..5c732e23 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -3962,7 +3962,7 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) link = _dbus_list_pop_first_link (&connection->incoming_messages); connection->n_incoming -= 1; - _dbus_verbose ("Message %p (%s %s %s %s '%s') removed from incoming queue %p, %d incoming\n", + _dbus_verbose ("Message %p (%s %s %s %s sig:'%s' serial:%u) removed from incoming queue %p, %d incoming\n", link->data, dbus_message_type_to_string (dbus_message_get_type (link->data)), dbus_message_get_path (link->data) ? @@ -3975,6 +3975,7 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) dbus_message_get_member (link->data) : "no member", dbus_message_get_signature (link->data), + dbus_message_get_serial (link->data), connection, connection->n_incoming); _dbus_message_trace_ref (link->data, -1, -1, -- cgit v1.2.1 From 46cc82e1bbb84e6f9a1dde962c57079f39eca079 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 23 Jan 2013 13:14:17 +0100 Subject: Let dbus-daemon not print unavailable options on windows. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=42441 Reviewed-by: Simon McVittie --- bus/main.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/bus/main.c b/bus/main.c index 970c1def..e53e5f89 100644 --- a/bus/main.c +++ b/bus/main.c @@ -131,7 +131,23 @@ signal_handler (int sig) static void usage (void) { - fprintf (stderr, DBUS_DAEMON_NAME " [--version] [--session] [--system] [--config-file=FILE] [--print-address[=DESCRIPTOR]] [--print-pid[=DESCRIPTOR]] [--fork] [--nofork] [--introspect] [--address=ADDRESS] [--systemd-activation] [--nopidfile]\n"); + fprintf (stderr, + DBUS_DAEMON_NAME + " [--version]" + " [--session]" + " [--system]" + " [--config-file=FILE]" + " [--print-address[=DESCRIPTOR]]" + " [--print-pid[=DESCRIPTOR]]" + " [--introspect]" + " [--address=ADDRESS]" + " [--nopidfile]" +#ifdef DBUS_UNIX + " [--fork]" + " [--nofork]" + " [--systemd-activation]" +#endif + "\n"); exit (1); } @@ -400,6 +416,7 @@ main (int argc, char **argv) { introspect (); } +#ifdef DBUS_UNIX else if (strcmp (arg, "--nofork") == 0) { flags &= ~BUS_CONTEXT_FLAG_FORK_ALWAYS; @@ -410,14 +427,15 @@ main (int argc, char **argv) flags &= ~BUS_CONTEXT_FLAG_FORK_NEVER; flags |= BUS_CONTEXT_FLAG_FORK_ALWAYS; } - else if (strcmp (arg, "--nopidfile") == 0) - { - flags &= ~BUS_CONTEXT_FLAG_WRITE_PID_FILE; - } else if (strcmp (arg, "--systemd-activation") == 0) { flags |= BUS_CONTEXT_FLAG_SYSTEMD_ACTIVATION; } +#endif + else if (strcmp (arg, "--nopidfile") == 0) + { + flags &= ~BUS_CONTEXT_FLAG_WRITE_PID_FILE; + } else if (strcmp (arg, "--system") == 0) { check_two_config_files (&config_file, "system"); -- cgit v1.2.1 From e1837696ef1143f6728189e89e0d2cecf3addb7a Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Mon, 24 Jun 2013 16:00:29 +0800 Subject: DBus Specification: remove incorrect table description I doubt this line was copied by mistake from section "Summary of types". Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66115 --- doc/dbus-specification.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index a6bedfae..324dfd43 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -4416,8 +4416,7 @@ The following table describes the keys that can be used to create - a match rule: - The following table summarizes the D-Bus types. + a match rule. -- cgit v1.2.1 From db80dcb6cb981f984c2b4dee0944a7906332cf0b Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 21 Jun 2013 17:13:06 +0800 Subject: Fix build failure if build with "--enable-stats" Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66004 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- bus/stats.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bus/stats.c b/bus/stats.c index 45531910..78f27e9a 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -203,8 +203,9 @@ bus_stats_handle_get_stats (DBusConnection *connection, if (!asv_add_uint32 (&iter, &arr_iter, "Serial", stats_serial++)) goto oom; - if (!_dbus_list_get_stats (&in_use, &in_free_list, &allocated) || - !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolUsedBytes", in_use) || + _dbus_list_get_stats (&in_use, &in_free_list, &allocated); + + if (!asv_add_uint32 (&iter, &arr_iter, "ListMemPoolUsedBytes", in_use) || !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolCachedBytes", in_free_list) || !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolAllocatedBytes", -- cgit v1.2.1 From 147a65270d1b7fce7a24e5565c6791975b51256d Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 20 Jun 2013 16:46:15 +0200 Subject: Use Doxyfile.in for cmake build system too. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=64875 Reviewed-by: Simon McVittie --- cmake/Doxyfile.cmake | 181 ----------------------------------------------- cmake/doc/CMakeLists.txt | 3 +- 2 files changed, 2 insertions(+), 182 deletions(-) delete mode 100644 cmake/Doxyfile.cmake diff --git a/cmake/Doxyfile.cmake b/cmake/Doxyfile.cmake deleted file mode 100644 index 3c63d95a..00000000 --- a/cmake/Doxyfile.cmake +++ /dev/null @@ -1,181 +0,0 @@ -# Doxyfile 0.1 - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = D-Bus -PROJECT_NUMBER = @VERSION@ -OUTPUT_DIRECTORY = api -OUTPUT_LANGUAGE = English -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = NO -STRIP_CODE_COMMENTS = YES -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -VERBATIM_HEADERS = YES -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = YES -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -ALIASES = -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = YES -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = YES -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_FORMAT = -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = @top_srcdir@/dbus -FILE_PATTERNS = *.c *.h -RECURSIVE = YES -#EXCLUDE = test - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = Makefile.* ChangeLog CHANGES CHANGES.* README \ - README.* *.png AUTHORS DESIGN DESIGN.* *.desktop \ - DESKTOP* COMMENTS HOWTO magic NOTES TODO THANKS - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = YES -MAN_OUTPUT = man -MAN_EXTENSION = .3dbus -MAN_LINKS = YES -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = "DBUS_BEGIN_DECLS=" \ - "DBUS_END_DECLS=" \ - "DOXYGEN_SHOULD_SKIP_THIS" \ - "DBUS_GNUC_DEPRECATED=" \ - "_DBUS_GNUC_PRINTF(from,to)=" \ - "DBUS_EXPORT=" -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -PERL_PATH = -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HAVE_DOT = NO -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -TEMPLATE_RELATIONS = YES -HIDE_UNDOC_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 640 -MAX_DOT_GRAPH_HEIGHT = 1024 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index bd1af17d..7fdfc219 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -6,9 +6,10 @@ endif(DOXYGEN_EXECUTABLE) if (DBUS_ENABLE_DOXYGEN_DOCS) set (top_srcdir ${CMAKE_SOURCE_DIR}/..) - configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_BINARY_DIR}/Doxyfile ) + configure_file(${CMAKE_SOURCE_DIR}/../Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile ) add_custom_target(doc COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) endif (DBUS_ENABLE_DOXYGEN_DOCS) -- cgit v1.2.1 From 2e5eb7d82f72fcb9044ecf57fa769343d86fdfa5 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 25 Jun 2013 15:37:27 +0800 Subject: cmake: fix a typo DBUS_DISABLE_ASSERTS should be DBUS_DISABLE_ASSERT Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66142 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- README.cmake | 2 +- cmake/CMakeLists.txt | 16 ++++++++-------- cmake/config.h.cmake | 2 +- dbus/dbus-sysdeps-win.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.cmake b/README.cmake index 9415a82d..376dac05 100644 --- a/README.cmake +++ b/README.cmake @@ -103,7 +103,7 @@ DBUS_BUILD_TESTS:BOOL=ON DBUS_DAEMON_NAME:STRING=dbus-daemon // Disable assertion checking -DBUS_DISABLE_ASSERTS:BOOL=OFF +DBUS_DISABLE_ASSERT:BOOL=OFF // Disable public API sanity checking DBUS_DISABLE_CHECKS:BOOL=OFF diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ed1df562..9e8bade5 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -96,7 +96,7 @@ if(NOT WIN32) endif(NOT WIN32) #AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) -option (DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF) +option (DBUS_DISABLE_ASSERT "Disable assertion checking" OFF) option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) @@ -161,12 +161,12 @@ if(WIN32) endif(MSVC) endif(WIN32) -if (UNIX AND NOT DBUS_DISABLE_ASSERTS) +if (UNIX AND NOT DBUS_DISABLE_ASSERT) # required for backtrace SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wl,--export-dynamic") SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wl,--export-dynamic") add_definitions(-DDBUS_BUILT_R_DYNAMIC) -endif (UNIX AND NOT DBUS_DISABLE_ASSERTS) +endif (UNIX AND NOT DBUS_DISABLE_ASSERT) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") @@ -559,7 +559,7 @@ message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} " message(" gcc coverage profiling: ${DBUS_GCOV_ENABLED} ") message(" Building unit tests: ${DBUS_BUILD_TESTS} ") message(" Building verbose mode: ${DBUS_ENABLE_VERBOSE_MODE} ") -message(" Building w/o assertions: ${DBUS_DISABLE_ASSERTS} ") +message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ") message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ") message(" Building bus stats API: ${DBUS_ENABLE_STATS} ") message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} ") @@ -595,9 +595,9 @@ if (DBUS_BUILD_TESTS) message("NOTE: building with unit tests increases the size of the installed library and renders it insecure.") endif(DBUS_BUILD_TESTS) -if (DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERTS) +if (DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERT) message("NOTE: building with unit tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)") -endif(DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERTS) +endif(DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERT) if (DBUS_GCOV_ENABLED) message("NOTE: building with coverage profiling is definitely for developers only.") @@ -607,9 +607,9 @@ if (DBUS_ENABLE_VERBOSE_MODE) message("NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance.") endif(DBUS_ENABLE_VERBOSE_MODE) -if(NOT DBUS_DISABLE_ASSERTS) +if(NOT DBUS_DISABLE_ASSERT) message("NOTE: building with assertions increases library size and decreases performance.") -endif(NOT DBUS_DISABLE_ASSERTS) +endif(NOT DBUS_DISABLE_ASSERT) if (DBUS_DISABLE_CHECKS) message("NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-BUS, but will slightly decrease D-BUS library size and _very_ slightly improve performance.") diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 91cf0806..f3829cc3 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -42,7 +42,7 @@ #cmakedefine DBUS_BUILD_TESTS 1 #cmakedefine DBUS_ENABLE_ANSI 1 #cmakedefine DBUS_ENABLE_VERBOSE_MODE 1 -#cmakedefine DBUS_DISABLE_ASSERTS 1 +#cmakedefine DBUS_DISABLE_ASSERT 1 #cmakedefine DBUS_DISABLE_CHECKS 1 /* xmldocs */ /* doxygen */ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 72ccb93d..6621af74 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2221,7 +2221,7 @@ _dbus_replace_install_prefix (const char *configure_time_path) #endif } -#if !defined (DBUS_DISABLE_ASSERTS) || defined(DBUS_BUILD_TESTS) +#if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_BUILD_TESTS) #if defined(_MSC_VER) || defined(DBUS_WINCE) # ifdef BACKTRACES -- cgit v1.2.1 From 75d4041a3ded9ca4a7fd9a1daa80ba99cecf26df Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 25 Jun 2013 12:16:54 +0100 Subject: NEWS, noting build-time configuration change --- NEWS | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/NEWS b/NEWS index 42081d56..230e589f 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,12 @@ D-Bus 1.7.6 (UNRELEASED) == +Build-time configuration changes: + +• The DBUS_DISABLE_ASSERTS CMake option didn't actually disable most + assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent + with the Autotools build system. (fd.o #66142, Chengwei Yang) + Fixes: • Don't crash on "dbus-send --session / x.y.z" which regressed in 1.7.4. @@ -9,6 +15,10 @@ Fixes: • If malloc() returns NULL in _dbus_string_init() or similar, don't free an invalid pointer if the string is later freed (fd.o #65959, Chengwei Yang) +• Windows-specific: + · Remove unavailable command-line options from 'dbus-daemon --help' + (fd.o #42441, Ralf Habacker) + D-Bus 1.7.4 (2013-06-13) == -- cgit v1.2.1 From a9e1c1c36b527e976cadcb39c2245b6f768c555e Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 25 Jun 2013 13:45:35 +0800 Subject: cmake: remove a duplicate line and fix coding style Signed-off-by: Chengwei Yang Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66142 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9e8bade5..836f4b23 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -64,7 +64,7 @@ set(EXPANDED_SYSCONFDIR ${DBUS_INSTALL_DIR}/etc) set(EXPANDED_DATADIR ${DBUS_INSTALL_DIR}/${DBUS_DATADIR}) set(DBUS_MACHINE_UUID_FILE ${DBUS_INSTALL_DIR}/lib/dbus/machine-id) set(DBUS_BINDIR ${EXPANDED_BINDIR}) -set(DBUS_DAEMONDIR ${EXPANDED_BINDIR}) +set(DBUS_DAEMONDIR ${EXPANDED_BINDIR}) #enable building of shared library @@ -100,8 +100,6 @@ option (DBUS_DISABLE_ASSERT "Disable assertion checking" OFF) option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) -option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) - find_package(EXPAT) find_package(X11) -- cgit v1.2.1 From 7038cdc249a96e9f8ada207105ff72ba63c1dfa4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 24 Jun 2013 13:41:33 +0100 Subject: Convert a{sv} helpers from Stats into generic utility code Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445 Reviewed-by: Ralf Habacker --- bus/stats.c | 239 ++++++++++-------------------------------- cmake/dbus/CMakeLists.txt | 2 + dbus/Makefile.am | 2 + dbus/dbus-asv-util.c | 260 ++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-asv-util.h | 46 ++++++++ 5 files changed, 362 insertions(+), 187 deletions(-) create mode 100644 dbus/dbus-asv-util.c create mode 100644 dbus/dbus-asv-util.h diff --git a/bus/stats.c b/bus/stats.c index 78f27e9a..0c71a549 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -1,4 +1,7 @@ /* stats.c - statistics from the bus driver + * + * Copyright © 2011-2012 Nokia Corporation + * Copyright © 2012-2013 Collabora Ltd. * * Licensed under the Academic Free License version 2.1 * @@ -21,6 +24,7 @@ #include #include "stats.h" +#include #include #include @@ -30,153 +34,6 @@ #ifdef DBUS_ENABLE_STATS -static DBusMessage * -new_asv_reply (DBusMessage *message, - DBusMessageIter *iter, - DBusMessageIter *arr_iter) -{ - DBusMessage *reply = dbus_message_new_method_return (message); - - if (reply == NULL) - return NULL; - - dbus_message_iter_init_append (reply, iter); - - if (!dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, "{sv}", - arr_iter)) - { - dbus_message_unref (reply); - return NULL; - } - - return reply; -} - -static dbus_bool_t -open_asv_entry (DBusMessageIter *arr_iter, - DBusMessageIter *entry_iter, - const char *key, - const char *type, - DBusMessageIter *var_iter) -{ - if (!dbus_message_iter_open_container (arr_iter, DBUS_TYPE_DICT_ENTRY, - NULL, entry_iter)) - return FALSE; - - if (!dbus_message_iter_append_basic (entry_iter, DBUS_TYPE_STRING, &key)) - { - dbus_message_iter_abandon_container (arr_iter, entry_iter); - return FALSE; - } - - if (!dbus_message_iter_open_container (entry_iter, DBUS_TYPE_VARIANT, - type, var_iter)) - { - dbus_message_iter_abandon_container (arr_iter, entry_iter); - return FALSE; - } - - return TRUE; -} - -static dbus_bool_t -close_asv_entry (DBusMessageIter *arr_iter, - DBusMessageIter *entry_iter, - DBusMessageIter *var_iter) -{ - if (!dbus_message_iter_close_container (entry_iter, var_iter)) - { - dbus_message_iter_abandon_container (arr_iter, entry_iter); - return FALSE; - } - - if (!dbus_message_iter_close_container (arr_iter, entry_iter)) - return FALSE; - - return TRUE; -} - -static dbus_bool_t -close_asv_reply (DBusMessageIter *iter, - DBusMessageIter *arr_iter) -{ - return dbus_message_iter_close_container (iter, arr_iter); -} - -static void -abandon_asv_entry (DBusMessageIter *arr_iter, - DBusMessageIter *entry_iter, - DBusMessageIter *var_iter) -{ - dbus_message_iter_abandon_container (entry_iter, var_iter); - dbus_message_iter_abandon_container (arr_iter, entry_iter); -} - -static void -abandon_asv_reply (DBusMessageIter *iter, - DBusMessageIter *arr_iter) -{ - dbus_message_iter_abandon_container (iter, arr_iter); -} - -static dbus_bool_t -asv_add_uint32 (DBusMessageIter *iter, - DBusMessageIter *arr_iter, - const char *key, - dbus_uint32_t value) -{ - DBusMessageIter entry_iter, var_iter; - - if (!open_asv_entry (arr_iter, &entry_iter, key, DBUS_TYPE_UINT32_AS_STRING, - &var_iter)) - goto oom; - - if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_UINT32, - &value)) - { - abandon_asv_entry (arr_iter, &entry_iter, &var_iter); - goto oom; - } - - if (!close_asv_entry (arr_iter, &entry_iter, &var_iter)) - goto oom; - - return TRUE; - -oom: - abandon_asv_reply (iter, arr_iter); - return FALSE; -} - -static dbus_bool_t -asv_add_string (DBusMessageIter *iter, - DBusMessageIter *arr_iter, - const char *key, - const char *value) -{ - DBusMessageIter entry_iter, var_iter; - - if (!open_asv_entry (arr_iter, &entry_iter, key, DBUS_TYPE_STRING_AS_STRING, - &var_iter)) - goto oom; - - if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_STRING, - &value)) - { - abandon_asv_entry (arr_iter, &entry_iter, &var_iter); - goto oom; - } - - if (!close_asv_entry (arr_iter, &entry_iter, &var_iter)) - goto oom; - - return TRUE; - -oom: - abandon_asv_reply (iter, arr_iter); - return FALSE; -} - dbus_bool_t bus_stats_handle_get_stats (DBusConnection *connection, BusTransaction *transaction, @@ -193,48 +50,50 @@ bus_stats_handle_get_stats (DBusConnection *connection, connections = bus_transaction_get_connections (transaction); - reply = new_asv_reply (message, &iter, &arr_iter); + reply = _dbus_asv_new_method_return (message, &iter, &arr_iter); if (reply == NULL) goto oom; /* Globals */ - if (!asv_add_uint32 (&iter, &arr_iter, "Serial", stats_serial++)) - goto oom; - _dbus_list_get_stats (&in_use, &in_free_list, &allocated); - if (!asv_add_uint32 (&iter, &arr_iter, "ListMemPoolUsedBytes", in_use) || - !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolCachedBytes", - in_free_list) || - !asv_add_uint32 (&iter, &arr_iter, "ListMemPoolAllocatedBytes", - allocated)) - goto oom; + if (!_dbus_asv_add_uint32 (&arr_iter, "Serial", stats_serial++) || + !_dbus_asv_add_uint32 (&arr_iter, "ListMemPoolUsedBytes", in_use) || + !_dbus_asv_add_uint32 (&arr_iter, "ListMemPoolCachedBytes", in_free_list) || + !_dbus_asv_add_uint32 (&arr_iter, "ListMemPoolAllocatedBytes", allocated)) + { + _dbus_asv_abandon (&iter, &arr_iter); + goto oom; + } /* Connections */ - if (!asv_add_uint32 (&iter, &arr_iter, "ActiveConnections", + if (!_dbus_asv_add_uint32 (&arr_iter, "ActiveConnections", bus_connections_get_n_active (connections)) || - !asv_add_uint32 (&iter, &arr_iter, "IncompleteConnections", + !_dbus_asv_add_uint32 (&arr_iter, "IncompleteConnections", bus_connections_get_n_incomplete (connections)) || - !asv_add_uint32 (&iter, &arr_iter, "MatchRules", + !_dbus_asv_add_uint32 (&arr_iter, "MatchRules", bus_connections_get_total_match_rules (connections)) || - !asv_add_uint32 (&iter, &arr_iter, "PeakMatchRules", + !_dbus_asv_add_uint32 (&arr_iter, "PeakMatchRules", bus_connections_get_peak_match_rules (connections)) || - !asv_add_uint32 (&iter, &arr_iter, "PeakMatchRulesPerConnection", + !_dbus_asv_add_uint32 (&arr_iter, "PeakMatchRulesPerConnection", bus_connections_get_peak_match_rules_per_conn (connections)) || - !asv_add_uint32 (&iter, &arr_iter, "BusNames", + !_dbus_asv_add_uint32 (&arr_iter, "BusNames", bus_connections_get_total_bus_names (connections)) || - !asv_add_uint32 (&iter, &arr_iter, "PeakBusNames", + !_dbus_asv_add_uint32 (&arr_iter, "PeakBusNames", bus_connections_get_peak_bus_names (connections)) || - !asv_add_uint32 (&iter, &arr_iter, "PeakBusNamesPerConnection", + !_dbus_asv_add_uint32 (&arr_iter, "PeakBusNamesPerConnection", bus_connections_get_peak_bus_names_per_conn (connections))) - goto oom; + { + _dbus_asv_abandon (&iter, &arr_iter); + goto oom; + } /* end */ - if (!close_asv_reply (&iter, &arr_iter)) + if (!_dbus_asv_close (&iter, &arr_iter)) goto oom; if (!bus_transaction_send_from_driver (transaction, connection, reply)) @@ -290,25 +149,28 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, stats_connection = bus_service_get_primary_owners_connection (service); _dbus_assert (stats_connection != NULL); - reply = new_asv_reply (message, &iter, &arr_iter); + reply = _dbus_asv_new_method_return (message, &iter, &arr_iter); if (reply == NULL) goto oom; /* Bus daemon per-connection stats */ - if (!asv_add_uint32 (&iter, &arr_iter, "Serial", stats_serial++) || - !asv_add_uint32 (&iter, &arr_iter, "MatchRules", + if (!_dbus_asv_add_uint32 (&arr_iter, "Serial", stats_serial++) || + !_dbus_asv_add_uint32 (&arr_iter, "MatchRules", bus_connection_get_n_match_rules (stats_connection)) || - !asv_add_uint32 (&iter, &arr_iter, "PeakMatchRules", + !_dbus_asv_add_uint32 (&arr_iter, "PeakMatchRules", bus_connection_get_peak_match_rules (stats_connection)) || - !asv_add_uint32 (&iter, &arr_iter, "BusNames", + !_dbus_asv_add_uint32 (&arr_iter, "BusNames", bus_connection_get_n_services_owned (stats_connection)) || - !asv_add_uint32 (&iter, &arr_iter, "PeakBusNames", + !_dbus_asv_add_uint32 (&arr_iter, "PeakBusNames", bus_connection_get_peak_bus_names (stats_connection)) || - !asv_add_string (&iter, &arr_iter, "UniqueName", + !_dbus_asv_add_uint32 (&arr_iter, "UniqueName", bus_connection_get_name (stats_connection))) - goto oom; + { + _dbus_asv_abandon (&iter, &arr_iter); + goto oom; + } /* DBusConnection per-connection stats */ @@ -318,21 +180,24 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, &out_messages, &out_bytes, &out_fds, &out_peak_bytes, &out_peak_fds); - if (!asv_add_uint32 (&iter, &arr_iter, "IncomingMessages", in_messages) || - !asv_add_uint32 (&iter, &arr_iter, "IncomingBytes", in_bytes) || - !asv_add_uint32 (&iter, &arr_iter, "IncomingFDs", in_fds) || - !asv_add_uint32 (&iter, &arr_iter, "PeakIncomingBytes", in_peak_bytes) || - !asv_add_uint32 (&iter, &arr_iter, "PeakIncomingFDs", in_peak_fds) || - !asv_add_uint32 (&iter, &arr_iter, "OutgoingMessages", out_messages) || - !asv_add_uint32 (&iter, &arr_iter, "OutgoingBytes", out_bytes) || - !asv_add_uint32 (&iter, &arr_iter, "OutgoingFDs", out_fds) || - !asv_add_uint32 (&iter, &arr_iter, "PeakOutgoingBytes", out_peak_bytes) || - !asv_add_uint32 (&iter, &arr_iter, "PeakOutgoingFDs", out_peak_fds)) - goto oom; + if (!_dbus_asv_add_uint32 (&arr_iter, "IncomingMessages", in_messages) || + !_dbus_asv_add_uint32 (&arr_iter, "IncomingBytes", in_bytes) || + !_dbus_asv_add_uint32 (&arr_iter, "IncomingFDs", in_fds) || + !_dbus_asv_add_uint32 (&arr_iter, "PeakIncomingBytes", in_peak_bytes) || + !_dbus_asv_add_uint32 (&arr_iter, "PeakIncomingFDs", in_peak_fds) || + !_dbus_asv_add_uint32 (&arr_iter, "OutgoingMessages", out_messages) || + !_dbus_asv_add_uint32 (&arr_iter, "OutgoingBytes", out_bytes) || + !_dbus_asv_add_uint32 (&arr_iter, "OutgoingFDs", out_fds) || + !_dbus_asv_add_uint32 (&arr_iter, "PeakOutgoingBytes", out_peak_bytes) || + !_dbus_asv_add_uint32 (&arr_iter, "PeakOutgoingFDs", out_peak_fds)) + { + _dbus_asv_abandon (&iter, &arr_iter); + goto oom; + } /* end */ - if (!close_asv_reply (&iter, &arr_iter)) + if (!_dbus_asv_close (&iter, &arr_iter)) goto oom; if (!bus_transaction_send_from_driver (transaction, caller_connection, diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 6b2d0635..1d04d46e 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -149,6 +149,7 @@ set (DBUS_SHARED_HEADERS ### should be underscore-prefixed but don't really need ### to be unless they move to DBUS_SHARED_SOURCES later) set (DBUS_UTIL_SOURCES + ${DBUS_DIR}/dbus-asv-util.c ${DBUS_DIR}/dbus-auth-script.c ${DBUS_DIR}/dbus-auth-util.c ${DBUS_DIR}/dbus-credentials-util.c @@ -173,6 +174,7 @@ if (DBUS_BUILD_TESTS) endif (DBUS_BUILD_TESTS) set (DBUS_UTIL_HEADERS + ${DBUS_DIR}/dbus-asv-util.h ${DBUS_DIR}/dbus-auth-script.h ${DBUS_DIR}/dbus-mainloop.h ${DBUS_DIR}/dbus-message-factory.h diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 90c2c901..9628c834 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -237,6 +237,8 @@ DBUS_SHARED_SOURCES= \ ### should be underscore-prefixed but don't really need ### to be unless they move to DBUS_SHARED_SOURCES later) DBUS_UTIL_SOURCES= \ + dbus-asv-util.c \ + dbus-asv-util.h \ dbus-auth-script.c \ dbus-auth-script.h \ dbus-auth-util.c \ diff --git a/dbus/dbus-asv-util.c b/dbus/dbus-asv-util.c new file mode 100644 index 00000000..583e41fa --- /dev/null +++ b/dbus/dbus-asv-util.c @@ -0,0 +1,260 @@ +/* dbus-asv-util.c - utility functions for a{sv} + * + * Copyright © 2011-2012 Nokia Corporation + * Copyright © 2012-2013 Collabora Ltd. + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include + +#include + +#include "dbus/dbus-asv-util.h" + +/** + * Convenience function to create a method-call reply whose type is a{sv} + * (map from string to variant). + * + * Append values with 0 or more sequences of _dbus_asv_open_entry(), + * appending a value to var_iter, and _dbus_asv_close_entry(), + * then close the a{sv} with _dbus_asv_close() or _dbus_asv_abandon(). + * + * This must be paired with a call to _dbus_asv_close() or _dbus_asv_abandon(). + * + * @param message a method call message + * @param iter an iterator which will be initialized to append to the message + * @param arr_iter an iterator which will be initialized to append to the array + * @returns a new message, or #NULL if not enough memory + */ +DBusMessage * +_dbus_asv_new_method_return (DBusMessage *message, + DBusMessageIter *iter, + DBusMessageIter *arr_iter) +{ + DBusMessage *reply = dbus_message_new_method_return (message); + + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append (reply, iter); + + if (!dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, "{sv}", + arr_iter)) + { + dbus_message_unref (reply); + return NULL; + } + + return reply; +} + +/* + * Open a new entry in an a{sv} (map from string to variant). + * + * This must be paired with a call to either _dbus_asv_close_entry() + * or _dbus_asv_abandon_entry(). + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param entry_iter will be initialized to append to the dict-entry + * @param key a UTF-8 key for the map + * @param type the type of the variant value, e.g. DBUS_TYPE_STRING_AS_STRING + * @param var_iter will be initialized to append (i.e. write) to the variant + * @returns #TRUE on success, or #FALSE if not enough memory + */ +static dbus_bool_t +_dbus_asv_open_entry (DBusMessageIter *arr_iter, + DBusMessageIter *entry_iter, + const char *key, + const char *type, + DBusMessageIter *var_iter) +{ + if (!dbus_message_iter_open_container (arr_iter, DBUS_TYPE_DICT_ENTRY, + NULL, entry_iter)) + return FALSE; + + if (!dbus_message_iter_append_basic (entry_iter, DBUS_TYPE_STRING, &key)) + { + dbus_message_iter_abandon_container (arr_iter, entry_iter); + return FALSE; + } + + if (!dbus_message_iter_open_container (entry_iter, DBUS_TYPE_VARIANT, + type, var_iter)) + { + dbus_message_iter_abandon_container (arr_iter, entry_iter); + return FALSE; + } + + return TRUE; +} + +/* + * Closes an a{sv} entry after successfully appending the value. + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param entry_iter the iterator appending to the dict-entry, will be closed + * @param var_iter the iterator appending to the variant, will be closed + * @returns #TRUE on success, or #FALSE if not enough memory + */ +static dbus_bool_t +_dbus_asv_close_entry (DBusMessageIter *arr_iter, + DBusMessageIter *entry_iter, + DBusMessageIter *var_iter) +{ + if (!dbus_message_iter_close_container (entry_iter, var_iter)) + { + dbus_message_iter_abandon_container (arr_iter, entry_iter); + return FALSE; + } + + if (!dbus_message_iter_close_container (arr_iter, entry_iter)) + return FALSE; + + return TRUE; +} + +/** + * Closes an a{sv} after successfully appending all values. + * + * If this function fails, you must abandon iter and whatever + * larger data structure (message, etc.) the a{sv} was embedded in. + * + * @param iter the iterator which is appending to the message or other data structure containing the a{sv} + * @param arr_iter the iterator appending to the array, will be closed + * @returns #TRUE on success, or #FALSE if not enough memory + */ +dbus_bool_t +_dbus_asv_close (DBusMessageIter *iter, + DBusMessageIter *arr_iter) +{ + return dbus_message_iter_close_container (iter, arr_iter); +} + +/* + * Closes an a{sv} entry after unsuccessfully appending a value. + * You must also abandon the a{sv} itself (for instance with + * _dbus_asv_abandon()), and abandon whatever larger data structure + * the a{sv} was embedded in. + * + * @param iter the iterator which is appending to the message or other data structure containing the a{sv} + * @param arr_iter the iterator appending to the array, will be closed + * @returns #TRUE on success, or #FALSE if not enough memory + */ +static void +_dbus_asv_abandon_entry (DBusMessageIter *arr_iter, + DBusMessageIter *entry_iter, + DBusMessageIter *var_iter) +{ + dbus_message_iter_abandon_container (entry_iter, var_iter); + dbus_message_iter_abandon_container (arr_iter, entry_iter); +} + +/** + * Closes an a{sv} after unsuccessfully appending a value. + * + * You must also abandon whatever larger data structure (message, etc.) + * the a{sv} was embedded in. + * + * @param iter the iterator which is appending to the message or other data structure containing the a{sv} + * @param arr_iter the iterator appending to the array, will be closed + */ +void +_dbus_asv_abandon (DBusMessageIter *iter, + DBusMessageIter *arr_iter) +{ + dbus_message_iter_abandon_container (iter, arr_iter); +} + +/** + * Create a new entry in an a{sv} (map from string to variant) + * with a 32-bit unsigned integer value. + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param key a UTF-8 key for the map + * @param value the value + * @returns #TRUE on success, or #FALSE if not enough memory + */ +dbus_bool_t +_dbus_asv_add_uint32 (DBusMessageIter *arr_iter, + const char *key, + dbus_uint32_t value) +{ + DBusMessageIter entry_iter, var_iter; + + if (!_dbus_asv_open_entry (arr_iter, &entry_iter, key, + DBUS_TYPE_UINT32_AS_STRING, &var_iter)) + return FALSE; + + if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_UINT32, + &value)) + { + _dbus_asv_abandon_entry (arr_iter, &entry_iter, &var_iter); + return FALSE; + } + + if (!_dbus_asv_close_entry (arr_iter, &entry_iter, &var_iter)) + return FALSE; + + return TRUE; +} + +/** + * Create a new entry in an a{sv} (map from string to variant) + * with a UTF-8 string value. + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param key a UTF-8 key for the map + * @param value the value + * @returns #TRUE on success, or #FALSE if not enough memory + */ +dbus_bool_t +_dbus_asv_add_string (DBusMessageIter *arr_iter, + const char *key, + const char *value) +{ + DBusMessageIter entry_iter, var_iter; + + if (!_dbus_asv_open_entry (arr_iter, &entry_iter, key, + DBUS_TYPE_STRING_AS_STRING, &var_iter)) + return FALSE; + + if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_STRING, + &value)) + { + _dbus_asv_abandon_entry (arr_iter, &entry_iter, &var_iter); + return FALSE; + } + + if (!_dbus_asv_close_entry (arr_iter, &entry_iter, &var_iter)) + return FALSE; + + return TRUE; +} diff --git a/dbus/dbus-asv-util.h b/dbus/dbus-asv-util.h new file mode 100644 index 00000000..0337260a --- /dev/null +++ b/dbus/dbus-asv-util.h @@ -0,0 +1,46 @@ +/* dbus-asv-util.h - utility functions for a{sv} + * + * Copyright © 2011-2012 Nokia Corporation + * Copyright © 2012-2013 Collabora Ltd. + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef DBUS_ASV_UTIL_H +#define DBUS_ASV_UTIL_H + +#include + +DBUS_BEGIN_DECLS + +DBusMessage *_dbus_asv_new_method_return (DBusMessage *message, + DBusMessageIter *iter, + DBusMessageIter *arr_iter); +dbus_bool_t _dbus_asv_close (DBusMessageIter *iter, + DBusMessageIter *arr_iter); +void _dbus_asv_abandon (DBusMessageIter *iter, + DBusMessageIter *arr_iter); + +dbus_bool_t _dbus_asv_add_uint32 (DBusMessageIter *arr_iter, + const char *key, + dbus_uint32_t value); +dbus_bool_t _dbus_asv_add_string (DBusMessageIter *arr_iter, + const char *key, + const char *value); + +#endif -- cgit v1.2.1 From 2fe0e999347e7e665ac21c2c53c026d53cd9a163 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 25 Jun 2013 11:34:11 +0800 Subject: Fix build failure if build with checks but without asserts Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65990 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- dbus/dbus-connection.c | 6 +++--- dbus/dbus-message.c | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 5c732e23..efc1cfbd 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -336,8 +336,8 @@ struct DBusConnection #ifndef DBUS_DISABLE_CHECKS unsigned int have_connection_lock : 1; /**< Used to check locking */ #endif - -#ifndef DBUS_DISABLE_CHECKS + +#if !defined(DBUS_DISABLE_CHECKS) || !defined(DBUS_DISABLE_ASSERT) int generation; /**< _dbus_current_generation that should correspond to this connection */ #endif }; @@ -1354,7 +1354,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->disconnected_message_arrived = FALSE; connection->disconnected_message_processed = FALSE; -#ifndef DBUS_DISABLE_CHECKS +#if !defined(DBUS_DISABLE_CHECKS) || !defined(DBUS_DISABLE_ASSERT) connection->generation = _dbus_current_generation; #endif diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 696991f6..01dcaa8e 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -777,6 +777,12 @@ _dbus_message_iter_check (DBusMessageRealIter *iter) return TRUE; } +#else +static dbus_bool_t +_dbus_message_iter_check (DBusMessageRealIter *iter) +{ + return TRUE; +} #endif /* DBUS_DISABLE_CHECKS */ /** -- cgit v1.2.1 From e632ceab0acc280bf1163dcde1853495599868e2 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 25 Jun 2013 15:42:23 +0800 Subject: Explicitly define macros to get less confusing conditions Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65990 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- cmake/config.h.cmake | 6 ++++++ configure.ac | 9 +++++++++ dbus/dbus-connection.c | 4 ++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index f3829cc3..7b9d3109 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -43,7 +43,13 @@ #cmakedefine DBUS_ENABLE_ANSI 1 #cmakedefine DBUS_ENABLE_VERBOSE_MODE 1 #cmakedefine DBUS_DISABLE_ASSERT 1 +#ifndef DBUS_DISABLE_ASSERT +# define DBUS_ENABLE_ASSERT 1 +#endif #cmakedefine DBUS_DISABLE_CHECKS 1 +#ifndef DBUS_DISABLE_CHECKS +# define DBUS_ENABLE_CHECKS 1 +#endif /* xmldocs */ /* doxygen */ #cmakedefine DBUS_GCOV_ENABLED 1 diff --git a/configure.ac b/configure.ac index 4c63f982..782dfbae 100644 --- a/configure.ac +++ b/configure.ac @@ -297,6 +297,15 @@ if test x$enable_checks = xno; then DISABLE_UNUSED_WARNINGS="unused-label" fi +AH_BOTTOM([ +/* explicitly define these macros to get less confusing conditions */ +#ifndef DBUS_DISABLE_ASSERT +# define DBUS_ENABLE_ASSERT 1 +#endif +#ifndef DBUS_DISABLE_CHECKS +# define DBUS_ENABLE_CHECKS 1 +#endif]) + if test x$enable_userdb_cache = xyes; then AC_DEFINE(DBUS_ENABLE_USERDB_CACHE,1,[Build with caching of user data]) fi diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index efc1cfbd..fda334a4 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -337,7 +337,7 @@ struct DBusConnection unsigned int have_connection_lock : 1; /**< Used to check locking */ #endif -#if !defined(DBUS_DISABLE_CHECKS) || !defined(DBUS_DISABLE_ASSERT) +#if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) int generation; /**< _dbus_current_generation that should correspond to this connection */ #endif }; @@ -1354,7 +1354,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->disconnected_message_arrived = FALSE; connection->disconnected_message_processed = FALSE; -#if !defined(DBUS_DISABLE_CHECKS) || !defined(DBUS_DISABLE_ASSERT) +#if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) connection->generation = _dbus_current_generation; #endif -- cgit v1.2.1 From e7503d188a4d9e3c9c827f16e85580cdd239ef55 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 25 Jun 2013 12:29:30 +0100 Subject: _dbus_message_iter_check: compile non-dummy version if asserting, too --- dbus/dbus-message.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 01dcaa8e..3f97ef28 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -729,7 +729,7 @@ dbus_message_cache_or_finalize (DBusMessage *message) dbus_message_finalize (message); } -#ifndef DBUS_DISABLE_CHECKS +#if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) static dbus_bool_t _dbus_message_iter_check (DBusMessageRealIter *iter) { @@ -777,13 +777,7 @@ _dbus_message_iter_check (DBusMessageRealIter *iter) return TRUE; } -#else -static dbus_bool_t -_dbus_message_iter_check (DBusMessageRealIter *iter) -{ - return TRUE; -} -#endif /* DBUS_DISABLE_CHECKS */ +#endif /* DBUS_ENABLE_CHECKS || DBUS_ENABLE_ASSERT */ /** * Implementation of the varargs arg-getting functions. -- cgit v1.2.1 From 11516f65d0a7a8f5b5c61ab53aac4e4cf3ec9a15 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 21 Jun 2013 17:58:56 +0800 Subject: Fix build failure if build with tests but without verbose mode Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66005 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- dbus/dbus-mempool.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-mempool.c b/dbus/dbus-mempool.c index 0c3f117d..f1539933 100644 --- a/dbus/dbus-mempool.c +++ b/dbus/dbus-mempool.c @@ -459,8 +459,10 @@ time_for_size (int size) { int i; int j; +#ifdef DBUS_ENABLE_VERBOSE_MODE clock_t start; clock_t end; +#endif #define FREE_ARRAY_SIZE 512 #define N_ITERATIONS FREE_ARRAY_SIZE * 512 void *to_free[FREE_ARRAY_SIZE]; @@ -470,8 +472,10 @@ time_for_size (int size) _dbus_verbose (" malloc\n"); +#ifdef DBUS_ENABLE_VERBOSE_MODE start = clock (); - +#endif + i = 0; j = 0; while (i < N_ITERATIONS) @@ -496,6 +500,7 @@ time_for_size (int size) ++i; } +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", @@ -506,6 +511,7 @@ time_for_size (int size) _dbus_verbose (" mempools\n"); start = clock (); +#endif pool = _dbus_mem_pool_new (size, FALSE); @@ -535,6 +541,7 @@ time_for_size (int size) _dbus_mem_pool_free (pool); +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", @@ -543,6 +550,7 @@ time_for_size (int size) _dbus_verbose (" zeroed malloc\n"); start = clock (); +#endif i = 0; j = 0; @@ -568,6 +576,7 @@ time_for_size (int size) ++i; } +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", @@ -576,6 +585,7 @@ time_for_size (int size) _dbus_verbose (" zeroed mempools\n"); start = clock (); +#endif pool = _dbus_mem_pool_new (size, TRUE); @@ -605,10 +615,12 @@ time_for_size (int size) _dbus_mem_pool_free (pool); +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", N_ITERATIONS, (end - start) / (double) CLOCKS_PER_SEC); +#endif } /** -- cgit v1.2.1 From 9665b8ecd84c650804945104d1ffe4f06cce199f Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 26 Jun 2013 15:40:12 +0800 Subject: FreeBSD: explicit include signal.h to fix build failure In Linux envrionment, signal.h included by sys/wait.h, however, this isn't the case in FreeBSD. So explicit include it to fix build failure. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66197 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- tools/dbus-run-session.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/dbus-run-session.c b/tools/dbus-run-session.c index 4f0b32b5..4f7243f7 100644 --- a/tools/dbus-run-session.c +++ b/tools/dbus-run-session.c @@ -34,6 +34,7 @@ #include #include +#include #define MAX_ADDR_LEN 512 #define PIPE_READ_END 0 -- cgit v1.2.1 From 973684f02290cfda7552cc0d1a87c5767660550f Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 26 Jun 2013 20:26:37 +0800 Subject: dbus-launch: fix coding style Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068 --- tools/dbus-launch.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 632a0042..86d325f9 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -756,31 +756,31 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, if (envvar == NULL || args == NULL) goto oom; - args[0] = xstrdup (runprog); + args[0] = xstrdup (runprog); if (!args[0]) goto oom; - for (i = 1; i <= (argc-remaining_args); i++) - { - size_t len = strlen (argv[remaining_args+i-1])+1; - args[i] = malloc (len); - if (!args[i]) - goto oom; - strncpy (args[i], argv[remaining_args+i-1], len); - } - args[i] = NULL; + for (i = 1; i <= (argc-remaining_args); i++) + { + size_t len = strlen (argv[remaining_args+i-1])+1; + args[i] = malloc (len); + if (!args[i]) + goto oom; + strncpy (args[i], argv[remaining_args+i-1], len); + } + args[i] = NULL; - strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); - strcat (envvar, bus_address); - putenv (envvar); + strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); + strcat (envvar, bus_address); + putenv (envvar); - execvp (runprog, args); - fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno)); - exit (1); + execvp (runprog, args); + fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno)); + exit (1); } else { print_variables (bus_address, bus_pid, bus_wid, c_shell_syntax, - bourne_shell_syntax, binary_syntax); + bourne_shell_syntax, binary_syntax); } verbose ("dbus-launch exiting\n"); -- cgit v1.2.1 From 8aa07c7e489c44dd6fe3199558ffb5401f0bdeab Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sun, 23 Jun 2013 10:49:09 +0800 Subject: dbus-launch: align document Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068 --- doc/dbus-launch.1.xml.in | 21 ++++++++++++++++++--- tools/dbus-launch.c | 5 ++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/doc/dbus-launch.1.xml.in b/doc/dbus-launch.1.xml.in index 727495b7..31dd6eac 100644 --- a/doc/dbus-launch.1.xml.in +++ b/doc/dbus-launch.1.xml.in @@ -20,10 +20,14 @@ - dbus-launch --version + dbus-launch + --version + --help --sh-syntax --csh-syntax --auto-syntax + --binary-syntax + --close-stderr --exit-with-session --autolaunch=MACHINEID --config-file=FILENAME @@ -175,8 +179,12 @@ no real reason to use it outside of the libdbus implementation anyhow. Choose --csh-syntax or --sh-syntax based on the SHELL environment variable. - -Write to stdout a nul-terminated bus address, then the bus PID as a + + + + + +Write to stdout a nul-terminated bus address, then the bus PID as a binary integer of size sizeof(pid_t), then the bus X window ID as a binary integer of size sizeof(long). Integers are in the machine's byte order, not network byte order or any other canonical byte order. @@ -242,6 +250,13 @@ use it manually. It may change in the future. Print the version of dbus-launch + + + + + +Print the help info of dbus-launch + diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 86d325f9..99143a62 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -182,7 +182,10 @@ verbose (const char *format, static void usage (int ecode) { - fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session]\n"); + fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax]" + " [--csh-syntax] [--auto-syntax] [--binary-syntax] [--close-stderr]" + " [--exit-with-session] [--autolaunch=MACHINEID]" + " [--config-file=FILENAME] [PROGRAM] [ARGS...]\n"); exit (ecode); } -- cgit v1.2.1 From eec093bbdb14d17d9d1cc01bca3fff7f1d3931e7 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 26 Jun 2013 20:31:07 +0800 Subject: dbus-launch: do not verbose output if build with verbose mode disabled Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068 --- tools/dbus-launch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 99143a62..80e1419d 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -153,6 +153,7 @@ void verbose (const char *format, ...) { +#ifdef DBUS_ENABLE_VERBOSE_MODE va_list args; static int verbose = TRUE; static int verbose_initted = FALSE; @@ -177,6 +178,7 @@ verbose (const char *format, va_start (args, format); vfprintf (stderr, format, args); va_end (args); +#endif /* DBUS_ENABLE_VERBOSE_MODE */ } static void -- cgit v1.2.1 From 23fa534a0a6ec74ed22fcf132a00fac4a78ca994 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 26 Jun 2013 21:35:09 +0800 Subject: kqueue: remove unused variable Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66035 --- bus/dir-watch-kqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c index ac6290cc..c60560f0 100644 --- a/bus/dir-watch-kqueue.c +++ b/bus/dir-watch-kqueue.c @@ -139,7 +139,7 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) int new_fds[MAX_DIRS_TO_WATCH]; char *new_dirs[MAX_DIRS_TO_WATCH]; DBusList *link; - int i, j, f, fd; + int i, j, fd; struct kevent ev; if (!_init_kqueue (context)) -- cgit v1.2.1 From 5fdb93a49c6b66f6461d4842821cb51d6e58658e Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 13:55:14 +0800 Subject: Fix two small typos in README.win Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66300 --- README.win | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.win b/README.win index d18f23d0..4e4f7574 100644 --- a/README.win +++ b/README.win @@ -88,13 +88,13 @@ FAQ The OpenWengo dbus-c++ binding has been ported to windows see in WinDBus svn (http://sf.net/projects/windbus) - The related test applicationa are running well. + The related test applications are running well. TODO ---- -Oktober 2010: +October 2010: - the code wrapped with DBUS_WIN_FIXME should be inspected if it required for windows -- cgit v1.2.1 From f023c0e265443e8caab45aa9aa18ce245aa22af0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 14:34:22 +0800 Subject: Remove invoke of va_end before va_start Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66300 --- dbus/dbus-errors.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dbus/dbus-errors.c b/dbus/dbus-errors.c index db3305b9..a0571a50 100644 --- a/dbus/dbus-errors.c +++ b/dbus/dbus-errors.c @@ -235,7 +235,7 @@ dbus_error_free (DBusError *error) * must ensure the name and message are global data that won't be * freed. You probably want dbus_set_error() instead, in most cases. * - * @param error the error.or #NULL + * @param error the error or #NULL * @param name the error name (not copied!!!) * @param message the error message (not copied!!!) */ @@ -379,7 +379,6 @@ dbus_set_error (DBusError *error, message_from_error (name))) { _dbus_string_free (&str); - va_end (args); goto nomem; } } -- cgit v1.2.1 From 160fbc9ec110fc3aa691b86971b50ee8dc740783 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 28 Jun 2013 11:37:28 +0100 Subject: NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 96d4b0c2..01e306f6 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ Fixes: • If malloc() returns NULL in _dbus_string_init() or similar, don't free an invalid pointer if the string is later freed (fd.o #65959, Chengwei Yang) +• If malloc() returns NULL in dbus_set_error(), don't va_end() a va_list + that was never va_start()ed (fd.o #66300, Chengwei Yang) + D-Bus 1.6.12 (2013-06-13) == -- cgit v1.2.1 From 0c20a0b38ecbdaa7a39340aeebabc8285179b122 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 28 Jun 2013 11:47:15 +0100 Subject: NEWS for master --- NEWS | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/NEWS b/NEWS index ee1a4b9b..a25b9a56 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,14 @@ Build-time configuration changes: assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent with the Autotools build system. (fd.o #66142, Chengwei Yang) +Enhancements: + +• Be thread-safe by default on all platforms, even if + dbus_threads_init_default() has not been called. For compatibility with + older libdbus, library users should continue to call + dbus_threads_init_default(): it is harmless to do so. + (fd.o #54972, Simon McVittie) + Fixes: • Don't crash on "dbus-send --session / x.y.z" which regressed in 1.7.4. @@ -18,10 +26,23 @@ Fixes: • If malloc() returns NULL in dbus_set_error(), don't va_end() a va_list that was never va_start()ed (fd.o #66300, Chengwei Yang) +• fix build failure with --enable-stats (fd.o #66004, Chengwei Yang) + +• Unix-specific: + · dbus-run-session: compile on FreeBSD (fd.o #66197, Chengwei Yang) + • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' (fd.o #42441, Ralf Habacker) +• Internal changes: + · add DBUS_ENABLE_ASSERT, DBUS_ENABLE_CHECKS for less confusing + conditionals (fd.o #66142, Chengwei Yang) + · improve verbose-mode output (fd.o #63047, Colin Walters) + · consolidate Autotools and CMake build (fd.o #64875, Ralf Habacker) + · fix various unused variables, unusual build configurations + etc. (fd.o #65712, #65990, #66005; Chengwei Yang) + D-Bus 1.7.4 (2013-06-13) == -- cgit v1.2.1 From 2dfb5ff69bb87f17ed98219f354c545fe31300d3 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 10:18:35 +0800 Subject: cmake: clean up libxml2 glue Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66257 --- cmake/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 836f4b23..c6743517 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -296,10 +296,9 @@ if("${sysname}" MATCHES ".*SOLARIS.*") endif(HAVE_CONSOLE_OWNER_FILE) endif("${sysname}" MATCHES ".*SOLARIS.*") -#AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use])) -if(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) - message(FATAL "Neither expat nor libxml2 found!") -endif(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) +if(NOT EXPAT_FOUND) + message(FATAL "expat not found!") +endif(NOT EXPAT_FOUND) SET(XML_LIB "Expat") SET(XML_LIBRARY ${EXPAT_LIBRARIES}) @@ -566,7 +565,6 @@ message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} " message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} ") message(" Building XML docs: ${DBUS_ENABLE_XML_DOCS} ") #message(" Gettext libs (empty OK): ${INTLLIBS} ") -message(" Using XML parser: ${XML_LIB} ") message(" Daemon executable name: ${DBUS_DAEMON_NAME}") if (WIN32) message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") -- cgit v1.2.1 From 1f9e5d70c7cb6bba6c440d9552711859fdadfea9 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 09:36:32 +0800 Subject: dir-watch: remove dnotify backend dnotify as a dir watch backend is broken since Jan 2010 (almost 3.5 years). According to fd.o: #33001, it's no harm to remove dnotify from this project. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33001 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- INSTALL | 1 - README.cmake | 4 --- bus/Makefile.am | 4 --- bus/dir-watch-dnotify.c | 93 ------------------------------------------------- bus/main.c | 7 ---- cmake/CMakeLists.txt | 6 ---- cmake/config.h.cmake | 1 - configure.ac | 20 ----------- 8 files changed, 136 deletions(-) delete mode 100644 bus/dir-watch-dnotify.c diff --git a/INSTALL b/INSTALL index 4e905c58..f2f0122c 100644 --- a/INSTALL +++ b/INSTALL @@ -56,7 +56,6 @@ Core library Optional: - libselinux (for SELinux integration) - - dnotify (for automatic service file reload) - doxygen (for API documentation) - xmlto or meinproc4 (for Spec & other XML documentation) diff --git a/README.cmake b/README.cmake index 376dac05..4932e66b 100644 --- a/README.cmake +++ b/README.cmake @@ -149,10 +149,6 @@ gcc only: // compile with coverage profiling instrumentation DBUS_GCOV_ENABLED:BOOL=OFF -linux only: -// build with dnotify support -DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX:BOOL=ON - solaris only: // enable console owner file HAVE_CONSOLE_OWNER_FILE:BOOL=ON diff --git a/bus/Makefile.am b/bus/Makefile.am index 74c62e74..526f1101 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -50,13 +50,9 @@ else if DBUS_BUS_ENABLE_INOTIFY DIR_WATCH_SOURCE=dir-watch-inotify.c else -if DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX -DIR_WATCH_SOURCE=dir-watch-dnotify.c -else DIR_WATCH_SOURCE=dir-watch-default.c endif endif -endif BUS_SOURCES= \ activation.c \ diff --git a/bus/dir-watch-dnotify.c b/bus/dir-watch-dnotify.c deleted file mode 100644 index b38d7d19..00000000 --- a/bus/dir-watch-dnotify.c +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ -/* dir-watch-dnotify.c OS specific directory change notification for message bus - * - * Copyright (C) 2003 Red Hat, Inc. - * - * Licensed under the Academic Free License version 2.1 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#include - -#define _GNU_SOURCE -#include -#include -#include -#ifdef HAVE_ERRNO_H -#include -#endif - -#include -#include "dir-watch.h" - -#define MAX_DIRS_TO_WATCH 128 - -/* use a static array to avoid handling OOM */ -static int fds[MAX_DIRS_TO_WATCH]; -static int num_fds = 0; - -void -bus_watch_directory (const char *dir, BusContext *context) -{ - int fd; - - _dbus_assert (dir != NULL); - - if (num_fds >= MAX_DIRS_TO_WATCH ) - { - _dbus_warn ("Cannot watch config directory '%s'. Already watching %d directories\n", dir, MAX_DIRS_TO_WATCH); - goto out; - } - - fd = open (dir, O_RDONLY); - if (fd < 0) - { - _dbus_warn ("Cannot open directory '%s'; error '%s'\n", dir, _dbus_strerror (errno)); - goto out; - } - - if (fcntl (fd, F_NOTIFY, DN_CREATE|DN_DELETE|DN_RENAME|DN_MODIFY) == -1) - { - _dbus_warn ("Cannot setup D_NOTIFY for '%s' error '%s'\n", dir, _dbus_strerror (errno)); - close (fd); - goto out; - } - - fds[num_fds++] = fd; - _dbus_verbose ("Added watch on config directory '%s'\n", dir); - - out: - ; -} - -void -bus_drop_all_directory_watches (void) -{ - int i; - - _dbus_verbose ("Dropping all watches on config directories\n"); - - for (i = 0; i < num_fds; i++) - { - if (close (fds[i]) != 0) - { - _dbus_verbose ("Error closing fd %d for config directory watch\n", fds[i]); - } - } - - num_fds = 0; -} diff --git a/bus/main.c b/bus/main.c index e53e5f89..53a77e25 100644 --- a/bus/main.c +++ b/bus/main.c @@ -61,10 +61,6 @@ signal_handler (int sig) { switch (sig) { -#ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX - case SIGIO: - /* explicit fall-through */ -#endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX */ #ifdef SIGHUP case SIGHUP: { @@ -649,9 +645,6 @@ main (int argc, char **argv) #ifdef SIGHUP _dbus_set_signal_handler (SIGHUP, signal_handler); #endif -#ifdef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX - _dbus_set_signal_handler (SIGIO, signal_handler); -#endif /* DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX */ #endif /* DBUS_UNIX */ _dbus_verbose ("We are on D-Bus...\n"); diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c6743517..5fcff046 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -279,11 +279,6 @@ endif(NOT MSVC) #AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto) #selinux missing -#AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto) -if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - option (DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX "build with dnotify support (linux only)" ON) # add a check ! -endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - #AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support (FreeBSD only)]),enable_kqueue=$enableval,enable_kqueue=auto) #missing @@ -561,7 +556,6 @@ message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} " message(" Building bus stats API: ${DBUS_ENABLE_STATS} ") message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} ") #message(" Building SELinux support: ${have_selinux} ") -#message(" Building dnotify support: ${have_dnotify} ") message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} ") message(" Building XML docs: ${DBUS_ENABLE_XML_DOCS} ") #message(" Gettext libs (empty OK): ${INTLLIBS} ") diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 7b9d3109..969a625c 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -69,7 +69,6 @@ #endif /* selinux */ -#cmakedefine DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 1 /* kqueue */ #cmakedefine HAVE_CONSOLE_OWNER_FILE 1 #define DBUS_CONSOLE_OWNER_FILE "@DBUS_CONSOLE_OWNER_FILE@" diff --git a/configure.ac b/configure.ac index 782dfbae..755e4f04 100644 --- a/configure.ac +++ b/configure.ac @@ -150,7 +150,6 @@ AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs],[build DOXYGE AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto) AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto) AC_ARG_ENABLE(libaudit,AS_HELP_STRING([--enable-libaudit],[build audit daemon support for SELinux]),enable_libaudit=$enableval,enable_libaudit=auto) -AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto) AC_ARG_ENABLE(inotify, AS_HELP_STRING([--enable-inotify],[build with inotify support (linux only)]),enable_inotify=$enableval,enable_inotify=auto) AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support]),enable_kqueue=$enableval,enable_kqueue=auto) AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto) @@ -1060,24 +1059,6 @@ fi AM_CONDITIONAL(DBUS_BUS_ENABLE_INOTIFY, test x$have_inotify = xyes) -# dnotify checks -if test x$enable_dnotify = xno ; then - have_dnotify=no; -else - if test x$have_inotify = xno -a x$host_os = xlinux-gnu -o x$host_os = xlinux; then - have_dnotify=yes; - else - have_dnotify=no; - fi -fi - -dnl check if dnotify backend is enabled -if test x$have_dnotify = xyes; then - AC_DEFINE(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX,1,[Use dnotify on Linux]) -fi - -AM_CONDITIONAL(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX, test x$have_dnotify = xyes) - # For simplicity, we require the userland API for epoll_create1 at # compile-time (glibc 2.9), but we'll run on kernels that turn out # not to have it at runtime. @@ -1863,7 +1844,6 @@ echo " Building bus stats API: ${enable_stats} Building SELinux support: ${have_selinux} Building inotify support: ${have_inotify} - Building dnotify support: ${have_dnotify} Building kqueue support: ${have_kqueue} Building systemd support: ${have_systemd} Building X11 code: ${have_x11} -- cgit v1.2.1 From 6af363bbbcdf2a8ff079b7b77764e8b83cd04727 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 10:23:12 +0800 Subject: cmake: get rid of useless commented out code Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66257 --- cmake/CMakeLists.txt | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5fcff046..9bf59234 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -95,7 +95,6 @@ if(NOT WIN32) include (FindThreads) endif(NOT WIN32) -#AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) option (DBUS_DISABLE_ASSERT "Disable assertion checking" OFF) option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) @@ -229,7 +228,6 @@ ENABLE_TESTING() ########### command line options ############### # TODO: take check from configure.in -#AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE) option (DBUS_BUILD_TESTS "enable unit test code" ON) if(DBUS_BUILD_TESTS) @@ -246,7 +244,6 @@ if(WIN32) option (DBUS_SERVICE "enable dbus service installer" OFF) endif(WIN32) -#AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) option (DBUS_ENABLE_ANSI "enable -ansi -pedantic gcc flags" OFF) if(DBUS_ENABLE_ANSI) if(NOT MSVC) @@ -256,14 +253,11 @@ if(DBUS_ENABLE_ANSI) endif(NOT MSVC) endif(DBUS_ENABLE_ANSI) -#AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE) option (DBUS_ENABLE_VERBOSE_MODE "support verbose debug mode" ON) -#AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes) option (DBUS_DISABLE_CHECKS "Disable public API sanity checking" OFF) if(NOT MSVC) - #AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no) option (DBUS_GCOV_ENABLED "compile with coverage profiling instrumentation (gcc only)" OFF) if(DBUS_GCOV_ENABLED) add_definitions(-fprofile-arcs -ftest-coverage) @@ -273,16 +267,6 @@ if(NOT MSVC) endif(DBUS_GCOV_ENABLED) endif(NOT MSVC) -#AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto) -# -> moved before include(ConfigureChecks.cmake) - -#AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto) -#selinux missing - -#AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support (FreeBSD only)]),enable_kqueue=$enableval,enable_kqueue=auto) -#missing - -#AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto) STRING(TOUPPER ${CMAKE_SYSTEM_NAME} sysname) if("${sysname}" MATCHES ".*SOLARIS.*") option (HAVE_CONSOLE_OWNER_FILE "enable console owner file (solaris only)" ON) @@ -299,15 +283,6 @@ SET(XML_LIB "Expat") SET(XML_LIBRARY ${EXPAT_LIBRARIES}) SET(XML_INCLUDE_DIR ${EXPAT_INCLUDE_DIR}) -#AC_ARG_WITH(init-scripts, AS_HELP_STRING([--with-init-scripts=[redhat]],[Style of init scripts to install])) -#AC_ARG_WITH(session-socket-dir, AS_HELP_STRING([--with-session-socket-dir=[dirname]],[Where to put sockets for the per-login-session message bus])) -#AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check])) -#AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon])) -#AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon])) -#AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip])) -#AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filename]],[file whose owner determines current console owner])) -#AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=],[User for running the DBUS daemon (messagebus)])) -#AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon])) # all missing or hardcoded for now # 'hidden' ones @@ -387,17 +362,6 @@ endif (MSVC_IDE) endif (NOT $ENV{TEMP} STREQUAL "") endif (NOT $ENV{TMPDIR} STREQUAL "") -#AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check])) - -#AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon])) - -#if ! test -z "$with_system_pid_file"; then -# DBUS_SYSTEM_PID_FILE=$with_system_pid_file -#elif test x$operating_system = xredhat ; then -# DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid -#else -# DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid -#fi # TODO: fix redhet if (WIN32) # bus-test expects a non empty string @@ -406,18 +370,12 @@ else (WIN32) set (DBUS_SYSTEM_PID_FILE ${EXPANDED_LOCALSTATEDIR}/run/dbus/pid) endif (WIN32) -#AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon])) - -#AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip])) - if (WIN32) set (DBUS_CONSOLE_AUTH_DIR "") else (WIN32) set (DBUS_CONSOLE_AUTH_DIR "/var/run/console/") endif (WIN32) -#AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=],[User for running the DBUS daemon (messagebus)])) - set (DBUS_USER ) # In Autotools this has a different default on QNX, but there seems little @@ -528,7 +486,6 @@ message(" install exec_prefix: ${exec_prefix} " message(" install libdir: ${EXPANDED_LIBDIR} ") message(" install bindir: ${EXPANDED_BINDIR} ") message(" install sysconfdir: ${EXPANDED_SYSCONFDIR} ") -#message(" install localstatedir: ${EXPANDED_LOCALSTATEDIR} ") message(" install datadir: ${EXPANDED_DATADIR} ") message(" source code location: ${DBUS_SOURCE_DIR} ") message(" build dir: ${CMAKE_BINARY_DIR} ") @@ -547,7 +504,6 @@ message(" Doxygen: ${DOXYGEN} " message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} ") -#message(" Maintainer mode: ${USE_MAINTAINER_MODE} ") message(" gcc coverage profiling: ${DBUS_GCOV_ENABLED} ") message(" Building unit tests: ${DBUS_BUILD_TESTS} ") message(" Building verbose mode: ${DBUS_ENABLE_VERBOSE_MODE} ") @@ -555,18 +511,14 @@ message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ") message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ") message(" Building bus stats API: ${DBUS_ENABLE_STATS} ") message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} ") -#message(" Building SELinux support: ${have_selinux} ") message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} ") message(" Building XML docs: ${DBUS_ENABLE_XML_DOCS} ") -#message(" Gettext libs (empty OK): ${INTLLIBS} ") message(" Daemon executable name: ${DBUS_DAEMON_NAME}") if (WIN32) message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ") message(" Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ") else (WIN32) -#message(" Init scripts style: ${with_init_scripts} ") -#message(" Abstract socket names: ${have_abstract_sockets} ") message(" System bus socket: ${DBUS_SYSTEM_SOCKET} ") message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") message(" System bus PID file: ${DBUS_SYSTEM_PID_FILE} ") -- cgit v1.2.1 From 982bfa106d8f551190ea6f19f0a36cd89fff4b86 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 10:27:08 +0800 Subject: cmake: terminate to generate makefiles due to fatal error FATAL isn't a valid key for message according to cmake document here. http://www.cmake.org/cmake/help/v2.8.8/cmake.html#command%3amessage Due to the real fatal error, FATAL_ERROR should be used to terminate cmake from continue generating makefiles. Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66257 --- cmake/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 9bf59234..6c17461f 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -276,7 +276,7 @@ if("${sysname}" MATCHES ".*SOLARIS.*") endif("${sysname}" MATCHES ".*SOLARIS.*") if(NOT EXPAT_FOUND) - message(FATAL "expat not found!") + message(FATAL_ERROR "expat not found!") endif(NOT EXPAT_FOUND) SET(XML_LIB "Expat") @@ -354,7 +354,7 @@ endif (MSVC_IDE) else (NOT $ENV{TMP} STREQUAL "") if (WIN32) #Should never happen, both TMP and TEMP seem always set on Windows - message(FATAL "Could not determine a usable temporary directory") + message(FATAL_ERROR "Could not determine a usable temporary directory") else(WIN32) set (DBUS_SESSION_SOCKET_DIR /tmp) endif(WIN32) -- cgit v1.2.1 From 1ec2e5a5387d131efc6affb7bfc49642c8186df8 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 10:48:15 +0800 Subject: cmake: align dir watch backend detection with autotools Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66257 --- cmake/CMakeLists.txt | 23 +++++++++++++++++++++++ cmake/bus/CMakeLists.txt | 17 ++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6c17461f..45d90c99 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -267,6 +267,27 @@ if(NOT MSVC) endif(DBUS_GCOV_ENABLED) endif(NOT MSVC) +if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + option (DBUS_BUS_ENABLE_INOTIFY "build with inotify support (linux only)" ON) + if(DBUS_BUS_ENABLE_INOTIFY) + check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H) + if(NOT HAVE_SYS_INOTIFY_H) + message(FATAL_ERROR "sys/inotify.h not found!") + endif(NOT HAVE_SYS_INOTIFY_H) + endif(DBUS_BUS_ENABLE_INOTIFY) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*BSD") + option (DBUS_BUS_ENABLE_KQUEUE "build with kqueue support (FreeBSD only)" ON) + if(DBUS_BUS_ENABLE_KQUEUE) + # cmake check a header by compiling a test program with + # the header, sys/event.h needs stdint.h and sys/types.h + # to work. + check_include_files("stdint.h;sys/types.h;sys/event.h" HAVE_SYS_EVENT_H) + if(NOT HAVE_SYS_EVENT_H) + message(FATAL_ERROR "sys/event.h not found!") + endif(NOT HAVE_SYS_EVENT_H) + endif(DBUS_BUS_ENABLE_KQUEUE) +endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + STRING(TOUPPER ${CMAKE_SYSTEM_NAME} sysname) if("${sysname}" MATCHES ".*SOLARIS.*") option (HAVE_CONSOLE_OWNER_FILE "enable console owner file (solaris only)" ON) @@ -511,6 +532,8 @@ message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ") message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ") message(" Building bus stats API: ${DBUS_ENABLE_STATS} ") message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} ") +message(" Building inotify support: ${DBUS_BUS_ENABLE_INOTIFY} ") +message(" Building kqueue support: ${DBUS_BUS_ENABLE_KQUEUE} ") message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} ") message(" Building XML docs: ${DBUS_ENABLE_XML_DOCS} ") message(" Daemon executable name: ${DBUS_DAEMON_NAME}") diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index f2ea55eb..6fa19f27 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -31,9 +31,13 @@ ENDFOREACH(FILE) SET (XML_SOURCES ${BUS_DIR}/config-loader-expat.c) -# after next cvs update -#set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-default.c) -set (DIR_WATCH_SOURCE ) +if (DBUS_BUS_ENABLE_INOTIFY) + set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-inotify.c) +elseif (DBUS_BUS_ENABLE_KQUEUE) + set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-kqueue.c) +else (DBUS_BUS_ENABLE_INOTIFY) + set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-default.c) +endif (DBUS_BUS_ENABLE_INOTIFY) set (BUS_SOURCES ${BUS_DIR}/activation.c @@ -42,14 +46,13 @@ set (BUS_SOURCES ${BUS_DIR}/bus.h ${BUS_DIR}/config-parser.c ${BUS_DIR}/config-parser.h - ${BUS_DIR}/config-parser-common.c - ${BUS_DIR}/config-parser-common.h + ${BUS_DIR}/config-parser-common.c + ${BUS_DIR}/config-parser-common.h # ${BUS_DIR}/config-parser-trivial.c ${BUS_DIR}/connection.c ${BUS_DIR}/connection.h ${BUS_DIR}/desktop-file.c ${BUS_DIR}/desktop-file.h - ${BUS_DIR}/dir-watch-default.c ${BUS_DIR}/dir-watch.h ${BUS_DIR}/dispatch.c ${BUS_DIR}/dispatch.h @@ -77,7 +80,7 @@ if(DBUS_ENABLE_STATS) ${BUS_DIR}/stats.c ${BUS_DIR}/stats.h ) -endif() +endif(DBUS_ENABLE_STATS) include_directories(${XML_INCLUDE_DIR}) -- cgit v1.2.1 From a73058a45c7c07b9ccfa8e69df4a65149e5c8b27 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 28 Jun 2013 12:03:05 +0100 Subject: NEWS for 33001 --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index a25b9a56..4c91dccb 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,12 @@ D-Bus 1.7.6 (UNRELEASED) Build-time configuration changes: +• Directory change notification via dnotify on Linux is no longer + supported; it hadn't compiled successfully since 2010 in any case. + If you don't have inotify (Linux) or kqueue (*BSD), you will need + to send SIGHUP to the dbus-daemon when its configuration changes. + (fd.o #33001, Chengwei Yang) + • The DBUS_DISABLE_ASSERTS CMake option didn't actually disable most assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent with the Autotools build system. (fd.o #66142, Chengwei Yang) -- cgit v1.2.1 From dec9025626e556e58e2dbfbb9eacea17e70ce87b Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 14:40:42 +0800 Subject: DBusString: fix a typo Signed-off-by: Chengwei Yang [separated out of a larger patch -smcv] Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66300 --- dbus/dbus-string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 52eb0f23..2b4e4ed6 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -977,7 +977,7 @@ do { \ dbus_bool_t _dbus_string_insert_2_aligned (DBusString *str, int insert_at, - const unsigned char octets[4]) + const unsigned char octets[2]) { DBUS_STRING_PREAMBLE (str); -- cgit v1.2.1 From db2757f8127fcf9208ea70273904ac78fcd6bd64 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 16:24:37 +0800 Subject: tests to embedded tests: replaced in dbus-daemon Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291 --- bus/activation.c | 4 ++-- bus/config-parser-trivial.c | 4 ++-- bus/config-parser.c | 4 ++-- bus/dispatch.c | 4 ++-- bus/expirelist.c | 4 ++-- bus/policy.c | 4 ++-- bus/policy.h | 2 +- bus/signals.c | 6 +++--- bus/test-launch-helper.c | 8 ++++---- bus/test-main.c | 8 ++++---- bus/test-system.c | 8 ++++---- bus/test.c | 2 +- bus/test.h | 2 +- 13 files changed, 30 insertions(+), 30 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index fcb71337..42694409 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -2232,7 +2232,7 @@ dbus_activation_systemd_failure (BusActivation *activation, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include @@ -2579,4 +2579,4 @@ bus_activation_service_reload_test (const DBusString *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/bus/config-parser-trivial.c b/bus/config-parser-trivial.c index 6ef50f8e..64a05c3a 100644 --- a/bus/config-parser-trivial.c +++ b/bus/config-parser-trivial.c @@ -330,7 +330,7 @@ bus_config_parser_get_service_dirs (BusConfigParser *parser) return &parser->service_dirs; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include #include "test.h" @@ -712,5 +712,5 @@ finish: return retval; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/bus/config-parser.c b/bus/config-parser.c index ff73ed03..6b59dfc5 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -2742,7 +2742,7 @@ bus_config_parser_steal_service_context_table (BusConfigParser *parser) return table; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include typedef enum @@ -3636,5 +3636,5 @@ bus_config_parser_test (const DBusString *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/bus/dispatch.c b/bus/dispatch.c index 7a96f9dc..72d228ae 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -428,7 +428,7 @@ bus_dispatch_remove_connection (DBusConnection *connection) NULL); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include @@ -4907,4 +4907,4 @@ bus_unix_fds_passing_test(const DBusString *test_data_dir) } #endif -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/bus/expirelist.c b/bus/expirelist.c index 1a12ea45..9a3886e9 100644 --- a/bus/expirelist.c +++ b/bus/expirelist.c @@ -281,7 +281,7 @@ bus_expire_list_contains_item (BusExpireList *list, return _dbus_list_find_last (&list->items, item) != NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS typedef struct { @@ -399,4 +399,4 @@ bus_expire_list_test (const DBusString *test_data_dir) return result; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/bus/policy.c b/bus/policy.c index 379cea95..082f3853 100644 --- a/bus/policy.c +++ b/bus/policy.c @@ -1302,12 +1302,12 @@ bus_client_policy_check_can_own (BusClientPolicy *policy, return bus_rules_check_can_own (policy->rules, service_name); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS dbus_bool_t bus_policy_check_can_own (BusPolicy *policy, const DBusString *service_name) { return bus_rules_check_can_own (policy->default_rules, service_name); } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/bus/policy.h b/bus/policy.h index 3ff6f482..d1d3e72b 100644 --- a/bus/policy.h +++ b/bus/policy.h @@ -161,7 +161,7 @@ dbus_bool_t bus_client_policy_append_rule (BusClientPolicy *policy, BusPolicyRule *rule); void bus_client_policy_optimize (BusClientPolicy *policy); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS dbus_bool_t bus_policy_check_can_own (BusPolicy *policy, const DBusString *service_name); #endif diff --git a/bus/signals.c b/bus/signals.c index 28506d3f..72487edd 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -64,7 +64,7 @@ bus_match_rule_new (DBusConnection *matches_go_to) rule->refcount = 1; rule->matches_go_to = matches_go_to; -#ifndef DBUS_BUILD_TESTS +#ifndef DBUS_ENABLE_EMBEDDED_TESTS _dbus_assert (rule->matches_go_to != NULL); #endif @@ -2056,7 +2056,7 @@ bus_matchmaker_get_recipients (BusMatchmaker *matchmaker, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "test.h" #include @@ -2811,5 +2811,5 @@ bus_signals_test (const DBusString *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/bus/test-launch-helper.c b/bus/test-launch-helper.c index ab36b6ec..e88c989c 100644 --- a/bus/test-launch-helper.c +++ b/bus/test-launch-helper.c @@ -29,7 +29,7 @@ #include #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static void die (const char *failure) { @@ -56,7 +56,7 @@ test_post_hook (const char *name) { check_memleaks (name); } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ #ifdef ACTIVATION_LAUNCHER_DO_OOM @@ -97,7 +97,7 @@ bus_activation_helper_oom_test (void *data) int main (int argc, char **argv) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS const char *dir; DBusString config_file; @@ -137,7 +137,7 @@ main (int argc, char **argv) printf ("%s: Success\n", argv[0]); return 0; -#else /* DBUS_BUILD_TESTS */ +#else /* DBUS_ENABLE_EMBEDDED_TESTS */ printf ("Not compiled with test support\n"); diff --git a/bus/test-main.c b/bus/test-main.c index 0f736c7c..01d22870 100644 --- a/bus/test-main.c +++ b/bus/test-main.c @@ -31,7 +31,7 @@ #include #include "selinux.h" -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static void die (const char *failure) { @@ -52,7 +52,7 @@ check_memleaks (const char *name) die ("memleaks"); } } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ static DBusInitialFDs *initial_fds = NULL; @@ -84,7 +84,7 @@ test_post_hook (void) int main (int argc, char **argv) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS const char *dir; const char *only; DBusString test_data_dir; @@ -181,7 +181,7 @@ main (int argc, char **argv) return 0; -#else /* DBUS_BUILD_TESTS */ +#else /* DBUS_ENABLE_EMBEDDED_TESTS */ printf ("Not compiled with test support\n"); diff --git a/bus/test-system.c b/bus/test-system.c index 56a7d4ea..5f02d0ab 100644 --- a/bus/test-system.c +++ b/bus/test-system.c @@ -29,7 +29,7 @@ #include #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static void die (const char *failure) { @@ -50,7 +50,7 @@ check_memleaks (const char *name) die ("memleaks"); } } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ static void test_pre_hook (void) @@ -67,7 +67,7 @@ test_post_hook (void) int main (int argc, char **argv) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS const char *dir; DBusString test_data_dir; @@ -98,7 +98,7 @@ main (int argc, char **argv) printf ("%s: Success\n", argv[0]); return 0; -#else /* DBUS_BUILD_TESTS */ +#else /* DBUS_ENABLE_EMBEDDED_TESTS */ printf ("Not compiled with test support\n"); diff --git a/bus/test.c b/bus/test.c index 1ca96070..31ef4c8f 100644 --- a/bus/test.c +++ b/bus/test.c @@ -23,7 +23,7 @@ #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "test.h" #include #include diff --git a/bus/test.h b/bus/test.h index 98a2c6ba..38b74e89 100644 --- a/bus/test.h +++ b/bus/test.h @@ -24,7 +24,7 @@ #ifndef BUS_TEST_H #define BUS_TEST_H -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include #include -- cgit v1.2.1 From 11c5dc126e5ad21a4a72fd15700b19dd937b053a Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 16:26:27 +0800 Subject: tests to embedded tests: replaced in tools Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291 --- tools/dbus-launch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 80e1419d..ea24f5ce 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -1106,7 +1106,7 @@ main (int argc, char **argv) verbose ("Calling exec()\n"); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* exec from testdir */ if (getenv("DBUS_USE_TEST_BINARY") != NULL) { @@ -1123,7 +1123,7 @@ main (int argc, char **argv) "Failed to execute test message bus daemon %s: %s. Will try again with the system path.\n", TEST_BUS_BINARY, strerror (errno)); } - #endif /* DBUS_BUILD_TESTS */ + #endif /* DBUS_ENABLE_EMBEDDED_TESTS */ execl (DBUS_DAEMONDIR"/dbus-daemon", DBUS_DAEMONDIR"/dbus-daemon", -- cgit v1.2.1 From 4df8738794422c216b25e1bc1bbc80654c948c5d Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 16:25:54 +0800 Subject: tests to embedded tests: replaced in libdbus Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291 --- dbus/dbus-address.c | 2 +- dbus/dbus-auth-script.c | 4 ++-- dbus/dbus-auth-util.c | 4 ++-- dbus/dbus-connection-internal.h | 2 +- dbus/dbus-connection.c | 4 ++-- dbus/dbus-credentials-util.c | 4 ++-- dbus/dbus-dataslot.c | 4 ++-- dbus/dbus-hash.c | 4 ++-- dbus/dbus-internals.c | 6 +++--- dbus/dbus-internals.h | 4 ++-- dbus/dbus-keyring.c | 6 +++--- dbus/dbus-list.c | 2 +- dbus/dbus-mainloop.c | 2 +- dbus/dbus-marshal-basic.c | 4 ++-- dbus/dbus-marshal-byteswap-util.c | 4 ++-- dbus/dbus-marshal-recursive-util.c | 4 ++-- dbus/dbus-marshal-validate-util.c | 4 ++-- dbus/dbus-memory.c | 30 +++++++++++++++--------------- dbus/dbus-mempool.c | 14 +++++++------- dbus/dbus-message-factory.c | 4 ++-- dbus/dbus-message-factory.h | 4 ++-- dbus/dbus-message-util.c | 8 ++++---- dbus/dbus-message.c | 2 +- dbus/dbus-misc.c | 2 +- dbus/dbus-object-tree.c | 28 ++++++++++++++-------------- dbus/dbus-server-debug-pipe.c | 4 ++-- dbus/dbus-server.c | 8 ++++---- dbus/dbus-sha.c | 4 ++-- dbus/dbus-signature.c | 2 +- dbus/dbus-socket-set-poll.c | 2 +- dbus/dbus-spawn-win.c | 10 +++++----- dbus/dbus-spawn.c | 6 +++--- dbus/dbus-string-util.c | 4 ++-- dbus/dbus-string.c | 16 ++++++++-------- dbus/dbus-sysdeps-unix.c | 2 +- dbus/dbus-sysdeps-util.c | 4 ++-- dbus/dbus-sysdeps-win.c | 4 ++-- dbus/dbus-test.c | 6 +++--- dbus/dbus-threads.c | 4 ++-- dbus/dbus-transport-unix.c | 2 +- dbus/dbus-transport.c | 4 ++-- dbus/dbus-userdb-util.c | 4 ++-- dbus/dbus-userdb.c | 4 ++-- 43 files changed, 123 insertions(+), 123 deletions(-) diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c index 90484dc1..7bfdee64 100644 --- a/dbus/dbus-address.c +++ b/dbus/dbus-address.c @@ -648,7 +648,7 @@ dbus_address_unescape_value (const char *value, /** @} */ /* End of public API */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index cbdd748f..c1f0c88e 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -22,7 +22,7 @@ */ #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-auth-script.h" #include "dbus-auth.h" @@ -800,4 +800,4 @@ _dbus_auth_script_run (const DBusString *filename) } /** @} */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-auth-util.c b/dbus/dbus-auth-util.c index 776e8e27..e88d6696 100644 --- a/dbus/dbus-auth-util.c +++ b/dbus/dbus-auth-util.c @@ -33,7 +33,7 @@ /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include "dbus-auth-script.h" #include @@ -167,4 +167,4 @@ _dbus_auth_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h index 3d37f188..2842f2f4 100644 --- a/dbus/dbus-connection-internal.h +++ b/dbus/dbus-connection-internal.h @@ -115,7 +115,7 @@ void _dbus_connection_get_stats (DBusConnection *connection, dbus_uint32_t *out_peak_fds); -/* if DBUS_BUILD_TESTS */ +/* if DBUS_ENABLE_EMBEDDED_TESTS */ const char* _dbus_connection_get_address (DBusConnection *connection); /* This _dbus_bus_* stuff doesn't really belong here, but dbus-bus-internal.h seems diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index fda334a4..86adaa55 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -446,7 +446,7 @@ _dbus_connection_wakeup_mainloop (DBusConnection *connection) (*connection->wakeup_main_function) (connection->wakeup_main_data); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Gets the locks so we can examine them * @@ -6283,7 +6283,7 @@ dbus_connection_get_outgoing_unix_fds (DBusConnection *connection) return res; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Returns the address of the transport object of this connection * diff --git a/dbus/dbus-credentials-util.c b/dbus/dbus-credentials-util.c index 59cdcb83..d2d164f7 100644 --- a/dbus/dbus-credentials-util.c +++ b/dbus/dbus-credentials-util.c @@ -33,7 +33,7 @@ /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include #include @@ -203,4 +203,4 @@ _dbus_credentials_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-dataslot.c b/dbus/dbus-dataslot.c index 412e7f4f..e37c9dd5 100644 --- a/dbus/dbus-dataslot.c +++ b/dbus/dbus-dataslot.c @@ -348,7 +348,7 @@ _dbus_data_slot_list_free (DBusDataSlotList *list) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include @@ -459,4 +459,4 @@ _dbus_data_slot_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c index c4c6f935..c80835aa 100644 --- a/dbus/dbus-hash.c +++ b/dbus/dbus-hash.c @@ -1401,7 +1401,7 @@ _dbus_hash_table_get_n_entries (DBusHashTable *table) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include @@ -1828,4 +1828,4 @@ _dbus_hash_test (void) return ret; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 63559be9..257f1d4c 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -861,7 +861,7 @@ _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str) if (!_dbus_read_local_machine_uuid (&machine_uuid, FALSE, &error)) { -#ifndef DBUS_BUILD_TESTS +#ifndef DBUS_ENABLE_EMBEDDED_TESTS /* For the test suite, we may not be installed so just continue silently * here. But in a production build, we want to be nice and loud about * this. @@ -940,7 +940,7 @@ _dbus_real_assert_not_reached (const char *explanation, } #endif /* DBUS_DISABLE_ASSERT */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static dbus_bool_t run_failing_each_malloc (int n_mallocs, const char *description, @@ -1035,6 +1035,6 @@ _dbus_test_oom_handling (const char *description, return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** @} */ diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index ca011a51..0856f8f7 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -266,7 +266,7 @@ void _dbus_verbose_bytes_of_string (const DBusString *str, extern const char *_dbus_no_memory_message; #define _DBUS_SET_OOM(error) dbus_set_error_const ((error), DBUS_ERROR_NO_MEMORY, _dbus_no_memory_message) -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* Memory debugging */ void _dbus_set_fail_alloc_counter (int until_next_fail); int _dbus_get_fail_alloc_counter (void); @@ -290,7 +290,7 @@ dbus_bool_t _dbus_test_oom_handling (const char *description, #define _dbus_decrement_fail_alloc_counter() (FALSE) #define _dbus_disable_mem_pools() (FALSE) #define _dbus_get_malloc_blocks_outstanding (0) -#endif /* !DBUS_BUILD_TESTS */ +#endif /* !DBUS_ENABLE_EMBEDDED_TESTS */ typedef void (* DBusShutdownFunction) (void *data); dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction function, diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 3b9ce315..0e433a8f 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -80,7 +80,7 @@ * Maximum number of keys in the keyring before * we just ignore the rest */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #define MAX_KEYS_IN_FILE 10 #else #define MAX_KEYS_IN_FILE 256 @@ -1023,7 +1023,7 @@ _dbus_keyring_get_hex_key (DBusKeyring *keyring, /** @} */ /* end of exposed API */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include @@ -1156,5 +1156,5 @@ _dbus_keyring_test (void) return FALSE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index 525e0678..c4c1856f 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -788,7 +788,7 @@ _dbus_list_length_is_one (DBusList **list) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index cef676a3..457242db 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -922,7 +922,7 @@ _dbus_loop_quit (DBusLoop *loop) int _dbus_get_oom_wait (void) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* make tests go fast */ return 0; #else diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index 88b19f36..cdbac587 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -1501,7 +1501,7 @@ _dbus_first_type_in_signature_c_str (const char *str, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include @@ -1992,4 +1992,4 @@ _dbus_marshal_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-marshal-byteswap-util.c b/dbus/dbus-marshal-byteswap-util.c index edb74cad..57874859 100644 --- a/dbus/dbus-marshal-byteswap-util.c +++ b/dbus/dbus-marshal-byteswap-util.c @@ -23,7 +23,7 @@ #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-marshal-byteswap.h" #include "dbus-test.h" #include @@ -102,4 +102,4 @@ _dbus_marshal_byteswap_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c index 95124140..6d62983f 100644 --- a/dbus/dbus-marshal-recursive-util.c +++ b/dbus/dbus-marshal-recursive-util.c @@ -23,7 +23,7 @@ #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-marshal-recursive.h" #include "dbus-marshal-basic.h" @@ -3574,4 +3574,4 @@ container_destroy (TestTypeNode *node) #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-marshal-validate-util.c b/dbus/dbus-marshal-validate-util.c index 81135bcf..d52cb6d8 100644 --- a/dbus/dbus-marshal-validate-util.c +++ b/dbus/dbus-marshal-validate-util.c @@ -22,7 +22,7 @@ */ #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -585,4 +585,4 @@ _dbus_marshal_validate_test (void) #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index 6cf04498..d59e8f8c 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -97,7 +97,7 @@ * @{ */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static dbus_bool_t debug_initialized = FALSE; static int fail_nth = -1; static size_t fail_size = 0; @@ -240,7 +240,7 @@ _dbus_get_fail_alloc_failures (void) return n_failures_per_failure; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Called when about to alloc some memory; if * it returns #TRUE, then the allocation should @@ -294,7 +294,7 @@ _dbus_decrement_fail_alloc_counter (void) return FALSE; } } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** * Get the number of outstanding malloc()'d blocks. @@ -460,7 +460,7 @@ set_guards (void *real_block, void* dbus_malloc (size_t bytes) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_initialize_malloc_debug (); if (_dbus_decrement_fail_alloc_counter ()) @@ -472,7 +472,7 @@ dbus_malloc (size_t bytes) if (bytes == 0) /* some system mallocs handle this, some don't */ return NULL; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS else if (fail_size != 0 && bytes > fail_size) return NULL; else if (guards) @@ -499,7 +499,7 @@ dbus_malloc (size_t bytes) void *mem; mem = malloc (bytes); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (mem) { _dbus_atomic_inc (&n_blocks_outstanding); @@ -530,7 +530,7 @@ dbus_malloc (size_t bytes) void* dbus_malloc0 (size_t bytes) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_initialize_malloc_debug (); if (_dbus_decrement_fail_alloc_counter ()) @@ -543,7 +543,7 @@ dbus_malloc0 (size_t bytes) if (bytes == 0) return NULL; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS else if (fail_size != 0 && bytes > fail_size) return NULL; else if (guards) @@ -571,7 +571,7 @@ dbus_malloc0 (size_t bytes) void *mem; mem = calloc (bytes, 1); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (mem) { _dbus_atomic_inc (&n_blocks_outstanding); @@ -601,7 +601,7 @@ void* dbus_realloc (void *memory, size_t bytes) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_initialize_malloc_debug (); if (_dbus_decrement_fail_alloc_counter ()) @@ -617,7 +617,7 @@ dbus_realloc (void *memory, dbus_free (memory); return NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS else if (fail_size != 0 && bytes > fail_size) return NULL; else if (guards) @@ -677,7 +677,7 @@ dbus_realloc (void *memory, void *mem; mem = realloc (memory, bytes); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (mem == NULL && malloc_cannot_fail) { _dbus_warn ("out of memory: malloc (%ld)\n", (long) bytes); @@ -700,7 +700,7 @@ dbus_realloc (void *memory, void dbus_free (void *memory) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (guards) { check_guards (memory, TRUE); @@ -724,7 +724,7 @@ dbus_free (void *memory) if (memory) /* we guarantee it's safe to free (NULL) */ { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifdef DBUS_DISABLE_ASSERT _dbus_atomic_dec (&n_blocks_outstanding); #else @@ -912,7 +912,7 @@ dbus_shutdown (void) /** @} */ /** End of public API docs block */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" /** diff --git a/dbus/dbus-mempool.c b/dbus/dbus-mempool.c index f1539933..e7445853 100644 --- a/dbus/dbus-mempool.c +++ b/dbus/dbus-mempool.c @@ -213,7 +213,7 @@ _dbus_mem_pool_free (DBusMemPool *pool) void* _dbus_mem_pool_alloc (DBusMemPool *pool) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (_dbus_disable_mem_pools ()) { DBusMemBlock *block; @@ -280,7 +280,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) /* Need a new block */ DBusMemBlock *block; int alloc_size; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS int saved_counter; #endif @@ -294,7 +294,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) alloc_size = sizeof (DBusMemBlock) - ELEMENT_PADDING + pool->block_size; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* We save/restore the counter, so that memory pools won't * cause a given function to have different number of * allocations on different invocations. i.e. when testing @@ -310,7 +310,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) else block = dbus_malloc (alloc_size); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_set_fail_alloc_counter (saved_counter); _dbus_assert (saved_counter == _dbus_get_fail_alloc_counter ()); #endif @@ -349,7 +349,7 @@ _dbus_mem_pool_dealloc (DBusMemPool *pool, { VALGRIND_MEMPOOL_FREE (pool, element); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (_dbus_disable_mem_pools ()) { DBusMemBlock *block; @@ -449,7 +449,7 @@ _dbus_mem_pool_get_stats (DBusMemPool *pool, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include #include @@ -644,4 +644,4 @@ _dbus_mem_pool_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-message-factory.c b/dbus/dbus-message-factory.c index efa4e029..b742e4c1 100644 --- a/dbus/dbus-message-factory.c +++ b/dbus/dbus-message-factory.c @@ -24,7 +24,7 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-message-factory.h" #include "dbus-message-private.h" #include "dbus-signature.h" @@ -1302,4 +1302,4 @@ _dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter, #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-message-factory.h b/dbus/dbus-message-factory.h index b0747504..fd7a4764 100644 --- a/dbus/dbus-message-factory.h +++ b/dbus/dbus-message-factory.h @@ -24,7 +24,7 @@ #ifndef DBUS_MESSAGE_FACTORY_H #define DBUS_MESSAGE_FACTORY_H -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include #include @@ -56,6 +56,6 @@ dbus_bool_t _dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter, DBUS_END_DECLS -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ #endif /* DBUS_MESSAGE_FACTORY_H */ diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index f7859520..a5ce5106 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -45,7 +45,7 @@ * @{ */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Reads arguments from a message iterator given a variable argument * list. Only arguments of basic type and arrays of fixed-length @@ -76,11 +76,11 @@ dbus_message_iter_get_args (DBusMessageIter *iter, return retval; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include "dbus-message-factory.h" #include @@ -1542,4 +1542,4 @@ _dbus_message_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 3f97ef28..5d3517c6 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -56,7 +56,7 @@ static void dbus_message_finalize (DBusMessage *message); * @{ */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static dbus_bool_t _dbus_enable_message_cache (void) { diff --git a/dbus/dbus-misc.c b/dbus/dbus-misc.c index b1610133..6ca30f24 100644 --- a/dbus/dbus-misc.c +++ b/dbus/dbus-misc.c @@ -173,7 +173,7 @@ dbus_get_version (int *major_version_p, /** @} */ /* End of public API */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 172c9d95..086fc64a 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -503,7 +503,7 @@ unlock: connection = tree->connection; /* Unlock and call application code */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (connection) #endif { @@ -515,7 +515,7 @@ unlock: if (unregister_function) (* unregister_function) (connection, user_data); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (connection) #endif dbus_connection_unref (connection); @@ -638,7 +638,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -653,7 +653,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, if (!_dbus_string_init (&xml)) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -698,7 +698,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &v_STRING)) goto out; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -711,7 +711,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, result = DBUS_HANDLER_RESULT_HANDLED; out: -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -762,7 +762,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, path = NULL; if (!dbus_message_get_path_decomposed (message, &path)) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -777,7 +777,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, if (path == NULL) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -846,7 +846,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_verbose (" (invoking a handler)\n"); #endif -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -863,7 +863,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, message, user_data); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif _dbus_connection_lock (tree->connection); @@ -886,7 +886,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, } else { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -1057,7 +1057,7 @@ _dbus_object_tree_list_registered_and_unlock (DBusObjectTree *tree, parent_path, child_entries); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -1214,7 +1214,7 @@ flatten_path (const char **path) } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -1962,4 +1962,4 @@ _dbus_object_tree_test (void) #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-server-debug-pipe.c b/dbus/dbus-server-debug-pipe.c index 419db5c5..8f5ff5fb 100644 --- a/dbus/dbus-server-debug-pipe.c +++ b/dbus/dbus-server-debug-pipe.c @@ -31,7 +31,7 @@ #include "dbus-string.h" #include "dbus-protocol.h" -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * @defgroup DBusServerDebugPipe DBusServerDebugPipe @@ -427,5 +427,5 @@ _dbus_transport_open_debug_pipe (DBusAddressEntry *entry, /** @} */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index e0212662..efe7d1d8 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -26,7 +26,7 @@ #include "dbus-server-unix.h" #include "dbus-server-socket.h" #include "dbus-string.h" -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-server-debug-pipe.h" #endif #include "dbus-address.h" @@ -529,7 +529,7 @@ static const struct { } listen_funcs[] = { { _dbus_server_listen_socket } , { _dbus_server_listen_platform_specific } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS , { _dbus_server_listen_debug_pipe } #endif }; @@ -1188,7 +1188,7 @@ dbus_server_get_data (DBusServer *server, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include @@ -1244,4 +1244,4 @@ _dbus_server_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-sha.c b/dbus/dbus-sha.c index d1827522..febfba20 100644 --- a/dbus/dbus-sha.c +++ b/dbus/dbus-sha.c @@ -511,7 +511,7 @@ _dbus_sha_compute (const DBusString *data, /** @} */ /* end of exported functions */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include @@ -966,4 +966,4 @@ _dbus_sha_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-signature.c b/dbus/dbus-signature.c index c130de5b..8a4701c9 100644 --- a/dbus/dbus-signature.c +++ b/dbus/dbus-signature.c @@ -410,7 +410,7 @@ dbus_type_is_valid (int typecode) /** @} */ /* end of DBusSignature group */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * @ingroup DBusSignatureInternals diff --git a/dbus/dbus-socket-set-poll.c b/dbus/dbus-socket-set-poll.c index 65a1fd23..e322a3b4 100644 --- a/dbus/dbus-socket-set-poll.c +++ b/dbus/dbus-socket-set-poll.c @@ -44,7 +44,7 @@ typedef struct { #define MINIMUM_SIZE 8 /* If we're in the regression tests, force reallocation to happen sooner */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #define DEFAULT_SIZE_HINT 1 #else #define DEFAULT_SIZE_HINT MINIMUM_SIZE diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index 3dae4f38..cd8ca666 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -63,7 +63,7 @@ struct DBusBabysitter int refcount; HANDLE start_sync_event; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS HANDLE end_sync_event; #endif @@ -109,7 +109,7 @@ _dbus_babysitter_new (void) return NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS sitter->end_sync_event = CreateEvent (NULL, FALSE, FALSE, NULL); if (sitter->end_sync_event == NULL) { @@ -250,7 +250,7 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) sitter->start_sync_event = NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (sitter->end_sync_event != NULL) { CloseHandle (sitter->end_sync_event); @@ -628,7 +628,7 @@ babysitter (void *parameter) sitter->child_handle = NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS SetEvent (sitter->end_sync_event); #endif @@ -753,7 +753,7 @@ _dbus_babysitter_set_result_function (DBusBabysitter *sitter, sitter->finished_data = user_data; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static char * get_test_exec (const char *exe, diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 55a7e1e6..f8d5fd1c 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -936,7 +936,7 @@ do_exec (int child_err_report_fd, DBusSpawnChildSetupFunc child_setup, void *user_data) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS int i, max_open; #endif @@ -947,7 +947,7 @@ do_exec (int child_err_report_fd, if (child_setup) (* child_setup) (user_data); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS max_open = sysconf (_SC_OPEN_MAX); for (i = 3; i < max_open; i++) @@ -1325,7 +1325,7 @@ _dbus_babysitter_set_result_function (DBusBabysitter *sitter, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static char * get_test_exec (const char *exe, diff --git a/dbus/dbus-string-util.c b/dbus/dbus-string-util.c index 922580da..3babc053 100644 --- a/dbus/dbus-string-util.c +++ b/dbus/dbus-string-util.c @@ -115,7 +115,7 @@ _dbus_string_find_byte_backward (const DBusString *str, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include @@ -935,4 +935,4 @@ _dbus_string_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 2b4e4ed6..7bdb88a9 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -285,9 +285,9 @@ compact (DBusRealString *real, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* Not using this feature at the moment, - * so marked DBUS_BUILD_TESTS-only + * so marked DBUS_ENABLE_EMBEDDED_TESTS-only */ /** * Locks a string such that any attempts to change the string will @@ -311,7 +311,7 @@ _dbus_string_lock (DBusString *str) #define MAX_WASTE 48 compact (real, MAX_WASTE); } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ static dbus_bool_t reallocate_for_length (DBusRealString *real, @@ -337,11 +337,11 @@ reallocate_for_length (DBusRealString *real, */ #ifdef DBUS_DISABLE_ASSERT #else -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS new_allocated = 0; /* ensure a realloc every time so that we go * through all malloc failure codepaths */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ #endif /* !DBUS_DISABLE_ASSERT */ /* But be sure we always alloc at least space for the new length */ @@ -1904,7 +1904,7 @@ _dbus_string_skip_white_reverse (const DBusString *str, * @todo owen correctly notes that this is a stupid function (it was * written purely for test code, * e.g. dbus-message-builder.c). Probably should be enforced as test - * code only with ifdef DBUS_BUILD_TESTS + * code only with ifdef DBUS_ENABLE_EMBEDDED_TESTS * * @param source the source string * @param dest the destination string (contents are replaced) @@ -1948,7 +1948,7 @@ _dbus_string_pop_line (DBusString *source, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Deletes up to and including the first blank space * in the string. @@ -1967,7 +1967,7 @@ _dbus_string_delete_first_word (DBusString *str) } #endif -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Deletes any leading blanks in the string * diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 4a586c72..c2e6f9fc 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3923,7 +3923,7 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, if (!_dbus_homedir_from_uid (uid, &homedir)) goto failed; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS { const char *override; diff --git a/dbus/dbus-sysdeps-util.c b/dbus/dbus-sysdeps-util.c index 4b3d16f2..6b361ef0 100644 --- a/dbus/dbus-sysdeps-util.c +++ b/dbus/dbus-sysdeps-util.c @@ -80,7 +80,7 @@ _dbus_get_environment (void) return environment; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static void check_dirname (const char *filename, const char *dirname) @@ -196,4 +196,4 @@ _dbus_sysdeps_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 6621af74..c2ba30a4 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2221,7 +2221,7 @@ _dbus_replace_install_prefix (const char *configure_time_path) #endif } -#if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_BUILD_TESTS) +#if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_ENABLE_EMBEDDED_TESTS) #if defined(_MSC_VER) || defined(DBUS_WINCE) # ifdef BACKTRACES @@ -3457,7 +3457,7 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, _dbus_string_append(&homedir,homepath); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS { const char *override; diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c index 224a6c8c..1539bce9 100644 --- a/dbus/dbus-test.c +++ b/dbus/dbus-test.c @@ -28,7 +28,7 @@ #include #include -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static void die (const char *failure) { @@ -84,7 +84,7 @@ run_data_test (const char *test_name, } } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** * An exported symbol to be run in order to execute @@ -98,7 +98,7 @@ run_data_test (const char *test_name, void dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *specific_test) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (!_dbus_threads_init_debug ()) die ("debug threads init"); diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 1781bdaf..45b262dc 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -457,7 +457,7 @@ dbus_threads_init_default (void) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS dbus_bool_t _dbus_threads_init_debug (void) @@ -465,4 +465,4 @@ _dbus_threads_init_debug (void) return dbus_threads_init (NULL); } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c index 6ba5c0b5..9a9fea50 100644 --- a/dbus/dbus-transport-unix.c +++ b/dbus/dbus-transport-unix.c @@ -412,7 +412,7 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS dbus_bool_t _dbus_transport_unix_test (void) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index c483d764..fff76cc4 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -32,7 +32,7 @@ #include "dbus-credentials.h" #include "dbus-mainloop.h" #include "dbus-message.h" -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-server-debug-pipe.h" #endif @@ -348,7 +348,7 @@ static const struct { { _dbus_transport_open_socket }, { _dbus_transport_open_platform_specific }, { _dbus_transport_open_autolaunch } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS , { _dbus_transport_open_debug_pipe } #endif }; diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c index 38ea4ef0..62495d83 100644 --- a/dbus/dbus-userdb-util.c +++ b/dbus/dbus-userdb-util.c @@ -437,7 +437,7 @@ _dbus_groups_from_uid (dbus_uid_t uid, } /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include /** @@ -490,4 +490,4 @@ _dbus_userdb_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 73f8fcef..b792cbe4 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -602,7 +602,7 @@ _dbus_user_database_flush (DBusUserDatabase *db) _dbus_hash_table_remove_all(db->groups); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Increments refcount of user database. * @param db the database @@ -617,7 +617,7 @@ _dbus_user_database_ref (DBusUserDatabase *db) return db; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** * Decrements refcount of user database. -- cgit v1.2.1 From 134701b758d834eda139843fcb90c144b57a08b0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 16:06:41 +0800 Subject: tests to embedded tests: replaced in automake files Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291 --- bus/Makefile.am | 4 ++-- configure.ac | 6 +----- dbus/Makefile.am | 2 +- test/Makefile.am | 6 +++--- test/name-test/Makefile.am | 4 ++-- 5 files changed, 9 insertions(+), 13 deletions(-) diff --git a/bus/Makefile.am b/bus/Makefile.am index 526f1101..cd0c67da 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -164,7 +164,7 @@ endif DBUS_UNIX ## compiled, so we don't put them in TESTS here; we run them in test/ ## instead. -if DBUS_BUILD_TESTS +if DBUS_ENABLE_EMBEDDED_TESTS ## we use noinst_PROGRAMS not check_PROGRAMS so that we build ## even when not doing "make check" @@ -178,7 +178,7 @@ noinst_PROGRAMS += bus-test-launch-helper noinst_PROGRAMS += dbus-daemon-launch-helper-test endif DBUS_UNIX -endif DBUS_BUILD_TESTS +endif DBUS_ENABLE_EMBEDDED_TESTS bus_test_system_SOURCES= \ $(XML_SOURCES) \ diff --git a/configure.ac b/configure.ac index 755e4f04..c80fcfcb 100644 --- a/configure.ac +++ b/configure.ac @@ -192,16 +192,12 @@ AC_ARG_ENABLE([tests], []) # DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files -# and also some stuff in the test/ subdir. DBUS_BUILD_TESTS was an older -# name for this. -AM_CONDITIONAL([DBUS_BUILD_TESTS], [test "x$enable_embedded_tests" = xyes]) +# and also some stuff in the test/ subdir. AM_CONDITIONAL([DBUS_ENABLE_EMBEDDED_TESTS], [test "x$enable_embedded_tests" = xyes]) if test "x$enable_embedded_tests" = xyes; then AC_DEFINE([DBUS_ENABLE_EMBEDDED_TESTS], [1], [Define to build test code into the library and binaries]) - AC_DEFINE([DBUS_BUILD_TESTS], [1], - [Define to build test code into the library and binaries]) fi # DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API. diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 9628c834..e118cbbb 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -310,7 +310,7 @@ endif noinst_PROGRAMS = -if DBUS_BUILD_TESTS +if DBUS_ENABLE_EMBEDDED_TESTS # We can't actually run this til we've reached test/ noinst_PROGRAMS += dbus-test endif diff --git a/test/Makefile.am b/test/Makefile.am index 6f0e6e10..074017a5 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -33,7 +33,7 @@ libdbus_testutils_la_LIBADD = \ noinst_LTLIBRARIES = libdbus-testutils.la -if DBUS_BUILD_TESTS +if DBUS_ENABLE_EMBEDDED_TESTS ## break-loader removed for now ## these binaries are used in tests but are not themselves tests TEST_BINARIES = \ @@ -59,12 +59,12 @@ if DBUS_UNIX TESTS += ../bus/bus-test-launch-helper$(EXEEXT) endif -else !DBUS_BUILD_TESTS +else !DBUS_ENABLE_EMBEDDED_TESTS TEST_BINARIES= TESTS= -endif !DBUS_BUILD_TESTS +endif !DBUS_ENABLE_EMBEDDED_TESTS noinst_PROGRAMS= $(TEST_BINARIES) diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 6aaf1783..424dad3a 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -11,7 +11,7 @@ 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 +if DBUS_ENABLE_EMBEDDED_TESTS 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 @@ -20,7 +20,7 @@ endif EXTRA_DIST=run-test.sh run-test-systemserver.sh test-wait-for-echo.py test-activation-forking.py -if DBUS_BUILD_TESTS +if DBUS_ENABLE_EMBEDDED_TESTS ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we ## build even when not doing "make check" -- cgit v1.2.1 From 0cb7d487bc02730a4f6100108446c05aeb3b4453 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 16:23:03 +0800 Subject: tests to embedded tests: replaced in cmake files Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66291 --- cmake/CMakeLists.txt | 4 +++- cmake/bus/CMakeLists.txt | 4 ++-- cmake/config.h.cmake | 1 - cmake/dbus/CMakeLists.txt | 8 ++++---- cmake/test/name-test/CMakeLists.txt | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 45d90c99..f25e55d9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -231,7 +231,9 @@ ENABLE_TESTING() option (DBUS_BUILD_TESTS "enable unit test code" ON) if(DBUS_BUILD_TESTS) - add_definitions(-DDBUS_BUILD_TESTS -DDBUS_ENABLE_EMBEDDED_TESTS) + set (DBUS_ENABLE_EMBEDDED_TESTS ON) + set (DBUS_ENABLE_MODULAR_TESTS ON) + add_definitions(-DDBUS_ENABLE_EMBEDDED_TESTS -DDBUS_ENABLE_MODULAR_TESTS) endif(DBUS_BUILD_TESTS) option (DBUS_USE_OUTPUT_DEBUG_STRING "enable win32 debug port for message output" OFF) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 6fa19f27..9943584a 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -107,12 +107,12 @@ if (DBUS_SERVICE) install_targets(/bin dbus-service ) endif (DBUS_SERVICE) -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c) target_link_libraries(bus-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) set_target_properties(bus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_BINARY_DIR}/test/data) -endif (DBUS_BUILD_TESTS) +endif (DBUS_ENABLE_EMBEDDED_TESTS) if(MSVC) project_source_group(${GROUP_CODE} bus_test_SOURCES dummy) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 969a625c..a961d1ab 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -39,7 +39,6 @@ #define TEST_BUS_BINARY "@TEST_BUS_BINARY@" /* Some dbus features */ -#cmakedefine DBUS_BUILD_TESTS 1 #cmakedefine DBUS_ENABLE_ANSI 1 #cmakedefine DBUS_ENABLE_VERBOSE_MODE 1 #cmakedefine DBUS_DISABLE_ASSERT 1 diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 1d04d46e..0205f852 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -166,12 +166,12 @@ set (DBUS_UTIL_SOURCES ${DBUS_DIR}/dbus-sysdeps-util.c ) -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES} ${DBUS_DIR}/dbus-test.c ) -endif (DBUS_BUILD_TESTS) +endif (DBUS_ENABLE_EMBEDDED_TESTS) set (DBUS_UTIL_HEADERS ${DBUS_DIR}/dbus-asv-util.h @@ -298,13 +298,13 @@ else(WIN32) target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT} rt) endif(WIN32) -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus") ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c) target_link_libraries(dbus-test ${DBUS_INTERNAL_LIBRARIES}) add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data) set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) -ENDIF (DBUS_BUILD_TESTS) +ENDIF (DBUS_ENABLE_EMBEDDED_TESTS) if (UNIX) # set version info diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index 80b9908b..44e4f6d1 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -1,4 +1,4 @@ -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) set (NAMEtest-DIR ../../../test/name-test) @@ -36,4 +36,4 @@ add_executable(test-autolaunch ${NAMEtest-DIR}/test-autolaunch.c) target_link_libraries(test-autolaunch dbus-testutils) ADD_TEST(test-autolaunch ${EXECUTABLE_OUTPUT_PATH}/test-autolaunch) -endif (DBUS_BUILD_TESTS) +endif (DBUS_ENABLE_EMBEDDED_TESTS) -- cgit v1.2.1 From 32e5cab56a6707cf897f918999720ff7e455255e Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sat, 29 Jun 2013 11:56:20 +0800 Subject: Fix: a non ascii byte will trigger BadAddress error If a byte in DBusString *unescaped isn't a ascii byte, which will be cast to char (signed char on most of platform), so that's the issue unsigned char cast to signed char. e.g. "\303\266" is a valid unicode character, if everything goes right, it will be escaped to "%c3%b6". However, in fact, it escaped to "%3%6". _dbus_string_append_byte_as_hex() take an int parameter, so negative byte is valid, but cause get a negative index in array. So garbage value will get. e.g. '\303' --> hexdigits[((signed byte)(-61)) >> 4] is hexdigits[-4]. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=53499 Sgne-off-by: Chengwei Yang [fixed whitespace -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-address.c | 6 +++--- dbus/dbus-string.c | 2 +- dbus/dbus-string.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c index 90484dc1..f3d48d0a 100644 --- a/dbus/dbus-address.c +++ b/dbus/dbus-address.c @@ -104,15 +104,15 @@ dbus_bool_t _dbus_address_append_escaped (DBusString *escaped, const DBusString *unescaped) { - const char *p; - const char *end; + const unsigned char *p; + const unsigned char *end; dbus_bool_t ret; int orig_len; ret = FALSE; orig_len = _dbus_string_get_length (escaped); - p = _dbus_string_get_const_data (unescaped); + p = (const unsigned char *) _dbus_string_get_const_data (unescaped); end = p + _dbus_string_get_length (unescaped); while (p != end) { diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 52eb0f23..0f63612f 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -2228,7 +2228,7 @@ _dbus_string_starts_with_c_str (const DBusString *a, */ dbus_bool_t _dbus_string_append_byte_as_hex (DBusString *str, - int byte) + unsigned char byte) { const char hexdigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h index 4ef59db1..86fb8c39 100644 --- a/dbus/dbus-string.h +++ b/dbus/dbus-string.h @@ -259,7 +259,7 @@ void _dbus_string_delete_first_word (DBusString *str); void _dbus_string_delete_leading_blanks (DBusString *str); void _dbus_string_chop_white (DBusString *str); dbus_bool_t _dbus_string_append_byte_as_hex (DBusString *str, - int byte); + unsigned char byte); dbus_bool_t _dbus_string_hex_encode (const DBusString *source, int start, DBusString *dest, -- cgit v1.2.1 From cef5a419f4a8f00c6cc0b57d5a01ac347fff9598 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sat, 29 Jun 2013 12:21:27 +0800 Subject: Test: add a test case for escaping byte > 127 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=53499 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- dbus/dbus-address.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c index f3d48d0a..6506d213 100644 --- a/dbus/dbus-address.c +++ b/dbus/dbus-address.c @@ -678,7 +678,9 @@ static const EscapeTest escape_tests[] = { { "Z", "Z" }, { "a", "a" }, { "i", "i" }, - { "z", "z" } + { "z", "z" }, + /* Bug: https://bugs.freedesktop.org/show_bug.cgi?id=53499 */ + { "%c3%b6", "\303\266" } }; static const char* invalid_escaped_values[] = { -- cgit v1.2.1 From 00c1c0ac1fb9258747c56ff77a4a35beb44bd994 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 1 Jul 2013 12:14:02 +0100 Subject: Make the test for #53499 more obviously correct --- dbus/dbus-address.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c index 6506d213..18f00947 100644 --- a/dbus/dbus-address.c +++ b/dbus/dbus-address.c @@ -680,7 +680,7 @@ static const EscapeTest escape_tests[] = { { "i", "i" }, { "z", "z" }, /* Bug: https://bugs.freedesktop.org/show_bug.cgi?id=53499 */ - { "%c3%b6", "\303\266" } + { "%c3%b6", "\xc3\xb6" } }; static const char* invalid_escaped_values[] = { -- cgit v1.2.1 From d9dc58efce46faf1dd49050a3a0ce2731313bace Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 1 Jul 2013 12:15:04 +0100 Subject: NEWS for 1.6.x --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 01e306f6..150a5344 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ D-Bus 1.6.14 (UNRELEASED) Fixes: +• Escape addresses containing non-ASCII characters correctly + (fd.o #53499, Chengwei Yang) + • If malloc() returns NULL in _dbus_string_init() or similar, don't free an invalid pointer if the string is later freed (fd.o #65959, Chengwei Yang) -- cgit v1.2.1 From 8cda82b726349b8f0a719a9945541e253b3f2118 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 28 Jun 2013 20:26:28 +0800 Subject: cmake: do not bind to any particular POSIX C standard This caused build failures on FreeBSD. Defining _POSIX_C_SOURCE to a particular version will disable common non-POSIX extensions like PF_UNIX, and on some systems will also disable features of later POSIX versions, like IPv6. If we don't ask for a specific version, we'll get some sort of sensible default. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66257 Signed-off-by: Chengwei Yang [made the commit message more concise -smcv] Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index f25e55d9..aecc74cd 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -103,7 +103,7 @@ find_package(EXPAT) find_package(X11) # analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac -add_definitions(-D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE) +add_definitions(-D_GNU_SOURCE) # do config checks INCLUDE(ConfigureChecks.cmake) -- cgit v1.2.1 From 9587ddb917d71c53dd69ff408955f1626a5b460a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 1 Jul 2013 12:24:53 +0100 Subject: NEWS for 1.7.x --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3b7894fe..08b87d27 100644 --- a/NEWS +++ b/NEWS @@ -50,7 +50,7 @@ Fixes: · improve verbose-mode output (fd.o #63047, Colin Walters) · consolidate Autotools and CMake build (fd.o #64875, Ralf Habacker) · fix various unused variables, unusual build configurations - etc. (fd.o #65712, #65990, #66005; Chengwei Yang) + etc. (fd.o #65712, #65990, #66005, #66257; Chengwei Yang) D-Bus 1.7.4 (2013-06-13) == -- cgit v1.2.1 From 2de11abd56a7ee350e98b8a957c7c7a4902945ce Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 24 Jul 2013 21:48:58 +0100 Subject: test/marshal: Ensure we use suitably aligned buffers This test was failing on s390; though it could fail on other platforms too. Basically we need to be sure we're passing at least word-aligned buffers to the demarshalling code. malloc() will do that for us. https://bugs.freedesktop.org/show_bug.cgi?id=67279 --- test/marshal.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/test/marshal.c b/test/marshal.c index e9ac7e30..e65ee7c1 100644 --- a/test/marshal.c +++ b/test/marshal.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -244,14 +245,30 @@ int main (int argc, char **argv) { + int ret; + char *aligned_le_blob; + char *aligned_be_blob; + g_test_init (&argc, &argv, NULL); - g_test_add ("/demarshal/le", Fixture, le_blob, setup, test_endian, teardown); - g_test_add ("/demarshal/be", Fixture, be_blob, setup, test_endian, teardown); - g_test_add ("/demarshal/needed/le", Fixture, le_blob, setup, test_needed, + /* We have to pass in a buffer that's at least "default aligned", + * i.e. on GNU systems to 8 or 16. The linker may have only given + * us byte-alignment for the char[] static variables. + */ + aligned_le_blob = g_malloc (sizeof (le_blob)); + memcpy (aligned_le_blob, le_blob, sizeof (le_blob)); + aligned_be_blob = g_malloc (sizeof (be_blob)); + memcpy (aligned_be_blob, be_blob, sizeof (be_blob)); + + g_test_add ("/demarshal/le", Fixture, aligned_le_blob, setup, test_endian, teardown); + g_test_add ("/demarshal/be", Fixture, aligned_be_blob, setup, test_endian, teardown); + g_test_add ("/demarshal/needed/le", Fixture, aligned_le_blob, setup, test_needed, teardown); - g_test_add ("/demarshal/needed/be", Fixture, be_blob, setup, test_needed, + g_test_add ("/demarshal/needed/be", Fixture, aligned_be_blob, setup, test_needed, teardown); - return g_test_run (); + ret = g_test_run (); + g_free (aligned_le_blob); + g_free (aligned_be_blob); + return ret; } -- cgit v1.2.1 From b4ffcdc5eb2ff89f2c4715130f061c82232775ef Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 24 Jul 2013 21:48:58 +0100 Subject: test/marshal: Ensure we use suitably aligned buffers This test was failing on s390; though it could fail on other platforms too. Basically we need to be sure we're passing at least word-aligned buffers to the demarshalling code. malloc() will do that for us. https://bugs.freedesktop.org/show_bug.cgi?id=67279 --- test/marshal.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/test/marshal.c b/test/marshal.c index e9ac7e30..e65ee7c1 100644 --- a/test/marshal.c +++ b/test/marshal.c @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -244,14 +245,30 @@ int main (int argc, char **argv) { + int ret; + char *aligned_le_blob; + char *aligned_be_blob; + g_test_init (&argc, &argv, NULL); - g_test_add ("/demarshal/le", Fixture, le_blob, setup, test_endian, teardown); - g_test_add ("/demarshal/be", Fixture, be_blob, setup, test_endian, teardown); - g_test_add ("/demarshal/needed/le", Fixture, le_blob, setup, test_needed, + /* We have to pass in a buffer that's at least "default aligned", + * i.e. on GNU systems to 8 or 16. The linker may have only given + * us byte-alignment for the char[] static variables. + */ + aligned_le_blob = g_malloc (sizeof (le_blob)); + memcpy (aligned_le_blob, le_blob, sizeof (le_blob)); + aligned_be_blob = g_malloc (sizeof (be_blob)); + memcpy (aligned_be_blob, be_blob, sizeof (be_blob)); + + g_test_add ("/demarshal/le", Fixture, aligned_le_blob, setup, test_endian, teardown); + g_test_add ("/demarshal/be", Fixture, aligned_be_blob, setup, test_endian, teardown); + g_test_add ("/demarshal/needed/le", Fixture, aligned_le_blob, setup, test_needed, teardown); - g_test_add ("/demarshal/needed/be", Fixture, be_blob, setup, test_needed, + g_test_add ("/demarshal/needed/be", Fixture, aligned_be_blob, setup, test_needed, teardown); - return g_test_run (); + ret = g_test_run (); + g_free (aligned_le_blob); + g_free (aligned_be_blob); + return ret; } -- cgit v1.2.1 From a5c21d3874384cae540659388a6217824daf7167 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 29 Jun 2013 13:45:41 +0200 Subject: Add WINXP <= SP3 support to _dbus_getsid(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index c2ba30a4..69d250ba 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -832,6 +832,38 @@ _dbus_pid_for_log (void) } #ifndef DBUS_WINCE + +static BOOL is_winxp_sp3_or_lower() +{ + OSVERSIONINFOEX osvi; + DWORDLONG dwlConditionMask = 0; + int op=VER_LESS_EQUAL; + + // Initialize the OSVERSIONINFOEX structure. + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + osvi.dwMajorVersion = 5; + osvi.dwMinorVersion = 1; + osvi.wServicePackMajor = 3; + osvi.wServicePackMinor = 0; + + // Initialize the condition mask. + + VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op ); + VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op ); + VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op ); + VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op ); + + // Perform the test. + + return VerifyVersionInfo( + &osvi, + VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + dwlConditionMask); +} + /** Gets our SID * @param sid points to sid buffer, need to be freed with LocalFree() * @param process_id the process id for which the sid should be returned @@ -845,7 +877,8 @@ _dbus_getsid(char **sid, dbus_pid_t process_id) DWORD n; PSID psid; int retval = FALSE; - HANDLE process_handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); + + HANDLE process_handle = OpenProcess(is_winxp_sp3_or_lower() ? PROCESS_QUERY_INFORMATION : PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); if (!OpenProcessToken (process_handle, TOKEN_QUERY, &process_token)) { -- cgit v1.2.1 From 2f24bc861612a544736b81cf6672dfc942df7ec7 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 29 Jun 2013 13:46:53 +0200 Subject: Dump fetched sid on return of _dbus_getsid(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 69d250ba..9df1c2d9 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -912,7 +912,7 @@ failed: if (process_token != INVALID_HANDLE_VALUE) CloseHandle (process_token); - _dbus_verbose("_dbus_getsid() returns %d\n",retval); + _dbus_verbose("_dbus_getsid() got '%s' and returns %d\n", *sid, retval); return retval; } #endif -- cgit v1.2.1 From d6b67a0383f9eec06798949a50e2878a918f08e9 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 7 Aug 2013 20:47:55 +0200 Subject: Fixed bug of unsupported GetExtendTcpTable() on Windows XP SP2 and earlier. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 9df1c2d9..aa0f97e2 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -104,6 +104,31 @@ _dbus_win_set_errno (int err) #endif } +static BOOL is_winxp_sp3_or_lower(); + +/* + * _MIB_TCPROW_EX and friends are not available in system headers + * and are mapped to attribute identical ...OWNER_PID typedefs. + */ +typedef MIB_TCPROW_OWNER_PID _MIB_TCPROW_EX; +typedef MIB_TCPTABLE_OWNER_PID MIB_TCPTABLE_EX; +typedef PMIB_TCPTABLE_OWNER_PID PMIB_TCPTABLE_EX; +typedef DWORD (WINAPI *ProcAllocateAndGetTcpExtTableFromStack)(PMIB_TCPTABLE_EX*,BOOL,HANDLE,DWORD,DWORD); +static ProcAllocateAndGetTcpExtTableFromStack lpfnAllocateAndGetTcpExTableFromStack = NULL; + +static BOOL load_ex_ip_helper_procedures(void) +{ + HMODULE hModule = LoadLibrary ("iphlpapi.dll"); + if (hModule == NULL) + return FALSE; + + lpfnAllocateAndGetTcpExTableFromStack = (ProcAllocateAndGetTcpExtTableFromStack)GetProcAddress (hModule, "AllocateAndGetTcpExTableFromStack"); + if (lpfnAllocateAndGetTcpExTableFromStack == NULL) + return FALSE; + + return TRUE; +} + /** * @brief return peer process id from tcp handle for localhost connections * @param handle tcp socket descriptor @@ -160,6 +185,43 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) return 0; } + if (is_winxp_sp3_or_lower ()) + { + DWORD errorCode, dwSize; + PMIB_TCPTABLE_EX lpBuffer = NULL; + + if (!load_ex_ip_helper_procedures ()) + { + _dbus_verbose + ("Error not been able to load iphelper procedures\n"); + return 0; + } + errorCode = (*lpfnAllocateAndGetTcpExTableFromStack) (&lpBuffer, TRUE, GetProcessHeap(), 0, 2); + if (errorCode != NO_ERROR) + { + _dbus_verbose + ("Error not been able to call AllocateAndGetTcpExTableFromStack()\n"); + return 0; + } + + result = 0; + for (dwSize = 0; dwSize < lpBuffer->dwNumEntries; dwSize++) + { + int local_port = ntohs (lpBuffer->table[dwSize].dwLocalPort); + if (local_port == peer_port) + { + result = lpBuffer->table[dwSize].dwOwningPid; + break; + } + } + + if (lpBuffer) + HeapFree (GetProcessHeap(), 0, lpBuffer); + + _dbus_verbose ("got pid %d\n", (int)result); + return result; + } + if ((result = GetExtendedTcpTable (NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) == ERROR_INSUFFICIENT_BUFFER) { -- cgit v1.2.1 From 4886ff454e3b6d42727fe266557eccd68d728c78 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 8 Aug 2013 16:48:04 +0200 Subject: Only take process id of localhost client connection entries. This patch makes sure, that the process id is fetched only from localhost client address connections fetched from the tcp table. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index aa0f97e2..14fbf131 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -208,7 +208,8 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) for (dwSize = 0; dwSize < lpBuffer->dwNumEntries; dwSize++) { int local_port = ntohs (lpBuffer->table[dwSize].dwLocalPort); - if (local_port == peer_port) + int local_address = ntohl (lpBuffer->table[dwSize].dwLocalAddr); + if (local_address == INADDR_LOOPBACK && local_port == peer_port) { result = lpBuffer->table[dwSize].dwOwningPid; break; @@ -244,8 +245,10 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) for (i = 0; i < tcp_table->dwNumEntries; i++) { MIB_TCPROW_OWNER_PID *p = &tcp_table->table[i]; + int local_address = ntohl (p->dwLocalAddr); int local_port = ntohs (p->dwLocalPort); - if (p->dwState == MIB_TCP_STATE_ESTAB && local_port == peer_port) + if (p->dwState == MIB_TCP_STATE_ESTAB + && local_address == INADDR_LOOPBACK && local_port == peer_port) result = p->dwOwningPid; } -- cgit v1.2.1 From 0b2b6cba926a739ac56666f86ad4f88cbf5a8d48 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 8 Aug 2013 16:52:54 +0200 Subject: Add doc to load_ex_ip_helper_procedures(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 14fbf131..3c46bd1f 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -116,6 +116,11 @@ typedef PMIB_TCPTABLE_OWNER_PID PMIB_TCPTABLE_EX; typedef DWORD (WINAPI *ProcAllocateAndGetTcpExtTableFromStack)(PMIB_TCPTABLE_EX*,BOOL,HANDLE,DWORD,DWORD); static ProcAllocateAndGetTcpExtTableFromStack lpfnAllocateAndGetTcpExTableFromStack = NULL; +/** + * AllocateAndGetTcpExTableFromStack() is undocumented and not exported, + * but is the only way to do this in older XP versions. + * @return true if the procedures could be loaded + */ static BOOL load_ex_ip_helper_procedures(void) { HMODULE hModule = LoadLibrary ("iphlpapi.dll"); -- cgit v1.2.1 From 2fd9e2c2559991295649635969464772bb6fd1e9 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 8 Aug 2013 22:42:35 +0200 Subject: Fix for broken wine AllocateAndGetTcpExTableFromStack() implementation. On wine (tested with 1.5.6) the mentioned function could not be located in iphlpapi.dll using LoadLibrary()/GetProcAddress(), which is the prefered method to get a tcp peer pid on WinXP <= SP2. To workaround this limitation we use GetExtendedTcpTable() first to get the peer pid. If this fails (which happens at least on real WinXP SP2) we then use AllocateAndGetTcpExTableFromStack() to get the pid. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 154 ++++++++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 70 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 3c46bd1f..4f0b308d 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -134,6 +134,86 @@ static BOOL load_ex_ip_helper_procedures(void) return TRUE; } + +dbus_pid_t get_pid_from_extended_tcp_table(int peer_port) +{ + dbus_pid_t result; + DWORD size; + MIB_TCPTABLE_OWNER_PID *tcp_table; + DWORD i; + + if ((result = + GetExtendedTcpTable (NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) == ERROR_INSUFFICIENT_BUFFER) + { + tcp_table = (MIB_TCPTABLE_OWNER_PID *) dbus_malloc (size); + if (tcp_table == NULL) + { + _dbus_verbose ("Error allocating memory\n"); + return 0; + } + } + + if ((result = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) + { + _dbus_verbose ("Error fetching tcp table %d\n", (int)result); + dbus_free (tcp_table); + return 0; + } + + result = 0; + for (i = 0; i < tcp_table->dwNumEntries; i++) + { + MIB_TCPROW_OWNER_PID *p = &tcp_table->table[i]; + int local_address = ntohl (p->dwLocalAddr); + int local_port = ntohs (p->dwLocalPort); + if (p->dwState == MIB_TCP_STATE_ESTAB + && local_address == INADDR_LOOPBACK && local_port == peer_port) + result = p->dwOwningPid; + } + + _dbus_verbose ("got pid %d\n", (int)result); + dbus_free (tcp_table); + return result; +} + +dbus_pid_t get_pid_from_tcp_ex_table(int peer_port) +{ + dbus_pid_t result; + DWORD errorCode, dwSize; + PMIB_TCPTABLE_EX lpBuffer = NULL; + + if (!load_ex_ip_helper_procedures ()) + { + _dbus_verbose + ("Error not been able to load iphelper procedures\n"); + return 0; + } + + errorCode = lpfnAllocateAndGetTcpExTableFromStack (&lpBuffer, TRUE, GetProcessHeap(), 0, 2); + + if (errorCode != NO_ERROR) + { + _dbus_verbose + ("Error not been able to call AllocateAndGetTcpExTableFromStack()\n"); + return 0; + } + result = 0; + for (dwSize = 0; dwSize < lpBuffer->dwNumEntries; dwSize++) + { + int local_port = ntohs (lpBuffer->table[dwSize].dwLocalPort); + int local_address = ntohl (lpBuffer->table[dwSize].dwLocalAddr); + if (local_address == INADDR_LOOPBACK && local_port == peer_port) + { + result = lpBuffer->table[dwSize].dwOwningPid; + break; + } + } + if (lpBuffer) + HeapFree (GetProcessHeap(), 0, lpBuffer); + _dbus_verbose ("got pid %d\n", (int)result); + return result; +} + /** * @brief return peer process id from tcp handle for localhost connections * @param handle tcp socket descriptor @@ -147,9 +227,6 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) int peer_port; dbus_pid_t result; - DWORD size; - MIB_TCPTABLE_OWNER_PID *tcp_table; - DWORD i; dbus_bool_t is_localhost = FALSE; getpeername (handle, (struct sockaddr *) &addr, &len); @@ -190,75 +267,12 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) return 0; } - if (is_winxp_sp3_or_lower ()) - { - DWORD errorCode, dwSize; - PMIB_TCPTABLE_EX lpBuffer = NULL; + _dbus_verbose ("\n"); - if (!load_ex_ip_helper_procedures ()) - { - _dbus_verbose - ("Error not been able to load iphelper procedures\n"); - return 0; - } - errorCode = (*lpfnAllocateAndGetTcpExTableFromStack) (&lpBuffer, TRUE, GetProcessHeap(), 0, 2); - if (errorCode != NO_ERROR) - { - _dbus_verbose - ("Error not been able to call AllocateAndGetTcpExTableFromStack()\n"); - return 0; - } - - result = 0; - for (dwSize = 0; dwSize < lpBuffer->dwNumEntries; dwSize++) - { - int local_port = ntohs (lpBuffer->table[dwSize].dwLocalPort); - int local_address = ntohl (lpBuffer->table[dwSize].dwLocalAddr); - if (local_address == INADDR_LOOPBACK && local_port == peer_port) - { - result = lpBuffer->table[dwSize].dwOwningPid; - break; - } - } - - if (lpBuffer) - HeapFree (GetProcessHeap(), 0, lpBuffer); - - _dbus_verbose ("got pid %d\n", (int)result); + result = get_pid_from_extended_tcp_table(peer_port); + if (result > 0) return result; - } - - if ((result = - GetExtendedTcpTable (NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) == ERROR_INSUFFICIENT_BUFFER) - { - tcp_table = (MIB_TCPTABLE_OWNER_PID *) dbus_malloc (size); - if (tcp_table == NULL) - { - _dbus_verbose ("Error allocating memory\n"); - return 0; - } - } - - if ((result = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) - { - _dbus_verbose ("Error fetching tcp table %d\n", result); - dbus_free (tcp_table); - return 0; - } - - result = 0; - for (i = 0; i < tcp_table->dwNumEntries; i++) - { - MIB_TCPROW_OWNER_PID *p = &tcp_table->table[i]; - int local_address = ntohl (p->dwLocalAddr); - int local_port = ntohs (p->dwLocalPort); - if (p->dwState == MIB_TCP_STATE_ESTAB - && local_address == INADDR_LOOPBACK && local_port == peer_port) - result = p->dwOwningPid; - } - - _dbus_verbose ("got pid %d\n", result); - dbus_free (tcp_table); + result = get_pid_from_tcp_ex_table(peer_port); return result; } -- cgit v1.2.1 From 9cc21aa0015759a57d921374badf20a6afe80556 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 8 Aug 2013 22:53:40 +0200 Subject: Refactored get_pid_from_extended_tcp_table() and get_pid_from_tcp_ex_table() to be more equal. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 4f0b308d..abc14b1a 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -138,11 +138,10 @@ static BOOL load_ex_ip_helper_procedures(void) dbus_pid_t get_pid_from_extended_tcp_table(int peer_port) { dbus_pid_t result; - DWORD size; + DWORD errorCode, size, i; MIB_TCPTABLE_OWNER_PID *tcp_table; - DWORD i; - if ((result = + if ((errorCode = GetExtendedTcpTable (NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) == ERROR_INSUFFICIENT_BUFFER) { tcp_table = (MIB_TCPTABLE_OWNER_PID *) dbus_malloc (size); @@ -153,9 +152,9 @@ dbus_pid_t get_pid_from_extended_tcp_table(int peer_port) } } - if ((result = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) + if ((errorCode = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) { - _dbus_verbose ("Error fetching tcp table %d\n", (int)result); + _dbus_verbose ("Error fetching tcp table %d\n", (int)errorCode); dbus_free (tcp_table); return 0; } @@ -179,8 +178,8 @@ dbus_pid_t get_pid_from_extended_tcp_table(int peer_port) dbus_pid_t get_pid_from_tcp_ex_table(int peer_port) { dbus_pid_t result; - DWORD errorCode, dwSize; - PMIB_TCPTABLE_EX lpBuffer = NULL; + DWORD errorCode, i; + PMIB_TCPTABLE_EX tcp_table = NULL; if (!load_ex_ip_helper_procedures ()) { @@ -189,7 +188,7 @@ dbus_pid_t get_pid_from_tcp_ex_table(int peer_port) return 0; } - errorCode = lpfnAllocateAndGetTcpExTableFromStack (&lpBuffer, TRUE, GetProcessHeap(), 0, 2); + errorCode = lpfnAllocateAndGetTcpExTableFromStack (&tcp_table, TRUE, GetProcessHeap(), 0, 2); if (errorCode != NO_ERROR) { @@ -197,19 +196,21 @@ dbus_pid_t get_pid_from_tcp_ex_table(int peer_port) ("Error not been able to call AllocateAndGetTcpExTableFromStack()\n"); return 0; } + result = 0; - for (dwSize = 0; dwSize < lpBuffer->dwNumEntries; dwSize++) + for (i = 0; i < tcp_table->dwNumEntries; i++) { - int local_port = ntohs (lpBuffer->table[dwSize].dwLocalPort); - int local_address = ntohl (lpBuffer->table[dwSize].dwLocalAddr); + _MIB_TCPROW_EX *p = &tcp_table->table[i]; + int local_port = ntohs (p->dwLocalPort); + int local_address = ntohl (p->dwLocalAddr); if (local_address == INADDR_LOOPBACK && local_port == peer_port) { - result = lpBuffer->table[dwSize].dwOwningPid; + result = p->dwOwningPid; break; } } - if (lpBuffer) - HeapFree (GetProcessHeap(), 0, lpBuffer); + if (tcp_table) + HeapFree (GetProcessHeap(), 0, tcp_table); _dbus_verbose ("got pid %d\n", (int)result); return result; } -- cgit v1.2.1 From 8a76654a4363b4af87fec72c30ebf0ca4bda7a6f Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 8 Aug 2013 23:23:11 +0200 Subject: Add debug messages to load_ex_ip_helper_procedures(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index abc14b1a..c418904b 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -125,11 +125,17 @@ static BOOL load_ex_ip_helper_procedures(void) { HMODULE hModule = LoadLibrary ("iphlpapi.dll"); if (hModule == NULL) + { + _dbus_verbose ("could not load iphlpapi.dll\n"); return FALSE; + } lpfnAllocateAndGetTcpExTableFromStack = (ProcAllocateAndGetTcpExtTableFromStack)GetProcAddress (hModule, "AllocateAndGetTcpExTableFromStack"); if (lpfnAllocateAndGetTcpExTableFromStack == NULL) + { + _dbus_verbose ("could not find function AllocateAndGetTcpExTableFromStack in iphlpapi.dll\n"); return FALSE; + } return TRUE; } -- cgit v1.2.1 From 9554ca9d9fde59f1d14b670c5d400795b07cd3cd Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 9 Aug 2013 16:14:35 +0200 Subject: Fixed remaining issues. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66060 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 69 +++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 25 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index c418904b..20ecb4eb 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -121,27 +121,33 @@ static ProcAllocateAndGetTcpExtTableFromStack lpfnAllocateAndGetTcpExTableFromSt * but is the only way to do this in older XP versions. * @return true if the procedures could be loaded */ -static BOOL load_ex_ip_helper_procedures(void) +static BOOL +load_ex_ip_helper_procedures(void) { - HMODULE hModule = LoadLibrary ("iphlpapi.dll"); - if (hModule == NULL) - { - _dbus_verbose ("could not load iphlpapi.dll\n"); - return FALSE; - } - - lpfnAllocateAndGetTcpExTableFromStack = (ProcAllocateAndGetTcpExtTableFromStack)GetProcAddress (hModule, "AllocateAndGetTcpExTableFromStack"); - if (lpfnAllocateAndGetTcpExTableFromStack == NULL) - { - _dbus_verbose ("could not find function AllocateAndGetTcpExTableFromStack in iphlpapi.dll\n"); - return FALSE; - } + HMODULE hModule = LoadLibrary ("iphlpapi.dll"); + if (hModule == NULL) + { + _dbus_verbose ("could not load iphlpapi.dll\n"); + return FALSE; + } - return TRUE; + lpfnAllocateAndGetTcpExTableFromStack = (ProcAllocateAndGetTcpExtTableFromStack)GetProcAddress (hModule, "AllocateAndGetTcpExTableFromStack"); + if (lpfnAllocateAndGetTcpExTableFromStack == NULL) + { + _dbus_verbose ("could not find function AllocateAndGetTcpExTableFromStack in iphlpapi.dll\n"); + return FALSE; + } + return TRUE; } - -dbus_pid_t get_pid_from_extended_tcp_table(int peer_port) +/** + * get pid from localhost tcp connection using peer_port + * This function is available on WinXP >= SP3 + * @param peer_port peers tcp port + * @return process id or 0 if connection has not been found + */ +static dbus_pid_t +get_pid_from_extended_tcp_table(int peer_port) { dbus_pid_t result; DWORD errorCode, size, i; @@ -157,6 +163,11 @@ dbus_pid_t get_pid_from_extended_tcp_table(int peer_port) return 0; } } + else + { + _dbus_verbose ("unexpected error returned from GetExtendedTcpTable %d\n", errorCode); + return 0; + } if ((errorCode = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) { @@ -176,12 +187,20 @@ dbus_pid_t get_pid_from_extended_tcp_table(int peer_port) result = p->dwOwningPid; } - _dbus_verbose ("got pid %d\n", (int)result); dbus_free (tcp_table); + _dbus_verbose ("got pid %d\n", (int)result); return result; } -dbus_pid_t get_pid_from_tcp_ex_table(int peer_port) +/** + * get pid from localhost tcp connection using peer_port + * This function is available on all WinXP versions, but + * not in wine (at least version <= 1.6.0) + * @param peer_port peers tcp port + * @return process id or 0 if connection has not been found + */ +static dbus_pid_t +get_pid_from_tcp_ex_table(int peer_port) { dbus_pid_t result; DWORD errorCode, i; @@ -215,8 +234,8 @@ dbus_pid_t get_pid_from_tcp_ex_table(int peer_port) break; } } - if (tcp_table) - HeapFree (GetProcessHeap(), 0, tcp_table); + + HeapFree (GetProcessHeap(), 0, tcp_table); _dbus_verbose ("got pid %d\n", (int)result); return result; } @@ -242,7 +261,7 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) { struct sockaddr_in *s = (struct sockaddr_in *) &addr; peer_port = ntohs (s->sin_port); - is_localhost = (htonl (s->sin_addr.s_addr) == INADDR_LOOPBACK); + is_localhost = (ntohl (s->sin_addr.s_addr) == INADDR_LOOPBACK); } else if (addr.ss_family == AF_INET6) { @@ -274,12 +293,12 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) return 0; } - _dbus_verbose ("\n"); + _dbus_verbose ("trying to get peers pid"); - result = get_pid_from_extended_tcp_table(peer_port); + result = get_pid_from_extended_tcp_table (peer_port); if (result > 0) return result; - result = get_pid_from_tcp_ex_table(peer_port); + result = get_pid_from_tcp_ex_table (peer_port); return result; } -- cgit v1.2.1 From 006c5750b374851685cd80ccc5d71375203236fa Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 12 Aug 2013 17:46:48 +0200 Subject: Documentation fix. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=29666 Reviewed-by: Chengwei Yang --- dbus/dbus-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 7b5f09af..3b775c76 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -557,7 +557,7 @@ out: * * @param type bus type * @param error address where an error can be returned. - * @returns a #DBusConnection with new ref + * @returns a #DBusConnection with new ref or #NULL on error */ DBusConnection * dbus_bus_get (DBusBusType type, -- cgit v1.2.1 From bc02680c698554b59d42b5c32b0cc65b06c8f70e Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 19 Aug 2013 21:29:18 +0200 Subject: Fixed compiler warning on windows. https://bugs.freedesktop.org/show_bug.cgi?id=61874 Reviewed-by: Simon McVittie --- tools/dbus-launch-win.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index 215fac3f..d899010a 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -159,8 +159,8 @@ main (int argc, char **argv) if (result == 0) { if (verbose) - fprintf (stderr, "Could not start " DBUS_DAEMON_NAME ". error=%d\n", - GetLastError ()); + fprintf (stderr, "Could not start " DBUS_DAEMON_NAME ". error=%u\n", + (unsigned)GetLastError ()); return 4; } -- cgit v1.2.1 From 039758ca6987ebd20f6535af3e06deac9cb604d3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Aug 2013 18:02:42 +0100 Subject: NEWS --- NEWS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/NEWS b/NEWS index 08b87d27..2c00a0ec 100644 --- a/NEWS +++ b/NEWS @@ -37,12 +37,18 @@ Fixes: • fix build failure with --enable-stats (fd.o #66004, Chengwei Yang) +• fix a regression test on platforms with strict alignment (fd.o #67279, + Colin Walters) + • Unix-specific: · dbus-run-session: compile on FreeBSD (fd.o #66197, Chengwei Yang) • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' (fd.o #42441, Ralf Habacker) + · Add support for looking up local TCPv4 clients' credentials on + Windows XP via the undocumented AllocateAndGetTcpExTableFromStack + function (fd.o #66060, Ralf Habacker) • Internal changes: · add DBUS_ENABLE_ASSERT, DBUS_ENABLE_CHECKS for less confusing -- cgit v1.2.1 From 5ad2668fb36e8ab2664e7a8f044f3a8b7ca96b0b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Aug 2013 18:03:24 +0100 Subject: NEWS for 1.6 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 150a5344..bef985ee 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,9 @@ Fixes: • If malloc() returns NULL in dbus_set_error(), don't va_end() a va_list that was never va_start()ed (fd.o #66300, Chengwei Yang) +• Fix a regression test on platforms with strict alignment (fd.o #67279, + Colin Walters) + D-Bus 1.6.12 (2013-06-13) == -- cgit v1.2.1 From 46af309cf5e3f4a0a8c773461b65a7bacb9e87e0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 19 Jul 2013 10:04:40 +0800 Subject: Fix build with "--enable-stats" Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- bus/stats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/stats.c b/bus/stats.c index 0c71a549..ec768ec7 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -165,7 +165,7 @@ bus_stats_handle_get_connection_stats (DBusConnection *caller_connection, bus_connection_get_n_services_owned (stats_connection)) || !_dbus_asv_add_uint32 (&arr_iter, "PeakBusNames", bus_connection_get_peak_bus_names (stats_connection)) || - !_dbus_asv_add_uint32 (&arr_iter, "UniqueName", + !_dbus_asv_add_string (&arr_iter, "UniqueName", bus_connection_get_name (stats_connection))) { _dbus_asv_abandon (&iter, &arr_iter); -- cgit v1.2.1 From 4b63567c02022cc3a5dc2f4ef03c7bd344766b43 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Aug 2013 18:21:58 +0100 Subject: GetConnectionCredentials: add The initial set of credentials is just UnixUserID and ProcessID. The rest can follow when someone is sufficiently interested to actually test them. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445 Reviewed-by: Ralf Habacker [rename a function that Ralf found unclear -smcv] Signed-off-by: Simon McVittie --- bus/driver.c | 77 +++++++++++++++++++++++++++ doc/dbus-specification.xml | 102 ++++++++++++++++++++++++++++++++++++ test/dbus-daemon.c | 127 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 306 insertions(+) diff --git a/bus/driver.c b/bus/driver.c index 01e56fb9..23197e43 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -33,6 +33,7 @@ #include "stats.h" #include "utils.h" +#include #include #include #include @@ -1523,6 +1524,80 @@ bus_driver_handle_get_connection_selinux_security_context (DBusConnection *conne return FALSE; } +static dbus_bool_t +bus_driver_handle_get_connection_credentials (DBusConnection *connection, + BusTransaction *transaction, + DBusMessage *message, + DBusError *error) +{ + DBusConnection *conn; + DBusMessage *reply; + DBusMessageIter reply_iter; + DBusMessageIter array_iter; + unsigned long ulong_val; + const char *service; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + reply = NULL; + + conn = bus_driver_get_conn_helper (connection, message, "credentials", + &service, error); + + if (conn == NULL) + goto failed; + + reply = _dbus_asv_new_method_return (message, &reply_iter, &array_iter); + if (reply == NULL) + goto oom; + + /* we can't represent > 32-bit pids; if your system needs them, please + * add ProcessID64 to the spec or something */ + if (dbus_connection_get_unix_process_id (conn, &ulong_val) && + ulong_val <= _DBUS_UINT32_MAX) + { + if (!_dbus_asv_add_uint32 (&array_iter, "ProcessID", ulong_val)) + goto oom; + } + + /* we can't represent > 32-bit uids; if your system needs them, please + * add UnixUserID64 to the spec or something */ + if (dbus_connection_get_unix_user (conn, &ulong_val) && + ulong_val <= _DBUS_UINT32_MAX) + { + if (!_dbus_asv_add_uint32 (&array_iter, "UnixUserID", ulong_val)) + goto oom; + } + + if (!_dbus_asv_close (&reply_iter, &array_iter)) + goto oom; + + if (! bus_transaction_send_from_driver (transaction, connection, reply)) + { + /* this time we don't want to close the iterator again, so just + * get rid of the message */ + dbus_message_unref (reply); + reply = NULL; + goto oom; + } + + return TRUE; + + oom: + BUS_SET_OOM (error); + + failed: + _DBUS_ASSERT_ERROR_IS_SET (error); + + if (reply) + { + _dbus_asv_abandon (&reply_iter, &array_iter); + dbus_message_unref (reply); + } + + return FALSE; +} + static dbus_bool_t bus_driver_handle_reload_config (DBusConnection *connection, BusTransaction *transaction, @@ -1703,6 +1778,8 @@ static const MessageHandler dbus_message_handlers[] = { "", DBUS_TYPE_STRING_AS_STRING, bus_driver_handle_get_id }, + { "GetConnectionCredentials", "s", "a{sv}", + bus_driver_handle_get_connection_credentials }, { NULL, NULL, NULL, NULL } }; diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 324dfd43..f5d8a348 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -5579,6 +5579,108 @@ + + <literal>org.freedesktop.DBus.GetConnectionCredentials</literal> + + As a method: + + DICT<STRING,VARIANT> GetConnectionCredentials (in STRING bus_name) + + Message arguments: + + + + + Argument + Type + Description + + + + + 0 + STRING + Unique or well-known bus name of the connection to + query, such as :12.34 or + com.example.tea + + + + + Reply arguments: + + + + + Argument + Type + Description + + + + + 0 + DICT<STRING,VARIANT> + Credentials + + + + + + + + Returns as many credentials as possible for the process connected to + the server. If unable to determine certain credentials (for instance, + because the process is not on the same machine as the bus daemon, + or because this version of the bus daemon does not support a + particular security framework), or if the values of those credentials + cannot be represented as documented here, then those credentials + are omitted. + + + + Keys in the returned dictionary not containing "." are defined + by this specification. Bus daemon implementors supporting + credentials frameworks not mentioned in this document should either + contribute patches to this specification, or use keys containing + "." and starting with a reversed domain name. + + + + + Key + Value type + Value + + + + + UnixUserID + UINT32 + The numeric Unix user ID, as defined by POSIX + + + ProcessID + UINT32 + The numeric process ID, on platforms that have + this concept. On Unix, this is the process ID defined by + POSIX. + + + + + + + + This method was added in D-Bus 1.7 to reduce the round-trips + required to list a process's credentials. In older versions, calling + this method will fail: applications should recover by using the + separate methods such as + + instead. + + + <literal>org.freedesktop.DBus.AddMatch</literal> diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index cc871530..69b6791e 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -39,6 +39,7 @@ #else # include # include +# include #endif typedef struct { @@ -309,6 +310,131 @@ test_echo (Fixture *f, count, elapsed); } +static void +pending_call_store_reply (DBusPendingCall *pc, + void *data) +{ + DBusMessage **message_p = data; + + *message_p = dbus_pending_call_steal_reply (pc); + g_assert (*message_p != NULL); +} + +static void +test_creds (Fixture *f, + gconstpointer context) +{ + const char *unique = dbus_bus_get_unique_name (f->left_conn); + DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetConnectionCredentials"); + DBusPendingCall *pc; + DBusMessageIter args_iter; + DBusMessageIter arr_iter; + DBusMessageIter pair_iter; + DBusMessageIter var_iter; + enum { + SEEN_UNIX_USER = 1, + SEEN_PID = 2, + SEEN_WINDOWS_SID = 4 + } seen = 0; + + if (m == NULL) + g_error ("OOM"); + + if (!dbus_message_append_args (m, + DBUS_TYPE_STRING, &unique, + DBUS_TYPE_INVALID)) + g_error ("OOM"); + + if (!dbus_connection_send_with_reply (f->left_conn, m, &pc, + DBUS_TIMEOUT_USE_DEFAULT) || + pc == NULL) + g_error ("OOM"); + + dbus_message_unref (m); + m = NULL; + + if (dbus_pending_call_get_completed (pc)) + pending_call_store_reply (pc, &m); + else if (!dbus_pending_call_set_notify (pc, pending_call_store_reply, + &m, NULL)) + g_error ("OOM"); + + while (m == NULL) + g_main_context_iteration (NULL, TRUE); + + g_assert_cmpstr (dbus_message_get_signature (m), ==, "a{sv}"); + + dbus_message_iter_init (m, &args_iter); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&args_iter), ==, + DBUS_TYPE_ARRAY); + g_assert_cmpuint (dbus_message_iter_get_element_type (&args_iter), ==, + DBUS_TYPE_DICT_ENTRY); + dbus_message_iter_recurse (&args_iter, &arr_iter); + + while (dbus_message_iter_get_arg_type (&arr_iter) != DBUS_TYPE_INVALID) + { + const char *name; + + dbus_message_iter_recurse (&arr_iter, &pair_iter); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&pair_iter), ==, + DBUS_TYPE_STRING); + dbus_message_iter_get_basic (&pair_iter, &name); + dbus_message_iter_next (&pair_iter); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&pair_iter), ==, + DBUS_TYPE_VARIANT); + dbus_message_iter_recurse (&pair_iter, &var_iter); + + if (g_strcmp0 (name, "UnixUserID") == 0) + { +#ifdef G_OS_UNIX + guint32 u32; + + g_assert (!(seen & SEEN_UNIX_USER)); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==, + DBUS_TYPE_UINT32); + dbus_message_iter_get_basic (&var_iter, &u32); + g_message ("%s of this process is %u", name, u32); + g_assert_cmpuint (u32, ==, geteuid ()); + seen |= SEEN_UNIX_USER; +#else + g_assert_not_reached (); +#endif + } + else if (g_strcmp0 (name, "ProcessID") == 0) + { + guint32 u32; + + g_assert (!(seen & SEEN_PID)); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==, + DBUS_TYPE_UINT32); + dbus_message_iter_get_basic (&var_iter, &u32); + g_message ("%s of this process is %u", name, u32); +#ifdef G_OS_UNIX + g_assert_cmpuint (u32, ==, getpid ()); +#elif defined(G_OS_WIN32) + g_assert_cmpuint (u32, ==, GetCurrentProcessId ()); +#else + g_assert_not_reached (); +#endif + seen |= SEEN_PID; + } + + dbus_message_iter_next (&arr_iter); + } + +#ifdef G_OS_UNIX + g_assert (seen & SEEN_UNIX_USER); + g_assert (seen & SEEN_PID); +#endif + +#ifdef G_OS_WIN32 + /* FIXME: when implemented: + g_assert (seen & SEEN_WINDOWS_SID); + */ +#endif +} + static void teardown (Fixture *f, gconstpointer context G_GNUC_UNUSED) @@ -363,6 +489,7 @@ main (int argc, g_test_add ("/echo/session", Fixture, NULL, setup, test_echo, teardown); g_test_add ("/echo/limited", Fixture, &limited_config, setup, test_echo, teardown); + g_test_add ("/creds", Fixture, NULL, setup, test_creds, teardown); return g_test_run (); } -- cgit v1.2.1 From 82d37b93ec777933a1b7ab8f8b2ad31a20d6af6b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Feb 2013 19:22:30 +0000 Subject: Document GetAdtAuditSessionData and GetConnectionSELinuxSecurityContext These are only part of the DBus interface because dbus-daemon didn't previously support multiple interfaces. I don't know enough about either of these security frameworks to know what they return, but perhaps one day someone who knows about Solaris or SELinux will tell us... Bug: https://bugs.freedesktop.org/show_bug.cgi?id=54445 Reviewed-by: Ralf Habacker --- doc/dbus-specification.xml | 117 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index f5d8a348..4eaa7206 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -5681,6 +5681,123 @@ + + <literal>org.freedesktop.DBus.GetAdtAuditSessionData</literal> + + As a method: + + ARRAY of BYTE GetAdtAuditSessionData (in STRING bus_name) + + Message arguments: + + + + + Argument + Type + Description + + + + + 0 + STRING + Unique or well-known bus name of the connection to + query, such as :12.34 or + com.example.tea + + + + + Reply arguments: + + + + + Argument + Type + Description + + + + + 0 + ARRAY of BYTE + auditing data as returned by + adt_export_session_data() + + + + + Returns auditing data used by Solaris ADT, in an unspecified + binary format. If you know what this means, please contribute + documentation via the D-Bus bug tracking system. + This method is on the core DBus interface for historical reasons; + the same information should be made available via + + in future. + + + + + <literal>org.freedesktop.DBus.GetConnectionSELinuxSecurityContext</literal> + + As a method: + + ARRAY of BYTE GetConnectionSELinuxSecurityContext (in STRING bus_name) + + Message arguments: + + + + + Argument + Type + Description + + + + + 0 + STRING + Unique or well-known bus name of the connection to + query, such as :12.34 or + com.example.tea + + + + + Reply arguments: + + + + + Argument + Type + Description + + + + + 0 + ARRAY of BYTE + some sort of string of bytes, not necessarily UTF-8, + not including '\0' + + + + + Returns the security context used by SELinux, in an unspecified + format. If you know what this means, please contribute + documentation via the D-Bus bug tracking system. + This method is on the core DBus interface for historical reasons; + the same information should be made available via + + in future. + + + + <literal>org.freedesktop.DBus.AddMatch</literal> -- cgit v1.2.1 From 0928169cf80bf767f7246ecaa52cc01e198bb15a Mon Sep 17 00:00:00 2001 From: Ivan Romanov Date: Thu, 22 Aug 2013 19:11:23 +0100 Subject: Use iface instead of interface in function parameters Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66493 Reviewed-by: Simon McVittie --- dbus/dbus-message.c | 62 ++++++++++++++++++++++++++--------------------------- dbus/dbus-message.h | 12 +++++------ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 5d3517c6..079251ea 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -1259,7 +1259,7 @@ dbus_message_new (int message_type) * * @param destination name that the message should be sent to or #NULL * @param path object path the message should be sent to - * @param interface interface to invoke method on, or #NULL + * @param iface interface to invoke method on, or #NULL * @param method method to invoke * * @returns a new DBusMessage, free with dbus_message_unref() @@ -1267,7 +1267,7 @@ dbus_message_new (int message_type) DBusMessage* dbus_message_new_method_call (const char *destination, const char *path, - const char *interface, + const char *iface, const char *method) { DBusMessage *message; @@ -1277,8 +1277,8 @@ dbus_message_new_method_call (const char *destination, _dbus_return_val_if_fail (destination == NULL || _dbus_check_is_valid_bus_name (destination), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_path (path), NULL); - _dbus_return_val_if_fail (interface == NULL || - _dbus_check_is_valid_interface (interface), NULL); + _dbus_return_val_if_fail (iface == NULL || + _dbus_check_is_valid_interface (iface), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_member (method), NULL); message = dbus_message_new_empty_header (); @@ -1288,7 +1288,7 @@ dbus_message_new_method_call (const char *destination, if (!_dbus_header_create (&message->header, DBUS_COMPILER_BYTE_ORDER, DBUS_MESSAGE_TYPE_METHOD_CALL, - destination, path, interface, method, NULL)) + destination, path, iface, method, NULL)) { dbus_message_unref (message); return NULL; @@ -1351,22 +1351,22 @@ dbus_message_new_method_return (DBusMessage *method_call) * specification defines the syntax of these fields). * * @param path the path to the object emitting the signal - * @param interface the interface the signal is emitted from + * @param iface the interface the signal is emitted from * @param name name of the signal * @returns a new DBusMessage, free with dbus_message_unref() */ DBusMessage* dbus_message_new_signal (const char *path, - const char *interface, + const char *iface, const char *name) { DBusMessage *message; _dbus_return_val_if_fail (path != NULL, NULL); - _dbus_return_val_if_fail (interface != NULL, NULL); + _dbus_return_val_if_fail (iface != NULL, NULL); _dbus_return_val_if_fail (name != NULL, NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_path (path), NULL); - _dbus_return_val_if_fail (_dbus_check_is_valid_interface (interface), NULL); + _dbus_return_val_if_fail (_dbus_check_is_valid_interface (iface), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_member (name), NULL); message = dbus_message_new_empty_header (); @@ -1376,7 +1376,7 @@ dbus_message_new_signal (const char *path, if (!_dbus_header_create (&message->header, DBUS_COMPILER_BYTE_ORDER, DBUS_MESSAGE_TYPE_SIGNAL, - NULL, path, interface, name, NULL)) + NULL, path, iface, name, NULL)) { dbus_message_unref (message); return NULL; @@ -3126,23 +3126,23 @@ dbus_message_get_path_decomposed (DBusMessage *message, * in the D-Bus specification. * * @param message the message - * @param interface the interface or #NULL to unset + * @param iface the interface or #NULL to unset * @returns #FALSE if not enough memory */ dbus_bool_t dbus_message_set_interface (DBusMessage *message, - const char *interface) + const char *iface) { _dbus_return_val_if_fail (message != NULL, FALSE); _dbus_return_val_if_fail (!message->locked, FALSE); - _dbus_return_val_if_fail (interface == NULL || - _dbus_check_is_valid_interface (interface), + _dbus_return_val_if_fail (iface == NULL || + _dbus_check_is_valid_interface (iface), FALSE); return set_or_delete_string_field (message, DBUS_HEADER_FIELD_INTERFACE, DBUS_TYPE_STRING, - interface); + iface); } /** @@ -3177,28 +3177,28 @@ dbus_message_get_interface (DBusMessage *message) * Checks if the message has an interface * * @param message the message - * @param interface the interface name + * @param iface the interface name * @returns #TRUE if the interface field in the header matches */ dbus_bool_t dbus_message_has_interface (DBusMessage *message, - const char *interface) + const char *iface) { const char *msg_interface; msg_interface = dbus_message_get_interface (message); if (msg_interface == NULL) { - if (interface == NULL) + if (iface == NULL) return TRUE; else return FALSE; } - if (interface == NULL) + if (iface == NULL) return FALSE; - if (strcmp (msg_interface, interface) == 0) + if (strcmp (msg_interface, iface) == 0) return TRUE; return FALSE; @@ -3490,13 +3490,13 @@ dbus_message_get_signature (DBusMessage *message) static dbus_bool_t _dbus_message_has_type_interface_member (DBusMessage *message, int type, - const char *interface, + const char *iface, const char *member) { const char *n; _dbus_assert (message != NULL); - _dbus_assert (interface != NULL); + _dbus_assert (iface != NULL); _dbus_assert (member != NULL); if (dbus_message_get_type (message) != type) @@ -3512,7 +3512,7 @@ _dbus_message_has_type_interface_member (DBusMessage *message, { n = dbus_message_get_interface (message); - if (n == NULL || strcmp (n, interface) == 0) + if (n == NULL || strcmp (n, iface) == 0) return TRUE; } @@ -3528,18 +3528,18 @@ _dbus_message_has_type_interface_member (DBusMessage *message, * protocol allows method callers to leave out the interface name. * * @param message the message - * @param interface the name to check (must not be #NULL) + * @param iface the name to check (must not be #NULL) * @param method the name to check (must not be #NULL) * * @returns #TRUE if the message is the specified method call */ dbus_bool_t dbus_message_is_method_call (DBusMessage *message, - const char *interface, + const char *iface, const char *method) { _dbus_return_val_if_fail (message != NULL, FALSE); - _dbus_return_val_if_fail (interface != NULL, FALSE); + _dbus_return_val_if_fail (iface != NULL, FALSE); _dbus_return_val_if_fail (method != NULL, FALSE); /* don't check that interface/method are valid since it would be * expensive, and not catch many common errors @@ -3547,7 +3547,7 @@ dbus_message_is_method_call (DBusMessage *message, return _dbus_message_has_type_interface_member (message, DBUS_MESSAGE_TYPE_METHOD_CALL, - interface, method); + iface, method); } /** @@ -3556,18 +3556,18 @@ dbus_message_is_method_call (DBusMessage *message, * has a different interface or member field, returns #FALSE. * * @param message the message - * @param interface the name to check (must not be #NULL) + * @param iface the name to check (must not be #NULL) * @param signal_name the name to check (must not be #NULL) * * @returns #TRUE if the message is the specified signal */ dbus_bool_t dbus_message_is_signal (DBusMessage *message, - const char *interface, + const char *iface, const char *signal_name) { _dbus_return_val_if_fail (message != NULL, FALSE); - _dbus_return_val_if_fail (interface != NULL, FALSE); + _dbus_return_val_if_fail (iface != NULL, FALSE); _dbus_return_val_if_fail (signal_name != NULL, FALSE); /* don't check that interface/name are valid since it would be * expensive, and not catch many common errors @@ -3575,7 +3575,7 @@ dbus_message_is_signal (DBusMessage *message, return _dbus_message_has_type_interface_member (message, DBUS_MESSAGE_TYPE_SIGNAL, - interface, signal_name); + iface, signal_name); } /** diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h index 5500492d..4fd44dab 100644 --- a/dbus/dbus-message.h +++ b/dbus/dbus-message.h @@ -71,13 +71,13 @@ DBusMessage* dbus_message_new (int message_type); DBUS_EXPORT DBusMessage* dbus_message_new_method_call (const char *bus_name, const char *path, - const char *interface, + const char *iface, const char *method); DBUS_EXPORT DBusMessage* dbus_message_new_method_return (DBusMessage *method_call); DBUS_EXPORT DBusMessage* dbus_message_new_signal (const char *path, - const char *interface, + const char *iface, const char *name); DBUS_EXPORT DBusMessage* dbus_message_new_error (DBusMessage *reply_to, @@ -108,12 +108,12 @@ dbus_bool_t dbus_message_has_path (DBusMessage *message, const char *object_path); DBUS_EXPORT dbus_bool_t dbus_message_set_interface (DBusMessage *message, - const char *interface); + const char *iface); DBUS_EXPORT const char* dbus_message_get_interface (DBusMessage *message); DBUS_EXPORT dbus_bool_t dbus_message_has_interface (DBusMessage *message, - const char *interface); + const char *iface); DBUS_EXPORT dbus_bool_t dbus_message_set_member (DBusMessage *message, const char *member); @@ -146,11 +146,11 @@ DBUS_EXPORT dbus_bool_t dbus_message_get_no_reply (DBusMessage *message); DBUS_EXPORT dbus_bool_t dbus_message_is_method_call (DBusMessage *message, - const char *interface, + const char *iface, const char *method); DBUS_EXPORT dbus_bool_t dbus_message_is_signal (DBusMessage *message, - const char *interface, + const char *iface, const char *signal_name); DBUS_EXPORT dbus_bool_t dbus_message_is_error (DBusMessage *message, -- cgit v1.2.1 From 15bc915d7469233eeed997044f79bd619b62bd4e Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 20 Jun 2013 22:03:49 +0800 Subject: Doc: fix incorrect param names, missing params, non-exist params Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65755 --- dbus/dbus-connection.c | 7 ++++--- dbus/dbus-keyring.c | 6 +++--- dbus/dbus-marshal-header.c | 4 +++- dbus/dbus-message.c | 9 ++++----- dbus/dbus-object-tree.c | 1 + dbus/dbus-syntax.c | 8 ++++---- dbus/dbus-sysdeps-unix.c | 3 +++ dbus/dbus-sysdeps-util-unix.c | 2 -- dbus/dbus-sysdeps-util-win.c | 4 +--- dbus/dbus-sysdeps-win.c | 8 ++++---- dbus/dbus-sysdeps-wince-glue.c | 2 +- dbus/dbus-test.c | 1 + dbus/dbus-transport-socket.c | 2 +- dbus/dbus-transport.c | 2 ++ 14 files changed, 32 insertions(+), 27 deletions(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 86adaa55..a471ea6b 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -5230,7 +5230,8 @@ dbus_connection_get_unix_process_id (DBusConnection *connection, * connection. * * @param connection the connection - * @param data return location for audit data + * @param data return location for audit data + * @param data_size return location for length of audit data * @returns #TRUE if audit data is filled in with a valid ucred pointer */ dbus_bool_t @@ -6068,7 +6069,7 @@ dbus_connection_get_max_message_size (DBusConnection *connection) * result in disconnecting the connection. * * @param connection a #DBusConnection - * @param size maximum message unix fds the connection can receive + * @param n maximum message unix fds the connection can receive */ void dbus_connection_set_max_message_unix_fds (DBusConnection *connection, @@ -6166,7 +6167,7 @@ dbus_connection_get_max_received_size (DBusConnection *connection) * The semantics are analogous to those of dbus_connection_set_max_received_size(). * * @param connection the connection - * @param size the maximum size in bytes of all outstanding messages + * @param n the maximum size in bytes of all outstanding messages */ void dbus_connection_set_max_received_unix_fds (DBusConnection *connection, diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 0e433a8f..f0c64de3 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -697,10 +697,10 @@ _dbus_keyring_unref (DBusKeyring *keyring) /** * Creates a new keyring that lives in the ~/.dbus-keyrings directory - * of the given user credentials. If the credentials are #NULL or - * empty, uses those of the current process. + * of the user represented by @p credentials. If the @p credentials are + * #NULL or empty, uses those of the current process. * - * @param username username to get keyring for, or #NULL + * @param credentials a set of credentials representing a user or #NULL * @param context which keyring to get * @param error return location for errors * @returns the keyring or #NULL on error diff --git a/dbus/dbus-marshal-header.c b/dbus/dbus-marshal-header.c index 88887a82..48151c62 100644 --- a/dbus/dbus-marshal-header.c +++ b/dbus/dbus-marshal-header.c @@ -276,6 +276,7 @@ _dbus_header_cache_known_nonexistent (DBusHeader *header, * Writes a struct of { byte, variant } with the given basic type. * * @param writer the writer (should be ready to write a struct) + * @param field the header field * @param type the type of the value * @param value the value as for _dbus_marshal_set_basic() * @returns #FALSE if no memory @@ -336,6 +337,7 @@ write_basic_field (DBusTypeWriter *writer, * Sets a struct of { byte, variant } with the given basic type. * * @param reader the reader (should be iterating over the array pointing at the field to set) + * @param field the header field * @param type the type of the value * @param value the value as for _dbus_marshal_set_basic() * @param realign_root where to realign from @@ -452,7 +454,6 @@ _dbus_header_reinit (DBusHeader *header) * to make the header valid, you have to call _dbus_header_create(). * * @param header header to initialize - * @param byte_order byte order of the header * @returns #FALSE if not enough memory */ dbus_bool_t @@ -514,6 +515,7 @@ _dbus_header_copy (const DBusHeader *header, * sense, and passing them in will trigger an assertion failure. * * @param header the header + * @param byte_order byte order of the header * @param message_type the message type * @param destination destination field or #NULL * @param path path field or #NULL diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 079251ea..20c8be35 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -3981,7 +3981,7 @@ _dbus_message_loader_get_unix_fds(DBusMessageLoader *loader, * * @param loader the message loader. * @param fds the array fds were read into - * @param max_n_fds how many fds were read + * @param n_fds how many fds were read */ void @@ -4409,7 +4409,7 @@ _dbus_message_loader_get_max_message_size (DBusMessageLoader *loader) * Sets the maximum unix fds per message we allow. * * @param loader the loader - * @param size the max number of unix fds in a message + * @param n the max number of unix fds in a message */ void _dbus_message_loader_set_max_message_unix_fds (DBusMessageLoader *loader, @@ -4729,9 +4729,8 @@ dbus_message_demarshal (const char *str, * Generally, this function is only useful for encapsulating D-Bus messages in * a different protocol. * - * @param str data to be marshalled - * @param len the length of str - * @param error the location to save errors to + * @param buf data to be marshalled + * @param len the length of @p buf * @returns -1 if there was no valid data to be demarshalled, 0 if there wasn't enough data to determine how much should be demarshalled. Otherwise returns the number of bytes to be demarshalled * */ diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 086fc64a..f6ae19de 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -741,6 +741,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, * * @param tree the global object tree * @param message the message to dispatch + * @param found_object return location for the object * @returns whether message was handled successfully */ DBusHandlerResult diff --git a/dbus/dbus-syntax.c b/dbus/dbus-syntax.c index 47922875..7ef659cb 100644 --- a/dbus/dbus-syntax.c +++ b/dbus/dbus-syntax.c @@ -93,7 +93,7 @@ dbus_validate_path (const char *path, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid interface name, which must not be #NULL + * @param name a potentially invalid interface name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ @@ -140,7 +140,7 @@ dbus_validate_interface (const char *name, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid member name, which must not be #NULL + * @param name a potentially invalid member name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ @@ -187,7 +187,7 @@ dbus_validate_member (const char *name, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid error name, which must not be #NULL + * @param name a potentially invalid error name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ @@ -234,7 +234,7 @@ dbus_validate_error_name (const char *name, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid bus name, which must not be #NULL + * @param name a potentially invalid bus name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index c2e6f9fc..66f55d75 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -2929,6 +2929,7 @@ _dbus_close (int fd, * (i.e. avoids stdin/stdout/stderr). Sets O_CLOEXEC. * * @param fd the file descriptor to duplicate + * @param error address of error location. * @returns duplicated file descriptor * */ int @@ -3441,6 +3442,7 @@ _read_subprocess_line_argv (const char *progpath, * address. If a failure happens, returns #FALSE and * sets an error in @p error. * + * @param scope scope of autolaunch (Windows only) * @param address a DBusString where the address can be stored * @param error a DBusError to store the error in case of failure * @returns #TRUE on success, #FALSE if an error happened @@ -3569,6 +3571,7 @@ _dbus_read_local_machine_uuid (DBusGUID *machine_id, /** * quries launchd for a specific env var which holds the socket path. + * @param socket_path append the socket path to this DBusString * @param launchd_env_var the env var to look up * @param error a DBusError to store the error in case of failure * @return the value of the env var diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 6053265b..9ad63b43 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -449,8 +449,6 @@ _dbus_init_system_log (dbus_bool_t is_daemon) * * @param severity a severity value * @param msg a printf-style format string - * @param args arguments for the format string - * */ void _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index abb10f70..71ed8b79 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -54,7 +54,7 @@ * Does the chdir, fork, setsid, etc. to become a daemon process. * * @param pidfile #NULL, or pidfile to create - * @param print_pid_fd file descriptor to print daemon's pid to, or -1 for none + * @param print_pid_pipe file descriptor to print daemon's pid to, or -1 for none * @param error return location for errors * @param keep_umask #TRUE to keep the original umask * @returns #FALSE on failure @@ -272,8 +272,6 @@ _dbus_init_system_log (dbus_bool_t is_daemon) * * @param severity a severity value * @param msg a printf-style format string - * @param args arguments for the format string - * */ void _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 20ecb4eb..38758bd4 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -522,7 +522,7 @@ _dbus_close_socket (int fd, * on exec. Should be called for all file * descriptors in D-Bus code. * - * @param fd the file descriptor + * @param handle the Windows HANDLE */ void _dbus_fd_set_close_on_exec (intptr_t handle) @@ -538,7 +538,7 @@ _dbus_fd_set_close_on_exec (intptr_t handle) /** * Sets a file descriptor to be nonblocking. * - * @param fd the file descriptor. + * @param handle the file descriptor. * @param error address of error location. * @returns #TRUE on success. */ @@ -1909,7 +1909,7 @@ again: * The point of the byte is that on some systems we have to * use sendmsg()/recvmsg() to transmit credentials. * - * @param client_fd the client file descriptor + * @param handle the client file descriptor * @param credentials struct to fill with credentials of client * @param error location to store error code * @returns #TRUE on success @@ -3418,7 +3418,7 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) /** * return the absolute path of the dbus installation * - * @param s buffer for installation path + * @param prefix buffer for installation path * @param len length of buffer * @returns #FALSE on failure */ diff --git a/dbus/dbus-sysdeps-wince-glue.c b/dbus/dbus-sysdeps-wince-glue.c index 74b1371f..e276f046 100644 --- a/dbus/dbus-sysdeps-wince-glue.c +++ b/dbus/dbus-sysdeps-wince-glue.c @@ -491,7 +491,7 @@ SearchPathA (LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, /** Gets our SID - * @param points to sid buffer, need to be freed with LocalFree() + * @param sid points to sid buffer, need to be freed with LocalFree() * @returns process sid */ dbus_bool_t diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c index 1539bce9..b707ee22 100644 --- a/dbus/dbus-test.c +++ b/dbus/dbus-test.c @@ -94,6 +94,7 @@ run_data_test (const char *test_name, * (with --enable-tests=no) * * @param test_data_dir the directory with test data (test/data normally) + * @param specific_test run specific test or #NULL to run all tests */ void dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *specific_test) diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 544d00a9..acb91cf8 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -1299,7 +1299,7 @@ _dbus_transport_new_for_socket (int fd, * @param host the host to connect to * @param port the port to connect to * @param family the address family to connect to - * @param path to nonce file + * @param noncefile path to nonce file * @param error location to store reason for failure. * @returns a new transport, or #NULL on failure. */ diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index fff76cc4..47437f21 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -242,6 +242,7 @@ _dbus_transport_finalize_base (DBusTransport *transport) * opened DBusTransport object. If it isn't, returns #NULL * and sets @p error. * + * @param address the address to be checked. * @param error address where an error can be returned. * @returns a new transport, or #NULL on failure. */ @@ -272,6 +273,7 @@ check_address (const char *address, DBusError *error) * Creates a new transport for the "autostart" method. * This creates a client-side of a transport. * + * @param scope scope of autolaunch (Windows only) * @param error address where an error can be returned. * @returns a new transport, or #NULL on failure. */ -- cgit v1.2.1 From 014ea556251259cd3c6965b78b42ebb903291e77 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 27 Jun 2013 12:56:20 +0800 Subject: Ignore more unused staff if build with tests but without asserts https://bugs.freedesktop.org/show_bug.cgi?id=66069 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index c80fcfcb..8caea402 100644 --- a/configure.ac +++ b/configure.ac @@ -273,6 +273,11 @@ if test x$enable_asserts = xno; then AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking]) DISABLE_UNUSED_WARNINGS="unused-label" R_DYNAMIC_LDFLAG="" + if test x$enable_embedded_tests = xyes; then + DISABLE_UNUSED_WARNINGS="$DISABLE_UNUSED_WARNINGS \ + unused-but-set-variable unused-variable \ + unused-function" + fi else # -rdynamic is needed for glibc's backtrace_symbols to work. # No clue how much overhead this adds, but it's useful -- cgit v1.2.1 From 4bb8b5629382f346f55e67cf466784b68dbe00ae Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 2 Jul 2013 13:31:38 +0800 Subject: DBus Spec: Fix sample service file There are two errors in the sample service file. First, a typo, Names should be Name. Second, can not specify multiple names. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66481 Signed-off-by: Chengwei Yang Reviewed-by: Simon McVittie --- doc/dbus-specification.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 4eaa7206..65abd29f 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -4659,7 +4659,7 @@ # Sample service description file [D-BUS Service] - Names=org.freedesktop.ConfigurationDatabase;org.gnome.GConf; + Name=org.freedesktop.ConfigurationDatabase Exec=/usr/libexec/gconfd-2 -- cgit v1.2.1 From c1daecad31899256f0fc8ed77e30fd5278015226 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 12 Jul 2013 11:34:31 +0800 Subject: Move function to the right place where it supposed to be used Reviewed-by: Simon McVittie --- dbus/dbus-mainloop.c | 21 --------------------- dbus/dbus-watch.c | 43 ++++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 42 deletions(-) diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 457242db..8b4da164 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -34,27 +34,6 @@ #define MAINLOOP_SPEW 0 -#if MAINLOOP_SPEW -#ifdef DBUS_ENABLE_VERBOSE_MODE -static const char* -watch_flags_to_string (int flags) -{ - const char *watch_type; - - if ((flags & DBUS_WATCH_READABLE) && - (flags & DBUS_WATCH_WRITABLE)) - watch_type = "readwrite"; - else if (flags & DBUS_WATCH_READABLE) - watch_type = "read"; - else if (flags & DBUS_WATCH_WRITABLE) - watch_type = "write"; - else - watch_type = "not read or write"; - return watch_type; -} -#endif /* DBUS_ENABLE_VERBOSE_MODE */ -#endif /* MAINLOOP_SPEW */ - struct DBusLoop { int refcount; diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c index b9f4ac23..b82c57d4 100644 --- a/dbus/dbus-watch.c +++ b/dbus/dbus-watch.c @@ -259,6 +259,25 @@ _dbus_watch_list_free (DBusWatchList *watch_list) dbus_free (watch_list); } +#ifdef DBUS_ENABLE_VERBOSE_MODE +static const char* +watch_flags_to_string (int flags) +{ + const char *watch_type; + + if ((flags & DBUS_WATCH_READABLE) && + (flags & DBUS_WATCH_WRITABLE)) + watch_type = "readwrite"; + else if (flags & DBUS_WATCH_READABLE) + watch_type = "read"; + else if (flags & DBUS_WATCH_WRITABLE) + watch_type = "write"; + else + watch_type = "not read or write"; + return watch_type; +} +#endif /* DBUS_ENABLE_VERBOSE_MODE */ + /** * Sets the watch functions. This function is the "backend" * for dbus_connection_set_watch_functions() and @@ -292,27 +311,9 @@ _dbus_watch_list_set_functions (DBusWatchList *watch_list, DBusList *next = _dbus_list_get_next_link (&watch_list->watches, link); -#ifdef DBUS_ENABLE_VERBOSE_MODE - { - const char *watch_type; - int flags; - - flags = dbus_watch_get_flags (link->data); - if ((flags & DBUS_WATCH_READABLE) && - (flags & DBUS_WATCH_WRITABLE)) - watch_type = "readwrite"; - else if (flags & DBUS_WATCH_READABLE) - watch_type = "read"; - else if (flags & DBUS_WATCH_WRITABLE) - watch_type = "write"; - else - watch_type = "not read or write"; - - _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", - watch_type, - dbus_watch_get_socket (link->data)); - } -#endif /* DBUS_ENABLE_VERBOSE_MODE */ + _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", + watch_flags_to_string (dbus_watch_get_flags (link->data)), + dbus_watch_get_socket (link->data)); if (!(* add_function) (link->data, data)) { -- cgit v1.2.1 From df537d3f9f8c9c6e81f0ae0c233cd4555acdf61b Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 16 Jul 2013 14:34:59 +0800 Subject: Fix reference doc in comments --- dbus/dbus-auth.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index d2c37a7a..a0f72773 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -2238,8 +2238,8 @@ process_command (DBusAuth *auth) /** * Creates a new auth conversation object for the server side. - * See doc/dbus-sasl-profile.txt for full details on what - * this object does. + * See http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * for full details on what this object does. * * @returns the new object or #NULL if no memory */ @@ -2284,8 +2284,8 @@ _dbus_auth_server_new (const DBusString *guid) /** * Creates a new auth conversation object for the client side. - * See doc/dbus-sasl-profile.txt for full details on what - * this object does. + * See http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * for full details on what this object does. * * @returns the new object or #NULL if no memory */ -- cgit v1.2.1 From d6432126514fd496d57f03311b3d471c627d8b4a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Aug 2013 20:46:51 +0100 Subject: More NEWS --- NEWS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/NEWS b/NEWS index 2c00a0ec..e9eff4f9 100644 --- a/NEWS +++ b/NEWS @@ -15,12 +15,19 @@ Build-time configuration changes: Enhancements: +• D-Bus Specification 0.22 + · Document GetAdtAuditSessionData() and + GetConnectionSELinuxSecurityContext() (fd.o #54445, Simon) + · Fix example .service file (fd.o #66481, Chengwei Yang) + • Be thread-safe by default on all platforms, even if dbus_threads_init_default() has not been called. For compatibility with older libdbus, library users should continue to call dbus_threads_init_default(): it is harmless to do so. (fd.o #54972, Simon McVittie) +• Add GetConnectionCredentials() method (fd.o #54445, Simon) + Fixes: • Escape addresses containing non-ASCII characters correctly @@ -40,6 +47,11 @@ Fixes: • fix a regression test on platforms with strict alignment (fd.o #67279, Colin Walters) +• Avoid calling function parameters "interface" since certain Windows headers + have a namespace-polluting macro of that name (fd.o #66493, Ivan Romanov) + +• Assorted Doxygen fixes (fd.o #65755, Chengwei Yang) + • Unix-specific: · dbus-run-session: compile on FreeBSD (fd.o #66197, Chengwei Yang) -- cgit v1.2.1 From 1809c7ad2a72b7186bbff0180aaae72337055829 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Tue, 11 Oct 2011 16:41:31 +0100 Subject: Unset/free also windows user function, finalizing the connection It's currently not used, but it's safer to unset it and free user's data for avoiding future head-aches https://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Simon McVittie --- dbus/dbus-connection.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index a471ea6b..51c0a25c 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -2707,6 +2707,7 @@ _dbus_connection_last_unref (DBusConnection *connection) dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); dbus_connection_set_wakeup_main_function (connection, NULL, NULL, NULL); dbus_connection_set_unix_user_function (connection, NULL, NULL, NULL); + dbus_connection_set_windows_user_function (connection, NULL, NULL, NULL); _dbus_watch_list_free (connection->watches); connection->watches = NULL; -- cgit v1.2.1 From 36bb2125d1dbca0ee30fbe29090c4a6a7be37854 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 00:43:02 +0200 Subject: Fix confusion between "is it authenticated?" and "try to authenticate" Historically, _dbus_transport_get_is_authenticated() has had the side-effect of trying to advance the authentication state machine (if there's enough buffered input to do so). This seems an inappropriate activity for what looks like a simple getter. Split it into _dbus_transport_try_to_authenticate (which does what it always used to do) and _dbus_transport_peek_is_authenticated (which is the simple getter version). To minimize the difference in behaviour for the stable branch of D-Bus, I've only used _dbus_transport_peek_is_authenticated where it was used in an assertion, which should clearly not have side effects (and I've checked that the asserting function cannot be called until both authentication and authorization have completed). Replacing most of the calls to get_is_authenticated with try_to_authenticate is a possible piece of future work. Based on patches from Cosimo Alfarano, who noticed this assertion-with-side-effects. Signed-off-by: Simon McVittie https://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Cosimo Alfarano --- dbus/dbus-connection.c | 26 +++++++++++++------------- dbus/dbus-transport-protected.h | 2 +- dbus/dbus-transport-socket.c | 16 ++++++++-------- dbus/dbus-transport.c | 33 ++++++++++++++++++++++++++++----- dbus/dbus-transport.h | 3 ++- 5 files changed, 52 insertions(+), 28 deletions(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 51c0a25c..a6caaea6 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -490,9 +490,9 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection, DBusPendingCall *pending; dbus_uint32_t reply_serial; DBusMessage *message; - - _dbus_assert (_dbus_transport_get_is_authenticated (connection->transport)); - + + _dbus_assert (_dbus_transport_peek_is_authenticated (connection->transport)); + _dbus_list_append_link (&connection->incoming_messages, link); message = link->data; @@ -2977,9 +2977,9 @@ dbus_connection_get_is_authenticated (DBusConnection *connection) dbus_bool_t res; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); - res = _dbus_transport_get_is_authenticated (connection->transport); + res = _dbus_transport_try_to_authenticate (connection->transport); CONNECTION_UNLOCK (connection); return res; @@ -5174,10 +5174,10 @@ dbus_connection_get_unix_user (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (uid != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_unix_user (connection->transport, @@ -5210,10 +5210,10 @@ dbus_connection_get_unix_process_id (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (pid != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_unix_process_id (connection->transport, @@ -5245,10 +5245,10 @@ dbus_connection_get_adt_audit_session_data (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (data != NULL, FALSE); _dbus_return_val_if_fail (data_size != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_adt_audit_session_data (connection->transport, @@ -5341,10 +5341,10 @@ dbus_connection_get_windows_user (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (windows_sid_p != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_windows_user (connection->transport, diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h index 44b9d785..396f0ffd 100644 --- a/dbus/dbus-transport-protected.h +++ b/dbus/dbus-transport-protected.h @@ -111,7 +111,7 @@ struct DBusTransport DBusFreeFunction free_windows_user_data; /**< Function to free windows_user_data */ unsigned int disconnected : 1; /**< #TRUE if we are disconnected. */ - unsigned int authenticated : 1; /**< Cache of auth state; use _dbus_transport_get_is_authenticated() to query value */ + unsigned int authenticated : 1; /**< Cache of auth state; use _dbus_transport_peek_is_authenticated() to query value */ unsigned int send_credentials_pending : 1; /**< #TRUE if we need to send credentials */ unsigned int receive_credentials_pending : 1; /**< #TRUE if we need to receive credentials */ unsigned int is_server : 1; /**< #TRUE if on the server side */ diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index acb91cf8..c7c62918 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -135,7 +135,7 @@ check_write_watch (DBusTransport *transport) _dbus_transport_ref (transport); - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) needed = _dbus_connection_has_messages_to_send_unlocked (transport->connection); else { @@ -190,7 +190,7 @@ check_read_watch (DBusTransport *transport) _dbus_transport_ref (transport); - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) need_read_watch = (_dbus_counter_get_size_value (transport->live_messages) < transport->max_live_messages_size) && (_dbus_counter_get_unix_fd_value (transport->live_messages) < transport->max_live_messages_unix_fds); @@ -404,7 +404,7 @@ do_authentication (DBusTransport *transport, oom = FALSE; - orig_auth_state = _dbus_transport_get_is_authenticated (transport); + orig_auth_state = _dbus_transport_try_to_authenticate (transport); /* This is essential to avoid the check_write_watch() at the end, * we don't want to add a write watch in do_iteration before @@ -419,7 +419,7 @@ do_authentication (DBusTransport *transport, _dbus_transport_ref (transport); - while (!_dbus_transport_get_is_authenticated (transport) && + while (!_dbus_transport_try_to_authenticate (transport) && _dbus_transport_get_is_connected (transport)) { if (!exchange_credentials (transport, do_reading, do_writing)) @@ -477,7 +477,7 @@ do_authentication (DBusTransport *transport, out: if (auth_completed) - *auth_completed = (orig_auth_state != _dbus_transport_get_is_authenticated (transport)); + *auth_completed = (orig_auth_state != _dbus_transport_try_to_authenticate (transport)); check_read_watch (transport); check_write_watch (transport); @@ -498,7 +498,7 @@ do_writing (DBusTransport *transport) dbus_bool_t oom; /* No messages without authentication! */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) { _dbus_verbose ("Not authenticated, not writing anything\n"); return TRUE; @@ -703,7 +703,7 @@ do_reading (DBusTransport *transport) _dbus_verbose ("fd = %d\n",socket_transport->fd); /* No messages without authentication! */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) return TRUE; oom = FALSE; @@ -1055,7 +1055,7 @@ socket_do_iteration (DBusTransport *transport, poll_fd.fd = socket_transport->fd; poll_fd.events = 0; - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) { /* This is kind of a hack; if we have stuff to write, then try * to avoid the poll. This is probably about a 5% speedup on an diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 47437f21..e68a9f03 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -686,10 +686,33 @@ auth_via_default_rules (DBusTransport *transport) return allow; } +/** + * Returns #TRUE if we have been authenticated. It will return #TRUE even if + * the transport is now disconnected, but was ever authenticated before + * disconnecting. + * + * This replaces the older _dbus_transport_get_is_authenticated() which + * had side-effects. + * + * @param transport the transport + * @returns whether we're authenticated + */ +dbus_bool_t +_dbus_transport_peek_is_authenticated (DBusTransport *transport) +{ + return transport->authenticated; +} /** - * Returns #TRUE if we have been authenticated. Will return #TRUE - * even if the transport is disconnected. + * Returns #TRUE if we have been authenticated. It will return #TRUE even if + * the transport is now disconnected, but was ever authenticated before + * disconnecting. + * + * If we have not finished authenticating, but we have enough buffered input + * to finish the job, then this function will do so before it returns. + * + * This used to be called _dbus_transport_get_is_authenticated(), but that + * name seems inappropriate for a function with side-effects. * * @todo we drop connection->mutex when calling the unix_user_function, * and windows_user_function, which may not be safe really. @@ -698,7 +721,7 @@ auth_via_default_rules (DBusTransport *transport) * @returns whether we're authenticated */ dbus_bool_t -_dbus_transport_get_is_authenticated (DBusTransport *transport) +_dbus_transport_try_to_authenticate (DBusTransport *transport) { if (transport->authenticated) return TRUE; @@ -1085,12 +1108,12 @@ _dbus_transport_get_dispatch_status (DBusTransport *transport) _dbus_counter_get_unix_fd_value (transport->live_messages) >= transport->max_live_messages_unix_fds) return DBUS_DISPATCH_COMPLETE; /* complete for now */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) { if (_dbus_auth_do_work (transport->auth) == DBUS_AUTH_STATE_WAITING_FOR_MEMORY) return DBUS_DISPATCH_NEED_MEMORY; - else if (!_dbus_transport_get_is_authenticated (transport)) + else if (!_dbus_transport_try_to_authenticate (transport)) return DBUS_DISPATCH_COMPLETE; } diff --git a/dbus/dbus-transport.h b/dbus/dbus-transport.h index 4b821517..80fa24ef 100644 --- a/dbus/dbus-transport.h +++ b/dbus/dbus-transport.h @@ -38,7 +38,8 @@ DBusTransport* _dbus_transport_ref (DBusTransport void _dbus_transport_unref (DBusTransport *transport); void _dbus_transport_disconnect (DBusTransport *transport); dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport); +dbus_bool_t _dbus_transport_peek_is_authenticated (DBusTransport *transport); +dbus_bool_t _dbus_transport_try_to_authenticate (DBusTransport *transport); dbus_bool_t _dbus_transport_get_is_anonymous (DBusTransport *transport); dbus_bool_t _dbus_transport_can_pass_unix_fd (DBusTransport *transport); -- cgit v1.2.1 From 600621dbc8073527a958091316eddfbb490c1032 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Fri, 23 Aug 2013 01:11:10 +0200 Subject: Factor out DBusAuthorization from DBusTransport In order to authorize/reject a connection in a polite way, instead of cutting it off after authentication succeed and Hello() is sent, because authorization failed, we need to factor out some authorization bits from DBusTransport and pass them to DBusAuth. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Simon McVittie --- bus/driver.c | 11 ++ cmake/dbus/CMakeLists.txt | 2 + dbus/Makefile.am | 10 +- dbus/dbus-transport-protected.h | 13 +- dbus/dbus-transport.c | 267 ++++++++-------------------------------- doc/dbus-specification.xml | 8 ++ 6 files changed, 82 insertions(+), 229 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index 23197e43..564cecb4 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1535,6 +1535,7 @@ bus_driver_handle_get_connection_credentials (DBusConnection *connection, DBusMessageIter reply_iter; DBusMessageIter array_iter; unsigned long ulong_val; + char *windows_sid; const char *service; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1569,6 +1570,16 @@ bus_driver_handle_get_connection_credentials (DBusConnection *connection, goto oom; } + if (dbus_connection_get_windows_user (conn, &windows_sid)) + { + if (!_dbus_asv_add_string (&array_iter, "WindowsSID", windows_sid)) + { + dbus_free(windows_sid); + goto oom; + } + dbus_free(windows_sid); + } + if (!_dbus_asv_close (&reply_iter, &array_iter)) goto oom; diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 0205f852..bb7278c5 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -32,6 +32,7 @@ set (dbusinclude_HEADERS set (DBUS_LIB_SOURCES ${DBUS_DIR}/dbus-address.c ${DBUS_DIR}/dbus-auth.c + ${DBUS_DIR}/dbus-authorization.c ${DBUS_DIR}/dbus-bus.c ${DBUS_DIR}/dbus-connection.c ${DBUS_DIR}/dbus-credentials.c @@ -75,6 +76,7 @@ endif(UNIX) set (DBUS_LIB_HEADERS ${DBUS_DIR}/dbus-auth.h + ${DBUS_DIR}/dbus-authorization.h ${DBUS_DIR}/dbus-connection-internal.h ${DBUS_DIR}/dbus-credentials.h ${DBUS_DIR}/dbus-keyring.h diff --git a/dbus/Makefile.am b/dbus/Makefile.am index e118cbbb..180a44e4 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -150,6 +150,8 @@ DBUS_LIB_SOURCES= \ dbus-address.c \ dbus-auth.c \ dbus-auth.h \ + dbus-authorization.c \ + dbus-authorization.h \ dbus-bus.c \ dbus-connection.c \ dbus-connection-internal.h \ @@ -208,8 +210,8 @@ DBUS_LIB_SOURCES= \ DBUS_SHARED_SOURCES= \ dbus-dataslot.c \ dbus-dataslot.h \ - dbus-file.c \ - dbus-file.h \ + dbus-file.c \ + dbus-file.h \ dbus-hash.c \ dbus-hash.h \ dbus-internals.c \ @@ -221,8 +223,8 @@ DBUS_SHARED_SOURCES= \ dbus-memory.c \ dbus-mempool.c \ dbus-mempool.h \ - dbus-pipe.c \ - dbus-pipe.h \ + dbus-pipe.c \ + dbus-pipe.h \ dbus-string.c \ dbus-string.h \ dbus-string-private.h \ diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h index 396f0ffd..93380ab9 100644 --- a/dbus/dbus-transport-protected.h +++ b/dbus/dbus-transport-protected.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -88,6 +89,7 @@ struct DBusTransport DBusMessageLoader *loader; /**< Message-loading buffer. */ DBusAuth *auth; /**< Authentication conversation */ + DBusAuthorization *authorization; /**< Authorization conversation */ DBusCredentials *credentials; /**< Credentials of other end read from the socket */ @@ -100,23 +102,12 @@ struct DBusTransport char *expected_guid; /**< GUID we expect the server to have, #NULL on server side or if we don't have an expectation */ - DBusAllowUnixUserFunction unix_user_function; /**< Function for checking whether a user is authorized. */ - void *unix_user_data; /**< Data for unix_user_function */ - - DBusFreeFunction free_unix_user_data; /**< Function to free unix_user_data */ - - DBusAllowWindowsUserFunction windows_user_function; /**< Function for checking whether a user is authorized. */ - void *windows_user_data; /**< Data for windows_user_function */ - - DBusFreeFunction free_windows_user_data; /**< Function to free windows_user_data */ - unsigned int disconnected : 1; /**< #TRUE if we are disconnected. */ unsigned int authenticated : 1; /**< Cache of auth state; use _dbus_transport_peek_is_authenticated() to query value */ unsigned int send_credentials_pending : 1; /**< #TRUE if we need to send credentials */ unsigned int receive_credentials_pending : 1; /**< #TRUE if we need to receive credentials */ unsigned int is_server : 1; /**< #TRUE if on the server side */ unsigned int unused_bytes_recovered : 1; /**< #TRUE if we've recovered unused bytes from auth */ - unsigned int allow_anonymous : 1; /**< #TRUE if an anonymous client can connect */ }; dbus_bool_t _dbus_transport_init_base (DBusTransport *transport, diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index e68a9f03..661b54ff 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -28,6 +28,7 @@ #include "dbus-connection-internal.h" #include "dbus-watch.h" #include "dbus-auth.h" +#include "dbus-authorization.h" #include "dbus-address.h" #include "dbus-credentials.h" #include "dbus-mainloop.h" @@ -106,6 +107,7 @@ _dbus_transport_init_base (DBusTransport *transport, { DBusMessageLoader *loader; DBusAuth *auth; + DBusAuthorization *authorization = NULL; /* non-NULL only if is_server=TRUE */ DBusCounter *counter; char *address_copy; DBusCredentials *creds; @@ -113,13 +115,26 @@ _dbus_transport_init_base (DBusTransport *transport, loader = _dbus_message_loader_new (); if (loader == NULL) return FALSE; - - if (server_guid) - auth = _dbus_auth_server_new (server_guid); + + if (server_guid != NULL) + { + authorization = _dbus_authorization_new (); + if (authorization == NULL) + { + _dbus_message_loader_unref (loader); + return FALSE; /* OOM */ + } + + auth = _dbus_auth_server_new (server_guid); + } else - auth = _dbus_auth_client_new (); + { + auth = _dbus_auth_client_new (); + } if (auth == NULL) { + if (authorization != NULL) + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -128,6 +143,8 @@ _dbus_transport_init_base (DBusTransport *transport, if (counter == NULL) { _dbus_auth_unref (auth); + if (authorization != NULL) + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -137,11 +154,13 @@ _dbus_transport_init_base (DBusTransport *transport, { _dbus_counter_unref (counter); _dbus_auth_unref (auth); + if (authorization != NULL) + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } - if (server_guid) + if (server_guid != NULL) { _dbus_assert (address == NULL); address_copy = NULL; @@ -155,6 +174,8 @@ _dbus_transport_init_base (DBusTransport *transport, _dbus_credentials_unref (creds); _dbus_counter_unref (counter); _dbus_auth_unref (auth); + if (authorization != NULL) + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -163,6 +184,7 @@ _dbus_transport_init_base (DBusTransport *transport, transport->refcount = 1; transport->vtable = vtable; transport->loader = loader; + transport->authorization = authorization; transport->auth = auth; transport->live_messages = counter; transport->authenticated = FALSE; @@ -171,15 +193,7 @@ _dbus_transport_init_base (DBusTransport *transport, transport->send_credentials_pending = !transport->is_server; transport->receive_credentials_pending = transport->is_server; transport->address = address_copy; - - transport->unix_user_function = NULL; - transport->unix_user_data = NULL; - transport->free_unix_user_data = NULL; - transport->windows_user_function = NULL; - transport->windows_user_data = NULL; - transport->free_windows_user_data = NULL; - transport->expected_guid = NULL; /* Try to default to something that won't totally hose the system, @@ -203,6 +217,10 @@ _dbus_transport_init_base (DBusTransport *transport, if (transport->address) _dbus_verbose ("Initialized transport on address %s\n", transport->address); + /* we can have authorization data set only in server mode */ + _dbus_assert ((transport->is_server && transport->authorization != NULL) || + (!transport->is_server && transport->authorization == NULL)); + return TRUE; } @@ -218,14 +236,10 @@ _dbus_transport_finalize_base (DBusTransport *transport) if (!transport->disconnected) _dbus_transport_disconnect (transport); - if (transport->free_unix_user_data != NULL) - (* transport->free_unix_user_data) (transport->unix_user_data); - - if (transport->free_windows_user_data != NULL) - (* transport->free_windows_user_data) (transport->windows_user_data); - _dbus_message_loader_unref (transport->loader); _dbus_auth_unref (transport->auth); + if (transport->authorization) + _dbus_authorization_unref (transport->authorization); _dbus_counter_set_notify (transport->live_messages, 0, 0, NULL, NULL); _dbus_counter_unref (transport->live_messages); @@ -529,163 +543,6 @@ _dbus_transport_get_is_connected (DBusTransport *transport) return !transport->disconnected; } -static dbus_bool_t -auth_via_unix_user_function (DBusTransport *transport) -{ - DBusCredentials *auth_identity; - dbus_bool_t allow; - DBusConnection *connection; - DBusAllowUnixUserFunction unix_user_function; - void *unix_user_data; - dbus_uid_t uid; - - /* Dropping the lock here probably isn't that safe. */ - - auth_identity = _dbus_auth_get_identity (transport->auth); - _dbus_assert (auth_identity != NULL); - - connection = transport->connection; - unix_user_function = transport->unix_user_function; - unix_user_data = transport->unix_user_data; - uid = _dbus_credentials_get_unix_uid (auth_identity); - - _dbus_verbose ("unlock\n"); - _dbus_connection_unlock (connection); - - allow = (* unix_user_function) (connection, - uid, - unix_user_data); - - _dbus_verbose ("lock post unix user function\n"); - _dbus_connection_lock (connection); - - if (allow) - { - _dbus_verbose ("Client UID "DBUS_UID_FORMAT" authorized\n", uid); - } - else - { - _dbus_verbose ("Client UID "DBUS_UID_FORMAT - " was rejected, disconnecting\n", - _dbus_credentials_get_unix_uid (auth_identity)); - _dbus_transport_disconnect (transport); - } - - return allow; -} - -static dbus_bool_t -auth_via_windows_user_function (DBusTransport *transport) -{ - DBusCredentials *auth_identity; - dbus_bool_t allow; - DBusConnection *connection; - DBusAllowWindowsUserFunction windows_user_function; - void *windows_user_data; - char *windows_sid; - - /* Dropping the lock here probably isn't that safe. */ - - auth_identity = _dbus_auth_get_identity (transport->auth); - _dbus_assert (auth_identity != NULL); - - connection = transport->connection; - windows_user_function = transport->windows_user_function; - windows_user_data = transport->unix_user_data; - windows_sid = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity)); - - if (windows_sid == NULL) - { - /* OOM */ - return FALSE; - } - - _dbus_verbose ("unlock\n"); - _dbus_connection_unlock (connection); - - allow = (* windows_user_function) (connection, - windows_sid, - windows_user_data); - - _dbus_verbose ("lock post windows user function\n"); - _dbus_connection_lock (connection); - - if (allow) - { - _dbus_verbose ("Client SID '%s' authorized\n", windows_sid); - } - else - { - _dbus_verbose ("Client SID '%s' was rejected, disconnecting\n", - _dbus_credentials_get_windows_sid (auth_identity)); - _dbus_transport_disconnect (transport); - } - - return allow; -} - -static dbus_bool_t -auth_via_default_rules (DBusTransport *transport) -{ - DBusCredentials *auth_identity; - DBusCredentials *our_identity; - dbus_bool_t allow; - - auth_identity = _dbus_auth_get_identity (transport->auth); - _dbus_assert (auth_identity != NULL); - - /* By default, connection is allowed if the client is 1) root or 2) - * has the same UID as us or 3) anonymous is allowed. - */ - - our_identity = _dbus_credentials_new_from_current_process (); - if (our_identity == NULL) - { - /* OOM */ - return FALSE; - } - - if (transport->allow_anonymous || - _dbus_credentials_get_unix_uid (auth_identity) == 0 || - _dbus_credentials_same_user (our_identity, - auth_identity)) - { - if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) - _dbus_verbose ("Client authorized as SID '%s'" - "matching our SID '%s'\n", - _dbus_credentials_get_windows_sid(auth_identity), - _dbus_credentials_get_windows_sid(our_identity)); - else - _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT - " matching our UID "DBUS_UID_FORMAT"\n", - _dbus_credentials_get_unix_uid(auth_identity), - _dbus_credentials_get_unix_uid(our_identity)); - /* We have authenticated! */ - allow = TRUE; - } - else - { - if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) - _dbus_verbose ("Client authorized as SID '%s'" - " but our SID is '%s', disconnecting\n", - (_dbus_credentials_get_windows_sid(auth_identity) ? - _dbus_credentials_get_windows_sid(auth_identity) : ""), - (_dbus_credentials_get_windows_sid(our_identity) ? - _dbus_credentials_get_windows_sid(our_identity) : "")); - else - _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT - " but our UID is "DBUS_UID_FORMAT", disconnecting\n", - _dbus_credentials_get_unix_uid(auth_identity), - _dbus_credentials_get_unix_uid(our_identity)); - _dbus_transport_disconnect (transport); - allow = FALSE; - } - - _dbus_credentials_unref (our_identity); - - return allow; -} - /** * Returns #TRUE if we have been authenticated. It will return #TRUE even if * the transport is now disconnected, but was ever authenticated before @@ -775,33 +632,18 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) */ if (maybe_authenticated && transport->is_server) { - dbus_bool_t allow; DBusCredentials *auth_identity; - + auth_identity = _dbus_auth_get_identity (transport->auth); _dbus_assert (auth_identity != NULL); - /* If we have an auth'd user and a user function, delegate - * deciding whether auth credentials are good enough to the - * app; otherwise, use our default decision process. - */ - if (transport->unix_user_function != NULL && - _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_UNIX_USER_ID)) + /* If we have an authenticated user, delegate deciding whether auth + * credentials are good enough to the app */ + if (!_dbus_authorization_do_authorization (transport->authorization, auth_identity)) { - allow = auth_via_unix_user_function (transport); - } - else if (transport->windows_user_function != NULL && - _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_WINDOWS_SID)) - { - allow = auth_via_windows_user_function (transport); - } - else - { - allow = auth_via_default_rules (transport); + _dbus_transport_disconnect (transport); + maybe_authenticated = FALSE; } - - if (!allow) - maybe_authenticated = FALSE; } transport->authenticated = maybe_authenticated; @@ -931,6 +773,8 @@ _dbus_transport_set_connection (DBusTransport *transport, _dbus_assert (transport->connection == NULL); transport->connection = connection; + if (transport->is_server) + _dbus_authorization_set_connection (transport->authorization, connection); _dbus_transport_ref (transport); if (!(* transport->vtable->connection_set) (transport)) @@ -1413,20 +1257,17 @@ _dbus_transport_get_adt_audit_session_data (DBusTransport *transport, * @param old_data the old user data to be freed * @param old_free_data_function old free data function to free it with */ -void +inline void _dbus_transport_set_unix_user_function (DBusTransport *transport, DBusAllowUnixUserFunction function, void *data, DBusFreeFunction free_data_function, void **old_data, DBusFreeFunction *old_free_data_function) -{ - *old_data = transport->unix_user_data; - *old_free_data_function = transport->free_unix_user_data; - - transport->unix_user_function = function; - transport->unix_user_data = data; - transport->free_unix_user_data = free_data_function; +{ + if (transport->is_server) + _dbus_authorization_set_unix_authorization_callback (transport->authorization, function, + data, free_data_function, old_data, old_free_data_function); } /** @@ -1472,7 +1313,7 @@ _dbus_transport_get_windows_user (DBusTransport *transport, * @param old_free_data_function old free data function to free it with */ -void +inline void _dbus_transport_set_windows_user_function (DBusTransport *transport, DBusAllowWindowsUserFunction function, void *data, @@ -1480,12 +1321,9 @@ _dbus_transport_set_windows_user_function (DBusTransport *transport void **old_data, DBusFreeFunction *old_free_data_function) { - *old_data = transport->windows_user_data; - *old_free_data_function = transport->free_windows_user_data; - - transport->windows_user_function = function; - transport->windows_user_data = data; - transport->free_windows_user_data = free_data_function; + if (transport->is_server) + _dbus_authorization_set_windows_authorization_callback (transport->authorization, function, + data, free_data_function, old_data, old_free_data_function); } /** @@ -1509,11 +1347,12 @@ _dbus_transport_set_auth_mechanisms (DBusTransport *transport, * @param transport the transport * @param value #TRUE to allow anonymous connection */ -void +inline void _dbus_transport_set_allow_anonymous (DBusTransport *transport, dbus_bool_t value) { - transport->allow_anonymous = value != FALSE; + if (transport->is_server) + _dbus_authorization_set_allow_anonymous (transport->authorization, value); } #ifdef DBUS_ENABLE_STATS diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 65abd29f..eca494e3 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -5666,6 +5666,14 @@ this concept. On Unix, this is the process ID defined by POSIX. + + WindowsSID + STRING + The Windows security identifier in its string form, + e.g. "S-1-5-21-3623811015-3361044348-30300820-1013" for + a domain or local computer user or "S-1-5-18" for the + LOCAL_SYSTEM user + -- cgit v1.2.1 From d5d25b5efd35d8d9bbb9d58cae441debf8f7ded6 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Fri, 23 Aug 2013 01:30:55 +0200 Subject: Actually use DBusAuthorization in DBusAuth EXTERNAL mech Also update the authentication script so that DBusAuthorization default rules are used during testing. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Simon McVittie --- dbus/dbus-auth-script.c | 13 ++++++++++++- dbus/dbus-auth.c | 34 +++++++++++++++++++++++++++------- dbus/dbus-auth.h | 4 +++- dbus/dbus-transport.c | 2 +- 4 files changed, 43 insertions(+), 10 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index c1f0c88e..445452c7 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -30,6 +30,7 @@ #include "dbus-hash.h" #include "dbus-credentials.h" #include "dbus-internals.h" +#include "dbus-authorization.h" /** * @defgroup DBusAuthScript code for running unit test scripts for DBusAuth @@ -401,6 +402,7 @@ _dbus_auth_script_run (const DBusString *filename) "SERVER")) { DBusCredentials *creds; + DBusAuthorization *authorization; if (auth != NULL) { @@ -408,7 +410,16 @@ _dbus_auth_script_run (const DBusString *filename) goto out; } - auth = _dbus_auth_server_new (&guid); + /* empty authorization, it will use default rules */ + authorization = _dbus_authorization_new (); + if (authorization == NULL) + { + _dbus_warn ("no memory to create DBusAuthorization\n"); + goto out; + } + auth = _dbus_auth_server_new (&guid, authorization); + /* DBusAuth owns it, or finalized on OOM */ + _dbus_authorization_unref (authorization); if (auth == NULL) { _dbus_warn ("no memory to create DBusAuth\n"); diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index a0f72773..35efa3a8 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -30,6 +30,7 @@ #include "dbus-sha.h" #include "dbus-protocol.h" #include "dbus-credentials.h" +#include "dbus-authorization.h" /** * @defgroup DBusAuth Authentication @@ -213,6 +214,8 @@ typedef struct { DBusAuth base; /**< Parent class */ + DBusAuthorization *authorization; /* DBus Authorization callbacks */ + int failures; /**< Number of times client has been rejected */ int max_failures; /**< Number of times we reject before disconnect */ @@ -1115,12 +1118,26 @@ handle_server_data_external_mech (DBusAuth *auth, DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID, auth->credentials)) return FALSE; - - if (!send_ok (auth)) - return FALSE; - _dbus_verbose ("%s: authenticated client based on socket credentials\n", - DBUS_AUTH_NAME (auth)); + /* Do a first authorization of the transport, in order to REJECT + * immediately connection if needed (FDO#39720), transport will + * re-authorize later, but it will close the connection on fail, + * we want to REJECT now if possible */ + if (_dbus_authorization_do_authorization (DBUS_AUTH_SERVER (auth)->authorization, + auth->authorized_identity)) + { + if (!send_ok (auth)) + return FALSE; + } + else + { + _dbus_verbose ("%s: desired identity does not match server identity: " + "not authorized\n", DBUS_AUTH_NAME (auth)); + return send_rejected (auth); + } + + _dbus_verbose ("%s: authenticated and authorized client based on " + "socket credentials\n", DBUS_AUTH_NAME (auth)); return TRUE; } @@ -2244,7 +2261,8 @@ process_command (DBusAuth *auth) * @returns the new object or #NULL if no memory */ DBusAuth* -_dbus_auth_server_new (const DBusString *guid) +_dbus_auth_server_new (const DBusString *guid, + DBusAuthorization *authorization) { DBusAuth *auth; DBusAuthServer *server_auth; @@ -2272,7 +2290,8 @@ _dbus_auth_server_new (const DBusString *guid) server_auth = DBUS_AUTH_SERVER (auth); server_auth->guid = guid_copy; - + server_auth->authorization = _dbus_authorization_ref (authorization); + /* perhaps this should be per-mechanism with a lower * max */ @@ -2363,6 +2382,7 @@ _dbus_auth_unref (DBusAuth *auth) _dbus_assert (DBUS_AUTH_IS_SERVER (auth)); _dbus_string_free (& DBUS_AUTH_SERVER (auth)->guid); + _dbus_authorization_unref (DBUS_AUTH_SERVER (auth)->authorization); } if (auth->keyring) diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h index ae3f3647..3f178a22 100644 --- a/dbus/dbus-auth.h +++ b/dbus/dbus-auth.h @@ -27,6 +27,7 @@ #include #include #include +#include DBUS_BEGIN_DECLS @@ -41,7 +42,8 @@ typedef enum DBUS_AUTH_STATE_AUTHENTICATED } DBusAuthState; -DBusAuth* _dbus_auth_server_new (const DBusString *guid); +DBusAuth* _dbus_auth_server_new (const DBusString *guid, + DBusAuthorization *authorization); DBusAuth* _dbus_auth_client_new (void); DBusAuth* _dbus_auth_ref (DBusAuth *auth); void _dbus_auth_unref (DBusAuth *auth); diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 661b54ff..3a9cf84b 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -125,7 +125,7 @@ _dbus_transport_init_base (DBusTransport *transport, return FALSE; /* OOM */ } - auth = _dbus_auth_server_new (server_guid); + auth = _dbus_auth_server_new (server_guid, authorization); } else { -- cgit v1.2.1 From 78c447173dfba167ac8082652c02e453e4b519ce Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 23 Aug 2013 01:36:31 +0200 Subject: Add new files really. --- dbus/dbus-authorization.c | 344 ++++++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-authorization.h | 25 ++++ 2 files changed, 369 insertions(+) create mode 100644 dbus/dbus-authorization.c create mode 100644 dbus/dbus-authorization.h diff --git a/dbus/dbus-authorization.c b/dbus/dbus-authorization.c new file mode 100644 index 00000000..05a3aa87 --- /dev/null +++ b/dbus/dbus-authorization.c @@ -0,0 +1,344 @@ +#include +#include "dbus-internals.h" +#include "dbus-authorization.h" +#include "dbus-connection.h" +#include "dbus-connection-internal.h" + +struct DBusAuthorization { + int refcount; + + DBusConnection *connection; + + /* Authorization functions, used as callback by SASL (implemented by + * DBUsAuth) */ + DBusAllowUnixUserFunction unix_authorization_cb; + void *unix_data; + DBusFreeFunction unix_data_free; + + DBusAllowWindowsUserFunction windows_authorization_cb; + void *windows_data; + DBusFreeFunction windows_data_free; + + dbus_bool_t allow_anonymous; +}; + + +DBusAuthorization * +_dbus_authorization_new (void) +{ + DBusAuthorization *ret; + + ret = dbus_malloc0 (sizeof (DBusAuthorization)); + if (ret == NULL) + { + _dbus_verbose ("OOM\n"); + return NULL; /* OOM */ + } + + ret->refcount = 1; + + return ret; +} + +DBusAuthorization * +_dbus_authorization_ref (DBusAuthorization *self) +{ + _dbus_assert (self != NULL); + + self->refcount += 1; + + return self; +} + +void +_dbus_authorization_unref (DBusAuthorization *self) +{ + _dbus_assert (self != NULL); + _dbus_assert (self->refcount > 0); + + self->refcount -= 1; + + if (self->refcount == 0) + { + _dbus_verbose ("last reference, finalizing\n"); + + if (self->unix_data && self->unix_data_free) + { + _dbus_verbose ("freeing unix authorization callback data\n"); + (*self->unix_data_free) (self->unix_data); + self->unix_data = NULL; + } + + if (self->windows_data && self->windows_data_free) + { + _dbus_verbose ("freeing windows authorization callback data\n"); + (*self->windows_data_free) (self->windows_data); + self->windows_data = NULL; + } + + dbus_free (self); + } +} + +/* Called by transport's set_connection with the connection locked */ +void +_dbus_authorization_set_connection (DBusAuthorization *self, + DBusConnection *connection) +{ + _dbus_assert (connection != NULL); + _dbus_assert (self->connection == NULL); + + self->connection = connection; +} + + +/** + * Set the user set authorization callback for Unix identities authorizations. + * The callback will be called at the end of the EXTERNAL authentication + * mechanism and on every message. + + * See dbus_connection_set_unix_authorization_callback() and + * _dbus_transport_set_unix_authorization_callback(). + * + * @param self the authorization struct + * @param function the predicate + * @param data data to pass to the predicate + * @param free_data_function function to free the data + * @param old_data the old user data to be freed + * @param old_free_data_function old free data function to free it with + */ +void +_dbus_authorization_set_unix_authorization_callback (DBusAuthorization *self, + DBusAllowUnixUserFunction function, + void *data, + DBusFreeFunction free_data_function, + void **old_data, + DBusFreeFunction *old_free_data_function) +{ + *old_data = self->unix_data; + *old_free_data_function = self->unix_data_free; + + self->unix_authorization_cb = function; + self->unix_data = data; + self->unix_data_free = free_data_function; +} + +/** + * Set the user set authorization callback for Windows identities + * authorizations. + * The callback will be called at the end of the EXTERNAL authentication + * mechanism and on every message. + * + * See dbus_connection_set_windows_authorization_callback() and + * _dbus_transport_set_windows_authorization_callback(). + * + * @param self the authorization struct + * @param function the predicate + * @param data data to pass to the predicate + * @param free_data_function function to free the data + * @param old_data the old user data to be freed + * @param old_free_data_function old free data function to free it with + */ + +void +_dbus_authorization_set_windows_authorization_callback (DBusAuthorization *self, + DBusAllowWindowsUserFunction function, + void *data, + DBusFreeFunction free_data_function, + void **old_data, + DBusFreeFunction *old_free_data_function) +{ + *old_data = self->windows_data; + *old_free_data_function = self->windows_data_free; + + self->windows_authorization_cb = function; + self->windows_data = data; + self->windows_data_free = free_data_function; +} + +static dbus_bool_t +auth_via_unix_authorization_callback (DBusAuthorization *self, + DBusCredentials *auth_identity) +{ + + dbus_bool_t allow; + dbus_uid_t uid; + + /* Dropping the lock here probably isn't that safe. */ + + _dbus_assert (auth_identity != NULL); + + uid = _dbus_credentials_get_unix_uid (auth_identity); + + _dbus_verbose ("unlock connection before executing user's authorization callback\n"); + _dbus_connection_unlock (self->connection); + + allow = (*self->unix_authorization_cb) (self->connection, + uid, + self->unix_data); + + _dbus_verbose ("lock connection post unix-authorization callback\n"); + _dbus_connection_lock (self->connection); + + if (allow) + { + _dbus_verbose ("Client UID "DBUS_UID_FORMAT" authorized\n", uid); + } + else + { + _dbus_verbose ("Client UID "DBUS_UID_FORMAT " wasn't authorized.\n", + _dbus_credentials_get_unix_uid (auth_identity)); + } + + return allow; +} + + +static dbus_bool_t +auth_via_windows_authorization_callback (DBusAuthorization *self, + DBusCredentials *auth_identity) +{ + dbus_bool_t allow; + char *windows_sid; + + /* Dropping the lock here probably isn't that safe. */ + + _dbus_assert (auth_identity != NULL); + + windows_sid = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity)); + + if (windows_sid == NULL) + return FALSE; /* OOM */ + + _dbus_verbose ("unlock connection before executing user's authorization callback\n"); + _dbus_connection_unlock (self->connection); + + allow = (*self->windows_authorization_cb) (self->connection, + windows_sid, + self->windows_data); + + _dbus_verbose ("lock connection post windows user's authorization callback\n"); + _dbus_connection_lock (self->connection); + + if (allow) + { + _dbus_verbose ("Client SID '%s' authorized\n", windows_sid); + } + else + { + _dbus_verbose ("Client SID '%s' wasn't authorized\n", + _dbus_credentials_get_windows_sid (auth_identity)); + } + + dbus_free (windows_sid); + + return allow; +} + +static dbus_bool_t +auth_via_default_rules (DBusAuthorization *self, + DBusCredentials *auth_identity) + +{ + DBusCredentials *our_identity; + dbus_bool_t allow; + + _dbus_assert (auth_identity != NULL); + + /* By default, connection is allowed if the client is 1) root or 2) + * has the same UID as us or 3) anonymous is allowed. + */ + + our_identity = _dbus_credentials_new_from_current_process (); + if (our_identity == NULL) + return FALSE; /* OOM */ + + if (self->allow_anonymous || + _dbus_credentials_get_unix_uid (auth_identity) == 0 || + _dbus_credentials_same_user (our_identity, auth_identity)) + { + if (_dbus_credentials_include (our_identity, DBUS_CREDENTIAL_WINDOWS_SID)) + _dbus_verbose ("Client authenticated as SID '%s'" + "matching our SID '%s': authorized\n", + _dbus_credentials_get_windows_sid (auth_identity), + _dbus_credentials_get_windows_sid (our_identity)); + else + _dbus_verbose ("Client authenticated as UID "DBUS_UID_FORMAT + " matching our UID "DBUS_UID_FORMAT": authorized\n", + _dbus_credentials_get_unix_uid (auth_identity), + _dbus_credentials_get_unix_uid (our_identity)); + /* We have authenticated! */ + allow = TRUE; + } + else + { + if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) + _dbus_verbose ("Client authenticated as SID '%s'" + " but our SID is '%s', not authorizing\n", + (_dbus_credentials_get_windows_sid(auth_identity) ? + _dbus_credentials_get_windows_sid(auth_identity) : ""), + (_dbus_credentials_get_windows_sid(our_identity) ? + _dbus_credentials_get_windows_sid(our_identity) : "")); + else + _dbus_verbose ("Client authenticated as UID "DBUS_UID_FORMAT + " but our UID is "DBUS_UID_FORMAT", not authorizing\n", + _dbus_credentials_get_unix_uid(auth_identity), + _dbus_credentials_get_unix_uid(our_identity)); + allow = FALSE; + } + + _dbus_credentials_unref (our_identity); + + return allow; +} + +/* Called with DBusConnection lock held */ +dbus_bool_t +_dbus_authorization_do_authorization (DBusAuthorization *self, + DBusCredentials *auth_identity) +{ + dbus_bool_t allow; + + /* maybe-FIXME: at this point we *should* have a connection set unless we + * are in some test case, but we assert its presence only in some if's + * branches since default_rules does not need one and is used in a test case + * without a connection set */ + + if (_dbus_credentials_are_anonymous (auth_identity)) + { + allow = self->allow_anonymous; + } + if (self->unix_authorization_cb != NULL && + _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_UNIX_USER_ID)) + { + _dbus_assert (self->connection != NULL); + allow = auth_via_unix_authorization_callback (self, auth_identity); + } + else if (self->windows_authorization_cb != NULL && + _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_WINDOWS_SID)) + { + _dbus_assert (self->connection != NULL); + allow = auth_via_windows_authorization_callback (self, auth_identity); + } + else + { + allow = auth_via_default_rules (self, auth_identity); + } + + return allow; +} + + + +/** + * See dbus_connection_set_allow_anonymous() + * + * @param self an authorization struct + * @param value #TRUE to allow anonymous connection + */ +void +_dbus_authorization_set_allow_anonymous (DBusAuthorization *self, + dbus_bool_t value) +{ + self->allow_anonymous = value != FALSE; +} diff --git a/dbus/dbus-authorization.h b/dbus/dbus-authorization.h new file mode 100644 index 00000000..8f7f1d43 --- /dev/null +++ b/dbus/dbus-authorization.h @@ -0,0 +1,25 @@ +#ifndef _DBUS_AUTHORIZE_H +#define _DBUS_AUTHORIZE_H + +#include +#include + +typedef struct DBusAuthorization DBusAuthorization; + +DBusAuthorization *_dbus_authorization_new (void); +void _dbus_authorization_set_connection (DBusAuthorization *self, + DBusConnection *connection); +DBusAuthorization * _dbus_authorization_ref (DBusAuthorization *self); +void _dbus_authorization_unref (DBusAuthorization *self); +void _dbus_authorization_set_unix_authorization_callback (DBusAuthorization *self, + DBusAllowUnixUserFunction function, void *data, + DBusFreeFunction free_data_function, void **old_data, + DBusFreeFunction *old_free_data_function); +void _dbus_authorization_set_windows_authorization_callback (DBusAuthorization *self, + DBusAllowWindowsUserFunction function, void *data, + DBusFreeFunction free_data_function, void **old_data, + DBusFreeFunction *old_free_data_function); +dbus_bool_t _dbus_authorization_do_authorization (DBusAuthorization *self, DBusCredentials *creds); +void _dbus_authorization_set_allow_anonymous (DBusAuthorization *self, dbus_bool_t value); + +#endif /* _DBUS_AUTHORIZE_H */ -- cgit v1.2.1 From ef82b381524d30684a30b32b3b9016ed4229290c Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Fri, 23 Aug 2013 01:42:54 +0200 Subject: Rename authorized_identity in authenticated_identity for clarity sake. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Simon McVittie --- dbus/dbus-auth.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index 35efa3a8..6215f9e6 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -170,7 +170,7 @@ struct DBusAuth DBusCredentials *credentials; /**< Credentials read from socket */ - DBusCredentials *authorized_identity; /**< Credentials that are authorized */ + DBusCredentials *authenticated_identity; /**< Credentials that are authorized */ DBusCredentials *desired_identity; /**< Identity client has requested */ @@ -382,8 +382,8 @@ _dbus_auth_new (int size) if (auth->credentials == NULL) goto enomem_6; - auth->authorized_identity = _dbus_credentials_new (); - if (auth->authorized_identity == NULL) + auth->authenticated_identity = _dbus_credentials_new (); + if (auth->authenticated_identity == NULL) goto enomem_7; auth->desired_identity = _dbus_credentials_new (); @@ -397,7 +397,7 @@ _dbus_auth_new (int size) _dbus_credentials_unref (auth->desired_identity); #endif enomem_8: - _dbus_credentials_unref (auth->authorized_identity); + _dbus_credentials_unref (auth->authenticated_identity); enomem_7: _dbus_credentials_unref (auth->credentials); enomem_6: @@ -424,7 +424,7 @@ shutdown_mech (DBusAuth *auth) auth->already_asked_for_initial_response = FALSE; _dbus_string_set_length (&auth->identity, 0); - _dbus_credentials_clear (auth->authorized_identity); + _dbus_credentials_clear (auth->authenticated_identity); _dbus_credentials_clear (auth->desired_identity); if (auth->mech != NULL) @@ -745,13 +745,13 @@ sha1_handle_second_client_response (DBusAuth *auth, goto out_3; } - if (!_dbus_credentials_add_credentials (auth->authorized_identity, + if (!_dbus_credentials_add_credentials (auth->authenticated_identity, auth->desired_identity)) goto out_3; /* Copy process ID from the socket credentials if it's there */ - if (!_dbus_credentials_add_credential (auth->authorized_identity, + if (!_dbus_credentials_add_credential (auth->authenticated_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) goto out_3; @@ -1101,20 +1101,20 @@ handle_server_data_external_mech (DBusAuth *auth, auth->desired_identity)) { /* client has authenticated */ - if (!_dbus_credentials_add_credentials (auth->authorized_identity, + if (!_dbus_credentials_add_credentials (auth->authenticated_identity, auth->desired_identity)) return FALSE; /* also copy process ID from the socket credentials */ - if (!_dbus_credentials_add_credential (auth->authorized_identity, + if (!_dbus_credentials_add_credential (auth->authenticated_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) return FALSE; /* also copy audit data from the socket credentials */ - if (!_dbus_credentials_add_credential (auth->authorized_identity, + if (!_dbus_credentials_add_credential (auth->authenticated_identity, DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID, auth->credentials)) return FALSE; @@ -1124,7 +1124,7 @@ handle_server_data_external_mech (DBusAuth *auth, * re-authorize later, but it will close the connection on fail, * we want to REJECT now if possible */ if (_dbus_authorization_do_authorization (DBUS_AUTH_SERVER (auth)->authorization, - auth->authorized_identity)) + auth->authorized_identity)) { if (!send_ok (auth)) return FALSE; @@ -1232,7 +1232,7 @@ handle_server_data_anonymous_mech (DBusAuth *auth, /* Copy process ID from the socket credentials */ - if (!_dbus_credentials_add_credential (auth->authorized_identity, + if (!_dbus_credentials_add_credential (auth->authenticated_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) return FALSE; @@ -2397,7 +2397,7 @@ _dbus_auth_unref (DBusAuth *auth) dbus_free_string_array (auth->allowed_mechs); _dbus_credentials_unref (auth->credentials); - _dbus_credentials_unref (auth->authorized_identity); + _dbus_credentials_unref (auth->authenticated_identity); _dbus_credentials_unref (auth->desired_identity); dbus_free (auth); @@ -2754,7 +2754,7 @@ _dbus_auth_get_identity (DBusAuth *auth) { if (auth->state == &common_state_authenticated) { - return auth->authorized_identity; + return auth->authenticated_identity; } else { @@ -2762,8 +2762,8 @@ _dbus_auth_get_identity (DBusAuth *auth) * doesn't require allocation or something */ /* return empty credentials */ - _dbus_assert (_dbus_credentials_are_empty (auth->authorized_identity)); - return auth->authorized_identity; + _dbus_assert (_dbus_credentials_are_empty (auth->authenticated_identity)); + return auth->authenticated_identity; } } -- cgit v1.2.1 From 541063a3ab568db8302fbce3c15b22cdff154517 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 23 Aug 2013 01:46:56 +0200 Subject: Fixed rejected hunk complete. --- dbus/dbus-auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index 6215f9e6..a2187016 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -1124,7 +1124,7 @@ handle_server_data_external_mech (DBusAuth *auth, * re-authorize later, but it will close the connection on fail, * we want to REJECT now if possible */ if (_dbus_authorization_do_authorization (DBUS_AUTH_SERVER (auth)->authorization, - auth->authorized_identity)) + auth->authenticated_identity)) { if (!send_ok (auth)) return FALSE; -- cgit v1.2.1 From 22fc03d274f186a788efbdbe6b6dfcff1ad474df Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Fri, 7 Oct 2011 11:25:00 +0100 Subject: Enable anonymous authorization for tests Now that authorization is in SASL mechs, enable anonymous authorizations when we are testing anonymous mechs functionality Bug: http://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Simon McVittie --- dbus/dbus-auth-script.c | 9 +++++++-- test/data/auth/anonymous-server-successful.auth-script | 3 ++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 445452c7..107c92b2 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -398,8 +398,8 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_credentials_unref (creds); } - else if (_dbus_string_starts_with_c_str (&line, - "SERVER")) + else if (_dbus_string_starts_with_c_str (&line, "SERVER") || + _dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS")) { DBusCredentials *creds; DBusAuthorization *authorization; @@ -417,6 +417,11 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_warn ("no memory to create DBusAuthorization\n"); goto out; } + /* if we are testing an anonymous server, we need to enable + * anonymous authorization, or the mech will REJECT */ + if (_dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS")) + _dbus_authorization_set_allow_anonymous (authorization, TRUE); + auth = _dbus_auth_server_new (&guid, authorization); /* DBusAuth owns it, or finalized on OOM */ _dbus_authorization_unref (authorization); diff --git a/test/data/auth/anonymous-server-successful.auth-script b/test/data/auth/anonymous-server-successful.auth-script index 172ae9de..c53b30f9 100644 --- a/test/data/auth/anonymous-server-successful.auth-script +++ b/test/data/auth/anonymous-server-successful.auth-script @@ -1,6 +1,7 @@ ## this tests the server side in a successful auth of type ANONYMOUS -SERVER +## Act as a server that accepts anonymous authorization +SERVER_ANONYMOUS ## verify that prior to doing anything, we haven't authed as anyone EXPECT_HAVE_NO_CREDENTIALS SEND 'AUTH ANONYMOUS 442d42757320312e312e31' -- cgit v1.2.1 From 7f6d7229d8812d985d544cf5dd3636865c5abc81 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Fri, 23 Aug 2013 02:12:46 +0200 Subject: Remove refcounting from DBusAuth and DBusAuthorization Those structs are for DBusTransport internal use, they should not be referenced outside it. The transport needs only to allocate memory on initialization and free it on finalization. The lifecycle for the two allocated structs is DBusTransport lifecycle and at DBusTransport's finalization its connection is already disconnected. The assumption is that the transport owns a reference for any object the two structs holds a reference for (particularly DBusConnection) Bug: http://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Simon McVittie --- dbus/dbus-auth-script.c | 25 +++------------ dbus/dbus-auth.c | 81 ++++++++++++++++------------------------------- dbus/dbus-auth.h | 3 +- dbus/dbus-authorization.c | 73 ++++++++++++++++-------------------------- dbus/dbus-authorization.h | 3 +- dbus/dbus-transport.c | 18 +++++------ 6 files changed, 72 insertions(+), 131 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 107c92b2..d195dde5 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -250,6 +250,7 @@ _dbus_auth_script_run (const DBusString *filename) dbus_bool_t retval; int line_no; DBusAuth *auth; + DBusAuthorization *authorization; DBusString from_auth; DBusAuthState state; DBusString context; @@ -257,6 +258,7 @@ _dbus_auth_script_run (const DBusString *filename) retval = FALSE; auth = NULL; + authorization = NULL; _dbus_string_init_const (&guid, "5fa01f4202cd837709a3274ca0df9d00"); _dbus_string_init_const (&context, "org_freedesktop_test"); @@ -374,24 +376,16 @@ _dbus_auth_script_run (const DBusString *filename) goto out; } - /* test ref/unref */ - _dbus_auth_ref (auth); - _dbus_auth_unref (auth); - creds = _dbus_credentials_new_from_current_process (); if (creds == NULL) { _dbus_warn ("no memory for credentials\n"); - _dbus_auth_unref (auth); - auth = NULL; goto out; } if (!_dbus_auth_set_credentials (auth, creds)) { _dbus_warn ("no memory for setting credentials\n"); - _dbus_auth_unref (auth); - auth = NULL; _dbus_credentials_unref (creds); goto out; } @@ -402,7 +396,6 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS")) { DBusCredentials *creds; - DBusAuthorization *authorization; if (auth != NULL) { @@ -423,32 +416,22 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_authorization_set_allow_anonymous (authorization, TRUE); auth = _dbus_auth_server_new (&guid, authorization); - /* DBusAuth owns it, or finalized on OOM */ - _dbus_authorization_unref (authorization); if (auth == NULL) { _dbus_warn ("no memory to create DBusAuth\n"); goto out; } - /* test ref/unref */ - _dbus_auth_ref (auth); - _dbus_auth_unref (auth); - creds = _dbus_credentials_new_from_current_process (); if (creds == NULL) { _dbus_warn ("no memory for credentials\n"); - _dbus_auth_unref (auth); - auth = NULL; goto out; } if (!_dbus_auth_set_credentials (auth, creds)) { _dbus_warn ("no memory for setting credentials\n"); - _dbus_auth_unref (auth); - auth = NULL; _dbus_credentials_unref (creds); goto out; } @@ -806,7 +789,9 @@ _dbus_auth_script_run (const DBusString *filename) out: if (auth) - _dbus_auth_unref (auth); + _dbus_auth_free (auth); + if (authorization) + _dbus_authorization_free (authorization); _dbus_string_free (&file); _dbus_string_free (&line); diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index a2187016..3da25ec5 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -153,7 +153,6 @@ typedef struct */ struct DBusAuth { - int refcount; /**< reference count */ const char *side; /**< Client or server */ DBusString incoming; /**< Incoming data buffer */ @@ -346,8 +345,6 @@ _dbus_auth_new (int size) if (auth == NULL) return NULL; - auth->refcount = 1; - auth->keyring = NULL; auth->cookie_id = -1; @@ -2262,7 +2259,7 @@ process_command (DBusAuth *auth) */ DBusAuth* _dbus_auth_server_new (const DBusString *guid, - DBusAuthorization *authorization) + DBusAuthorization *authorization) { DBusAuth *auth; DBusAuthServer *server_auth; @@ -2290,7 +2287,7 @@ _dbus_auth_server_new (const DBusString *guid, server_auth = DBUS_AUTH_SERVER (auth); server_auth->guid = guid_copy; - server_auth->authorization = _dbus_authorization_ref (authorization); + server_auth->authorization = authorization; /* perhaps this should be per-mechanism with a lower * max @@ -2333,7 +2330,7 @@ _dbus_auth_client_new (void) * mechanism */ if (!send_auth (auth, &all_mechanisms[0])) { - _dbus_auth_unref (auth); + _dbus_auth_free (auth); return NULL; } @@ -2341,67 +2338,45 @@ _dbus_auth_client_new (void) } /** - * Increments the refcount of an auth object. - * - * @param auth the auth conversation - * @returns the auth conversation - */ -DBusAuth * -_dbus_auth_ref (DBusAuth *auth) -{ - _dbus_assert (auth != NULL); - - auth->refcount += 1; - - return auth; -} - -/** - * Decrements the refcount of an auth object. + * Free memory allocated for an auth object. * * @param auth the auth conversation */ void -_dbus_auth_unref (DBusAuth *auth) +_dbus_auth_free (DBusAuth *auth) { _dbus_assert (auth != NULL); - _dbus_assert (auth->refcount > 0); - auth->refcount -= 1; - if (auth->refcount == 0) + shutdown_mech (auth); + + if (DBUS_AUTH_IS_CLIENT (auth)) { - shutdown_mech (auth); + _dbus_string_free (& DBUS_AUTH_CLIENT (auth)->guid_from_server); + _dbus_list_clear (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); + } + else + { + _dbus_assert (DBUS_AUTH_IS_SERVER (auth)); - if (DBUS_AUTH_IS_CLIENT (auth)) - { - _dbus_string_free (& DBUS_AUTH_CLIENT (auth)->guid_from_server); - _dbus_list_clear (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); - } - else - { - _dbus_assert (DBUS_AUTH_IS_SERVER (auth)); + _dbus_string_free (& DBUS_AUTH_SERVER (auth)->guid); + } - _dbus_string_free (& DBUS_AUTH_SERVER (auth)->guid); - _dbus_authorization_unref (DBUS_AUTH_SERVER (auth)->authorization); - } + if (auth->keyring) + _dbus_keyring_unref (auth->keyring); - if (auth->keyring) - _dbus_keyring_unref (auth->keyring); + _dbus_string_free (&auth->context); + _dbus_string_free (&auth->challenge); + _dbus_string_free (&auth->identity); + _dbus_string_free (&auth->incoming); + _dbus_string_free (&auth->outgoing); - _dbus_string_free (&auth->context); - _dbus_string_free (&auth->challenge); - _dbus_string_free (&auth->identity); - _dbus_string_free (&auth->incoming); - _dbus_string_free (&auth->outgoing); + dbus_free_string_array (auth->allowed_mechs); - dbus_free_string_array (auth->allowed_mechs); + _dbus_credentials_unref (auth->credentials); + _dbus_credentials_unref (auth->authenticated_identity); + _dbus_credentials_unref (auth->desired_identity); - _dbus_credentials_unref (auth->credentials); - _dbus_credentials_unref (auth->authenticated_identity); - _dbus_credentials_unref (auth->desired_identity); - - dbus_free (auth); - } + dbus_free (auth); } /** diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h index 3f178a22..1cf0570a 100644 --- a/dbus/dbus-auth.h +++ b/dbus/dbus-auth.h @@ -45,8 +45,7 @@ typedef enum DBusAuth* _dbus_auth_server_new (const DBusString *guid, DBusAuthorization *authorization); DBusAuth* _dbus_auth_client_new (void); -DBusAuth* _dbus_auth_ref (DBusAuth *auth); -void _dbus_auth_unref (DBusAuth *auth); +void _dbus_auth_free (DBusAuth *auth); dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, const char **mechanisms); DBusAuthState _dbus_auth_do_work (DBusAuth *auth); diff --git a/dbus/dbus-authorization.c b/dbus/dbus-authorization.c index 05a3aa87..3f0b9660 100644 --- a/dbus/dbus-authorization.c +++ b/dbus/dbus-authorization.c @@ -5,8 +5,6 @@ #include "dbus-connection-internal.h" struct DBusAuthorization { - int refcount; - DBusConnection *connection; /* Authorization functions, used as callback by SASL (implemented by @@ -26,58 +24,31 @@ struct DBusAuthorization { DBusAuthorization * _dbus_authorization_new (void) { - DBusAuthorization *ret; - - ret = dbus_malloc0 (sizeof (DBusAuthorization)); - if (ret == NULL) - { - _dbus_verbose ("OOM\n"); - return NULL; /* OOM */ - } - - ret->refcount = 1; - - return ret; -} - -DBusAuthorization * -_dbus_authorization_ref (DBusAuthorization *self) -{ - _dbus_assert (self != NULL); - - self->refcount += 1; - - return self; + /* it returns the allocated memory or NULL in case of OOM */ + return dbus_malloc0 (sizeof (DBusAuthorization)); } void -_dbus_authorization_unref (DBusAuthorization *self) +_dbus_authorization_free (DBusAuthorization *self) { _dbus_assert (self != NULL); - _dbus_assert (self->refcount > 0); - self->refcount -= 1; + if (self->unix_data && self->unix_data_free) + { + _dbus_verbose ("freeing unix authorization callback data\n"); + (*self->unix_data_free) (self->unix_data); + self->unix_data = NULL; + } - if (self->refcount == 0) + if (self->windows_data && self->windows_data_free) { - _dbus_verbose ("last reference, finalizing\n"); - - if (self->unix_data && self->unix_data_free) - { - _dbus_verbose ("freeing unix authorization callback data\n"); - (*self->unix_data_free) (self->unix_data); - self->unix_data = NULL; - } - - if (self->windows_data && self->windows_data_free) - { - _dbus_verbose ("freeing windows authorization callback data\n"); - (*self->windows_data_free) (self->windows_data); - self->windows_data = NULL; - } - - dbus_free (self); + _dbus_verbose ("freeing windows authorization callback data\n"); + (*self->windows_data_free) (self->windows_data); + self->windows_data = NULL; } + + _dbus_verbose ("freeing memory for %p\n", self); + dbus_free (self); } /* Called by transport's set_connection with the connection locked */ @@ -85,6 +56,7 @@ void _dbus_authorization_set_connection (DBusAuthorization *self, DBusConnection *connection) { + _dbus_assert (self != NULL); _dbus_assert (connection != NULL); _dbus_assert (self->connection == NULL); @@ -115,6 +87,8 @@ _dbus_authorization_set_unix_authorization_callback (DBusAuthorization void **old_data, DBusFreeFunction *old_free_data_function) { + _dbus_assert (self != NULL); + *old_data = self->unix_data; *old_free_data_function = self->unix_data_free; @@ -148,6 +122,8 @@ _dbus_authorization_set_windows_authorization_callback (DBusAuthorization void **old_data, DBusFreeFunction *old_free_data_function) { + _dbus_assert (self != NULL); + *old_data = self->windows_data; *old_free_data_function = self->windows_data_free; @@ -166,6 +142,7 @@ auth_via_unix_authorization_callback (DBusAuthorization *self, /* Dropping the lock here probably isn't that safe. */ + _dbus_assert (self != NULL); _dbus_assert (auth_identity != NULL); uid = _dbus_credentials_get_unix_uid (auth_identity); @@ -203,6 +180,7 @@ auth_via_windows_authorization_callback (DBusAuthorization *self, /* Dropping the lock here probably isn't that safe. */ + _dbus_assert (self != NULL); _dbus_assert (auth_identity != NULL); windows_sid = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity)); @@ -243,6 +221,7 @@ auth_via_default_rules (DBusAuthorization *self, DBusCredentials *our_identity; dbus_bool_t allow; + _dbus_assert (self != NULL); _dbus_assert (auth_identity != NULL); /* By default, connection is allowed if the client is 1) root or 2) @@ -299,6 +278,8 @@ _dbus_authorization_do_authorization (DBusAuthorization *self, { dbus_bool_t allow; + _dbus_assert (self != NULL); + /* maybe-FIXME: at this point we *should* have a connection set unless we * are in some test case, but we assert its presence only in some if's * branches since default_rules does not need one and is used in a test case @@ -340,5 +321,7 @@ void _dbus_authorization_set_allow_anonymous (DBusAuthorization *self, dbus_bool_t value) { + _dbus_assert (self != NULL); + self->allow_anonymous = value != FALSE; } diff --git a/dbus/dbus-authorization.h b/dbus/dbus-authorization.h index 8f7f1d43..eca81d80 100644 --- a/dbus/dbus-authorization.h +++ b/dbus/dbus-authorization.h @@ -9,8 +9,7 @@ typedef struct DBusAuthorization DBusAuthorization; DBusAuthorization *_dbus_authorization_new (void); void _dbus_authorization_set_connection (DBusAuthorization *self, DBusConnection *connection); -DBusAuthorization * _dbus_authorization_ref (DBusAuthorization *self); -void _dbus_authorization_unref (DBusAuthorization *self); +void _dbus_authorization_free (DBusAuthorization *self); void _dbus_authorization_set_unix_authorization_callback (DBusAuthorization *self, DBusAllowUnixUserFunction function, void *data, DBusFreeFunction free_data_function, void **old_data, diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 3a9cf84b..db16574a 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -134,7 +134,7 @@ _dbus_transport_init_base (DBusTransport *transport, if (auth == NULL) { if (authorization != NULL) - _dbus_authorization_unref (authorization); + _dbus_authorization_free (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -142,9 +142,9 @@ _dbus_transport_init_base (DBusTransport *transport, counter = _dbus_counter_new (); if (counter == NULL) { - _dbus_auth_unref (auth); + _dbus_auth_free (auth); if (authorization != NULL) - _dbus_authorization_unref (authorization); + _dbus_authorization_free (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -153,9 +153,9 @@ _dbus_transport_init_base (DBusTransport *transport, if (creds == NULL) { _dbus_counter_unref (counter); - _dbus_auth_unref (auth); + _dbus_auth_free (auth); if (authorization != NULL) - _dbus_authorization_unref (authorization); + _dbus_authorization_free (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -173,9 +173,9 @@ _dbus_transport_init_base (DBusTransport *transport, { _dbus_credentials_unref (creds); _dbus_counter_unref (counter); - _dbus_auth_unref (auth); + _dbus_auth_free (auth); if (authorization != NULL) - _dbus_authorization_unref (authorization); + _dbus_authorization_free (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -237,9 +237,9 @@ _dbus_transport_finalize_base (DBusTransport *transport) _dbus_transport_disconnect (transport); _dbus_message_loader_unref (transport->loader); - _dbus_auth_unref (transport->auth); + _dbus_auth_free (transport->auth); if (transport->authorization) - _dbus_authorization_unref (transport->authorization); + _dbus_authorization_free (transport->authorization); _dbus_counter_set_notify (transport->live_messages, 0, 0, NULL, NULL); _dbus_counter_unref (transport->live_messages); -- cgit v1.2.1 From a4722d4480de77af6a0c8201882731dc35777d36 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Tue, 18 Oct 2011 12:08:00 +0100 Subject: dbus_connection_set_allow_anonymous(): fix doc Bug: http://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Ralf Habacker --- dbus/dbus-connection.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index a6caaea6..a82ebcf6 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -5413,6 +5413,11 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti * such as ANONYMOUS that supports anonymous auth must be included in * the list of available mechanisms for anonymous login to work. * + * Note that the mechanism might reject the connection even if anonymous + * authentication has been enabled if dbus_connection_set_unix_user_function() + * or dbus_connection_set_windows_user_function() have been used to set a + * specific authorization callback. + * * This setting also changes the default rule for connections * authorized as a user; normally, if a connection authorizes as * a user identity, it is permitted if the user identity is -- cgit v1.2.1 From 9c0a70f5a3faa6a76e9a06e4e192ce551d7b880c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 02:57:27 +0200 Subject: Add a simple manual test for authentication/authorization. Bug: http://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Ralf Habacker --- test/Makefile.am | 14 +- test/manual-authz.c | 405 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 417 insertions(+), 2 deletions(-) create mode 100644 test/manual-authz.c diff --git a/test/Makefile.am b/test/Makefile.am index 074017a5..4866b328 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -103,6 +103,8 @@ installable_tests = \ shell-test \ test-printf \ $(NULL) +installable_manual_tests += \ + $(NULL) if DBUS_WITH_GLIB installable_tests += \ @@ -116,6 +118,9 @@ installable_tests += \ test-syntax \ test-syslog \ $(NULL) +installable_manual_tests += \ + manual-authz \ + $(NULL) endif DBUS_WITH_GLIB installcheck_tests = @@ -132,6 +137,11 @@ TESTS_ENVIRONMENT = \ DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \ $(NULL) +manual_authz_SOURCES = manual-authz.c +manual_authz_LDADD = $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) \ + $(DBUS_GLIB_LIBS) + test_corrupt_SOURCES = corrupt.c test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \ $(GLIB_LIBS) \ @@ -173,9 +183,9 @@ TESTS += $(installable_tests) installcheck_tests += $(installable_tests) if DBUS_ENABLE_INSTALLED_TESTS - testexec_PROGRAMS += $(installable_tests) + testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests) else !DBUS_ENABLE_INSTALLED_TESTS - noinst_PROGRAMS += $(installable_tests) + noinst_PROGRAMS += $(installable_tests) $(installable_manual_tests) endif !DBUS_ENABLE_INSTALLED_TESTS endif DBUS_ENABLE_MODULAR_TESTS diff --git a/test/manual-authz.c b/test/manual-authz.c new file mode 100644 index 00000000..d228829b --- /dev/null +++ b/test/manual-authz.c @@ -0,0 +1,405 @@ +/* Simple sanity-check for authentication and authorization. + * + * Copyright © 2010-2011 Nokia Corporation + * Copyright © 2012 Collabora Ltd. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include + +#include + +#include +#include + +#ifdef G_OS_UNIX +#include +#include +#endif + +typedef struct { + DBusError e; + + DBusServer *normal_server; + DBusServer *anon_allowed_server; + DBusServer *anon_only_server; + DBusServer *anon_mech_only_server; + DBusServer *anon_disallowed_server; + DBusServer *permissive_server; + DBusServer *unhappy_server; + DBusServer *same_uid_server; + DBusServer *same_uid_or_anon_server; +} Fixture; + +static void oom (void) G_GNUC_NORETURN; +static void +oom (void) +{ + g_error ("out of memory"); +} + +static void +assert_no_error (const DBusError *e) +{ + if (G_UNLIKELY (dbus_error_is_set (e))) + g_error ("expected success but got error: %s: %s", e->name, e->message); +} + +static DBusHandlerResult +server_message_cb (DBusConnection *conn, + DBusMessage *message, + void *data) +{ + if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) + { + dbus_connection_unref (conn); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL) + { + DBusMessage *reply = dbus_message_new_method_return (message); + const char *hello = "Hello, world!"; + unsigned long uid; + char *sid; + + if (dbus_connection_get_unix_user (conn, &uid)) + { + g_message ("message from uid %lu", uid); + } + else if (dbus_connection_get_windows_user (conn, &sid)) + { + if (sid == NULL) + oom (); + + g_message ("message from sid \"%s\"", sid); + dbus_free (sid); + } + else if (dbus_connection_get_is_anonymous (conn)) + { + g_message ("message from Anonymous"); + } + else + { + g_message ("message from ... someone?"); + } + + if (reply == NULL) + oom (); + + if (!dbus_message_append_args (reply, + DBUS_TYPE_STRING, &hello, + DBUS_TYPE_INVALID)) + oom (); + + if (!dbus_connection_send (conn, reply, NULL)) + oom (); + + dbus_message_unref (reply); + + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static dbus_bool_t +permissive_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_message ("accepting Unix user %lu", uid); + return TRUE; +} + +static dbus_bool_t +permissive_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_message ("accepting Windows user \"%s\"", sid); + return TRUE; +} + +static dbus_bool_t +broken_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_error ("libdbus called the Unix user function for an ANONYMOUS-only " + "connection"); + return FALSE; +} + +static dbus_bool_t +broken_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_error ("libdbus called the Windows user function for an ANONYMOUS-only " + "connection"); + return FALSE; +} + +static dbus_bool_t +unhappy_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_message ("rejecting Unix user %lu", uid); + return FALSE; +} + +static dbus_bool_t +unhappy_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_message ("rejecting Windows user \"%s\"", sid); + return FALSE; +} + +static dbus_bool_t +same_uid_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_message ("checking whether Unix user %lu owns this process", uid); + /* I'd use _dbus_unix_user_is_process_owner(), but it's private... */ +#ifdef G_OS_UNIX + return (geteuid () == uid); +#else + return FALSE; +#endif +} + +static dbus_bool_t +same_uid_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_message ("checking whether Windows user \"%s\" owns this process", sid); + g_message ("Stub implementation consistent with dbus-sysdeps-util-win: " + "assume they do"); + return TRUE; +} + +static void +new_conn_cb (DBusServer *server, + DBusConnection *conn, + void *data) +{ + Fixture *f = data; + + dbus_connection_ref (conn); + dbus_connection_setup_with_g_main (conn, NULL); + + if (!dbus_connection_add_filter (conn, server_message_cb, f, NULL)) + oom (); + + if (server == f->normal_server) + { + } + else if (server == f->anon_allowed_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + } + else if (server == f->anon_only_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + + dbus_connection_set_unix_user_function (conn, unhappy_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, unhappy_win_func, + f, NULL); + } + else if (server == f->anon_mech_only_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + + /* should never get called */ + dbus_connection_set_unix_user_function (conn, broken_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, broken_win_func, + f, NULL); + } + else if (server == f->anon_disallowed_server) + { + dbus_connection_set_allow_anonymous (conn, FALSE); + + /* should never get called */ + dbus_connection_set_unix_user_function (conn, broken_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, broken_win_func, + f, NULL); + } + else if (server == f->permissive_server) + { + dbus_connection_set_unix_user_function (conn, permissive_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, permissive_win_func, + f, NULL); + } + else if (server == f->unhappy_server) + { + dbus_connection_set_unix_user_function (conn, unhappy_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, unhappy_win_func, + f, NULL); + } + else if (server == f->same_uid_server) + { + dbus_connection_set_unix_user_function (conn, same_uid_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, same_uid_win_func, + f, NULL); + } + else if (server == f->same_uid_or_anon_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + + dbus_connection_set_unix_user_function (conn, same_uid_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, same_uid_win_func, + f, NULL); + } + else + { + g_assert_not_reached (); + } +} + +static void +setup (Fixture *f, + const gchar *listen_addr) +{ + const char *only_anon[] = { "ANONYMOUS", NULL }; + char *connect_addr; + + f->normal_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->normal_server != NULL); + dbus_server_set_new_connection_function (f->normal_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->normal_server, NULL); + connect_addr = dbus_server_get_address (f->normal_server); + g_message ("Normal server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_allowed_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_allowed_server != NULL); + dbus_server_set_new_connection_function (f->anon_allowed_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->anon_allowed_server, NULL); + connect_addr = dbus_server_get_address (f->anon_allowed_server); + g_message ("Anonymous-allowed server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_only_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_only_server != NULL); + dbus_server_set_new_connection_function (f->anon_only_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->anon_only_server, NULL); + connect_addr = dbus_server_get_address (f->anon_only_server); + g_message ("Anonymous-only server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_mech_only_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_mech_only_server != NULL); + dbus_server_set_auth_mechanisms (f->anon_mech_only_server, only_anon); + dbus_server_set_new_connection_function (f->anon_mech_only_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->anon_mech_only_server, NULL); + connect_addr = dbus_server_get_address (f->anon_mech_only_server); + g_message ("Anon mech only server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_disallowed_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_disallowed_server != NULL); + dbus_server_set_auth_mechanisms (f->anon_disallowed_server, only_anon); + dbus_server_set_new_connection_function (f->anon_disallowed_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->anon_disallowed_server, NULL); + connect_addr = dbus_server_get_address (f->anon_disallowed_server); + g_message ("Anonymous-disallowed server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->permissive_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->permissive_server != NULL); + dbus_server_set_new_connection_function (f->permissive_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->permissive_server, NULL); + connect_addr = dbus_server_get_address (f->permissive_server); + g_message ("Permissive server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->unhappy_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->unhappy_server != NULL); + dbus_server_set_new_connection_function (f->unhappy_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->unhappy_server, NULL); + connect_addr = dbus_server_get_address (f->unhappy_server); + g_message ("Unhappy server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->same_uid_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->same_uid_server != NULL); + dbus_server_set_new_connection_function (f->same_uid_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->same_uid_server, NULL); + connect_addr = dbus_server_get_address (f->same_uid_server); + g_message ("Same-UID server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->same_uid_or_anon_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->same_uid_or_anon_server != NULL); + dbus_server_set_new_connection_function (f->same_uid_or_anon_server, + new_conn_cb, f, NULL); + dbus_server_setup_with_g_main (f->same_uid_or_anon_server, NULL); + connect_addr = dbus_server_get_address (f->same_uid_or_anon_server); + g_message ("Same-UID-or-anon server:\n%s", connect_addr); + dbus_free (connect_addr); +} + +int +main (int argc, + char **argv) +{ + Fixture f = { DBUS_ERROR_INIT }; + + if (argc >= 2) + setup (&f, argv[1]); + else + setup (&f, "tcp:host=127.0.0.1"); + + for (;;) + g_main_context_iteration (NULL, TRUE); +} -- cgit v1.2.1 From 65cd1208e0559fffe4ba82ef10c6491744869b09 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 03:01:53 +0200 Subject: trivial: re-word authorization failure message Bug: http://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Ralf Habacker --- dbus/dbus-auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index 3da25ec5..fabe8c59 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -1128,8 +1128,8 @@ handle_server_data_external_mech (DBusAuth *auth, } else { - _dbus_verbose ("%s: desired identity does not match server identity: " - "not authorized\n", DBUS_AUTH_NAME (auth)); + _dbus_verbose ("%s: authenticated identity not authorized by server\n", + DBUS_AUTH_NAME (auth)); return send_rejected (auth); } -- cgit v1.2.1 From 71cfa9cdd0d73c650f79b49c21b42ccd36ad71cf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 12 Mar 2012 13:13:55 +0000 Subject: Add a test-case for trying to connect with the wrong GUID Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39720 Signed-off-by: Simon McVittie --- test/loopback.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/test/loopback.c b/test/loopback.c index d0d69c82..39cf03ab 100644 --- a/test/loopback.c +++ b/test/loopback.c @@ -1,7 +1,7 @@ /* Simple sanity-check for loopback through TCP and Unix sockets. * * Author: Simon McVittie - * Copyright © 2010-2011 Nokia Corporation + * Copyright © 2010-2012 Nokia Corporation * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files @@ -31,6 +31,8 @@ #include #include +#include + typedef struct { DBusError e; @@ -114,6 +116,66 @@ test_connect (Fixture *f, } } +static void +test_bad_guid (Fixture *f, + gconstpointer addr G_GNUC_UNUSED) +{ + DBusMessage *incoming; + gchar *address = g_strdup (dbus_server_get_address (f->server)); + gchar *guid; + + g_test_bug ("39720"); + + g_assert (f->server_conn == NULL); + + g_assert (strstr (address, "guid=") != NULL); + guid = strstr (address, "guid="); + g_assert_cmpuint (strlen (guid), >=, 5 + 32); + + /* Change the first char of the guid to something different */ + if (guid[5] == '0') + guid[5] = 'f'; + else + guid[5] = '0'; + + f->client_conn = dbus_connection_open_private (address, &f->e); + assert_no_error (&f->e); + g_assert (f->client_conn != NULL); + dbus_connection_setup_with_g_main (f->client_conn, NULL); + + while (f->server_conn == NULL) + { + g_print ("."); + g_main_context_iteration (NULL, TRUE); + } + + /* We get disconnected */ + + while (g_queue_is_empty (&f->server_messages)) + { + g_print ("."); + g_main_context_iteration (NULL, TRUE); + } + + g_assert_cmpuint (g_queue_get_length (&f->server_messages), ==, 1); + + incoming = g_queue_pop_head (&f->server_messages); + + g_assert (!dbus_message_contains_unix_fds (incoming)); + g_assert_cmpstr (dbus_message_get_destination (incoming), ==, NULL); + g_assert_cmpstr (dbus_message_get_error_name (incoming), ==, NULL); + g_assert_cmpstr (dbus_message_get_interface (incoming), ==, + DBUS_INTERFACE_LOCAL); + g_assert_cmpstr (dbus_message_get_member (incoming), ==, "Disconnected"); + g_assert_cmpstr (dbus_message_get_sender (incoming), ==, NULL); + g_assert_cmpstr (dbus_message_get_signature (incoming), ==, ""); + g_assert_cmpstr (dbus_message_get_path (incoming), ==, DBUS_PATH_LOCAL); + + dbus_message_unref (incoming); + + g_free (address); +} + static void test_message (Fixture *f, gconstpointer addr) @@ -189,6 +251,7 @@ main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); g_test_add ("/connect/tcp", Fixture, "tcp:host=127.0.0.1", setup, test_connect, teardown); @@ -207,5 +270,8 @@ main (int argc, test_message, teardown); #endif + g_test_add ("/message/bad-guid", Fixture, "tcp:host=127.0.0.1", setup, + test_bad_guid, teardown); + return g_test_run (); } -- cgit v1.2.1 From 5fcba306d9e4a9caf137e1550eacd566a7428944 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 23 Aug 2013 03:10:15 +0200 Subject: Manual rebase fix. --- test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 4866b328..8b2a5255 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -103,7 +103,7 @@ installable_tests = \ shell-test \ test-printf \ $(NULL) -installable_manual_tests += \ +installable_manual_tests = \ $(NULL) if DBUS_WITH_GLIB -- cgit v1.2.1 From 64e50dd167993fb2344d2d3be18bb0d5820b5b26 Mon Sep 17 00:00:00 2001 From: Cosimo Alfarano Date: Fri, 23 Aug 2013 01:56:48 +0200 Subject: Remove transport's call to _dbus_authorization_do_authorization(). All mechs do authorization before answering OK/REJECT. There is no reason to run a second round of authorization which will return the same answer of the first time (when OK) or will never be reched (if REJECTed). Bug: http://bugs.freedesktop.org/show_bug.cgi?id=39720 Reviewed-by: Simon McVittie --- dbus/dbus-transport.c | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index db16574a..da95d2c2 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -589,9 +589,6 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) if (transport->disconnected) return FALSE; - /* paranoia ref since we call user callbacks sometimes */ - _dbus_connection_ref_unlocked (transport->connection); - maybe_authenticated = (!(transport->send_credentials_pending || transport->receive_credentials_pending)); @@ -623,32 +620,12 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) _dbus_verbose ("Client expected GUID '%s' and we got '%s' from the server\n", transport->expected_guid, server_guid); _dbus_transport_disconnect (transport); - _dbus_connection_unref_unlocked (transport->connection); return FALSE; } } - /* If we're the server, see if we want to allow this identity to proceed. - */ - if (maybe_authenticated && transport->is_server) - { - DBusCredentials *auth_identity; - - auth_identity = _dbus_auth_get_identity (transport->auth); - _dbus_assert (auth_identity != NULL); - - /* If we have an authenticated user, delegate deciding whether auth - * credentials are good enough to the app */ - if (!_dbus_authorization_do_authorization (transport->authorization, auth_identity)) - { - _dbus_transport_disconnect (transport); - maybe_authenticated = FALSE; - } - } - transport->authenticated = maybe_authenticated; - _dbus_connection_unref_unlocked (transport->connection); return maybe_authenticated; } } -- cgit v1.2.1 From f9b4432dbb1a5e9575d2ae61305b57ad6c254149 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:21 +0100 Subject: Revert "Remove transport's call to _dbus_authorization_do_authorization()." This reverts commit 64e50dd167993fb2344d2d3be18bb0d5820b5b26. --- dbus/dbus-transport.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index da95d2c2..db16574a 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -589,6 +589,9 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) if (transport->disconnected) return FALSE; + /* paranoia ref since we call user callbacks sometimes */ + _dbus_connection_ref_unlocked (transport->connection); + maybe_authenticated = (!(transport->send_credentials_pending || transport->receive_credentials_pending)); @@ -620,12 +623,32 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) _dbus_verbose ("Client expected GUID '%s' and we got '%s' from the server\n", transport->expected_guid, server_guid); _dbus_transport_disconnect (transport); + _dbus_connection_unref_unlocked (transport->connection); return FALSE; } } + /* If we're the server, see if we want to allow this identity to proceed. + */ + if (maybe_authenticated && transport->is_server) + { + DBusCredentials *auth_identity; + + auth_identity = _dbus_auth_get_identity (transport->auth); + _dbus_assert (auth_identity != NULL); + + /* If we have an authenticated user, delegate deciding whether auth + * credentials are good enough to the app */ + if (!_dbus_authorization_do_authorization (transport->authorization, auth_identity)) + { + _dbus_transport_disconnect (transport); + maybe_authenticated = FALSE; + } + } + transport->authenticated = maybe_authenticated; + _dbus_connection_unref_unlocked (transport->connection); return maybe_authenticated; } } -- cgit v1.2.1 From b75b6c42024f9f1dc0f88d0d657c81b76d509ced Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:28 +0100 Subject: Revert "trivial: re-word authorization failure message" This reverts commit 65cd1208e0559fffe4ba82ef10c6491744869b09. --- dbus/dbus-auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index fabe8c59..3da25ec5 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -1128,8 +1128,8 @@ handle_server_data_external_mech (DBusAuth *auth, } else { - _dbus_verbose ("%s: authenticated identity not authorized by server\n", - DBUS_AUTH_NAME (auth)); + _dbus_verbose ("%s: desired identity does not match server identity: " + "not authorized\n", DBUS_AUTH_NAME (auth)); return send_rejected (auth); } -- cgit v1.2.1 From bb9e5f65e7acecda1a812e58875d8a65f5a065d3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:29 +0100 Subject: Revert "dbus_connection_set_allow_anonymous(): fix doc" This reverts commit a4722d4480de77af6a0c8201882731dc35777d36. --- dbus/dbus-connection.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index a82ebcf6..a6caaea6 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -5413,11 +5413,6 @@ dbus_connection_set_windows_user_function (DBusConnection *connecti * such as ANONYMOUS that supports anonymous auth must be included in * the list of available mechanisms for anonymous login to work. * - * Note that the mechanism might reject the connection even if anonymous - * authentication has been enabled if dbus_connection_set_unix_user_function() - * or dbus_connection_set_windows_user_function() have been used to set a - * specific authorization callback. - * * This setting also changes the default rule for connections * authorized as a user; normally, if a connection authorizes as * a user identity, it is permitted if the user identity is -- cgit v1.2.1 From 3006b952dbd939d01507d1397e8c4a0e03f2d7a6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:30 +0100 Subject: Revert "Remove refcounting from DBusAuth and DBusAuthorization" This reverts commit 7f6d7229d8812d985d544cf5dd3636865c5abc81. --- dbus/dbus-auth-script.c | 25 ++++++++++++--- dbus/dbus-auth.c | 81 +++++++++++++++++++++++++++++++---------------- dbus/dbus-auth.h | 3 +- dbus/dbus-authorization.c | 73 ++++++++++++++++++++++++++---------------- dbus/dbus-authorization.h | 3 +- dbus/dbus-transport.c | 18 +++++------ 6 files changed, 131 insertions(+), 72 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index d195dde5..107c92b2 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -250,7 +250,6 @@ _dbus_auth_script_run (const DBusString *filename) dbus_bool_t retval; int line_no; DBusAuth *auth; - DBusAuthorization *authorization; DBusString from_auth; DBusAuthState state; DBusString context; @@ -258,7 +257,6 @@ _dbus_auth_script_run (const DBusString *filename) retval = FALSE; auth = NULL; - authorization = NULL; _dbus_string_init_const (&guid, "5fa01f4202cd837709a3274ca0df9d00"); _dbus_string_init_const (&context, "org_freedesktop_test"); @@ -376,16 +374,24 @@ _dbus_auth_script_run (const DBusString *filename) goto out; } + /* test ref/unref */ + _dbus_auth_ref (auth); + _dbus_auth_unref (auth); + creds = _dbus_credentials_new_from_current_process (); if (creds == NULL) { _dbus_warn ("no memory for credentials\n"); + _dbus_auth_unref (auth); + auth = NULL; goto out; } if (!_dbus_auth_set_credentials (auth, creds)) { _dbus_warn ("no memory for setting credentials\n"); + _dbus_auth_unref (auth); + auth = NULL; _dbus_credentials_unref (creds); goto out; } @@ -396,6 +402,7 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS")) { DBusCredentials *creds; + DBusAuthorization *authorization; if (auth != NULL) { @@ -416,22 +423,32 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_authorization_set_allow_anonymous (authorization, TRUE); auth = _dbus_auth_server_new (&guid, authorization); + /* DBusAuth owns it, or finalized on OOM */ + _dbus_authorization_unref (authorization); if (auth == NULL) { _dbus_warn ("no memory to create DBusAuth\n"); goto out; } + /* test ref/unref */ + _dbus_auth_ref (auth); + _dbus_auth_unref (auth); + creds = _dbus_credentials_new_from_current_process (); if (creds == NULL) { _dbus_warn ("no memory for credentials\n"); + _dbus_auth_unref (auth); + auth = NULL; goto out; } if (!_dbus_auth_set_credentials (auth, creds)) { _dbus_warn ("no memory for setting credentials\n"); + _dbus_auth_unref (auth); + auth = NULL; _dbus_credentials_unref (creds); goto out; } @@ -789,9 +806,7 @@ _dbus_auth_script_run (const DBusString *filename) out: if (auth) - _dbus_auth_free (auth); - if (authorization) - _dbus_authorization_free (authorization); + _dbus_auth_unref (auth); _dbus_string_free (&file); _dbus_string_free (&line); diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index 3da25ec5..a2187016 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -153,6 +153,7 @@ typedef struct */ struct DBusAuth { + int refcount; /**< reference count */ const char *side; /**< Client or server */ DBusString incoming; /**< Incoming data buffer */ @@ -345,6 +346,8 @@ _dbus_auth_new (int size) if (auth == NULL) return NULL; + auth->refcount = 1; + auth->keyring = NULL; auth->cookie_id = -1; @@ -2259,7 +2262,7 @@ process_command (DBusAuth *auth) */ DBusAuth* _dbus_auth_server_new (const DBusString *guid, - DBusAuthorization *authorization) + DBusAuthorization *authorization) { DBusAuth *auth; DBusAuthServer *server_auth; @@ -2287,7 +2290,7 @@ _dbus_auth_server_new (const DBusString *guid, server_auth = DBUS_AUTH_SERVER (auth); server_auth->guid = guid_copy; - server_auth->authorization = authorization; + server_auth->authorization = _dbus_authorization_ref (authorization); /* perhaps this should be per-mechanism with a lower * max @@ -2330,7 +2333,7 @@ _dbus_auth_client_new (void) * mechanism */ if (!send_auth (auth, &all_mechanisms[0])) { - _dbus_auth_free (auth); + _dbus_auth_unref (auth); return NULL; } @@ -2338,45 +2341,67 @@ _dbus_auth_client_new (void) } /** - * Free memory allocated for an auth object. + * Increments the refcount of an auth object. * * @param auth the auth conversation + * @returns the auth conversation */ -void -_dbus_auth_free (DBusAuth *auth) +DBusAuth * +_dbus_auth_ref (DBusAuth *auth) { _dbus_assert (auth != NULL); + + auth->refcount += 1; + + return auth; +} - shutdown_mech (auth); +/** + * Decrements the refcount of an auth object. + * + * @param auth the auth conversation + */ +void +_dbus_auth_unref (DBusAuth *auth) +{ + _dbus_assert (auth != NULL); + _dbus_assert (auth->refcount > 0); - if (DBUS_AUTH_IS_CLIENT (auth)) + auth->refcount -= 1; + if (auth->refcount == 0) { - _dbus_string_free (& DBUS_AUTH_CLIENT (auth)->guid_from_server); - _dbus_list_clear (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); - } - else - { - _dbus_assert (DBUS_AUTH_IS_SERVER (auth)); + shutdown_mech (auth); - _dbus_string_free (& DBUS_AUTH_SERVER (auth)->guid); - } + if (DBUS_AUTH_IS_CLIENT (auth)) + { + _dbus_string_free (& DBUS_AUTH_CLIENT (auth)->guid_from_server); + _dbus_list_clear (& DBUS_AUTH_CLIENT (auth)->mechs_to_try); + } + else + { + _dbus_assert (DBUS_AUTH_IS_SERVER (auth)); - if (auth->keyring) - _dbus_keyring_unref (auth->keyring); + _dbus_string_free (& DBUS_AUTH_SERVER (auth)->guid); + _dbus_authorization_unref (DBUS_AUTH_SERVER (auth)->authorization); + } - _dbus_string_free (&auth->context); - _dbus_string_free (&auth->challenge); - _dbus_string_free (&auth->identity); - _dbus_string_free (&auth->incoming); - _dbus_string_free (&auth->outgoing); + if (auth->keyring) + _dbus_keyring_unref (auth->keyring); - dbus_free_string_array (auth->allowed_mechs); + _dbus_string_free (&auth->context); + _dbus_string_free (&auth->challenge); + _dbus_string_free (&auth->identity); + _dbus_string_free (&auth->incoming); + _dbus_string_free (&auth->outgoing); - _dbus_credentials_unref (auth->credentials); - _dbus_credentials_unref (auth->authenticated_identity); - _dbus_credentials_unref (auth->desired_identity); + dbus_free_string_array (auth->allowed_mechs); - dbus_free (auth); + _dbus_credentials_unref (auth->credentials); + _dbus_credentials_unref (auth->authenticated_identity); + _dbus_credentials_unref (auth->desired_identity); + + dbus_free (auth); + } } /** diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h index 1cf0570a..3f178a22 100644 --- a/dbus/dbus-auth.h +++ b/dbus/dbus-auth.h @@ -45,7 +45,8 @@ typedef enum DBusAuth* _dbus_auth_server_new (const DBusString *guid, DBusAuthorization *authorization); DBusAuth* _dbus_auth_client_new (void); -void _dbus_auth_free (DBusAuth *auth); +DBusAuth* _dbus_auth_ref (DBusAuth *auth); +void _dbus_auth_unref (DBusAuth *auth); dbus_bool_t _dbus_auth_set_mechanisms (DBusAuth *auth, const char **mechanisms); DBusAuthState _dbus_auth_do_work (DBusAuth *auth); diff --git a/dbus/dbus-authorization.c b/dbus/dbus-authorization.c index 3f0b9660..05a3aa87 100644 --- a/dbus/dbus-authorization.c +++ b/dbus/dbus-authorization.c @@ -5,6 +5,8 @@ #include "dbus-connection-internal.h" struct DBusAuthorization { + int refcount; + DBusConnection *connection; /* Authorization functions, used as callback by SASL (implemented by @@ -24,31 +26,58 @@ struct DBusAuthorization { DBusAuthorization * _dbus_authorization_new (void) { - /* it returns the allocated memory or NULL in case of OOM */ - return dbus_malloc0 (sizeof (DBusAuthorization)); + DBusAuthorization *ret; + + ret = dbus_malloc0 (sizeof (DBusAuthorization)); + if (ret == NULL) + { + _dbus_verbose ("OOM\n"); + return NULL; /* OOM */ + } + + ret->refcount = 1; + + return ret; +} + +DBusAuthorization * +_dbus_authorization_ref (DBusAuthorization *self) +{ + _dbus_assert (self != NULL); + + self->refcount += 1; + + return self; } void -_dbus_authorization_free (DBusAuthorization *self) +_dbus_authorization_unref (DBusAuthorization *self) { _dbus_assert (self != NULL); + _dbus_assert (self->refcount > 0); - if (self->unix_data && self->unix_data_free) - { - _dbus_verbose ("freeing unix authorization callback data\n"); - (*self->unix_data_free) (self->unix_data); - self->unix_data = NULL; - } + self->refcount -= 1; - if (self->windows_data && self->windows_data_free) + if (self->refcount == 0) { - _dbus_verbose ("freeing windows authorization callback data\n"); - (*self->windows_data_free) (self->windows_data); - self->windows_data = NULL; + _dbus_verbose ("last reference, finalizing\n"); + + if (self->unix_data && self->unix_data_free) + { + _dbus_verbose ("freeing unix authorization callback data\n"); + (*self->unix_data_free) (self->unix_data); + self->unix_data = NULL; + } + + if (self->windows_data && self->windows_data_free) + { + _dbus_verbose ("freeing windows authorization callback data\n"); + (*self->windows_data_free) (self->windows_data); + self->windows_data = NULL; + } + + dbus_free (self); } - - _dbus_verbose ("freeing memory for %p\n", self); - dbus_free (self); } /* Called by transport's set_connection with the connection locked */ @@ -56,7 +85,6 @@ void _dbus_authorization_set_connection (DBusAuthorization *self, DBusConnection *connection) { - _dbus_assert (self != NULL); _dbus_assert (connection != NULL); _dbus_assert (self->connection == NULL); @@ -87,8 +115,6 @@ _dbus_authorization_set_unix_authorization_callback (DBusAuthorization void **old_data, DBusFreeFunction *old_free_data_function) { - _dbus_assert (self != NULL); - *old_data = self->unix_data; *old_free_data_function = self->unix_data_free; @@ -122,8 +148,6 @@ _dbus_authorization_set_windows_authorization_callback (DBusAuthorization void **old_data, DBusFreeFunction *old_free_data_function) { - _dbus_assert (self != NULL); - *old_data = self->windows_data; *old_free_data_function = self->windows_data_free; @@ -142,7 +166,6 @@ auth_via_unix_authorization_callback (DBusAuthorization *self, /* Dropping the lock here probably isn't that safe. */ - _dbus_assert (self != NULL); _dbus_assert (auth_identity != NULL); uid = _dbus_credentials_get_unix_uid (auth_identity); @@ -180,7 +203,6 @@ auth_via_windows_authorization_callback (DBusAuthorization *self, /* Dropping the lock here probably isn't that safe. */ - _dbus_assert (self != NULL); _dbus_assert (auth_identity != NULL); windows_sid = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity)); @@ -221,7 +243,6 @@ auth_via_default_rules (DBusAuthorization *self, DBusCredentials *our_identity; dbus_bool_t allow; - _dbus_assert (self != NULL); _dbus_assert (auth_identity != NULL); /* By default, connection is allowed if the client is 1) root or 2) @@ -278,8 +299,6 @@ _dbus_authorization_do_authorization (DBusAuthorization *self, { dbus_bool_t allow; - _dbus_assert (self != NULL); - /* maybe-FIXME: at this point we *should* have a connection set unless we * are in some test case, but we assert its presence only in some if's * branches since default_rules does not need one and is used in a test case @@ -321,7 +340,5 @@ void _dbus_authorization_set_allow_anonymous (DBusAuthorization *self, dbus_bool_t value) { - _dbus_assert (self != NULL); - self->allow_anonymous = value != FALSE; } diff --git a/dbus/dbus-authorization.h b/dbus/dbus-authorization.h index eca81d80..8f7f1d43 100644 --- a/dbus/dbus-authorization.h +++ b/dbus/dbus-authorization.h @@ -9,7 +9,8 @@ typedef struct DBusAuthorization DBusAuthorization; DBusAuthorization *_dbus_authorization_new (void); void _dbus_authorization_set_connection (DBusAuthorization *self, DBusConnection *connection); -void _dbus_authorization_free (DBusAuthorization *self); +DBusAuthorization * _dbus_authorization_ref (DBusAuthorization *self); +void _dbus_authorization_unref (DBusAuthorization *self); void _dbus_authorization_set_unix_authorization_callback (DBusAuthorization *self, DBusAllowUnixUserFunction function, void *data, DBusFreeFunction free_data_function, void **old_data, diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index db16574a..3a9cf84b 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -134,7 +134,7 @@ _dbus_transport_init_base (DBusTransport *transport, if (auth == NULL) { if (authorization != NULL) - _dbus_authorization_free (authorization); + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -142,9 +142,9 @@ _dbus_transport_init_base (DBusTransport *transport, counter = _dbus_counter_new (); if (counter == NULL) { - _dbus_auth_free (auth); + _dbus_auth_unref (auth); if (authorization != NULL) - _dbus_authorization_free (authorization); + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -153,9 +153,9 @@ _dbus_transport_init_base (DBusTransport *transport, if (creds == NULL) { _dbus_counter_unref (counter); - _dbus_auth_free (auth); + _dbus_auth_unref (auth); if (authorization != NULL) - _dbus_authorization_free (authorization); + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -173,9 +173,9 @@ _dbus_transport_init_base (DBusTransport *transport, { _dbus_credentials_unref (creds); _dbus_counter_unref (counter); - _dbus_auth_free (auth); + _dbus_auth_unref (auth); if (authorization != NULL) - _dbus_authorization_free (authorization); + _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -237,9 +237,9 @@ _dbus_transport_finalize_base (DBusTransport *transport) _dbus_transport_disconnect (transport); _dbus_message_loader_unref (transport->loader); - _dbus_auth_free (transport->auth); + _dbus_auth_unref (transport->auth); if (transport->authorization) - _dbus_authorization_free (transport->authorization); + _dbus_authorization_unref (transport->authorization); _dbus_counter_set_notify (transport->live_messages, 0, 0, NULL, NULL); _dbus_counter_unref (transport->live_messages); -- cgit v1.2.1 From e5f16e571667908ca9eb149bc52c1a0ea980a3c1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:31 +0100 Subject: Revert "Enable anonymous authorization for tests" This reverts commit 22fc03d274f186a788efbdbe6b6dfcff1ad474df. --- dbus/dbus-auth-script.c | 9 ++------- test/data/auth/anonymous-server-successful.auth-script | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 107c92b2..445452c7 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -398,8 +398,8 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_credentials_unref (creds); } - else if (_dbus_string_starts_with_c_str (&line, "SERVER") || - _dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS")) + else if (_dbus_string_starts_with_c_str (&line, + "SERVER")) { DBusCredentials *creds; DBusAuthorization *authorization; @@ -417,11 +417,6 @@ _dbus_auth_script_run (const DBusString *filename) _dbus_warn ("no memory to create DBusAuthorization\n"); goto out; } - /* if we are testing an anonymous server, we need to enable - * anonymous authorization, or the mech will REJECT */ - if (_dbus_string_starts_with_c_str (&line, "SERVER_ANONYMOUS")) - _dbus_authorization_set_allow_anonymous (authorization, TRUE); - auth = _dbus_auth_server_new (&guid, authorization); /* DBusAuth owns it, or finalized on OOM */ _dbus_authorization_unref (authorization); diff --git a/test/data/auth/anonymous-server-successful.auth-script b/test/data/auth/anonymous-server-successful.auth-script index c53b30f9..172ae9de 100644 --- a/test/data/auth/anonymous-server-successful.auth-script +++ b/test/data/auth/anonymous-server-successful.auth-script @@ -1,7 +1,6 @@ ## this tests the server side in a successful auth of type ANONYMOUS -## Act as a server that accepts anonymous authorization -SERVER_ANONYMOUS +SERVER ## verify that prior to doing anything, we haven't authed as anyone EXPECT_HAVE_NO_CREDENTIALS SEND 'AUTH ANONYMOUS 442d42757320312e312e31' -- cgit v1.2.1 From 083169744b023667fe2646f76e5efb2e21bbc9dd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:31 +0100 Subject: Revert "Fixed rejected hunk complete." This reverts commit 541063a3ab568db8302fbce3c15b22cdff154517. --- dbus/dbus-auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index a2187016..6215f9e6 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -1124,7 +1124,7 @@ handle_server_data_external_mech (DBusAuth *auth, * re-authorize later, but it will close the connection on fail, * we want to REJECT now if possible */ if (_dbus_authorization_do_authorization (DBUS_AUTH_SERVER (auth)->authorization, - auth->authenticated_identity)) + auth->authorized_identity)) { if (!send_ok (auth)) return FALSE; -- cgit v1.2.1 From 383f596c4aee2561c90abca3ce9d1f52407a3eec Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:32 +0100 Subject: Revert "Rename authorized_identity in authenticated_identity for clarity sake." This reverts commit ef82b381524d30684a30b32b3b9016ed4229290c. --- dbus/dbus-auth.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index 6215f9e6..35efa3a8 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -170,7 +170,7 @@ struct DBusAuth DBusCredentials *credentials; /**< Credentials read from socket */ - DBusCredentials *authenticated_identity; /**< Credentials that are authorized */ + DBusCredentials *authorized_identity; /**< Credentials that are authorized */ DBusCredentials *desired_identity; /**< Identity client has requested */ @@ -382,8 +382,8 @@ _dbus_auth_new (int size) if (auth->credentials == NULL) goto enomem_6; - auth->authenticated_identity = _dbus_credentials_new (); - if (auth->authenticated_identity == NULL) + auth->authorized_identity = _dbus_credentials_new (); + if (auth->authorized_identity == NULL) goto enomem_7; auth->desired_identity = _dbus_credentials_new (); @@ -397,7 +397,7 @@ _dbus_auth_new (int size) _dbus_credentials_unref (auth->desired_identity); #endif enomem_8: - _dbus_credentials_unref (auth->authenticated_identity); + _dbus_credentials_unref (auth->authorized_identity); enomem_7: _dbus_credentials_unref (auth->credentials); enomem_6: @@ -424,7 +424,7 @@ shutdown_mech (DBusAuth *auth) auth->already_asked_for_initial_response = FALSE; _dbus_string_set_length (&auth->identity, 0); - _dbus_credentials_clear (auth->authenticated_identity); + _dbus_credentials_clear (auth->authorized_identity); _dbus_credentials_clear (auth->desired_identity); if (auth->mech != NULL) @@ -745,13 +745,13 @@ sha1_handle_second_client_response (DBusAuth *auth, goto out_3; } - if (!_dbus_credentials_add_credentials (auth->authenticated_identity, + if (!_dbus_credentials_add_credentials (auth->authorized_identity, auth->desired_identity)) goto out_3; /* Copy process ID from the socket credentials if it's there */ - if (!_dbus_credentials_add_credential (auth->authenticated_identity, + if (!_dbus_credentials_add_credential (auth->authorized_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) goto out_3; @@ -1101,20 +1101,20 @@ handle_server_data_external_mech (DBusAuth *auth, auth->desired_identity)) { /* client has authenticated */ - if (!_dbus_credentials_add_credentials (auth->authenticated_identity, + if (!_dbus_credentials_add_credentials (auth->authorized_identity, auth->desired_identity)) return FALSE; /* also copy process ID from the socket credentials */ - if (!_dbus_credentials_add_credential (auth->authenticated_identity, + if (!_dbus_credentials_add_credential (auth->authorized_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) return FALSE; /* also copy audit data from the socket credentials */ - if (!_dbus_credentials_add_credential (auth->authenticated_identity, + if (!_dbus_credentials_add_credential (auth->authorized_identity, DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID, auth->credentials)) return FALSE; @@ -1124,7 +1124,7 @@ handle_server_data_external_mech (DBusAuth *auth, * re-authorize later, but it will close the connection on fail, * we want to REJECT now if possible */ if (_dbus_authorization_do_authorization (DBUS_AUTH_SERVER (auth)->authorization, - auth->authorized_identity)) + auth->authorized_identity)) { if (!send_ok (auth)) return FALSE; @@ -1232,7 +1232,7 @@ handle_server_data_anonymous_mech (DBusAuth *auth, /* Copy process ID from the socket credentials */ - if (!_dbus_credentials_add_credential (auth->authenticated_identity, + if (!_dbus_credentials_add_credential (auth->authorized_identity, DBUS_CREDENTIAL_UNIX_PROCESS_ID, auth->credentials)) return FALSE; @@ -2397,7 +2397,7 @@ _dbus_auth_unref (DBusAuth *auth) dbus_free_string_array (auth->allowed_mechs); _dbus_credentials_unref (auth->credentials); - _dbus_credentials_unref (auth->authenticated_identity); + _dbus_credentials_unref (auth->authorized_identity); _dbus_credentials_unref (auth->desired_identity); dbus_free (auth); @@ -2754,7 +2754,7 @@ _dbus_auth_get_identity (DBusAuth *auth) { if (auth->state == &common_state_authenticated) { - return auth->authenticated_identity; + return auth->authorized_identity; } else { @@ -2762,8 +2762,8 @@ _dbus_auth_get_identity (DBusAuth *auth) * doesn't require allocation or something */ /* return empty credentials */ - _dbus_assert (_dbus_credentials_are_empty (auth->authenticated_identity)); - return auth->authenticated_identity; + _dbus_assert (_dbus_credentials_are_empty (auth->authorized_identity)); + return auth->authorized_identity; } } -- cgit v1.2.1 From 75f5b682cc57828fa8593b00f83342c03743cad1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:33 +0100 Subject: Revert "Add new files really." This reverts commit 78c447173dfba167ac8082652c02e453e4b519ce. --- dbus/dbus-authorization.c | 344 ---------------------------------------------- dbus/dbus-authorization.h | 25 ---- 2 files changed, 369 deletions(-) delete mode 100644 dbus/dbus-authorization.c delete mode 100644 dbus/dbus-authorization.h diff --git a/dbus/dbus-authorization.c b/dbus/dbus-authorization.c deleted file mode 100644 index 05a3aa87..00000000 --- a/dbus/dbus-authorization.c +++ /dev/null @@ -1,344 +0,0 @@ -#include -#include "dbus-internals.h" -#include "dbus-authorization.h" -#include "dbus-connection.h" -#include "dbus-connection-internal.h" - -struct DBusAuthorization { - int refcount; - - DBusConnection *connection; - - /* Authorization functions, used as callback by SASL (implemented by - * DBUsAuth) */ - DBusAllowUnixUserFunction unix_authorization_cb; - void *unix_data; - DBusFreeFunction unix_data_free; - - DBusAllowWindowsUserFunction windows_authorization_cb; - void *windows_data; - DBusFreeFunction windows_data_free; - - dbus_bool_t allow_anonymous; -}; - - -DBusAuthorization * -_dbus_authorization_new (void) -{ - DBusAuthorization *ret; - - ret = dbus_malloc0 (sizeof (DBusAuthorization)); - if (ret == NULL) - { - _dbus_verbose ("OOM\n"); - return NULL; /* OOM */ - } - - ret->refcount = 1; - - return ret; -} - -DBusAuthorization * -_dbus_authorization_ref (DBusAuthorization *self) -{ - _dbus_assert (self != NULL); - - self->refcount += 1; - - return self; -} - -void -_dbus_authorization_unref (DBusAuthorization *self) -{ - _dbus_assert (self != NULL); - _dbus_assert (self->refcount > 0); - - self->refcount -= 1; - - if (self->refcount == 0) - { - _dbus_verbose ("last reference, finalizing\n"); - - if (self->unix_data && self->unix_data_free) - { - _dbus_verbose ("freeing unix authorization callback data\n"); - (*self->unix_data_free) (self->unix_data); - self->unix_data = NULL; - } - - if (self->windows_data && self->windows_data_free) - { - _dbus_verbose ("freeing windows authorization callback data\n"); - (*self->windows_data_free) (self->windows_data); - self->windows_data = NULL; - } - - dbus_free (self); - } -} - -/* Called by transport's set_connection with the connection locked */ -void -_dbus_authorization_set_connection (DBusAuthorization *self, - DBusConnection *connection) -{ - _dbus_assert (connection != NULL); - _dbus_assert (self->connection == NULL); - - self->connection = connection; -} - - -/** - * Set the user set authorization callback for Unix identities authorizations. - * The callback will be called at the end of the EXTERNAL authentication - * mechanism and on every message. - - * See dbus_connection_set_unix_authorization_callback() and - * _dbus_transport_set_unix_authorization_callback(). - * - * @param self the authorization struct - * @param function the predicate - * @param data data to pass to the predicate - * @param free_data_function function to free the data - * @param old_data the old user data to be freed - * @param old_free_data_function old free data function to free it with - */ -void -_dbus_authorization_set_unix_authorization_callback (DBusAuthorization *self, - DBusAllowUnixUserFunction function, - void *data, - DBusFreeFunction free_data_function, - void **old_data, - DBusFreeFunction *old_free_data_function) -{ - *old_data = self->unix_data; - *old_free_data_function = self->unix_data_free; - - self->unix_authorization_cb = function; - self->unix_data = data; - self->unix_data_free = free_data_function; -} - -/** - * Set the user set authorization callback for Windows identities - * authorizations. - * The callback will be called at the end of the EXTERNAL authentication - * mechanism and on every message. - * - * See dbus_connection_set_windows_authorization_callback() and - * _dbus_transport_set_windows_authorization_callback(). - * - * @param self the authorization struct - * @param function the predicate - * @param data data to pass to the predicate - * @param free_data_function function to free the data - * @param old_data the old user data to be freed - * @param old_free_data_function old free data function to free it with - */ - -void -_dbus_authorization_set_windows_authorization_callback (DBusAuthorization *self, - DBusAllowWindowsUserFunction function, - void *data, - DBusFreeFunction free_data_function, - void **old_data, - DBusFreeFunction *old_free_data_function) -{ - *old_data = self->windows_data; - *old_free_data_function = self->windows_data_free; - - self->windows_authorization_cb = function; - self->windows_data = data; - self->windows_data_free = free_data_function; -} - -static dbus_bool_t -auth_via_unix_authorization_callback (DBusAuthorization *self, - DBusCredentials *auth_identity) -{ - - dbus_bool_t allow; - dbus_uid_t uid; - - /* Dropping the lock here probably isn't that safe. */ - - _dbus_assert (auth_identity != NULL); - - uid = _dbus_credentials_get_unix_uid (auth_identity); - - _dbus_verbose ("unlock connection before executing user's authorization callback\n"); - _dbus_connection_unlock (self->connection); - - allow = (*self->unix_authorization_cb) (self->connection, - uid, - self->unix_data); - - _dbus_verbose ("lock connection post unix-authorization callback\n"); - _dbus_connection_lock (self->connection); - - if (allow) - { - _dbus_verbose ("Client UID "DBUS_UID_FORMAT" authorized\n", uid); - } - else - { - _dbus_verbose ("Client UID "DBUS_UID_FORMAT " wasn't authorized.\n", - _dbus_credentials_get_unix_uid (auth_identity)); - } - - return allow; -} - - -static dbus_bool_t -auth_via_windows_authorization_callback (DBusAuthorization *self, - DBusCredentials *auth_identity) -{ - dbus_bool_t allow; - char *windows_sid; - - /* Dropping the lock here probably isn't that safe. */ - - _dbus_assert (auth_identity != NULL); - - windows_sid = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity)); - - if (windows_sid == NULL) - return FALSE; /* OOM */ - - _dbus_verbose ("unlock connection before executing user's authorization callback\n"); - _dbus_connection_unlock (self->connection); - - allow = (*self->windows_authorization_cb) (self->connection, - windows_sid, - self->windows_data); - - _dbus_verbose ("lock connection post windows user's authorization callback\n"); - _dbus_connection_lock (self->connection); - - if (allow) - { - _dbus_verbose ("Client SID '%s' authorized\n", windows_sid); - } - else - { - _dbus_verbose ("Client SID '%s' wasn't authorized\n", - _dbus_credentials_get_windows_sid (auth_identity)); - } - - dbus_free (windows_sid); - - return allow; -} - -static dbus_bool_t -auth_via_default_rules (DBusAuthorization *self, - DBusCredentials *auth_identity) - -{ - DBusCredentials *our_identity; - dbus_bool_t allow; - - _dbus_assert (auth_identity != NULL); - - /* By default, connection is allowed if the client is 1) root or 2) - * has the same UID as us or 3) anonymous is allowed. - */ - - our_identity = _dbus_credentials_new_from_current_process (); - if (our_identity == NULL) - return FALSE; /* OOM */ - - if (self->allow_anonymous || - _dbus_credentials_get_unix_uid (auth_identity) == 0 || - _dbus_credentials_same_user (our_identity, auth_identity)) - { - if (_dbus_credentials_include (our_identity, DBUS_CREDENTIAL_WINDOWS_SID)) - _dbus_verbose ("Client authenticated as SID '%s'" - "matching our SID '%s': authorized\n", - _dbus_credentials_get_windows_sid (auth_identity), - _dbus_credentials_get_windows_sid (our_identity)); - else - _dbus_verbose ("Client authenticated as UID "DBUS_UID_FORMAT - " matching our UID "DBUS_UID_FORMAT": authorized\n", - _dbus_credentials_get_unix_uid (auth_identity), - _dbus_credentials_get_unix_uid (our_identity)); - /* We have authenticated! */ - allow = TRUE; - } - else - { - if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) - _dbus_verbose ("Client authenticated as SID '%s'" - " but our SID is '%s', not authorizing\n", - (_dbus_credentials_get_windows_sid(auth_identity) ? - _dbus_credentials_get_windows_sid(auth_identity) : ""), - (_dbus_credentials_get_windows_sid(our_identity) ? - _dbus_credentials_get_windows_sid(our_identity) : "")); - else - _dbus_verbose ("Client authenticated as UID "DBUS_UID_FORMAT - " but our UID is "DBUS_UID_FORMAT", not authorizing\n", - _dbus_credentials_get_unix_uid(auth_identity), - _dbus_credentials_get_unix_uid(our_identity)); - allow = FALSE; - } - - _dbus_credentials_unref (our_identity); - - return allow; -} - -/* Called with DBusConnection lock held */ -dbus_bool_t -_dbus_authorization_do_authorization (DBusAuthorization *self, - DBusCredentials *auth_identity) -{ - dbus_bool_t allow; - - /* maybe-FIXME: at this point we *should* have a connection set unless we - * are in some test case, but we assert its presence only in some if's - * branches since default_rules does not need one and is used in a test case - * without a connection set */ - - if (_dbus_credentials_are_anonymous (auth_identity)) - { - allow = self->allow_anonymous; - } - if (self->unix_authorization_cb != NULL && - _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_UNIX_USER_ID)) - { - _dbus_assert (self->connection != NULL); - allow = auth_via_unix_authorization_callback (self, auth_identity); - } - else if (self->windows_authorization_cb != NULL && - _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_WINDOWS_SID)) - { - _dbus_assert (self->connection != NULL); - allow = auth_via_windows_authorization_callback (self, auth_identity); - } - else - { - allow = auth_via_default_rules (self, auth_identity); - } - - return allow; -} - - - -/** - * See dbus_connection_set_allow_anonymous() - * - * @param self an authorization struct - * @param value #TRUE to allow anonymous connection - */ -void -_dbus_authorization_set_allow_anonymous (DBusAuthorization *self, - dbus_bool_t value) -{ - self->allow_anonymous = value != FALSE; -} diff --git a/dbus/dbus-authorization.h b/dbus/dbus-authorization.h deleted file mode 100644 index 8f7f1d43..00000000 --- a/dbus/dbus-authorization.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _DBUS_AUTHORIZE_H -#define _DBUS_AUTHORIZE_H - -#include -#include - -typedef struct DBusAuthorization DBusAuthorization; - -DBusAuthorization *_dbus_authorization_new (void); -void _dbus_authorization_set_connection (DBusAuthorization *self, - DBusConnection *connection); -DBusAuthorization * _dbus_authorization_ref (DBusAuthorization *self); -void _dbus_authorization_unref (DBusAuthorization *self); -void _dbus_authorization_set_unix_authorization_callback (DBusAuthorization *self, - DBusAllowUnixUserFunction function, void *data, - DBusFreeFunction free_data_function, void **old_data, - DBusFreeFunction *old_free_data_function); -void _dbus_authorization_set_windows_authorization_callback (DBusAuthorization *self, - DBusAllowWindowsUserFunction function, void *data, - DBusFreeFunction free_data_function, void **old_data, - DBusFreeFunction *old_free_data_function); -dbus_bool_t _dbus_authorization_do_authorization (DBusAuthorization *self, DBusCredentials *creds); -void _dbus_authorization_set_allow_anonymous (DBusAuthorization *self, dbus_bool_t value); - -#endif /* _DBUS_AUTHORIZE_H */ -- cgit v1.2.1 From 414cb42dee3d7678ae24aca2f55ec0d83892fbb4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:34 +0100 Subject: Revert "Actually use DBusAuthorization in DBusAuth EXTERNAL mech" This reverts commit d5d25b5efd35d8d9bbb9d58cae441debf8f7ded6. --- dbus/dbus-auth-script.c | 13 +------------ dbus/dbus-auth.c | 34 +++++++--------------------------- dbus/dbus-auth.h | 4 +--- dbus/dbus-transport.c | 2 +- 4 files changed, 10 insertions(+), 43 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index 445452c7..c1f0c88e 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -30,7 +30,6 @@ #include "dbus-hash.h" #include "dbus-credentials.h" #include "dbus-internals.h" -#include "dbus-authorization.h" /** * @defgroup DBusAuthScript code for running unit test scripts for DBusAuth @@ -402,7 +401,6 @@ _dbus_auth_script_run (const DBusString *filename) "SERVER")) { DBusCredentials *creds; - DBusAuthorization *authorization; if (auth != NULL) { @@ -410,16 +408,7 @@ _dbus_auth_script_run (const DBusString *filename) goto out; } - /* empty authorization, it will use default rules */ - authorization = _dbus_authorization_new (); - if (authorization == NULL) - { - _dbus_warn ("no memory to create DBusAuthorization\n"); - goto out; - } - auth = _dbus_auth_server_new (&guid, authorization); - /* DBusAuth owns it, or finalized on OOM */ - _dbus_authorization_unref (authorization); + auth = _dbus_auth_server_new (&guid); if (auth == NULL) { _dbus_warn ("no memory to create DBusAuth\n"); diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index 35efa3a8..a0f72773 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -30,7 +30,6 @@ #include "dbus-sha.h" #include "dbus-protocol.h" #include "dbus-credentials.h" -#include "dbus-authorization.h" /** * @defgroup DBusAuth Authentication @@ -214,8 +213,6 @@ typedef struct { DBusAuth base; /**< Parent class */ - DBusAuthorization *authorization; /* DBus Authorization callbacks */ - int failures; /**< Number of times client has been rejected */ int max_failures; /**< Number of times we reject before disconnect */ @@ -1118,26 +1115,12 @@ handle_server_data_external_mech (DBusAuth *auth, DBUS_CREDENTIAL_ADT_AUDIT_DATA_ID, auth->credentials)) return FALSE; + + if (!send_ok (auth)) + return FALSE; - /* Do a first authorization of the transport, in order to REJECT - * immediately connection if needed (FDO#39720), transport will - * re-authorize later, but it will close the connection on fail, - * we want to REJECT now if possible */ - if (_dbus_authorization_do_authorization (DBUS_AUTH_SERVER (auth)->authorization, - auth->authorized_identity)) - { - if (!send_ok (auth)) - return FALSE; - } - else - { - _dbus_verbose ("%s: desired identity does not match server identity: " - "not authorized\n", DBUS_AUTH_NAME (auth)); - return send_rejected (auth); - } - - _dbus_verbose ("%s: authenticated and authorized client based on " - "socket credentials\n", DBUS_AUTH_NAME (auth)); + _dbus_verbose ("%s: authenticated client based on socket credentials\n", + DBUS_AUTH_NAME (auth)); return TRUE; } @@ -2261,8 +2244,7 @@ process_command (DBusAuth *auth) * @returns the new object or #NULL if no memory */ DBusAuth* -_dbus_auth_server_new (const DBusString *guid, - DBusAuthorization *authorization) +_dbus_auth_server_new (const DBusString *guid) { DBusAuth *auth; DBusAuthServer *server_auth; @@ -2290,8 +2272,7 @@ _dbus_auth_server_new (const DBusString *guid, server_auth = DBUS_AUTH_SERVER (auth); server_auth->guid = guid_copy; - server_auth->authorization = _dbus_authorization_ref (authorization); - + /* perhaps this should be per-mechanism with a lower * max */ @@ -2382,7 +2363,6 @@ _dbus_auth_unref (DBusAuth *auth) _dbus_assert (DBUS_AUTH_IS_SERVER (auth)); _dbus_string_free (& DBUS_AUTH_SERVER (auth)->guid); - _dbus_authorization_unref (DBUS_AUTH_SERVER (auth)->authorization); } if (auth->keyring) diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h index 3f178a22..ae3f3647 100644 --- a/dbus/dbus-auth.h +++ b/dbus/dbus-auth.h @@ -27,7 +27,6 @@ #include #include #include -#include DBUS_BEGIN_DECLS @@ -42,8 +41,7 @@ typedef enum DBUS_AUTH_STATE_AUTHENTICATED } DBusAuthState; -DBusAuth* _dbus_auth_server_new (const DBusString *guid, - DBusAuthorization *authorization); +DBusAuth* _dbus_auth_server_new (const DBusString *guid); DBusAuth* _dbus_auth_client_new (void); DBusAuth* _dbus_auth_ref (DBusAuth *auth); void _dbus_auth_unref (DBusAuth *auth); diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 3a9cf84b..661b54ff 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -125,7 +125,7 @@ _dbus_transport_init_base (DBusTransport *transport, return FALSE; /* OOM */ } - auth = _dbus_auth_server_new (server_guid, authorization); + auth = _dbus_auth_server_new (server_guid); } else { -- cgit v1.2.1 From 30fa2e1ace062314e9624b29239c2c7e9519e6c2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:09:35 +0100 Subject: Revert "Factor out DBusAuthorization from DBusTransport" This reverts commit 600621dbc8073527a958091316eddfbb490c1032. --- bus/driver.c | 11 -- cmake/dbus/CMakeLists.txt | 2 - dbus/Makefile.am | 10 +- dbus/dbus-transport-protected.h | 13 +- dbus/dbus-transport.c | 267 ++++++++++++++++++++++++++++++++-------- doc/dbus-specification.xml | 8 -- 6 files changed, 229 insertions(+), 82 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index 564cecb4..23197e43 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -1535,7 +1535,6 @@ bus_driver_handle_get_connection_credentials (DBusConnection *connection, DBusMessageIter reply_iter; DBusMessageIter array_iter; unsigned long ulong_val; - char *windows_sid; const char *service; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1570,16 +1569,6 @@ bus_driver_handle_get_connection_credentials (DBusConnection *connection, goto oom; } - if (dbus_connection_get_windows_user (conn, &windows_sid)) - { - if (!_dbus_asv_add_string (&array_iter, "WindowsSID", windows_sid)) - { - dbus_free(windows_sid); - goto oom; - } - dbus_free(windows_sid); - } - if (!_dbus_asv_close (&reply_iter, &array_iter)) goto oom; diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index bb7278c5..0205f852 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -32,7 +32,6 @@ set (dbusinclude_HEADERS set (DBUS_LIB_SOURCES ${DBUS_DIR}/dbus-address.c ${DBUS_DIR}/dbus-auth.c - ${DBUS_DIR}/dbus-authorization.c ${DBUS_DIR}/dbus-bus.c ${DBUS_DIR}/dbus-connection.c ${DBUS_DIR}/dbus-credentials.c @@ -76,7 +75,6 @@ endif(UNIX) set (DBUS_LIB_HEADERS ${DBUS_DIR}/dbus-auth.h - ${DBUS_DIR}/dbus-authorization.h ${DBUS_DIR}/dbus-connection-internal.h ${DBUS_DIR}/dbus-credentials.h ${DBUS_DIR}/dbus-keyring.h diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 180a44e4..e118cbbb 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -150,8 +150,6 @@ DBUS_LIB_SOURCES= \ dbus-address.c \ dbus-auth.c \ dbus-auth.h \ - dbus-authorization.c \ - dbus-authorization.h \ dbus-bus.c \ dbus-connection.c \ dbus-connection-internal.h \ @@ -210,8 +208,8 @@ DBUS_LIB_SOURCES= \ DBUS_SHARED_SOURCES= \ dbus-dataslot.c \ dbus-dataslot.h \ - dbus-file.c \ - dbus-file.h \ + dbus-file.c \ + dbus-file.h \ dbus-hash.c \ dbus-hash.h \ dbus-internals.c \ @@ -223,8 +221,8 @@ DBUS_SHARED_SOURCES= \ dbus-memory.c \ dbus-mempool.c \ dbus-mempool.h \ - dbus-pipe.c \ - dbus-pipe.h \ + dbus-pipe.c \ + dbus-pipe.h \ dbus-string.c \ dbus-string.h \ dbus-string-private.h \ diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h index 93380ab9..396f0ffd 100644 --- a/dbus/dbus-transport-protected.h +++ b/dbus/dbus-transport-protected.h @@ -27,7 +27,6 @@ #include #include #include -#include #include #include @@ -89,7 +88,6 @@ struct DBusTransport DBusMessageLoader *loader; /**< Message-loading buffer. */ DBusAuth *auth; /**< Authentication conversation */ - DBusAuthorization *authorization; /**< Authorization conversation */ DBusCredentials *credentials; /**< Credentials of other end read from the socket */ @@ -102,12 +100,23 @@ struct DBusTransport char *expected_guid; /**< GUID we expect the server to have, #NULL on server side or if we don't have an expectation */ + DBusAllowUnixUserFunction unix_user_function; /**< Function for checking whether a user is authorized. */ + void *unix_user_data; /**< Data for unix_user_function */ + + DBusFreeFunction free_unix_user_data; /**< Function to free unix_user_data */ + + DBusAllowWindowsUserFunction windows_user_function; /**< Function for checking whether a user is authorized. */ + void *windows_user_data; /**< Data for windows_user_function */ + + DBusFreeFunction free_windows_user_data; /**< Function to free windows_user_data */ + unsigned int disconnected : 1; /**< #TRUE if we are disconnected. */ unsigned int authenticated : 1; /**< Cache of auth state; use _dbus_transport_peek_is_authenticated() to query value */ unsigned int send_credentials_pending : 1; /**< #TRUE if we need to send credentials */ unsigned int receive_credentials_pending : 1; /**< #TRUE if we need to receive credentials */ unsigned int is_server : 1; /**< #TRUE if on the server side */ unsigned int unused_bytes_recovered : 1; /**< #TRUE if we've recovered unused bytes from auth */ + unsigned int allow_anonymous : 1; /**< #TRUE if an anonymous client can connect */ }; dbus_bool_t _dbus_transport_init_base (DBusTransport *transport, diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index 661b54ff..e68a9f03 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -28,7 +28,6 @@ #include "dbus-connection-internal.h" #include "dbus-watch.h" #include "dbus-auth.h" -#include "dbus-authorization.h" #include "dbus-address.h" #include "dbus-credentials.h" #include "dbus-mainloop.h" @@ -107,7 +106,6 @@ _dbus_transport_init_base (DBusTransport *transport, { DBusMessageLoader *loader; DBusAuth *auth; - DBusAuthorization *authorization = NULL; /* non-NULL only if is_server=TRUE */ DBusCounter *counter; char *address_copy; DBusCredentials *creds; @@ -115,26 +113,13 @@ _dbus_transport_init_base (DBusTransport *transport, loader = _dbus_message_loader_new (); if (loader == NULL) return FALSE; - - if (server_guid != NULL) - { - authorization = _dbus_authorization_new (); - if (authorization == NULL) - { - _dbus_message_loader_unref (loader); - return FALSE; /* OOM */ - } - - auth = _dbus_auth_server_new (server_guid); - } + + if (server_guid) + auth = _dbus_auth_server_new (server_guid); else - { - auth = _dbus_auth_client_new (); - } + auth = _dbus_auth_client_new (); if (auth == NULL) { - if (authorization != NULL) - _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -143,8 +128,6 @@ _dbus_transport_init_base (DBusTransport *transport, if (counter == NULL) { _dbus_auth_unref (auth); - if (authorization != NULL) - _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -154,13 +137,11 @@ _dbus_transport_init_base (DBusTransport *transport, { _dbus_counter_unref (counter); _dbus_auth_unref (auth); - if (authorization != NULL) - _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } - if (server_guid != NULL) + if (server_guid) { _dbus_assert (address == NULL); address_copy = NULL; @@ -174,8 +155,6 @@ _dbus_transport_init_base (DBusTransport *transport, _dbus_credentials_unref (creds); _dbus_counter_unref (counter); _dbus_auth_unref (auth); - if (authorization != NULL) - _dbus_authorization_unref (authorization); _dbus_message_loader_unref (loader); return FALSE; } @@ -184,7 +163,6 @@ _dbus_transport_init_base (DBusTransport *transport, transport->refcount = 1; transport->vtable = vtable; transport->loader = loader; - transport->authorization = authorization; transport->auth = auth; transport->live_messages = counter; transport->authenticated = FALSE; @@ -193,7 +171,15 @@ _dbus_transport_init_base (DBusTransport *transport, transport->send_credentials_pending = !transport->is_server; transport->receive_credentials_pending = transport->is_server; transport->address = address_copy; + + transport->unix_user_function = NULL; + transport->unix_user_data = NULL; + transport->free_unix_user_data = NULL; + transport->windows_user_function = NULL; + transport->windows_user_data = NULL; + transport->free_windows_user_data = NULL; + transport->expected_guid = NULL; /* Try to default to something that won't totally hose the system, @@ -217,10 +203,6 @@ _dbus_transport_init_base (DBusTransport *transport, if (transport->address) _dbus_verbose ("Initialized transport on address %s\n", transport->address); - /* we can have authorization data set only in server mode */ - _dbus_assert ((transport->is_server && transport->authorization != NULL) || - (!transport->is_server && transport->authorization == NULL)); - return TRUE; } @@ -236,10 +218,14 @@ _dbus_transport_finalize_base (DBusTransport *transport) if (!transport->disconnected) _dbus_transport_disconnect (transport); + if (transport->free_unix_user_data != NULL) + (* transport->free_unix_user_data) (transport->unix_user_data); + + if (transport->free_windows_user_data != NULL) + (* transport->free_windows_user_data) (transport->windows_user_data); + _dbus_message_loader_unref (transport->loader); _dbus_auth_unref (transport->auth); - if (transport->authorization) - _dbus_authorization_unref (transport->authorization); _dbus_counter_set_notify (transport->live_messages, 0, 0, NULL, NULL); _dbus_counter_unref (transport->live_messages); @@ -543,6 +529,163 @@ _dbus_transport_get_is_connected (DBusTransport *transport) return !transport->disconnected; } +static dbus_bool_t +auth_via_unix_user_function (DBusTransport *transport) +{ + DBusCredentials *auth_identity; + dbus_bool_t allow; + DBusConnection *connection; + DBusAllowUnixUserFunction unix_user_function; + void *unix_user_data; + dbus_uid_t uid; + + /* Dropping the lock here probably isn't that safe. */ + + auth_identity = _dbus_auth_get_identity (transport->auth); + _dbus_assert (auth_identity != NULL); + + connection = transport->connection; + unix_user_function = transport->unix_user_function; + unix_user_data = transport->unix_user_data; + uid = _dbus_credentials_get_unix_uid (auth_identity); + + _dbus_verbose ("unlock\n"); + _dbus_connection_unlock (connection); + + allow = (* unix_user_function) (connection, + uid, + unix_user_data); + + _dbus_verbose ("lock post unix user function\n"); + _dbus_connection_lock (connection); + + if (allow) + { + _dbus_verbose ("Client UID "DBUS_UID_FORMAT" authorized\n", uid); + } + else + { + _dbus_verbose ("Client UID "DBUS_UID_FORMAT + " was rejected, disconnecting\n", + _dbus_credentials_get_unix_uid (auth_identity)); + _dbus_transport_disconnect (transport); + } + + return allow; +} + +static dbus_bool_t +auth_via_windows_user_function (DBusTransport *transport) +{ + DBusCredentials *auth_identity; + dbus_bool_t allow; + DBusConnection *connection; + DBusAllowWindowsUserFunction windows_user_function; + void *windows_user_data; + char *windows_sid; + + /* Dropping the lock here probably isn't that safe. */ + + auth_identity = _dbus_auth_get_identity (transport->auth); + _dbus_assert (auth_identity != NULL); + + connection = transport->connection; + windows_user_function = transport->windows_user_function; + windows_user_data = transport->unix_user_data; + windows_sid = _dbus_strdup (_dbus_credentials_get_windows_sid (auth_identity)); + + if (windows_sid == NULL) + { + /* OOM */ + return FALSE; + } + + _dbus_verbose ("unlock\n"); + _dbus_connection_unlock (connection); + + allow = (* windows_user_function) (connection, + windows_sid, + windows_user_data); + + _dbus_verbose ("lock post windows user function\n"); + _dbus_connection_lock (connection); + + if (allow) + { + _dbus_verbose ("Client SID '%s' authorized\n", windows_sid); + } + else + { + _dbus_verbose ("Client SID '%s' was rejected, disconnecting\n", + _dbus_credentials_get_windows_sid (auth_identity)); + _dbus_transport_disconnect (transport); + } + + return allow; +} + +static dbus_bool_t +auth_via_default_rules (DBusTransport *transport) +{ + DBusCredentials *auth_identity; + DBusCredentials *our_identity; + dbus_bool_t allow; + + auth_identity = _dbus_auth_get_identity (transport->auth); + _dbus_assert (auth_identity != NULL); + + /* By default, connection is allowed if the client is 1) root or 2) + * has the same UID as us or 3) anonymous is allowed. + */ + + our_identity = _dbus_credentials_new_from_current_process (); + if (our_identity == NULL) + { + /* OOM */ + return FALSE; + } + + if (transport->allow_anonymous || + _dbus_credentials_get_unix_uid (auth_identity) == 0 || + _dbus_credentials_same_user (our_identity, + auth_identity)) + { + if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) + _dbus_verbose ("Client authorized as SID '%s'" + "matching our SID '%s'\n", + _dbus_credentials_get_windows_sid(auth_identity), + _dbus_credentials_get_windows_sid(our_identity)); + else + _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT + " matching our UID "DBUS_UID_FORMAT"\n", + _dbus_credentials_get_unix_uid(auth_identity), + _dbus_credentials_get_unix_uid(our_identity)); + /* We have authenticated! */ + allow = TRUE; + } + else + { + if (_dbus_credentials_include(our_identity,DBUS_CREDENTIAL_WINDOWS_SID)) + _dbus_verbose ("Client authorized as SID '%s'" + " but our SID is '%s', disconnecting\n", + (_dbus_credentials_get_windows_sid(auth_identity) ? + _dbus_credentials_get_windows_sid(auth_identity) : ""), + (_dbus_credentials_get_windows_sid(our_identity) ? + _dbus_credentials_get_windows_sid(our_identity) : "")); + else + _dbus_verbose ("Client authorized as UID "DBUS_UID_FORMAT + " but our UID is "DBUS_UID_FORMAT", disconnecting\n", + _dbus_credentials_get_unix_uid(auth_identity), + _dbus_credentials_get_unix_uid(our_identity)); + _dbus_transport_disconnect (transport); + allow = FALSE; + } + + _dbus_credentials_unref (our_identity); + + return allow; +} + /** * Returns #TRUE if we have been authenticated. It will return #TRUE even if * the transport is now disconnected, but was ever authenticated before @@ -632,18 +775,33 @@ _dbus_transport_try_to_authenticate (DBusTransport *transport) */ if (maybe_authenticated && transport->is_server) { + dbus_bool_t allow; DBusCredentials *auth_identity; - + auth_identity = _dbus_auth_get_identity (transport->auth); _dbus_assert (auth_identity != NULL); - /* If we have an authenticated user, delegate deciding whether auth - * credentials are good enough to the app */ - if (!_dbus_authorization_do_authorization (transport->authorization, auth_identity)) + /* If we have an auth'd user and a user function, delegate + * deciding whether auth credentials are good enough to the + * app; otherwise, use our default decision process. + */ + if (transport->unix_user_function != NULL && + _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_UNIX_USER_ID)) { - _dbus_transport_disconnect (transport); - maybe_authenticated = FALSE; + allow = auth_via_unix_user_function (transport); + } + else if (transport->windows_user_function != NULL && + _dbus_credentials_include (auth_identity, DBUS_CREDENTIAL_WINDOWS_SID)) + { + allow = auth_via_windows_user_function (transport); + } + else + { + allow = auth_via_default_rules (transport); } + + if (!allow) + maybe_authenticated = FALSE; } transport->authenticated = maybe_authenticated; @@ -773,8 +931,6 @@ _dbus_transport_set_connection (DBusTransport *transport, _dbus_assert (transport->connection == NULL); transport->connection = connection; - if (transport->is_server) - _dbus_authorization_set_connection (transport->authorization, connection); _dbus_transport_ref (transport); if (!(* transport->vtable->connection_set) (transport)) @@ -1257,17 +1413,20 @@ _dbus_transport_get_adt_audit_session_data (DBusTransport *transport, * @param old_data the old user data to be freed * @param old_free_data_function old free data function to free it with */ -inline void +void _dbus_transport_set_unix_user_function (DBusTransport *transport, DBusAllowUnixUserFunction function, void *data, DBusFreeFunction free_data_function, void **old_data, DBusFreeFunction *old_free_data_function) -{ - if (transport->is_server) - _dbus_authorization_set_unix_authorization_callback (transport->authorization, function, - data, free_data_function, old_data, old_free_data_function); +{ + *old_data = transport->unix_user_data; + *old_free_data_function = transport->free_unix_user_data; + + transport->unix_user_function = function; + transport->unix_user_data = data; + transport->free_unix_user_data = free_data_function; } /** @@ -1313,7 +1472,7 @@ _dbus_transport_get_windows_user (DBusTransport *transport, * @param old_free_data_function old free data function to free it with */ -inline void +void _dbus_transport_set_windows_user_function (DBusTransport *transport, DBusAllowWindowsUserFunction function, void *data, @@ -1321,9 +1480,12 @@ _dbus_transport_set_windows_user_function (DBusTransport *transport void **old_data, DBusFreeFunction *old_free_data_function) { - if (transport->is_server) - _dbus_authorization_set_windows_authorization_callback (transport->authorization, function, - data, free_data_function, old_data, old_free_data_function); + *old_data = transport->windows_user_data; + *old_free_data_function = transport->free_windows_user_data; + + transport->windows_user_function = function; + transport->windows_user_data = data; + transport->free_windows_user_data = free_data_function; } /** @@ -1347,12 +1509,11 @@ _dbus_transport_set_auth_mechanisms (DBusTransport *transport, * @param transport the transport * @param value #TRUE to allow anonymous connection */ -inline void +void _dbus_transport_set_allow_anonymous (DBusTransport *transport, dbus_bool_t value) { - if (transport->is_server) - _dbus_authorization_set_allow_anonymous (transport->authorization, value); + transport->allow_anonymous = value != FALSE; } #ifdef DBUS_ENABLE_STATS diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index eca494e3..65abd29f 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -5666,14 +5666,6 @@ this concept. On Unix, this is the process ID defined by POSIX. - - WindowsSID - STRING - The Windows security identifier in its string form, - e.g. "S-1-5-21-3623811015-3361044348-30300820-1013" for - a domain or local computer user or "S-1-5-18" for the - LOCAL_SYSTEM user - -- cgit v1.2.1 From 412538b3b9fb424c3af313815c3928a9ec221ad7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Jun 2013 19:58:22 +0100 Subject: Export dbus_setenv() as a utility function It's sufficiently portable that GLib has an equivalent, and I really don't want to have to either open-code it in dbus-run-session or link dbus-run-session statically. We have enough statically-linked rubbish already. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196 Reviewed-by: Colin Walters --- bus/activation-helper.c | 5 +++-- bus/config-parser.c | 9 +++++---- bus/dispatch.c | 3 ++- bus/test-launch-helper.c | 5 +++-- dbus/dbus-bus.c | 5 +++-- dbus/dbus-misc.h | 4 ++++ dbus/dbus-server-launchd.c | 3 ++- dbus/dbus-sysdeps.c | 14 ++++++++++---- dbus/dbus-sysdeps.h | 2 -- test/name-test/test-autolaunch.c | 3 +-- 10 files changed, 33 insertions(+), 20 deletions(-) diff --git a/bus/activation-helper.c b/bus/activation-helper.c index 8d7ae36f..e3b3323c 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -156,8 +157,8 @@ clear_environment (DBusError *error) } /* Ensure the bus is set to system */ - _dbus_setenv ("DBUS_STARTER_ADDRESS", DBUS_SYSTEM_BUS_DEFAULT_ADDRESS); - _dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system"); + dbus_setenv ("DBUS_STARTER_ADDRESS", DBUS_SYSTEM_BUS_DEFAULT_ADDRESS); + dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system"); #endif return TRUE; diff --git a/bus/config-parser.c b/bus/config-parser.c index 6b59dfc5..12a2d2e7 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -30,6 +30,7 @@ #include "selinux.h" #include #include +#include #include #include @@ -3417,10 +3418,10 @@ test_default_session_servicedirs (void) } #ifdef DBUS_UNIX - if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare")) + if (!dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare")) _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME"); - if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:")) + if (!dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:")) _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS"); #endif if (!_dbus_get_standard_session_servicedirs (&dirs)) @@ -3550,10 +3551,10 @@ test_default_system_servicedirs (void) } #ifdef DBUS_UNIX - if (!_dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare")) + if (!dbus_setenv ("XDG_DATA_HOME", "/testhome/foo/.testlocal/testshare")) _dbus_assert_not_reached ("couldn't setenv XDG_DATA_HOME"); - if (!_dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:")) + if (!dbus_setenv ("XDG_DATA_DIRS", ":/testusr/testlocal/testshare: :/testusr/testshare:")) _dbus_assert_not_reached ("couldn't setenv XDG_DATA_DIRS"); #endif if (!_dbus_get_standard_system_servicedirs (&dirs)) diff --git a/bus/dispatch.c b/bus/dispatch.c index 72d228ae..35a4b72b 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -34,6 +34,7 @@ #include "signals.h" #include "test.h" #include +#include #include #ifdef HAVE_UNIX_FD_PASSING @@ -4466,7 +4467,7 @@ setenv_TEST_LAUNCH_HELPER_CONFIG(const DBusString *test_data_dir, _dbus_verbose ("Setting TEST_LAUNCH_HELPER_CONFIG to '%s'\n", _dbus_string_get_const_data (&full)); - _dbus_setenv ("TEST_LAUNCH_HELPER_CONFIG", _dbus_string_get_const_data (&full)); + dbus_setenv ("TEST_LAUNCH_HELPER_CONFIG", _dbus_string_get_const_data (&full)); _dbus_string_free (&full); diff --git a/bus/test-launch-helper.c b/bus/test-launch-helper.c index e88c989c..e9ba412a 100644 --- a/bus/test-launch-helper.c +++ b/bus/test-launch-helper.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef DBUS_ENABLE_EMBEDDED_TESTS static void @@ -122,8 +123,8 @@ main (int argc, char **argv) return 1; /* use a config file that will actually work... */ - _dbus_setenv ("TEST_LAUNCH_HELPER_CONFIG", - _dbus_string_get_const_data (&config_file)); + dbus_setenv ("TEST_LAUNCH_HELPER_CONFIG", + _dbus_string_get_const_data (&config_file)); _dbus_string_free (&config_file); diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 3b775c76..9d2095f9 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -28,6 +28,7 @@ #include "dbus-internals.h" #include "dbus-message.h" #include "dbus-marshal-validate.h" +#include "dbus-misc.h" #include "dbus-threads-internal.h" #include "dbus-connection-internal.h" #include "dbus-string.h" @@ -293,10 +294,10 @@ init_connections_unlocked (void) * the above code will work right */ - if (!_dbus_setenv ("DBUS_ACTIVATION_ADDRESS", NULL)) + if (!dbus_setenv ("DBUS_ACTIVATION_ADDRESS", NULL)) return FALSE; - if (!_dbus_setenv ("DBUS_ACTIVATION_BUS_TYPE", NULL)) + if (!dbus_setenv ("DBUS_ACTIVATION_BUS_TYPE", NULL)) return FALSE; if (!_dbus_register_shutdown_func (addresses_shutdown_func, diff --git a/dbus/dbus-misc.h b/dbus/dbus-misc.h index 3504bcaa..6e72d9ed 100644 --- a/dbus/dbus-misc.h +++ b/dbus/dbus-misc.h @@ -44,6 +44,10 @@ void dbus_get_version (int *major_version_p, int *minor_version_p, int *micro_version_p); +DBUS_EXPORT +dbus_bool_t dbus_setenv (const char *variable, + const char *value); + /** @} */ DBUS_END_DECLS diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c index db4673c5..9832875e 100644 --- a/dbus/dbus-server-launchd.c +++ b/dbus/dbus-server-launchd.c @@ -40,6 +40,7 @@ #include #include +#include "dbus-misc.h" #include "dbus-server-socket.h" /* put other private launchd functions here */ @@ -176,7 +177,7 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error) else { display = launch_data_get_string(environment_param); - _dbus_setenv ("DISPLAY", display); + dbus_setenv ("DISPLAY", display); } } } diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 0fbf9e71..de3a18cb 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -29,6 +29,7 @@ #include "dbus-protocol.h" #include "dbus-string.h" #include "dbus-list.h" +#include "dbus-misc.h" /* NOTE: If you include any unix/windows-specific headers here, you are probably doing something * wrong and should be putting some code in dbus-sysdeps-unix.c or dbus-sysdeps-win.c. @@ -92,6 +93,8 @@ _dbus_abort (void) } /** + * @ingroup DBusMisc + * * Wrapper for setenv(). If the value is #NULL, unsets * the environment variable. * @@ -100,13 +103,16 @@ _dbus_abort (void) * we can not rely on internal implementation details of * the underlying libc library. * + * This function is not thread-safe, because altering the environment + * in Unix is not thread-safe in general. + * * @param varname name of environment variable - * @param value value of environment variable - * @returns #TRUE on success. + * @param value value of environment variable, or #NULL to unset + * @returns #TRUE on success, #FALSE if not enough memory. */ dbus_bool_t -_dbus_setenv (const char *varname, - const char *value) +dbus_setenv (const char *varname, + const char *value) { _dbus_assert (varname != NULL); diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 1053303a..e586946f 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -89,8 +89,6 @@ void _dbus_abort (void) _DBUS_GNUC_NORETURN; dbus_bool_t _dbus_check_setuid (void); const char* _dbus_getenv (const char *varname); -dbus_bool_t _dbus_setenv (const char *varname, - const char *value); dbus_bool_t _dbus_clearenv (void); char ** _dbus_get_environment (void); diff --git a/test/name-test/test-autolaunch.c b/test/name-test/test-autolaunch.c index adbeb185..732e6dc7 100644 --- a/test/name-test/test-autolaunch.c +++ b/test/name-test/test-autolaunch.c @@ -8,7 +8,6 @@ #endif #include -#include "dbus/dbus-sysdeps.h" int main (int argc, char *argv[]) @@ -16,7 +15,7 @@ main (int argc, char *argv[]) DBusConnection *conn = NULL; DBusError error; - _dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", NULL); + dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", NULL); dbus_error_init (&error); -- cgit v1.2.1 From 5ee72fe2e1e8fbb7ae09174e8df3ca28228ddd9b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Jun 2013 19:58:33 +0100 Subject: dbus-run-session: remove various extra variables from the environment DBUS_SESSION_BUS_PID is not mandatory to set, but we should unset it if present, since it points to a different session's bus. Likewise for DBUS_SESSION_BUS_WINDOWID. Similarly, if DBUS_STARTER_BUS_TYPE and DBUS_STARTER_ADDRESS are set (as they would be under GNOME Terminal 3.8, see ) then they are likely to point to a different session's bus. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39196 Signed-off-by: Simon McVittie Reviewed-by: Colin Walters --- doc/dbus-run-session.1.xml.in | 7 +++++++ tools/Makefile.am | 4 ++++ tools/dbus-run-session.c | 30 ++++++++---------------------- 3 files changed, 19 insertions(+), 22 deletions(-) diff --git a/doc/dbus-run-session.1.xml.in b/doc/dbus-run-session.1.xml.in index 693c5e4e..5181a8b1 100644 --- a/doc/dbus-run-session.1.xml.in +++ b/doc/dbus-run-session.1.xml.in @@ -130,6 +130,13 @@ contain a PROGRAM in the environment variable DBUS_SESSION_BUS_ADDRESS. + +The variables + DBUS_SESSION_BUS_PID, + DBUS_SESSION_BUS_WINDOWID, + DBUS_STARTER_BUS_TYPE and + DBUS_STARTER_ADDRESS + are removed from the environment, if present. BUGS diff --git a/tools/Makefile.am b/tools/Makefile.am index 464a8050..73d95fcf 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -47,6 +47,10 @@ dbus_launch_SOURCES= \ dbus_run_session_SOURCES = \ dbus-run-session.c + +dbus_run_session_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ + $(NULL) endif dbus_cleanup_sockets_SOURCES= \ diff --git a/tools/dbus-run-session.c b/tools/dbus-run-session.c index 4f7243f7..105ab3b4 100644 --- a/tools/dbus-run-session.c +++ b/tools/dbus-run-session.c @@ -36,6 +36,8 @@ #include #include +#include "dbus/dbus.h" + #define MAX_ADDR_LEN 512 #define PIPE_READ_END 0 #define PIPE_WRITE_END 1 @@ -100,22 +102,6 @@ oom (void) exit (1); } -static void * -xmalloc (size_t bytes) -{ - void *ret; - - if (bytes == 0) - bytes = 1; - - ret = malloc (bytes); - - if (ret == NULL) - oom (); - - return ret; -} - typedef enum { READ_STATUS_OK, /**< Read succeeded */ @@ -228,7 +214,6 @@ main (int argc, char **argv) int requires_arg = 0; pid_t bus_pid; pid_t app_pid; - char *envvar; while (i < argc) { @@ -397,11 +382,12 @@ main (int argc, char **argv) close (bus_address_pipe[PIPE_READ_END]); - envvar = xmalloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") + - strlen (bus_address) + 1); - strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); - strcat (envvar, bus_address); - putenv (envvar); + if (!dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", bus_address) || + !dbus_setenv ("DBUS_SESSION_BUS_PID", NULL) || + !dbus_setenv ("DBUS_SESSION_BUS_WINDOWID", NULL) || + !dbus_setenv ("DBUS_STARTER_ADDRESS", NULL) || + !dbus_setenv ("DBUS_STARTER_BUS_TYPE", NULL)) + oom (); app_pid = fork (); -- cgit v1.2.1 From fe459376481975e61c622494c08ea4ecbe082ea1 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 23 Aug 2013 15:52:18 +0800 Subject: DBus Spec: fix examples namespace to com.example There are a lot of examples in DBus Spec, and some of them just use the namespace org.freedesktop, and so as object namespace org/freedesktop. However, this is quite confusing. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66481 Reviewed-by: Simon McVittie --- doc/dbus-specification.xml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 65abd29f..673383a9 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -3661,8 +3661,8 @@ <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> - <node name="/org/freedesktop/sample_object"> - <interface name="org.freedesktop.SampleInterface"> + <node name="/com/example/sample_object"> + <interface name="com.example.SampleInterface"> <method name="Frobate"> <arg name="foo" type="i" direction="in"/> <arg name="bar" type="s" direction="out"/> @@ -3822,7 +3822,7 @@ unique-for-the-lifetime-of-the-bus name automatically assigned. Applications may request additional names for a connection. Additional names are usually "well-known names" such as - "org.freedesktop.TextEditor". When a name is bound to a connection, + "com.example.TextEditor". When a name is bound to a connection, that connection is said to own the name. @@ -3844,7 +3844,7 @@ This feature causes the right thing to happen if you start two text - editors for example; the first one may request "org.freedesktop.TextEditor", + editors for example; the first one may request "com.example.TextEditor", and the second will be queued as a possible owner of that name. When the first exits, the second will take over. @@ -4618,9 +4618,9 @@ With D-Bus, starting a service is normally done by name. That is, applications ask the message bus to start some program that will own a - well-known name, such as org.freedesktop.TextEditor. - This implies a contract documented along with the name - org.freedesktop.TextEditor for which objects + well-known name, such as com.example.TextEditor. + This implies a contract documented along with the name + com.example.TextEditor for which object the owner of that name will provide, and what interfaces those objects will have. @@ -4659,8 +4659,8 @@ # Sample service description file [D-BUS Service] - Name=org.freedesktop.ConfigurationDatabase - Exec=/usr/libexec/gconfd-2 + Name=com.example.ConfigurationDatabase + Exec=/usr/bin/sample-configd @@ -6040,9 +6040,9 @@ A service is an executable that can be launched by the bus daemon. Services normally guarantee some particular features, for example they may guarantee that they will request a specific name such as - "org.freedesktop.Screensaver", have a singleton object - "/org/freedesktop/Application", and that object will implement the - interface "org.freedesktop.ScreensaverControl". + "com.example.Screensaver", have a singleton object + "/com/example/Application", and that object will implement the + interface "com.example.Screensaver.Control". -- cgit v1.2.1 From 73ded5c619cbf001efa8aa216edcdccec9b2751c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:46:36 +0100 Subject: NEWS Also belatedly mention dbus-run-session in 1.7.4. --- NEWS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/NEWS b/NEWS index e9eff4f9..f65ddf75 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,9 @@ Enhancements: • Add GetConnectionCredentials() method (fd.o #54445, Simon) +• New API: dbus_setenv(), a simple wrapper around setenv(). + Note that this is not thread-safe. (fd.o #39196, Simon) + Fixes: • Escape addresses containing non-ASCII characters correctly @@ -53,6 +56,8 @@ Fixes: • Assorted Doxygen fixes (fd.o #65755, Chengwei Yang) • Unix-specific: + · dbus-run-session: clear some unwanted environment variables + (fd.o #39196, Simon) · dbus-run-session: compile on FreeBSD (fd.o #66197, Chengwei Yang) • Windows-specific: @@ -101,6 +106,12 @@ Enhancements: • Improve dbus-send documentation and command-line parsing (fd.o #65424, Chengwei Yang) +Unix-specific: + · dbus-run-session: experimental new tool to start a temporary D-Bus + session, e.g. for regression tests or a text console, replacing + certain uses of dbus-launch which weren't really correct + (fd.o #39196, Simon) + Other fixes: • In dbus-daemon, don't crash if a .service file starts with key=value -- cgit v1.2.1 From 82600c61dcb715e1651faaa4b5e577fca90bc35d Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 23 Aug 2013 16:49:39 +0800 Subject: Cleanup: polish verbose mode checking Reviewed-by: Simon McVittie --- bus/selinux.c | 19 +++++-------------- bus/signals.c | 2 -- dbus/dbus-connection.c | 11 ++--------- dbus/dbus-pending-call.c | 11 ++--------- 4 files changed, 9 insertions(+), 34 deletions(-) diff --git a/bus/selinux.c b/bus/selinux.c index 36287e9f..57c94326 100644 --- a/bus/selinux.c +++ b/bus/selinux.c @@ -936,8 +936,7 @@ bus_selinux_get_policy_root (void) void bus_selinux_id_table_print (DBusHashTable *service_table) { -#ifdef DBUS_ENABLE_VERBOSE_MODE -#ifdef HAVE_SELINUX +#if defined (DBUS_ENABLE_VERBOSE_MODE) && defined (HAVE_SELINUX) DBusHashIter iter; if (!selinux_enabled) @@ -953,19 +952,17 @@ bus_selinux_id_table_print (DBusHashTable *service_table) _dbus_verbose ("The context is %s\n", sid->ctx); _dbus_verbose ("The refcount is %d\n", sid->refcnt); } -#endif /* HAVE_SELINUX */ -#endif /* DBUS_ENABLE_VERBOSE_MODE */ +#endif /* DBUS_ENABLE_VERBOSE_MODE && HAVE_SELINUX */ } -#ifdef DBUS_ENABLE_VERBOSE_MODE -#ifdef HAVE_SELINUX /** * Print out some AVC statistics. */ static void bus_avc_print_stats (void) { +#if defined (DBUS_ENABLE_VERBOSE_MODE) && defined (HAVE_SELINUX) struct avc_cache_stats cstats; if (!selinux_enabled) @@ -983,9 +980,8 @@ bus_avc_print_stats (void) _dbus_verbose ("CAV hits: %d\n", cstats.cav_hits); _dbus_verbose ("CAV probes: %d\n", cstats.cav_probes); _dbus_verbose ("CAV misses: %d\n", cstats.cav_misses); +#endif /* DBUS_ENABLE_VERBOSE_MODE && HAVE_SELINUX */ } -#endif /* HAVE_SELINUX */ -#endif /* DBUS_ENABLE_VERBOSE_MODE */ /** @@ -1005,12 +1001,7 @@ bus_selinux_shutdown (void) sidput (bus_sid); bus_sid = SECSID_WILD; -#ifdef DBUS_ENABLE_VERBOSE_MODE - - if (_dbus_is_verbose()) - bus_avc_print_stats (); - -#endif /* DBUS_ENABLE_VERBOSE_MODE */ + bus_avc_print_stats (); avc_destroy (); #ifdef HAVE_LIBAUDIT diff --git a/bus/signals.c b/bus/signals.c index 72487edd..dab7154a 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -1980,12 +1980,10 @@ get_recipients_from_list (DBusList **rules, if (!_dbus_list_append (recipients_p, rule->matches_go_to)) return FALSE; } -#ifdef DBUS_ENABLE_VERBOSE_MODE else { _dbus_verbose ("Connection already receiving this message, so not adding again\n"); } -#endif /* DBUS_ENABLE_VERBOSE_MODE */ } link = _dbus_list_get_next_link (rules, link); diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index a6caaea6..759a6496 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -203,26 +203,19 @@ * @{ */ -#ifdef DBUS_ENABLE_VERBOSE_MODE static void _dbus_connection_trace_ref (DBusConnection *connection, int old_refcount, int new_refcount, const char *why) { +#ifdef DBUS_ENABLE_VERBOSE_MODE static int enabled = -1; _dbus_trace_ref ("DBusConnection", connection, old_refcount, new_refcount, why, "DBUS_CONNECTION_TRACE", &enabled); -} -#else -#define _dbus_connection_trace_ref(c,o,n,w) \ - do \ - {\ - (void) (o); \ - (void) (n); \ - } while (0) #endif +} /** * Internal struct representing a message filter function diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index 16044087..be534105 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -79,26 +79,19 @@ struct DBusPendingCall unsigned int timeout_added : 1; /**< Have added the timeout */ }; -#ifdef DBUS_ENABLE_VERBOSE_MODE static void _dbus_pending_call_trace_ref (DBusPendingCall *pending_call, int old_refcount, int new_refcount, const char *why) { +#ifdef DBUS_ENABLE_VERBOSE_MODE static int enabled = -1; _dbus_trace_ref ("DBusPendingCall", pending_call, old_refcount, new_refcount, why, "DBUS_PENDING_CALL_TRACE", &enabled); -} -#else -#define _dbus_pending_call_trace_ref(p, o, n, w) \ - do \ - {\ - (void) (o); \ - (void) (n); \ - } while (0) #endif +} static dbus_int32_t notify_user_data_slot = -1; -- cgit v1.2.1 From 77819311093eb7a7d9a0faa1d54d01db1e72df42 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 23 Aug 2013 16:52:38 +0800 Subject: Cleanup: polish inotify backend At previous, it will do get pid and print a verbose string per inotify event, and then do send signal to the daemon. This patch changes the behavior to get pid and print a verbose string one time. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 Reviewed-by: Simon McVittie --- bus/dir-watch-inotify.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index d684831d..862c3865 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -59,32 +59,30 @@ _handle_inotify_watch (DBusWatch *passed_watch, unsigned int flags, void *data) char buffer[INOTIFY_BUF_LEN]; ssize_t ret = 0; int i = 0; - pid_t pid; - dbus_bool_t have_change = FALSE; ret = read (inotify_fd, buffer, INOTIFY_BUF_LEN); if (ret < 0) _dbus_verbose ("Error reading inotify event: '%s'\n", _dbus_strerror(errno)); else if (!ret) _dbus_verbose ("Error reading inotify event: buffer too small\n"); + else + { + _dbus_verbose ("Sending SIGHUP signal on reception of %ld inotify event(s)\n", (long) ret); + (void) kill (_dbus_getpid(), SIGHUP); + } +#ifdef DBUS_ENABLE_VERBOSE_MODE while (i < ret) { struct inotify_event *ev; - pid = _dbus_getpid (); ev = (struct inotify_event *) &buffer[i]; i += INOTIFY_EVENT_SIZE + ev->len; -#ifdef DBUS_ENABLE_VERBOSE_MODE if (ev->len) _dbus_verbose ("event name: '%s'\n", ev->name); _dbus_verbose ("inotify event: wd=%d mask=%u cookie=%u len=%u\n", ev->wd, ev->mask, ev->cookie, ev->len); -#endif - _dbus_verbose ("Sending SIGHUP signal on reception of a inotify event\n"); - have_change = TRUE; } - if (have_change) - (void) kill (pid, SIGHUP); +#endif return TRUE; } -- cgit v1.2.1 From fa783ea4ea540e8a13102a77cddef235e3fc1d6b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 23 Aug 2013 11:54:01 +0100 Subject: fix whitespace --- bus/dir-watch-inotify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/dir-watch-inotify.c b/bus/dir-watch-inotify.c index 862c3865..49ebc721 100644 --- a/bus/dir-watch-inotify.c +++ b/bus/dir-watch-inotify.c @@ -68,7 +68,7 @@ _handle_inotify_watch (DBusWatch *passed_watch, unsigned int flags, void *data) else { _dbus_verbose ("Sending SIGHUP signal on reception of %ld inotify event(s)\n", (long) ret); - (void) kill (_dbus_getpid(), SIGHUP); + (void) kill (_dbus_getpid (), SIGHUP); } #ifdef DBUS_ENABLE_VERBOSE_MODE -- cgit v1.2.1 From 8203fe35da82cd9d3491ed8ac8a2a37cfa83f4e6 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 23 Aug 2013 16:57:30 +0800 Subject: Cleanup: simplify assertion check Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 Reviewed-by: Simon McVittie --- bus/driver.c | 17 +++-------------- dbus/dbus-string.c | 7 ++----- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/bus/driver.c b/bus/driver.c index 23197e43..e95a79d9 100644 --- a/bus/driver.c +++ b/bus/driver.c @@ -885,13 +885,7 @@ bus_driver_handle_update_activation_environment (DBusConnection *connection, /* The message signature has already been checked for us, * so let's just assert it's right. */ -#ifndef DBUS_DISABLE_ASSERT - { - int msg_type = dbus_message_iter_get_arg_type (&iter); - - _dbus_assert (msg_type == DBUS_TYPE_ARRAY); - } -#endif + _dbus_assert (dbus_message_iter_get_arg_type (&iter) == DBUS_TYPE_ARRAY); dbus_message_iter_recurse (&iter, &dict_iter); @@ -2008,13 +2002,8 @@ bus_driver_handle_message (DBusConnection *connection, _dbus_verbose ("Driver got a method call: %s\n", name); /* security checks should have kept this from getting here */ -#ifndef DBUS_DISABLE_ASSERT - { - const char *sender = dbus_message_get_sender (message); - - _dbus_assert (sender != NULL || strcmp (name, "Hello") == 0); - } -#endif + _dbus_assert (dbus_message_get_sender (message) != NULL || + strcmp (name, "Hello") == 0); for (ih = interface_handlers; ih->name != NULL; ih++) { diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 18e87eb2..81140a6e 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -335,14 +335,11 @@ reallocate_for_length (DBusRealString *real, * disable asserts to profile, you don't get this destroyer * of profiles. */ -#ifdef DBUS_DISABLE_ASSERT -#else -#ifdef DBUS_ENABLE_EMBEDDED_TESTS +#if defined (DBUS_ENABLE_EMBEDDED_TESTS) && !defined (DBUS_DISABLE_ASSERT) new_allocated = 0; /* ensure a realloc every time so that we go * through all malloc failure codepaths */ -#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ -#endif /* !DBUS_DISABLE_ASSERT */ +#endif /* But be sure we always alloc at least space for the new length */ new_allocated = MAX (new_allocated, -- cgit v1.2.1 From d61daf50ce54976d1926afcb2353383cde5804b6 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 23 Aug 2013 17:13:46 +0800 Subject: Fix comment about atomic operations Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 Reviewed-by: Simon McVittie --- dbus/dbus-server.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index efe7d1d8..2c2b9495 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -699,13 +699,11 @@ dbus_server_ref (DBusServer *server) _dbus_return_val_if_fail (server != NULL, NULL); - /* can't get the refcount without a side-effect */ old_refcount = _dbus_atomic_inc (&server->refcount); #ifndef DBUS_DISABLE_CHECKS if (_DBUS_UNLIKELY (old_refcount <= 0)) { - /* undo side-effect first */ _dbus_atomic_dec (&server->refcount); _dbus_warn_check_failed (_dbus_return_if_fail_warning_format, _DBUS_FUNCTION_NAME, "old_refcount > 0", @@ -736,13 +734,18 @@ dbus_server_unref (DBusServer *server) _dbus_return_if_fail (server != NULL); - /* can't get the refcount without a side-effect */ old_refcount = _dbus_atomic_dec (&server->refcount); #ifndef DBUS_DISABLE_CHECKS if (_DBUS_UNLIKELY (old_refcount <= 0)) { - /* undo side-effect first */ + /* undo side-effect first + * please do not try to simplify the code here by using + * _dbus_atomic_get(), why we don't use it is + * because it issues another atomic operation even though + * DBUS_DISABLE_CHECKS defined. + * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 + */ _dbus_atomic_inc (&server->refcount); _dbus_warn_check_failed (_dbus_return_if_fail_warning_format, _DBUS_FUNCTION_NAME, "old_refcount > 0", -- cgit v1.2.1 From 28f15d8b219877ac2dca771e823188d018db2db0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 23 Aug 2013 17:19:51 +0800 Subject: Fix debug output about dbus server ref count dbus_server_disconnect() invokes dbus_server_unref() at the end of function, the latter will print a trace about server ref count decrease 1. However, it doesn't invoke dbus_server_ref(), so there isn't a trace about server ref count increase in debug output. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 Reviewed-by: Simon McVittie --- dbus/dbus-server.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index 2c2b9495..19d8590c 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -780,16 +780,7 @@ dbus_server_disconnect (DBusServer *server) { _dbus_return_if_fail (server != NULL); -#ifdef DBUS_DISABLE_CHECKS - _dbus_atomic_inc (&server->refcount); -#else - { - dbus_int32_t old_refcount = _dbus_atomic_inc (&server->refcount); - - _dbus_return_if_fail (old_refcount > 0); - } -#endif - + dbus_server_ref (server); SERVER_LOCK (server); _dbus_assert (server->vtable->disconnect != NULL); -- cgit v1.2.1 From e1bc0164589193f8b5997580f60a5874065357fe Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 27 Aug 2013 17:32:56 +0200 Subject: Fixed gcc 4.8.1 -Wformat warnings on windows. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=67072 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 8 ++++---- dbus/dbus-sysdeps-win.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 38758bd4..efeb2a61 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -165,7 +165,7 @@ get_pid_from_extended_tcp_table(int peer_port) } else { - _dbus_verbose ("unexpected error returned from GetExtendedTcpTable %d\n", errorCode); + _dbus_win_warn_win_error ("unexpected error returned from GetExtendedTcpTable", errorCode); return 0; } @@ -188,7 +188,7 @@ get_pid_from_extended_tcp_table(int peer_port) } dbus_free (tcp_table); - _dbus_verbose ("got pid %d\n", (int)result); + _dbus_verbose ("got pid %lu\n", result); return result; } @@ -236,7 +236,7 @@ get_pid_from_tcp_ex_table(int peer_port) } HeapFree (GetProcessHeap(), 0, tcp_table); - _dbus_verbose ("got pid %d\n", (int)result); + _dbus_verbose ("got pid %lu\n", result); return result; } @@ -3840,7 +3840,7 @@ _dbus_win_set_error_from_win_error (DBusError *error, void _dbus_win_warn_win_error (const char *message, - int code) + unsigned long code) { DBusError error; diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 5e7f1e46..7cb1b6ff 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -44,7 +44,7 @@ const char* _dbus_win_error_from_last_error (void); void _dbus_win_startup_winsock (void); void _dbus_win_warn_win_error (const char *message, - int code); + unsigned long code); char * _dbus_win_error_string (int error_number); void _dbus_win_free_error_string (char *string); -- cgit v1.2.1 From 5366a920f4d8e04337d33f714037e1d4fc482a0e Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 29 Jun 2013 12:45:22 +0200 Subject: Fixed mingw gcc 4.8.1 complains about double defined macros. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=67072 Reviewed-by: Simon McVittie --- cmake/config.h.cmake | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index a961d1ab..824b5144 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -19,15 +19,8 @@ #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@" #cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@" #cmakedefine PACKAGE "@PACKAGE@" -/* Version number of package */ -#cmakedefine DBUS_MAJOR_VERSION @DBUS_MAJOR_VERSION@ -#cmakedefine DBUS_MINOR_VERSION @DBUS_MINOR_VERSION@ -#cmakedefine DBUS_MICRO_VERSION @DBUS_MICRO_VERSION@ -#cmakedefine DBUS_VERSION ((@DBUS_MAJOR_VERSION@ << 16) | (@DBUS_MINOR_VERSION@ << 8) | (@DBUS_MICRO_VERSION@)) -#cmakedefine DBUS_VERSION_STRING "@DBUS_VERSION_STRING@" -#cmakedefine DBUS_ENABLE_STATS -#define VERSION DBUS_VERSION_STRING +#cmakedefine DBUS_ENABLE_STATS #define TEST_LISTEN "@TEST_LISTEN@" -- cgit v1.2.1 From b1579df4ce0b2135d6c343066eb52e319df60228 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 28 Aug 2013 14:16:21 +0200 Subject: Generate autotools provided PACKAGE_.. and VERSION defines by a cmake macro. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=67072 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 8 +++++ cmake/config.h.cmake | 7 ++++- cmake/modules/MacrosAutotools.cmake | 60 +++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index aecc74cd..bde43f03 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -19,6 +19,14 @@ autoversion(../configure.ac dbus) # used by file version info set (DBUS_PATCH_VERSION "0") +# set PACKAGE_... variables +autopackage( + dbus + ${DBUS_VERSION_STRING} + "http://dbus.freedesktop.org" + "https://bugs.freedesktop.org/enter_bug.cgi?product=dbus" +) + include(Macros) TIMESTAMP(DBUS_BUILD_TIMESTAMP) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 824b5144..f14b169e 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -6,6 +6,12 @@ /* indicate that we are building with cmake */ #define DBUS_CMAKE 1 +@AUTOPACKAGE_CONFIG_H_TEMPLATE@ + +/* + * Variables defined by AC_DEFINE in ../configure.ac + * should be placed in this file +*/ #cmakedefine HAVE_GNUC_VARARGS 1 #cmakedefine DBUS_CONSOLE_AUTH_DIR "@DBUS_CONSOLE_AUTH_DIR@" @@ -18,7 +24,6 @@ #cmakedefine DBUS_SESSION_BUS_CONNECT_ADDRESS "@DBUS_SESSION_BUS_CONNECT_ADDRESS@" #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@" #cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@" -#cmakedefine PACKAGE "@PACKAGE@" #cmakedefine DBUS_ENABLE_STATS diff --git a/cmake/modules/MacrosAutotools.cmake b/cmake/modules/MacrosAutotools.cmake index ff30eaf9..68e8ae51 100644 --- a/cmake/modules/MacrosAutotools.cmake +++ b/cmake/modules/MacrosAutotools.cmake @@ -22,6 +22,66 @@ macro(autoversion config prefix) endmacro() +# +# Defines package related variables (PACKAGE_..., PACKAGE and VERSION) +# as done by autotools. +# +# Additional it defines a cmake variable named PACKAGE_CONFIG_H_TEMPLATE +# which could be placed in config.h templates to have those variables +# defined at code level like shown below: +# +# config.h.template +# ... +# @AUTOPACKAGE_CONFIG_H_TEMPLATE@ +# ... +# +macro(autopackage name version url support_url) + # Define to the full name of this package. + set(PACKAGE_NAME ${name}) + + # Define to the version of this package. + set(PACKAGE_VERSION ${version}) + + # Define to the home page for this package. + set(PACKAGE_URL ${url}) + + # Define to the address where bug reports for this package should be sent. + set(PACKAGE_BUGREPORT ${support_url}) + + # Define to the full name and version of this package. + set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") + + # Define to the one symbol short name of this package. + set(PACKAGE_TARNAME ${PACKAGE_NAME}) + + set(PACKAGE ${name}) + set(VERSION ${DBUS_VERSION_STRING}) + + set(AUTOPACKAGE_CONFIG_H_TEMPLATE "/* generated by cmake macro autopackage */\n +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT \"@PACKAGE_BUGREPORT@\" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME \"@PACKAGE_NAME@\" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING \"@PACKAGE_STRING@\" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME \"@PACKAGE_TARNAME@\" + +/* Define to the home page for this package. */ +#define PACKAGE_URL \"@PACKAGE_URL@\" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION \"@PACKAGE_VERSION@\" + +/* defined by autotools package */ +#define PACKAGE \"@PACKAGE@\" +#define VERSION \"@VERSION@\" +") +endmacro(autopackage) + # # parses config.h template and create cmake equivalent # not implemented yet -- cgit v1.2.1 From ced50f8be12ca91274c64bbf5455138e5f2ae7c3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 27 Aug 2013 13:53:42 +0100 Subject: libdbus-1.la: have proper dependencies on Windows Assigning to libdbus_1_la_DEPENDENCIES defeats Automake's normal dependency logic, which makes libdbus-1.la depend on all the static libraries that will go into it (it still had a corrct dependency on the other objects, which go through a separate variable). This meant libdbus-init-win wasn't necessarily built first. Use EXTRA_libdbus_1_la_DEPENDENCIES to avoid that problem. Signed-off-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68505 Acked-by: Ralf Habacker --- dbus/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/Makefile.am b/dbus/Makefile.am index e118cbbb..0f9033d1 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -39,7 +39,7 @@ dbus_res_ldflag = -Wl,$(dbus_res) no_undefined = -no-undefined export_symbols = -libdbus_1_la_DEPENDENCIES = $(dbus_res) +EXTRA_libdbus_1_la_DEPENDENCIES = $(dbus_res) intllibs = else -- cgit v1.2.1 From d98a587f766e00f50244cfa75008e75ee4af20f6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 27 Aug 2013 14:35:47 +0100 Subject: _dbus_get_tmpdir: be thread-safe Sharing a static variable between threads is not safe in general, and this function is used in the shared libdbus (for nonce files), so it can't rely on being single-threaded. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- bus/activation.c | 8 +++++++- dbus/dbus-internals.h | 3 ++- dbus/dbus-nonce.c | 6 +++++- dbus/dbus-sysdeps-unix.c | 8 +++++++- dbus/dbus-sysdeps-win.c | 8 +++++++- 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index 42694409..e03b6fec 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -2539,11 +2539,17 @@ dbus_bool_t bus_activation_service_reload_test (const DBusString *test_data_dir) { DBusString directory; + const char *tmp; if (!_dbus_string_init (&directory)) return FALSE; - if (!_dbus_string_append (&directory, _dbus_get_tmpdir())) + tmp = _dbus_get_tmpdir (); + + if (tmp == NULL) + return FALSE; + + if (!_dbus_string_append (&directory, tmp)) return FALSE; if (!_dbus_string_append (&directory, "/dbus-reload-test-") || diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 0856f8f7..e9ffb9e2 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -316,9 +316,10 @@ typedef enum _DBUS_LOCK_shutdown_funcs, _DBUS_LOCK_system_users, _DBUS_LOCK_message_cache, - /* index 10-11 */ + /* index 10-12 */ _DBUS_LOCK_shared_connections, _DBUS_LOCK_machine_uuid, + _DBUS_LOCK_sysdeps, _DBUS_N_GLOBAL_LOCKS } DBusGlobalLock; diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index e74c2dd5..ef037ef9 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -240,6 +240,7 @@ do_noncefile_create (DBusNonceFile *noncefile, dbus_bool_t use_subdir) { DBusString randomStr; + const char *tmp; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -257,8 +258,11 @@ do_noncefile_create (DBusNonceFile *noncefile, goto on_error; } + tmp = _dbus_get_tmpdir (); + if (!_dbus_string_init (&noncefile->dir) - || !_dbus_string_append (&noncefile->dir, _dbus_get_tmpdir())) + || tmp == NULL + || !_dbus_string_append (&noncefile->dir, tmp)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto on_error; diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 66f55d75..1dcb6f86 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3197,13 +3197,17 @@ _dbus_printf_string_upper_bound (const char *format, * Gets the temporary files directory by inspecting the environment variables * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned * - * @returns location of temp directory + * @returns location of temp directory, or #NULL if no memory for locking */ const char* _dbus_get_tmpdir(void) { + /* Protected by _DBUS_LOCK_sysdeps */ static const char* tmpdir = NULL; + if (!_DBUS_LOCK (sysdeps)) + return NULL; + if (tmpdir == NULL) { /* TMPDIR is what glibc uses, then @@ -3226,6 +3230,8 @@ _dbus_get_tmpdir(void) tmpdir = "/tmp"; } + _DBUS_UNLOCK (sysdeps); + _dbus_assert(tmpdir != NULL); return tmpdir; diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index efeb2a61..2f5e51fe 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2256,14 +2256,18 @@ _dbus_generate_random_bytes (DBusString *str, * Gets the temporary files directory by inspecting the environment variables * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned * - * @returns location of temp directory + * @returns location of temp directory, or #NULL if no memory for locking */ const char* _dbus_get_tmpdir(void) { + /* Protected by _DBUS_LOCK_sysdeps */ static const char* tmpdir = NULL; static char buf[1000]; + if (!_DBUS_LOCK (sysdeps)) + return NULL; + if (tmpdir == NULL) { char *last_slash; @@ -2285,6 +2289,8 @@ _dbus_get_tmpdir(void) tmpdir = buf; } + _DBUS_UNLOCK (sysdeps); + _dbus_assert(tmpdir != NULL); return tmpdir; -- cgit v1.2.1 From 31edd76313922780fb640f13ad1b5ed130fe442b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 30 Aug 2013 17:24:20 +0100 Subject: Revert "Add a statically-initialized implementation of _dbus_lock() on glibc systems" This reverts commit 83aaa9f359e90d3b8cae5d17f6d9ba4600cff68b. This wasn't right: because it looked for a symbol from pthread.h, modules could end up disagreeing about whether threading was enabled or not. --- dbus/dbus-sysdeps-pthread.c | 47 -------------------------------------------- dbus/dbus-threads-internal.h | 6 ------ dbus/dbus-threads.c | 14 ------------- 3 files changed, 67 deletions(-) diff --git a/dbus/dbus-sysdeps-pthread.c b/dbus/dbus-sysdeps-pthread.c index 2180c37b..1300ec35 100644 --- a/dbus/dbus-sysdeps-pthread.c +++ b/dbus/dbus-sysdeps-pthread.c @@ -300,50 +300,3 @@ _dbus_threads_unlock_platform_specific (void) { pthread_mutex_unlock (&init_mutex); } - -#ifdef DBUS_HAVE_STATIC_RECURSIVE_MUTEXES - -static pthread_mutex_t global_locks[] = { - /* 0-4 */ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - /* 5-9 */ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - /* 10-11 */ - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP, - PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP -}; - -_DBUS_STATIC_ASSERT (_DBUS_N_ELEMENTS (global_locks) == _DBUS_N_GLOBAL_LOCKS); - -dbus_bool_t -_dbus_lock (DBusGlobalLock lock) -{ - /* No initialization is needed. */ - _dbus_assert (lock >= 0); - _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); - - PTHREAD_CHECK ("pthread_mutex_lock", - pthread_mutex_lock (&(global_locks[lock]))); - return TRUE; -} - -void -_dbus_unlock (DBusGlobalLock lock) -{ - /* No initialization is needed. */ - _dbus_assert (lock >= 0); - _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); - - PTHREAD_CHECK ("pthread_mutex_unlock", - pthread_mutex_unlock (&(global_locks[lock]))); -} - -#endif diff --git a/dbus/dbus-threads-internal.h b/dbus/dbus-threads-internal.h index 228a8c05..64e8bac0 100644 --- a/dbus/dbus-threads-internal.h +++ b/dbus/dbus-threads-internal.h @@ -32,12 +32,6 @@ * @{ */ -/* glibc can implement global locks without needing an initialization step, - * which improves our thread-safety-by-default further. */ -#if defined(__GLIBC__) && defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP) -# define DBUS_HAVE_STATIC_RECURSIVE_MUTEXES 1 -#endif - /** * A mutex which is recursive if possible, else non-recursive. * This is typically recursive, but that cannot be relied upon. diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 45b262dc..12d40493 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -283,18 +283,6 @@ _dbus_condvar_wake_one (DBusCondVar *cond) _dbus_platform_condvar_wake_one (cond); } -#ifdef DBUS_HAVE_STATIC_RECURSIVE_MUTEXES - -static dbus_bool_t -init_global_locks (void) -{ - return TRUE; -} - -/* implementations in dbus-sysdeps-pthread.c */ - -#else /* !defined(DBUS_HAVE_STATIC_RECURSIVE_MUTEXES) */ - static DBusRMutex *global_locks[_DBUS_N_GLOBAL_LOCKS] = { NULL }; static void @@ -368,8 +356,6 @@ _dbus_unlock (DBusGlobalLock lock) _dbus_platform_rmutex_unlock (global_locks[lock]); } -#endif /* !defined(DBUS_HAVE_STATIC_RECURSIVE_MUTEXES) */ - /** @} */ /* end of internals */ /** -- cgit v1.2.1 From cc28d8d91055e7640932c67031ca0ec86dddac06 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 12:49:35 +0100 Subject: _dbus_file_path_extract_elements_from_tail: don't misuse static variable If we _dbus_verbose() from more than one thread at the same time, we don't want to get into trouble with static variables (and I don't think micro-optimizing this function is really worth it anyway). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- dbus/dbus-internals.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 257f1d4c..e2482597 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -332,25 +332,22 @@ _dbus_verbose_init (void) */ static char *_dbus_file_path_extract_elements_from_tail(const char *file,int level) { - static int prefix = -1; + int prefix = 0; + char *p = (char *)file + strlen(file); + int i = 0; - if (prefix == -1) + for (;p >= file;p--) { - char *p = (char *)file + strlen(file); - int i = 0; - prefix = 0; - for (;p >= file;p--) + if (DBUS_IS_DIR_SEPARATOR(*p)) { - if (DBUS_IS_DIR_SEPARATOR(*p)) + if (++i >= level) { - if (++i >= level) - { - prefix = p-file+1; - break; - } - } - } + prefix = p-file+1; + break; + } + } } + return (char *)file+prefix; } -- cgit v1.2.1 From e63961b75053d744bd06ce926df0b8a31c30fa77 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 12:50:16 +0100 Subject: _dbus_get_autolaunch_address: don't make argv static This function could be accessed from any thread, which would mean it scribbles on argv twice. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 1dcb6f86..13e13ca1 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3463,7 +3463,7 @@ _dbus_get_autolaunch_address (const char *scope, * but that's done elsewhere, and if it worked, this function wouldn't * be called.) */ const char *display; - static char *argv[6]; + char *argv[6]; int i; DBusString uuid; dbus_bool_t retval; -- cgit v1.2.1 From 53966707ae206dc42e3e2746d1a731c69c35a610 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 12:50:39 +0100 Subject: Comment some suspicious uses of static variables Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-unix.c | 2 ++ dbus/dbus-sysdeps-win.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 13e13ca1..8ecbfd36 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3948,6 +3948,8 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, } else { + /* Not strictly thread-safe, but if we fail at thread-safety here, + * the worst that will happen is some extra warnings. */ static dbus_bool_t already_warned = FALSE; if (!already_warned) { diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 2f5e51fe..1039cc64 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3622,6 +3622,8 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, } else { + /* Not strictly thread-safe, but if we fail at thread-safety here, + * the worst that will happen is some extra warnings. */ static dbus_bool_t already_warned = FALSE; if (!already_warned) { -- cgit v1.2.1 From b7a91bfd463fdef233cc48c7e1b09793e7fe56a7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 12:51:14 +0100 Subject: _dbus_win_startup_winsock: be thread-safe Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 1039cc64..68bd3a11 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -672,21 +672,26 @@ _dbus_connect_named_pipe (const char *path, #endif - - -void +/** + * @returns #FALSE if no memory + */ +dbus_bool_t _dbus_win_startup_winsock (void) { /* Straight from MSDN, deuglified */ + /* Protected by _DBUS_LOCK_sysdeps */ static dbus_bool_t beenhere = FALSE; WORD wVersionRequested; WSADATA wsaData; int err; + if (!_DBUS_LOCK (sysdeps)) + return FALSE; + if (beenhere) - return; + goto out; wVersionRequested = MAKEWORD (2, 0); @@ -710,6 +715,10 @@ _dbus_win_startup_winsock (void) } beenhere = TRUE; + +out: + _DBUS_UNLOCK (sysdeps); + return TRUE; } @@ -1054,7 +1063,11 @@ _dbus_full_duplex_pipe (int *fd1, int len; u_long arg; - _dbus_win_startup_winsock (); + if (!_dbus_win_startup_winsock ()) + { + _DBUS_SET_OOM (error); + return FALSE; + } temp = socket (AF_INET, SOCK_STREAM, 0); if (temp == INVALID_SOCKET) @@ -1498,7 +1511,11 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - _dbus_win_startup_winsock (); + if (!_dbus_win_startup_winsock ()) + { + _DBUS_SET_OOM (error); + return -1; + } _DBUS_ZERO (hints); @@ -1643,7 +1660,11 @@ _dbus_listen_tcp_socket (const char *host, *fds_p = NULL; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - _dbus_win_startup_winsock (); + if (!_dbus_win_startup_winsock ()) + { + _DBUS_SET_OOM (error); + return -1; + } _DBUS_ZERO (hints); -- cgit v1.2.1 From 765c9ebc595fb2621ddf22c2f95ce36499560e87 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 12:51:26 +0100 Subject: _dbus_check_setuid: comment on thread-safety Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-unix.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 8ecbfd36..52cf0925 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4172,6 +4172,8 @@ _dbus_check_setuid (void) uid_t ruid, euid, suid; /* Real, effective and saved user ID's */ gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */ + /* We call into this function from _dbus_threads_init_platform_specific() + * to make sure these are initialized before we start threading. */ static dbus_bool_t check_setuid_initialised; static dbus_bool_t is_setuid; -- cgit v1.2.1 From 3e35c91fd874c131b7d49599f64e3a5546cc4035 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 13:16:14 +0100 Subject: Move some sysdeps stuff only used by the dbus-daemon outside libdbus This means we don't need to worry about whether it's thread-safe, and makes libdbus a little smaller. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-unix.c | 178 ------------------------------------ dbus/dbus-sysdeps-util-unix.c | 177 ++++++++++++++++++++++++++++++++++++ dbus/dbus-sysdeps-util-win.c | 204 ++++++++++++++++++++++++++++++++++++++++++ dbus/dbus-sysdeps-win.c | 204 ------------------------------------------ 4 files changed, 381 insertions(+), 382 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 52cf0925..1cb4a58b 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3572,9 +3572,6 @@ _dbus_read_local_machine_uuid (DBusGUID *machine_id, return _dbus_read_uuid_file (&filename, machine_id, FALSE, error); } -#define DBUS_UNIX_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" -#define DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" - /** * quries launchd for a specific env var which holds the socket path. * @param socket_path append the socket path to this DBusString @@ -3725,167 +3722,6 @@ _dbus_lookup_session_address (dbus_bool_t *supported, #endif } -/** - * Returns the standard directories for a session bus to look for service - * activation files - * - * On UNIX this should be the standard xdg freedesktop.org data directories: - * - * XDG_DATA_HOME=${XDG_DATA_HOME-$HOME/.local/share} - * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} - * - * and - * - * DBUS_DATADIR - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_session_servicedirs (DBusList **dirs) -{ - const char *xdg_data_home; - const char *xdg_data_dirs; - DBusString servicedir_path; - - if (!_dbus_string_init (&servicedir_path)) - return FALSE; - - xdg_data_home = _dbus_getenv ("XDG_DATA_HOME"); - xdg_data_dirs = _dbus_getenv ("XDG_DATA_DIRS"); - - if (xdg_data_home != NULL) - { - if (!_dbus_string_append (&servicedir_path, xdg_data_home)) - goto oom; - } - else - { - const DBusString *homedir; - DBusString local_share; - - if (!_dbus_homedir_from_current_process (&homedir)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _dbus_string_get_const_data (homedir))) - goto oom; - - _dbus_string_init_const (&local_share, "/.local/share"); - if (!_dbus_concat_dir_and_file (&servicedir_path, &local_share)) - goto oom; - } - - if (!_dbus_string_append (&servicedir_path, ":")) - goto oom; - - if (xdg_data_dirs != NULL) - { - if (!_dbus_string_append (&servicedir_path, xdg_data_dirs)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, ":")) - goto oom; - } - else - { - if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:")) - goto oom; - } - - /* - * add configured datadir to defaults - * this may be the same as an xdg dir - * however the config parser should take - * care of duplicates - */ - if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) - goto oom; - - if (!_dbus_split_paths_and_append (&servicedir_path, - DBUS_UNIX_STANDARD_SESSION_SERVICEDIR, - dirs)) - goto oom; - - _dbus_string_free (&servicedir_path); - return TRUE; - - oom: - _dbus_string_free (&servicedir_path); - return FALSE; -} - - -/** - * Returns the standard directories for a system bus to look for service - * activation files - * - * On UNIX this should be the standard xdg freedesktop.org data directories: - * - * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} - * - * and - * - * DBUS_DATADIR - * - * On Windows there is no system bus and this function can return nothing. - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_system_servicedirs (DBusList **dirs) -{ - /* - * DBUS_DATADIR may be the same as one of the standard directories. However, - * the config parser should take care of the duplicates. - * - * Also, append /lib as counterpart of /usr/share on the root - * directory (the root directory does not know /share), in order to - * facilitate early boot system bus activation where /usr might not - * be available. - */ - static const char standard_search_path[] = - "/usr/local/share:" - "/usr/share:" - DBUS_DATADIR ":" - "/lib"; - DBusString servicedir_path; - - _dbus_string_init_const (&servicedir_path, standard_search_path); - - return _dbus_split_paths_and_append (&servicedir_path, - DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR, - dirs); -} - -/** - * Append the absolute path of the system.conf file - * (there is no system bus on Windows so this can just - * return FALSE and print a warning or something) - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_system_config_file (DBusString *str) -{ - return _dbus_string_append (str, DBUS_SYSTEM_CONFIG_FILE); -} - -/** - * Append the absolute path of the session.conf file. - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_session_config_file (DBusString *str) -{ - return _dbus_string_append (str, DBUS_SESSION_CONFIG_FILE); -} - /** * Called when the bus daemon is signaled to reload its configuration; any * caches should be nuked. Of course any caches that need explicit reload @@ -4065,20 +3901,6 @@ _dbus_socket_can_pass_unix_fd(int fd) { #endif } - -/* - * replaces the term DBUS_PREFIX in configure_time_path by the - * current dbus installation directory. On unix this function is a noop - * - * @param configure_time_path - * @return real path - */ -const char * -_dbus_replace_install_prefix (const char *configure_time_path) -{ - return configure_time_path; -} - /** * Closes all file descriptors except the first three (i.e. stdin, * stdout, stderr). diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 9ad63b43..631c199f 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1178,3 +1178,180 @@ fail: _dbus_string_free (&path); return FALSE; } + +/* + * replaces the term DBUS_PREFIX in configure_time_path by the + * current dbus installation directory. On unix this function is a noop + * + * @param configure_time_path + * @return real path + */ +const char * +_dbus_replace_install_prefix (const char *configure_time_path) +{ + return configure_time_path; +} + +#define DBUS_UNIX_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" +#define DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" + +/** + * Returns the standard directories for a session bus to look for service + * activation files + * + * On UNIX this should be the standard xdg freedesktop.org data directories: + * + * XDG_DATA_HOME=${XDG_DATA_HOME-$HOME/.local/share} + * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} + * + * and + * + * DBUS_DATADIR + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_session_servicedirs (DBusList **dirs) +{ + const char *xdg_data_home; + const char *xdg_data_dirs; + DBusString servicedir_path; + + if (!_dbus_string_init (&servicedir_path)) + return FALSE; + + xdg_data_home = _dbus_getenv ("XDG_DATA_HOME"); + xdg_data_dirs = _dbus_getenv ("XDG_DATA_DIRS"); + + if (xdg_data_home != NULL) + { + if (!_dbus_string_append (&servicedir_path, xdg_data_home)) + goto oom; + } + else + { + const DBusString *homedir; + DBusString local_share; + + if (!_dbus_homedir_from_current_process (&homedir)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _dbus_string_get_const_data (homedir))) + goto oom; + + _dbus_string_init_const (&local_share, "/.local/share"); + if (!_dbus_concat_dir_and_file (&servicedir_path, &local_share)) + goto oom; + } + + if (!_dbus_string_append (&servicedir_path, ":")) + goto oom; + + if (xdg_data_dirs != NULL) + { + if (!_dbus_string_append (&servicedir_path, xdg_data_dirs)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, ":")) + goto oom; + } + else + { + if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:")) + goto oom; + } + + /* + * add configured datadir to defaults + * this may be the same as an xdg dir + * however the config parser should take + * care of duplicates + */ + if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) + goto oom; + + if (!_dbus_split_paths_and_append (&servicedir_path, + DBUS_UNIX_STANDARD_SESSION_SERVICEDIR, + dirs)) + goto oom; + + _dbus_string_free (&servicedir_path); + return TRUE; + + oom: + _dbus_string_free (&servicedir_path); + return FALSE; +} + + +/** + * Returns the standard directories for a system bus to look for service + * activation files + * + * On UNIX this should be the standard xdg freedesktop.org data directories: + * + * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} + * + * and + * + * DBUS_DATADIR + * + * On Windows there is no system bus and this function can return nothing. + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_system_servicedirs (DBusList **dirs) +{ + /* + * DBUS_DATADIR may be the same as one of the standard directories. However, + * the config parser should take care of the duplicates. + * + * Also, append /lib as counterpart of /usr/share on the root + * directory (the root directory does not know /share), in order to + * facilitate early boot system bus activation where /usr might not + * be available. + */ + static const char standard_search_path[] = + "/usr/local/share:" + "/usr/share:" + DBUS_DATADIR ":" + "/lib"; + DBusString servicedir_path; + + _dbus_string_init_const (&servicedir_path, standard_search_path); + + return _dbus_split_paths_and_append (&servicedir_path, + DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR, + dirs); +} + +/** + * Append the absolute path of the system.conf file + * (there is no system bus on Windows so this can just + * return FALSE and print a warning or something) + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_system_config_file (DBusString *str) +{ + return _dbus_string_append (str, DBUS_SYSTEM_CONFIG_FILE); +} + +/** + * Append the absolute path of the session.conf file. + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_session_config_file (DBusString *str) +{ + return _dbus_string_append (str, DBUS_SESSION_CONFIG_FILE); +} diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index 71ed8b79..fe4b1a22 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -1528,3 +1528,207 @@ _dbus_command_for_pid (unsigned long pid, // FIXME return FALSE; } + +/* + * replaces the term DBUS_PREFIX in configure_time_path by the + * current dbus installation directory. On unix this function is a noop + * + * @param configure_time_path + * @return real path + */ +const char * +_dbus_replace_install_prefix (const char *configure_time_path) +{ +#ifndef DBUS_PREFIX + return configure_time_path; +#else + static char retval[1000]; + static char runtime_prefix[1000]; + int len = 1000; + int i; + + if (!configure_time_path) + return NULL; + + if ((!_dbus_get_install_root(runtime_prefix, len) || + strncmp (configure_time_path, DBUS_PREFIX "/", + strlen (DBUS_PREFIX) + 1))) { + strcat (retval, configure_time_path); + return retval; + } + + strcpy (retval, runtime_prefix); + strcat (retval, configure_time_path + strlen (DBUS_PREFIX) + 1); + + /* Somehow, in some situations, backslashes get collapsed in the string. + * Since windows C library accepts both forward and backslashes as + * path separators, convert all backslashes to forward slashes. + */ + + for(i = 0; retval[i] != '\0'; i++) { + if(retval[i] == '\\') + retval[i] = '/'; + } + return retval; +#endif +} + +/** + * return the relocated DATADIR + * + * @returns relocated DATADIR static string + */ + +static const char * +_dbus_windows_get_datadir (void) +{ + return _dbus_replace_install_prefix(DBUS_DATADIR); +} + +#undef DBUS_DATADIR +#define DBUS_DATADIR _dbus_windows_get_datadir () + + +#define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" +#define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" + +/** + * Returns the standard directories for a session bus to look for service + * activation files + * + * On Windows this should be data directories: + * + * %CommonProgramFiles%/dbus + * + * and + * + * relocated DBUS_DATADIR + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_session_servicedirs (DBusList **dirs) +{ + const char *common_progs; + DBusString servicedir_path; + + if (!_dbus_string_init (&servicedir_path)) + return FALSE; + +#ifdef DBUS_WINCE + { + /* On Windows CE, we adjust datadir dynamically to installation location. */ + const char *data_dir = _dbus_getenv ("DBUS_DATADIR"); + + if (data_dir != NULL) + { + if (!_dbus_string_append (&servicedir_path, data_dir)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) + goto oom; + } + } +#else +/* + the code for accessing services requires absolute base pathes + in case DBUS_DATADIR is relative make it absolute +*/ +#ifdef DBUS_WIN + { + DBusString p; + + _dbus_string_init_const (&p, DBUS_DATADIR); + + if (!_dbus_path_is_absolute (&p)) + { + char install_root[1000]; + if (_dbus_get_install_root (install_root, sizeof(install_root))) + if (!_dbus_string_append (&servicedir_path, install_root)) + goto oom; + } + } +#endif + if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) + goto oom; +#endif + + common_progs = _dbus_getenv ("CommonProgramFiles"); + + if (common_progs != NULL) + { + if (!_dbus_string_append (&servicedir_path, common_progs)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) + goto oom; + } + + if (!_dbus_split_paths_and_append (&servicedir_path, + DBUS_STANDARD_SESSION_SERVICEDIR, + dirs)) + goto oom; + + _dbus_string_free (&servicedir_path); + return TRUE; + + oom: + _dbus_string_free (&servicedir_path); + return FALSE; +} + +/** + * Returns the standard directories for a system bus to look for service + * activation files + * + * On UNIX this should be the standard xdg freedesktop.org data directories: + * + * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} + * + * and + * + * DBUS_DATADIR + * + * On Windows there is no system bus and this function can return nothing. + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_system_servicedirs (DBusList **dirs) +{ + *dirs = NULL; + return TRUE; +} + +/** + * Append the absolute path of the system.conf file + * (there is no system bus on Windows so this can just + * return FALSE and print a warning or something) + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_system_config_file (DBusString *str) +{ + return _dbus_get_config_file_name(str, "system.conf"); +} + +/** + * Append the absolute path of the session.conf file. + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_session_config_file (DBusString *str) +{ + return _dbus_get_config_file_name(str, "session.conf"); +} diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 68bd3a11..a77e5b58 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2347,50 +2347,6 @@ _dbus_delete_file (const DBusString *filename, return TRUE; } -/* - * replaces the term DBUS_PREFIX in configure_time_path by the - * current dbus installation directory. On unix this function is a noop - * - * @param configure_time_path - * @return real path - */ -const char * -_dbus_replace_install_prefix (const char *configure_time_path) -{ -#ifndef DBUS_PREFIX - return configure_time_path; -#else - static char retval[1000]; - static char runtime_prefix[1000]; - int len = 1000; - int i; - - if (!configure_time_path) - return NULL; - - if ((!_dbus_get_install_root(runtime_prefix, len) || - strncmp (configure_time_path, DBUS_PREFIX "/", - strlen (DBUS_PREFIX) + 1))) { - strcat (retval, configure_time_path); - return retval; - } - - strcpy (retval, runtime_prefix); - strcat (retval, configure_time_path + strlen (DBUS_PREFIX) + 1); - - /* Somehow, in some situations, backslashes get collapsed in the string. - * Since windows C library accepts both forward and backslashes as - * path separators, convert all backslashes to forward slashes. - */ - - for(i = 0; retval[i] != '\0'; i++) { - if(retval[i] == '\\') - retval[i] = '/'; - } - return retval; -#endif -} - #if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_ENABLE_EMBEDDED_TESTS) #if defined(_MSC_VER) || defined(DBUS_WINCE) @@ -3229,140 +3185,6 @@ _dbus_make_file_world_readable(const DBusString *filename, return TRUE; } -/** - * return the relocated DATADIR - * - * @returns relocated DATADIR static string - */ - -static const char * -_dbus_windows_get_datadir (void) -{ - return _dbus_replace_install_prefix(DBUS_DATADIR); -} - -#undef DBUS_DATADIR -#define DBUS_DATADIR _dbus_windows_get_datadir () - - -#define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" -#define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" - -/** - * Returns the standard directories for a session bus to look for service - * activation files - * - * On Windows this should be data directories: - * - * %CommonProgramFiles%/dbus - * - * and - * - * relocated DBUS_DATADIR - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_session_servicedirs (DBusList **dirs) -{ - const char *common_progs; - DBusString servicedir_path; - - if (!_dbus_string_init (&servicedir_path)) - return FALSE; - -#ifdef DBUS_WINCE - { - /* On Windows CE, we adjust datadir dynamically to installation location. */ - const char *data_dir = _dbus_getenv ("DBUS_DATADIR"); - - if (data_dir != NULL) - { - if (!_dbus_string_append (&servicedir_path, data_dir)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) - goto oom; - } - } -#else -/* - the code for accessing services requires absolute base pathes - in case DBUS_DATADIR is relative make it absolute -*/ -#ifdef DBUS_WIN - { - DBusString p; - - _dbus_string_init_const (&p, DBUS_DATADIR); - - if (!_dbus_path_is_absolute (&p)) - { - char install_root[1000]; - if (_dbus_get_install_root (install_root, sizeof(install_root))) - if (!_dbus_string_append (&servicedir_path, install_root)) - goto oom; - } - } -#endif - if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) - goto oom; -#endif - - common_progs = _dbus_getenv ("CommonProgramFiles"); - - if (common_progs != NULL) - { - if (!_dbus_string_append (&servicedir_path, common_progs)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) - goto oom; - } - - if (!_dbus_split_paths_and_append (&servicedir_path, - DBUS_STANDARD_SESSION_SERVICEDIR, - dirs)) - goto oom; - - _dbus_string_free (&servicedir_path); - return TRUE; - - oom: - _dbus_string_free (&servicedir_path); - return FALSE; -} - -/** - * Returns the standard directories for a system bus to look for service - * activation files - * - * On UNIX this should be the standard xdg freedesktop.org data directories: - * - * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} - * - * and - * - * DBUS_DATADIR - * - * On Windows there is no system bus and this function can return nothing. - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_system_servicedirs (DBusList **dirs) -{ - *dirs = NULL; - return TRUE; -} - /** * Atomically increments an integer * @@ -3550,32 +3372,6 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) return TRUE; } -/** - * Append the absolute path of the system.conf file - * (there is no system bus on Windows so this can just - * return FALSE and print a warning or something) - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_system_config_file (DBusString *str) -{ - return _dbus_get_config_file_name(str, "system.conf"); -} - -/** - * Append the absolute path of the session.conf file. - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_session_config_file (DBusString *str) -{ - return _dbus_get_config_file_name(str, "session.conf"); -} - /* See comment in dbus-sysdeps-unix.c */ dbus_bool_t _dbus_lookup_session_address (dbus_bool_t *supported, -- cgit v1.2.1 From b119fc4a142c467c6ca3f075596b03f6a00f957d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 30 Aug 2013 16:23:22 +0100 Subject: Fix unused function when SELinux is not enabled It must be one of the "only smcv tests this" configurations... --- bus/selinux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bus/selinux.c b/bus/selinux.c index 57c94326..c36c94ec 100644 --- a/bus/selinux.c +++ b/bus/selinux.c @@ -959,10 +959,11 @@ bus_selinux_id_table_print (DBusHashTable *service_table) /** * Print out some AVC statistics. */ +#ifdef HAVE_SELINUX static void bus_avc_print_stats (void) { -#if defined (DBUS_ENABLE_VERBOSE_MODE) && defined (HAVE_SELINUX) +#ifdef DBUS_ENABLE_VERBOSE_MODE struct avc_cache_stats cstats; if (!selinux_enabled) @@ -980,9 +981,9 @@ bus_avc_print_stats (void) _dbus_verbose ("CAV hits: %d\n", cstats.cav_hits); _dbus_verbose ("CAV probes: %d\n", cstats.cav_probes); _dbus_verbose ("CAV misses: %d\n", cstats.cav_misses); -#endif /* DBUS_ENABLE_VERBOSE_MODE && HAVE_SELINUX */ +#endif /* DBUS_ENABLE_VERBOSE_MODE */ } - +#endif /* HAVE_SELINUX */ /** * Destroy the AVC before we terminate. -- cgit v1.2.1 From 21a60c993b3fc25842fd6c2e840eb7ff5cd306b9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Sep 2013 17:31:56 +0100 Subject: Fix declaration of _dbus_win_startup_winsock This regressed in commit b7a91bfd. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68610 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-win.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 7cb1b6ff..90d14de0 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -42,7 +42,7 @@ extern void *_dbus_win_get_dll_hmodule (void); void _dbus_win_set_errno (int err); const char* _dbus_win_error_from_last_error (void); -void _dbus_win_startup_winsock (void); +dbus_bool_t _dbus_win_startup_winsock (void); void _dbus_win_warn_win_error (const char *message, unsigned long code); -- cgit v1.2.1 From 732021af1b6abaa999c2562b67d22665389cfdd9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 11:49:00 +0100 Subject: Allow dbus-daemon --nofork on Windows On Windows, the dbus-daemon is not able to fork (daemonize). If someone explicitly requests forking, it should fail, but if someone explicitly requests *not* forking, there seems no harm in allowing it. A few of the regression tests specifically require a dbus-daemon that will not fork, so allowing this option on Windows means those tests don't need an extra OS condition. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- bus/main.c | 4 ++-- doc/dbus-daemon.1.xml.in | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bus/main.c b/bus/main.c index 53a77e25..472458ed 100644 --- a/bus/main.c +++ b/bus/main.c @@ -138,9 +138,9 @@ usage (void) " [--introspect]" " [--address=ADDRESS]" " [--nopidfile]" + " [--nofork]" #ifdef DBUS_UNIX " [--fork]" - " [--nofork]" " [--systemd-activation]" #endif "\n"); @@ -412,12 +412,12 @@ main (int argc, char **argv) { introspect (); } -#ifdef DBUS_UNIX else if (strcmp (arg, "--nofork") == 0) { flags &= ~BUS_CONTEXT_FLAG_FORK_ALWAYS; flags |= BUS_CONTEXT_FLAG_FORK_NEVER; } +#ifdef DBUS_UNIX else if (strcmp (arg, "--fork") == 0) { flags &= ~BUS_CONTEXT_FLAG_FORK_NEVER; diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index aea25144..023bebae 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -89,10 +89,16 @@ with SIGHUP. Force the message bus to fork and become a daemon, even if the configuration file does not specify that it should. In most contexts the configuration file already gets this -right, though. - -Force the message bus not to fork and become a daemon, even if -the configuration file specifies that it should. +right, though. This option is not supported on Windows. + + + + + + Force the message bus not to fork and become a daemon, even if + the configuration file specifies that it should. On Windows, + the dbus-daemon never forks, so this option is allowed but does + nothing. -- cgit v1.2.1 From cae26e9facc32d90dcb2eecb89c7075e4fe8eb2b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 29 Aug 2013 11:51:45 +0100 Subject: _dbus_become_daemon: don't pretend it worked This function is meaningless (and possibly unimplementable) on Windows. We shouldn't call it; if we do, it should raise an error. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- dbus/dbus-sysdeps-util-win.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index fe4b1a22..4678b11e 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -65,7 +65,9 @@ _dbus_become_daemon (const DBusString *pidfile, DBusError *error, dbus_bool_t keep_umask) { - return TRUE; + dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED, + "Cannot daemonize on Windows"); + return FALSE; } /** -- cgit v1.2.1 From ce334cb0d6e141bc480f9d52741766018c2d16f7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Sep 2013 17:14:38 +0100 Subject: corrupt test: close connection before releasing GSocket GSocket takes responsibility for closing the fd, and there doesn't seem to be any way to tell it not to. When this test is adapted to run under DBusLoop as an alternative to dbus-glib, that becomes a problem, because DBusLoop/DBusSocketSetEpoll do not tolerate that. Work around it. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- test/corrupt.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/corrupt.c b/test/corrupt.c index 02495901..be0e0222 100644 --- a/test/corrupt.c +++ b/test/corrupt.c @@ -246,6 +246,16 @@ test_corrupt (Fixture *f, "/org/freedesktop/DBus/Local"); dbus_message_unref (incoming); + + /* Free the DBusConnection before the GSocket, because GSocket is + * going to close our fd. GSocket tolerates closing an already-closed + * fd, whereas DBusLoop + DBusSocketSetEpoll doesn't. On Unix + * we could use dup() but that isn't portable to Windows :-( + */ + dbus_connection_close (f->server_conn); + dbus_connection_unref (f->server_conn); + f->server_conn = NULL; + g_object_unref (socket); } @@ -325,6 +335,12 @@ test_byte_order (Fixture *f, "/org/freedesktop/DBus/Local"); dbus_message_unref (message); + + /* Free the DBusConnection before the GSocket, as above. */ + dbus_connection_close (f->server_conn); + dbus_connection_unref (f->server_conn); + f->server_conn = NULL; + g_object_unref (socket); } -- cgit v1.2.1 From f17fd1cc4e8d69f92986b6f452618c6c1b9819dc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 30 Aug 2013 17:45:52 +0100 Subject: Define DBUS_COMPILATION externally for all tests that use internal stuff It might as well go in the AM_CPPFLAGS rather than in the source code. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- cmake/CMakeLists.txt | 2 +- test/Makefile.am | 1 + test/internals/printf.c | 1 - test/internals/refs.c | 1 - test/internals/syslog.c | 1 - test/shell-test.c | 2 +- test/spawn-test.c | 2 -- test/test-utils.h | 4 ---- 8 files changed, 3 insertions(+), 11 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index bde43f03..32edc510 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -478,7 +478,7 @@ set(DBUS_INTERNAL_LIBRARIES dbus-internal) # important note: DBUS_INTERNAL_xxxxx_DEFINITIONS must *not* be set when building dbus-1 library set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC) set (DBUS_INTERNAL_LIBRARY_DEFINITIONS "-DDBUS_STATIC_BUILD") -set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD") +set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD -DDBUS_COMPILATION") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) diff --git a/test/Makefile.am b/test/Makefile.am index 8b2a5255..fe163c64 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -19,6 +19,7 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ static_cppflags = \ $(AM_CPPFLAGS) \ -DDBUS_STATIC_BUILD \ + -DDBUS_COMPILATION \ $(NULL) libdbus_testutils_la_CPPFLAGS = \ diff --git a/test/internals/printf.c b/test/internals/printf.c index 2d2fff8d..db151518 100644 --- a/test/internals/printf.c +++ b/test/internals/printf.c @@ -26,7 +26,6 @@ #include -#define DBUS_COMPILATION /* this test uses libdbus-internal */ #include #include #include diff --git a/test/internals/refs.c b/test/internals/refs.c index db43a4da..202dc043 100644 --- a/test/internals/refs.c +++ b/test/internals/refs.c @@ -29,7 +29,6 @@ #include #include -#define DBUS_COMPILATION /* this test uses libdbus-internal */ #include #include #include diff --git a/test/internals/syslog.c b/test/internals/syslog.c index 658281cb..2811b757 100644 --- a/test/internals/syslog.c +++ b/test/internals/syslog.c @@ -30,7 +30,6 @@ #include -#define DBUS_COMPILATION /* this test uses libdbus-internal */ #include #include diff --git a/test/shell-test.c b/test/shell-test.c index b479a9c6..d1dc5b5b 100644 --- a/test/shell-test.c +++ b/test/shell-test.c @@ -1,7 +1,7 @@ #include #include #include -#define DBUS_COMPILATION + #include #include #include diff --git a/test/spawn-test.c b/test/spawn-test.c index f1a55051..e6513fa6 100644 --- a/test/spawn-test.c +++ b/test/spawn-test.c @@ -1,10 +1,8 @@ #include #include -#define DBUS_COMPILATION /* cheat and use dbus-sysdeps */ #include #include -#undef DBUS_COMPILATION #include static void diff --git a/test/test-utils.h b/test/test-utils.h index 3e1e55e6..8d5357e1 100644 --- a/test/test-utils.h +++ b/test/test-utils.h @@ -1,14 +1,10 @@ #ifndef TEST_UTILS_H #define TEST_UTILS_H -#ifndef DBUS_COMPILATION -#define DBUS_COMPILATION /* Cheat and use private stuff */ -#endif #include #include #include #include #include -#undef DBUS_COMPILATION dbus_bool_t test_connection_setup (DBusLoop *loop, DBusConnection *connection); -- cgit v1.2.1 From 30e7a81302a60adc4ec497deee3c0dfe8ec1123e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Sep 2013 16:32:31 +0100 Subject: Tests: allow dbus-glib to be replaced with use of libdbus-internal We only use dbus-glib for its main loop; within dbus, DBusLoop is available as an alternative, although it isn't thread-safe and isn't public API. For tests that otherwise only use libdbus public API, it's desirable to be able to avoid DBusLoop, so we can run them against an installed libdbus as an integration test. However, if we don't have dbus-glib, we're going to have to use an in-tree main loop, which might as well be DBusLoop. The major disadvantage of using dbus-glib is that it isn't safe to link both dbus-1 and dbus-internal at the same time. This is awkward for a future test case that wants to use _dbus_getsid() in dbus-daemon.c, but only on Windows (fd.o #54445). If we use the same API wrapper around both dbus-glib and DBusLoop, we can compile that test against dbus-glib or against DBusLoop, depending on the platform. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- cmake/CMakeLists.txt | 4 +- cmake/test/name-test/CMakeLists.txt | 2 +- configure.ac | 31 +++++++++---- test/Makefile.am | 84 ++++++++++++++++++++++----------- test/corrupt.c | 21 +++++---- test/dbus-daemon-eavesdrop.c | 27 +++++++---- test/dbus-daemon.c | 21 ++++++--- test/loopback.c | 23 +++++---- test/manual-authz.c | 30 ++++++------ test/marshal.c | 1 - test/name-test/Makefile.am | 9 ++-- test/relay.c | 25 ++++++---- test/test-utils.c | 93 +++++++++++++++++++++++++++++++++---- test/test-utils.h | 35 ++++++++++---- 14 files changed, 287 insertions(+), 119 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 32edc510..fe111966 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -478,7 +478,9 @@ set(DBUS_INTERNAL_LIBRARIES dbus-internal) # important note: DBUS_INTERNAL_xxxxx_DEFINITIONS must *not* be set when building dbus-1 library set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC) set (DBUS_INTERNAL_LIBRARY_DEFINITIONS "-DDBUS_STATIC_BUILD") -set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD -DDBUS_COMPILATION") +# For now, the CMake build system doesn't support replacing the internal +# main loop with dbus-glib +set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD -DDBUS_COMPILATION -DDBUS_TEST_USE_INTERNAL") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index 44e4f6d1..bf096ba7 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -2,7 +2,7 @@ if (DBUS_ENABLE_EMBEDDED_TESTS) set (NAMEtest-DIR ../../../test/name-test) -add_definitions(-DDBUS_COMPILATION) +add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS}) add_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c) target_link_libraries(test-pending-call-dispatch ${DBUS_INTERNAL_LIBRARIES}) diff --git a/configure.ac b/configure.ac index 8caea402..ab7b1e17 100644 --- a/configure.ac +++ b/configure.ac @@ -210,7 +210,8 @@ AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevent post-2.32 AP with_glib=yes -if test "x$enable_modular_tests" != xno; then +AS_IF([test "x$enable_modular_tests" != xno], + [ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.24, gio-2.0 >= 2.24], [], [if test "x$enable_modular_tests" = xyes; then @@ -219,16 +220,25 @@ if test "x$enable_modular_tests" != xno; then else # assumed to be "auto" with_glib=no fi]) - # If dbus-gmain.[ch] returned to libdbus then we wouldn't need this - PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1], + ], + [with_glib=no]) + +# Not required, because we can use internal APIs (but that makes the +# "installable tests" less useful as integration tests) +AC_ARG_WITH([dbus_glib], + [AS_HELP_STRING([--with-dbus-glib], [Use dbus-glib for regression tests])], + [], + [with_dbus_glib=auto]) +AS_IF([test "x$with_dbus_glib" != xno], + [PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1], [], - [if test "x$enable_modular_tests" = xyes; then - 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" - with_glib=no - fi]) -fi + [AS_IF([test "x$with_dbus_glib" = xyes], + dnl specifically requested, but not found + [AC_MSG_ERROR([$DBUS_GLIB_ERRORS])], + dnl else: assumed to be "auto" + [with_dbus_glib=no])])]) +AM_CONDITIONAL([DBUS_WITH_DBUS_GLIB], [test "x$with_dbus_glib" != xno]) + if test "x$enable_modular_tests" != xno; then AC_DEFINE([DBUS_ENABLE_MODULAR_TESTS], [1], [Define to build independent test binaries]) @@ -1839,6 +1849,7 @@ echo " Building embedded tests: ${enable_embedded_tests} Building modular tests: ${enable_modular_tests} - with GLib: ${with_glib} + - with dbus-glib: ${with_dbus_glib} Building verbose mode: ${enable_verbose_mode} Building assertions: ${enable_asserts} Building checks: ${enable_checks} diff --git a/test/Makefile.am b/test/Makefile.am index fe163c64..281b3e2e 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -20,19 +20,40 @@ static_cppflags = \ $(AM_CPPFLAGS) \ -DDBUS_STATIC_BUILD \ -DDBUS_COMPILATION \ + -DDBUS_TEST_USE_INTERNAL \ $(NULL) -libdbus_testutils_la_CPPFLAGS = \ - $(static_cppflags) +noinst_LTLIBRARIES = libdbus-testutils-internal.la + +# You can link either libdbus-testutils, dbus-glib and libdbus-1, +# or libdbus-testutils-internal and libdbus-internal - never both in the +# same binary. +if DBUS_WITH_DBUS_GLIB +noinst_LTLIBRARIES += libdbus-testutils.la libdbus_testutils_la_SOURCES = \ test-utils.c \ test-utils.h \ $(NULL) libdbus_testutils_la_LIBADD = \ - $(top_builddir)/dbus/libdbus-internal.la \ + $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) \ + $(DBUS_GLIB_LIBS) \ $(NULL) +testutils_shared_if_possible = libdbus-testutils.la +else +testutils_shared_if_possible = libdbus-testutils-internal.la +endif -noinst_LTLIBRARIES = libdbus-testutils.la +libdbus_testutils_internal_la_CPPFLAGS = \ + $(static_cppflags) \ + $(NULL) +libdbus_testutils_internal_la_SOURCES = \ + test-utils.c \ + test-utils.h \ + $(NULL) +libdbus_testutils_internal_la_LIBADD = \ + $(top_builddir)/dbus/libdbus-internal.la \ + $(NULL) if DBUS_ENABLE_EMBEDDED_TESTS ## break-loader removed for now @@ -70,15 +91,15 @@ endif !DBUS_ENABLE_EMBEDDED_TESTS noinst_PROGRAMS= $(TEST_BINARIES) test_service_CPPFLAGS = $(static_cppflags) -test_service_LDADD = libdbus-testutils.la +test_service_LDADD = libdbus-testutils-internal.la test_names_CPPFLAGS = $(static_cppflags) -test_names_LDADD = libdbus-testutils.la +test_names_LDADD = libdbus-testutils-internal.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 +test_shell_service_LDADD = libdbus-testutils-internal.la shell_test_CPPFLAGS = $(static_cppflags) -shell_test_LDADD = libdbus-testutils.la +shell_test_LDADD = libdbus-testutils-internal.la spawn_test_CPPFLAGS = $(static_cppflags) spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la @@ -88,11 +109,11 @@ test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_refs_SOURCES = internals/refs.c test_refs_CPPFLAGS = $(static_cppflags) -test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) +test_refs_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS) test_syslog_SOURCES = internals/syslog.c test_syslog_CPPFLAGS = $(static_cppflags) -test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) +test_syslog_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS) EXTRA_DIST = dbus-test-runner @@ -139,45 +160,52 @@ TESTS_ENVIRONMENT = \ $(NULL) manual_authz_SOURCES = manual-authz.c -manual_authz_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +manual_authz_LDADD = \ + $(testutils_shared_if_possible) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_corrupt_SOURCES = corrupt.c -test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_corrupt_LDADD = \ + $(testutils_shared_if_possible) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_loopback_SOURCES = loopback.c -test_loopback_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_loopback_LDADD = \ + $(testutils_shared_if_possible) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_relay_SOURCES = relay.c -test_relay_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_relay_LDADD = \ + $(testutils_shared_if_possible) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_dbus_daemon_SOURCES = dbus-daemon.c -test_dbus_daemon_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_dbus_daemon_LDADD = \ + $(testutils_shared_if_possible) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) 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 \ +test_dbus_daemon_eavesdrop_LDADD = \ + $(testutils_shared_if_possible) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_marshal_SOURCES = marshal.c -test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_marshal_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_syntax_SOURCES = syntax.c -test_syntax_LDADD = $(top_builddir)/dbus/libdbus-1.la \ - $(GLIB_LIBS) +test_syntax_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) \ + $(NULL) if DBUS_ENABLE_MODULAR_TESTS TESTS += $(installable_tests) diff --git a/test/corrupt.c b/test/corrupt.c index be0e0222..1a7d4460 100644 --- a/test/corrupt.c +++ b/test/corrupt.c @@ -30,10 +30,12 @@ #include #include -#include + +#include "test-utils.h" typedef struct { DBusError e; + TestMainContext *ctx; DBusServer *server; DBusConnection *server_conn; @@ -72,13 +74,14 @@ new_conn_cb (DBusServer *server, g_assert (f->server_conn == NULL); f->server_conn = dbus_connection_ref (server_conn); - dbus_connection_setup_with_g_main (server_conn, NULL); + test_connection_setup (f->ctx, server_conn); } static void setup (Fixture *f, gconstpointer addr) { + f->ctx = test_main_context_get (); dbus_error_init (&f->e); g_queue_init (&f->client_messages); @@ -88,7 +91,7 @@ setup (Fixture *f, dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->server, NULL); + test_server_setup (f->ctx, f->server); } static void @@ -103,12 +106,12 @@ test_connect (Fixture *f, dbus_server_get_address (f->server), &f->e); assert_no_error (&f->e); g_assert (f->client_conn != NULL); - dbus_connection_setup_with_g_main (f->client_conn, NULL); + test_connection_setup (f->ctx, f->client_conn); while (f->server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } have_mem = dbus_connection_add_filter (f->client_conn, @@ -137,7 +140,7 @@ test_message (Fixture *f, while (g_queue_is_empty (&f->client_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->client_messages), ==, 1); @@ -229,7 +232,7 @@ test_corrupt (Fixture *f, while (g_queue_is_empty (&f->client_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } incoming = g_queue_pop_head (&f->client_messages); @@ -318,7 +321,7 @@ test_byte_order (Fixture *f, while (g_queue_is_empty (&f->client_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } message = g_queue_pop_head (&f->client_messages); @@ -368,6 +371,8 @@ teardown (Fixture *f, dbus_server_unref (f->server); f->server = NULL; } + + test_main_context_unref (f->ctx); } int diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c index 0bd923d2..2c45f54e 100644 --- a/test/dbus-daemon-eavesdrop.c +++ b/test/dbus-daemon-eavesdrop.c @@ -30,7 +30,6 @@ #include #include -#include #include @@ -42,6 +41,8 @@ # include #endif +#include "test-utils.h" + #define SENDER_NAME "test.eavesdrop.sender" #define SENDER_PATH "/test/eavesdrop/sender" #define SENDER_IFACE SENDER_NAME @@ -71,6 +72,7 @@ typedef enum { } SignalDst; typedef struct { + TestMainContext *ctx; DBusError e; GError *ge; @@ -160,7 +162,8 @@ spawn_dbus_daemon (gchar *binary, } static DBusConnection * -connect_to_bus (const gchar *address) +connect_to_bus (Fixture *f, + const gchar *address) { DBusConnection *conn; DBusError error = DBUS_ERROR_INIT; @@ -175,7 +178,7 @@ connect_to_bus (const gchar *address) g_assert (ok); g_assert (dbus_bus_get_unique_name (conn) != NULL); - dbus_connection_setup_with_g_main (conn, NULL); + test_connection_setup (f->ctx, conn); return conn; } @@ -380,6 +383,8 @@ setup (Fixture *f, gchar *config; gchar *address; + f->ctx = test_main_context_get (); + f->ge = NULL; dbus_error_init (&f->e); @@ -409,12 +414,12 @@ setup (Fixture *f, g_free (dbus_daemon); g_free (config); - f->sender = connect_to_bus (address); + f->sender = connect_to_bus (f, address); dbus_bus_request_name (f->sender, SENDER_NAME, DBUS_NAME_FLAG_DO_NOT_QUEUE, &(f->e)); - f->receiver = connect_to_bus (address); - f->eavesdropper = connect_to_bus (address); - f->politelistener = connect_to_bus (address); + f->receiver = connect_to_bus (f, address); + f->eavesdropper = connect_to_bus (f, address); + f->politelistener = connect_to_bus (f, address); add_receiver_filter (f); add_politelistener_filter (f); add_eavesdropper_filter (f); @@ -432,7 +437,7 @@ test_eavesdrop_broadcast (Fixture *f, while (!f->receiver_got_stopper || !f->politelistener_got_stopper || !f->eavesdropper_got_stopper) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); /* all the three connection can receive a broadcast */ g_assert_cmpint (f->receiver_dst, ==, BROADCAST); @@ -452,7 +457,7 @@ test_eavesdrop_unicast_to_sender (Fixture *f, while (!f->receiver_got_stopper || !f->politelistener_got_stopper || !f->eavesdropper_got_stopper) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); /* not directed to it and not broadcasted, they cannot receive it */ g_assert_cmpint (f->receiver_dst, ==, NONE_YET); @@ -472,7 +477,7 @@ test_eavesdrop_unicast_to_receiver (Fixture *f, while (!f->receiver_got_stopper || !f->politelistener_got_stopper || !f->eavesdropper_got_stopper) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); /* direct to him */ g_assert_cmpint (f->receiver_dst, ==, TO_ME); @@ -534,6 +539,8 @@ teardown (Fixture *f, #endif g_spawn_close_pid (f->daemon_pid); + + test_main_context_unref (f->ctx); } int diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 69b6791e..22ea23e3 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -29,7 +29,6 @@ #include #include -#include #include @@ -42,9 +41,13 @@ # include #endif +#include "test-utils.h" + typedef struct { gboolean skip; + TestMainContext *ctx; + DBusError e; GError *ge; @@ -127,7 +130,8 @@ spawn_dbus_daemon (gchar *binary, } static DBusConnection * -connect_to_bus (const gchar *address) +connect_to_bus (Fixture *f, + const gchar *address) { DBusConnection *conn; DBusError error = DBUS_ERROR_INIT; @@ -142,7 +146,7 @@ connect_to_bus (const gchar *address) g_assert (ok); g_assert (dbus_bus_get_unique_name (conn) != NULL); - dbus_connection_setup_with_g_main (conn, NULL); + test_connection_setup (f->ctx, conn); return conn; } @@ -184,6 +188,7 @@ setup (Fixture *f, gchar *arg; gchar *address; + f->ctx = test_main_context_get (); f->ge = NULL; dbus_error_init (&f->e); @@ -227,8 +232,8 @@ setup (Fixture *f, g_free (dbus_daemon); g_free (arg); - f->left_conn = connect_to_bus (address); - f->right_conn = connect_to_bus (address); + f->left_conn = connect_to_bus (f, address); + f->right_conn = connect_to_bus (f, address); g_free (address); } @@ -302,7 +307,7 @@ test_echo (Fixture *f, } while (received < count) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); elapsed = g_test_timer_elapsed (); @@ -361,7 +366,7 @@ test_creds (Fixture *f, g_error ("OOM"); while (m == NULL) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); g_assert_cmpstr (dbus_message_get_signature (m), ==, "a{sv}"); @@ -473,6 +478,8 @@ teardown (Fixture *f, g_spawn_close_pid (f->daemon_pid); f->daemon_pid = 0; } + + test_main_context_unref (f->ctx); } static Config limited_config = { diff --git a/test/loopback.c b/test/loopback.c index 39cf03ab..7526d8d2 100644 --- a/test/loopback.c +++ b/test/loopback.c @@ -29,11 +29,13 @@ #include #include -#include #include +#include "test-utils.h" + typedef struct { + TestMainContext *ctx; DBusError e; DBusServer *server; @@ -74,7 +76,7 @@ new_conn_cb (DBusServer *server, g_assert (f->server_conn == NULL); f->server_conn = dbus_connection_ref (server_conn); - dbus_connection_setup_with_g_main (server_conn, NULL); + test_connection_setup (f->ctx, server_conn); have_mem = dbus_connection_add_filter (server_conn, server_message_cb, f, NULL); @@ -85,6 +87,7 @@ static void setup (Fixture *f, gconstpointer addr) { + f->ctx = test_main_context_get (); dbus_error_init (&f->e); g_queue_init (&f->server_messages); @@ -94,7 +97,7 @@ setup (Fixture *f, dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->server, NULL); + test_server_setup (f->ctx, f->server); } static void @@ -107,12 +110,12 @@ test_connect (Fixture *f, dbus_server_get_address (f->server), &f->e); assert_no_error (&f->e); g_assert (f->client_conn != NULL); - dbus_connection_setup_with_g_main (f->client_conn, NULL); + test_connection_setup (f->ctx, f->client_conn); while (f->server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } } @@ -141,12 +144,12 @@ test_bad_guid (Fixture *f, f->client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->client_conn != NULL); - dbus_connection_setup_with_g_main (f->client_conn, NULL); + test_connection_setup (f->ctx, f->client_conn); while (f->server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } /* We get disconnected */ @@ -154,7 +157,7 @@ test_bad_guid (Fixture *f, while (g_queue_is_empty (&f->server_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->server_messages), ==, 1); @@ -197,7 +200,7 @@ test_message (Fixture *f, while (g_queue_is_empty (&f->server_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->server_messages), ==, 1); @@ -244,6 +247,8 @@ teardown (Fixture *f, dbus_server_unref (f->server); f->server = NULL; } + + test_main_context_unref (f->ctx); } int diff --git a/test/manual-authz.c b/test/manual-authz.c index d228829b..f9e3688e 100644 --- a/test/manual-authz.c +++ b/test/manual-authz.c @@ -29,15 +29,17 @@ #include #include -#include #ifdef G_OS_UNIX #include #include #endif +#include "test-utils.h" + typedef struct { DBusError e; + TestMainContext *ctx; DBusServer *normal_server; DBusServer *anon_allowed_server; @@ -212,7 +214,7 @@ new_conn_cb (DBusServer *server, Fixture *f = data; dbus_connection_ref (conn); - dbus_connection_setup_with_g_main (conn, NULL); + test_connection_setup (f->ctx, conn); if (!dbus_connection_add_filter (conn, server_message_cb, f, NULL)) oom (); @@ -301,7 +303,7 @@ setup (Fixture *f, g_assert (f->normal_server != NULL); dbus_server_set_new_connection_function (f->normal_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->normal_server, NULL); + test_server_setup (f->ctx, f->normal_server); connect_addr = dbus_server_get_address (f->normal_server); g_message ("Normal server:\n%s", connect_addr); dbus_free (connect_addr); @@ -311,7 +313,7 @@ setup (Fixture *f, g_assert (f->anon_allowed_server != NULL); dbus_server_set_new_connection_function (f->anon_allowed_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->anon_allowed_server, NULL); + test_server_setup (f->ctx, f->anon_allowed_server); connect_addr = dbus_server_get_address (f->anon_allowed_server); g_message ("Anonymous-allowed server:\n%s", connect_addr); dbus_free (connect_addr); @@ -321,7 +323,7 @@ setup (Fixture *f, g_assert (f->anon_only_server != NULL); dbus_server_set_new_connection_function (f->anon_only_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->anon_only_server, NULL); + test_server_setup (f->ctx, f->anon_only_server); connect_addr = dbus_server_get_address (f->anon_only_server); g_message ("Anonymous-only server:\n%s", connect_addr); dbus_free (connect_addr); @@ -332,7 +334,7 @@ setup (Fixture *f, dbus_server_set_auth_mechanisms (f->anon_mech_only_server, only_anon); dbus_server_set_new_connection_function (f->anon_mech_only_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->anon_mech_only_server, NULL); + test_server_setup (f->ctx, f->anon_mech_only_server); connect_addr = dbus_server_get_address (f->anon_mech_only_server); g_message ("Anon mech only server:\n%s", connect_addr); dbus_free (connect_addr); @@ -343,7 +345,7 @@ setup (Fixture *f, dbus_server_set_auth_mechanisms (f->anon_disallowed_server, only_anon); dbus_server_set_new_connection_function (f->anon_disallowed_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->anon_disallowed_server, NULL); + test_server_setup (f->ctx, f->anon_disallowed_server); connect_addr = dbus_server_get_address (f->anon_disallowed_server); g_message ("Anonymous-disallowed server:\n%s", connect_addr); dbus_free (connect_addr); @@ -353,7 +355,7 @@ setup (Fixture *f, g_assert (f->permissive_server != NULL); dbus_server_set_new_connection_function (f->permissive_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->permissive_server, NULL); + test_server_setup (f->ctx, f->permissive_server); connect_addr = dbus_server_get_address (f->permissive_server); g_message ("Permissive server:\n%s", connect_addr); dbus_free (connect_addr); @@ -363,7 +365,7 @@ setup (Fixture *f, g_assert (f->unhappy_server != NULL); dbus_server_set_new_connection_function (f->unhappy_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->unhappy_server, NULL); + test_server_setup (f->ctx, f->unhappy_server); connect_addr = dbus_server_get_address (f->unhappy_server); g_message ("Unhappy server:\n%s", connect_addr); dbus_free (connect_addr); @@ -373,7 +375,7 @@ setup (Fixture *f, g_assert (f->same_uid_server != NULL); dbus_server_set_new_connection_function (f->same_uid_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->same_uid_server, NULL); + test_server_setup (f->ctx, f->same_uid_server); connect_addr = dbus_server_get_address (f->same_uid_server); g_message ("Same-UID server:\n%s", connect_addr); dbus_free (connect_addr); @@ -383,7 +385,7 @@ setup (Fixture *f, g_assert (f->same_uid_or_anon_server != NULL); dbus_server_set_new_connection_function (f->same_uid_or_anon_server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->same_uid_or_anon_server, NULL); + test_server_setup (f->ctx, f->same_uid_or_anon_server); connect_addr = dbus_server_get_address (f->same_uid_or_anon_server); g_message ("Same-UID-or-anon server:\n%s", connect_addr); dbus_free (connect_addr); @@ -393,7 +395,7 @@ int main (int argc, char **argv) { - Fixture f = { DBUS_ERROR_INIT }; + Fixture f = { DBUS_ERROR_INIT, test_main_context_get () }; if (argc >= 2) setup (&f, argv[1]); @@ -401,5 +403,7 @@ main (int argc, setup (&f, "tcp:host=127.0.0.1"); for (;;) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f.ctx, TRUE); + + /* never returns */ } diff --git a/test/marshal.c b/test/marshal.c index e65ee7c1..d74e7671 100644 --- a/test/marshal.c +++ b/test/marshal.c @@ -30,7 +30,6 @@ #include #include -#include typedef struct { DBusError e; diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 424dad3a..54b02af0 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -3,6 +3,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -DDBUS_COMPILATION \ -DDBUS_STATIC_BUILD \ + -DDBUS_TEST_USE_INTERNAL \ $(NULL) # if assertions are enabled, improve backtraces @@ -31,9 +32,9 @@ 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_shutdown_LDADD=../libdbus-testutils.la -test_privserver_LDADD=../libdbus-testutils.la -test_privserver_client_LDADD=../libdbus-testutils.la -test_autolaunch_LDADD=../libdbus-testutils.la +test_shutdown_LDADD=../libdbus-testutils-internal.la +test_privserver_LDADD=../libdbus-testutils-internal.la +test_privserver_client_LDADD=../libdbus-testutils-internal.la +test_autolaunch_LDADD=../libdbus-testutils-internal.la endif diff --git a/test/relay.c b/test/relay.c index f4129d0a..ecfe4c82 100644 --- a/test/relay.c +++ b/test/relay.c @@ -29,7 +29,8 @@ #include #include -#include + +#include "test-utils.h" /* This is basically a miniature dbus-daemon. We relay messages from the client * on the left to the client on the right. @@ -43,6 +44,7 @@ */ typedef struct { + TestMainContext *ctx; DBusError e; DBusServer *server; @@ -113,13 +115,14 @@ new_conn_cb (DBusServer *server, f->right_server_conn = dbus_connection_ref (server_conn); } - dbus_connection_setup_with_g_main (server_conn, NULL); + test_connection_setup (f->ctx, server_conn); } static void setup (Fixture *f, gconstpointer data G_GNUC_UNUSED) { + f->ctx = test_main_context_get (); dbus_error_init (&f->e); g_queue_init (&f->messages); @@ -129,7 +132,7 @@ setup (Fixture *f, dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->server, NULL); + test_server_setup (f->ctx, f->server); } static void @@ -148,25 +151,25 @@ test_connect (Fixture *f, f->left_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->left_client_conn != NULL); - dbus_connection_setup_with_g_main (f->left_client_conn, NULL); + test_connection_setup (f->ctx, f->left_client_conn); while (f->left_server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } f->right_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->right_client_conn != NULL); - dbus_connection_setup_with_g_main (f->right_client_conn, NULL); + test_connection_setup (f->ctx, f->right_client_conn); dbus_free (address); while (f->right_server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } have_mem = dbus_connection_add_filter (f->right_client_conn, @@ -208,7 +211,7 @@ test_relay (Fixture *f, while (g_queue_get_length (&f->messages) < 2) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->messages), ==, 2); @@ -237,7 +240,7 @@ test_limit (Fixture *f, /* This was an attempt to reproduce fd.o #34393. It didn't work. */ g_test_bug ("34393"); dbus_connection_set_max_received_size (f->left_server_conn, 1); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); for (i = 0; i < MANY; i++) { @@ -253,7 +256,7 @@ test_limit (Fixture *f, { while (g_queue_is_empty (&f->messages)) { - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } while ((incoming = g_queue_pop_head (&f->messages)) != NULL) @@ -302,6 +305,8 @@ teardown (Fixture *f, dbus_server_unref (f->server); f->server = NULL; } + + test_main_context_unref (f->ctx); } int diff --git a/test/test-utils.c b/test/test-utils.c index c3c3ed34..9a4f3584 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -1,6 +1,13 @@ #include #include "test-utils.h" +#ifndef DBUS_TEST_USE_INTERNAL +# include +# include +#endif + +#ifdef DBUS_TEST_USE_INTERNAL + typedef struct { DBusLoop *loop; @@ -97,10 +104,14 @@ cdata_new (DBusLoop *loop, return cd; } +#endif /* DBUS_TEST_USE_INTERNAL */ + dbus_bool_t -test_connection_setup (DBusLoop *loop, +test_connection_setup (TestMainContext *ctx, DBusConnection *connection) { +#ifdef DBUS_TEST_USE_INTERNAL + DBusLoop *loop = ctx; CData *cd; cd = NULL; @@ -148,10 +159,23 @@ test_connection_setup (DBusLoop *loop, dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL); return FALSE; +#else /* !DBUS_TEST_USE_INTERNAL */ + + dbus_connection_setup_with_g_main (connection, ctx); + return TRUE; + +#endif /* !DBUS_TEST_USE_INTERNAL */ +} + +static void +die (const char *message) +{ + fprintf (stderr, "*** %s", message); + exit (1); } void -test_connection_shutdown (DBusLoop *loop, +test_connection_shutdown (TestMainContext *ctx, DBusConnection *connection) { if (!dbus_connection_set_watch_functions (connection, @@ -159,18 +183,20 @@ test_connection_shutdown (DBusLoop *loop, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting watch functions to NULL failed"); + die ("setting watch functions to NULL failed"); if (!dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting timeout functions to NULL failed"); + die ("setting timeout functions to NULL failed"); dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); } +#ifdef DBUS_TEST_USE_INTERNAL + typedef struct { DBusLoop *loop; @@ -252,10 +278,14 @@ remove_server_timeout (DBusTimeout *timeout, _dbus_loop_remove_timeout (context->loop, timeout); } +#endif /* DBUS_TEST_USE_INTERNAL */ + dbus_bool_t -test_server_setup (DBusLoop *loop, +test_server_setup (TestMainContext *ctx, DBusServer *server) { +#ifdef DBUS_TEST_USE_INTERNAL + DBusLoop *loop = ctx; ServerData *sd; sd = serverdata_new (loop, server); @@ -293,10 +323,17 @@ test_server_setup (DBusLoop *loop, test_server_shutdown (loop, server); return FALSE; + +#else /* !DBUS_TEST_USE_INTERNAL */ + + dbus_server_setup_with_g_main (server, ctx); + return TRUE; + +#endif /* !DBUS_TEST_USE_INTERNAL */ } void -test_server_shutdown (DBusLoop *loop, +test_server_shutdown (TestMainContext *ctx, DBusServer *server) { dbus_server_disconnect (server); @@ -305,11 +342,51 @@ test_server_shutdown (DBusLoop *loop, NULL, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting watch functions to NULL failed"); + die ("setting watch functions to NULL failed"); if (!dbus_server_set_timeout_functions (server, NULL, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting timeout functions to NULL failed"); + die ("setting timeout functions to NULL failed"); +} + +TestMainContext * +test_main_context_get (void) +{ +#ifdef DBUS_TEST_USE_INTERNAL + return _dbus_loop_new (); +#else + /* I suspect dbus-glib relies the default main context in some places */ + return g_main_context_ref (g_main_context_default ()); +#endif +} + +TestMainContext * +test_main_context_ref (TestMainContext *ctx) +{ +#ifdef DBUS_TEST_USE_INTERNAL + return _dbus_loop_ref (ctx); +#else + return g_main_context_ref (ctx); +#endif +} + +void test_main_context_unref (TestMainContext *ctx) +{ +#ifdef DBUS_TEST_USE_INTERNAL + _dbus_loop_unref (ctx); +#else + g_main_context_unref (ctx); +#endif +} + +void test_main_context_iterate (TestMainContext *ctx, + dbus_bool_t may_block) +{ +#ifdef DBUS_TEST_USE_INTERNAL + _dbus_loop_iterate (ctx, may_block); +#else + g_main_context_iteration (ctx, may_block); +#endif } diff --git a/test/test-utils.h b/test/test-utils.h index 8d5357e1..0d3f3690 100644 --- a/test/test-utils.h +++ b/test/test-utils.h @@ -1,21 +1,38 @@ #ifndef TEST_UTILS_H #define TEST_UTILS_H -#include + #include #include -#include -#include -dbus_bool_t test_connection_setup (DBusLoop *loop, +#include + +#ifdef DBUS_TEST_USE_INTERNAL + +# include +# include + typedef DBusLoop TestMainContext; + +#else /* !DBUS_TEST_USE_INTERNAL */ + +# include + typedef GMainContext TestMainContext; + +#endif /* !DBUS_TEST_USE_INTERNAL */ + +TestMainContext *test_main_context_get (void); +TestMainContext *test_main_context_ref (TestMainContext *ctx); +void test_main_context_unref (TestMainContext *ctx); +void test_main_context_iterate (TestMainContext *ctx, + dbus_bool_t may_block); + +dbus_bool_t test_connection_setup (TestMainContext *ctx, DBusConnection *connection); -void test_connection_shutdown (DBusLoop *loop, +void test_connection_shutdown (TestMainContext *ctx, DBusConnection *connection); -void test_connection_dispatch_all_messages (DBusConnection *connection); -dbus_bool_t test_connection_dispatch_one_message (DBusConnection *connection); -dbus_bool_t test_server_setup (DBusLoop *loop, +dbus_bool_t test_server_setup (TestMainContext *ctx, DBusServer *server); -void test_server_shutdown (DBusLoop *loop, +void test_server_shutdown (TestMainContext *ctx, DBusServer *server); #endif -- cgit v1.2.1 From 9d80d46a794e0770494aa517d1b94e7e6ea9e21d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Sep 2013 12:25:31 +0100 Subject: run-with-tmp-session-bus.sh: create a unique temporary file per process This makes the regression tests OK to run in parallel. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- test/name-test/.gitignore | 2 +- tools/run-with-tmp-session-bus.sh | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/test/name-test/.gitignore b/test/name-test/.gitignore index 09f7ad36..2bf313a5 100644 --- a/test/name-test/.gitignore +++ b/test/name-test/.gitignore @@ -3,7 +3,7 @@ Makefile Makefile.in echo-error-output.tmp -run-with-tmp-session-bus.conf +tmp-session-bus.*.conf test-ids test-names test-pending-call-dispatch diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh index 3245652e..94ae8fc8 100755 --- a/tools/run-with-tmp-session-bus.sh +++ b/tools/run-with-tmp-session-bus.sh @@ -4,9 +4,12 @@ SCRIPTNAME="$0" WRAPPED_SCRIPT="$1" shift +CONFIG_FILE=./tmp-session-bus.$$.conf + die () { echo "$SCRIPTNAME: $*" >&2 + rm -f "$CONFIG_FILE" exit 1 } @@ -14,7 +17,6 @@ if test -z "$DBUS_TOP_BUILDDIR" ; then die "Must set DBUS_TOP_BUILDDIR" fi -CONFIG_FILE=./run-with-tmp-session-bus.conf SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files" ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'` echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2 @@ -48,8 +50,13 @@ unset DBUS_SESSION_BUS_PID DBUS_USE_TEST_BINARY=1 export DBUS_USE_TEST_BINARY -exec $DBUS_TOP_BUILDDIR/tools/dbus-run-session \ +$DBUS_TOP_BUILDDIR/tools/dbus-run-session \ --config-file="$CONFIG_FILE" \ --dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \ -- \ "$WRAPPED_SCRIPT" "$@" +error=$? + +# clean up +rm -f "$CONFIG_FILE" +exit $error -- cgit v1.2.1 From 87df259d8c4aae3d188a15d7976c0f63141119e8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 3 Sep 2013 12:16:32 +0100 Subject: Add CPPFLAGS to "shared if possible" test binaries In principle we ought to define DBUS_STATIC_BUILD in anything that's using libdbus-internal.la (to avoid linking failures on statically-linked mingw builds), and DBUS_TEST_USE_INTERNAL in any test that's using the non-dbus-glib code paths of test-utils.[ch] (to avoid the GLib requirement, although in practice, everything "shared if possible" requires GLib at the moment anyway). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- test/Makefile.am | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/Makefile.am b/test/Makefile.am index 281b3e2e..405aa1c2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -39,9 +39,11 @@ libdbus_testutils_la_LIBADD = \ $(GLIB_LIBS) \ $(DBUS_GLIB_LIBS) \ $(NULL) -testutils_shared_if_possible = libdbus-testutils.la +testutils_shared_if_possible_cppflags = $(AM_CPPFLAGS) +testutils_shared_if_possible_libs = libdbus-testutils.la else -testutils_shared_if_possible = libdbus-testutils-internal.la +testutils_shared_if_possible_cppflags = $(static_cppflags) +testutils_shared_if_possible_libs = libdbus-testutils-internal.la endif libdbus_testutils_internal_la_CPPFLAGS = \ @@ -160,38 +162,44 @@ TESTS_ENVIRONMENT = \ $(NULL) manual_authz_SOURCES = manual-authz.c +manual_authz_CPPFLAGS = $(testutils_shared_if_possible_cppflags) manual_authz_LDADD = \ - $(testutils_shared_if_possible) \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ $(NULL) test_corrupt_SOURCES = corrupt.c +test_corrupt_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_corrupt_LDADD = \ - $(testutils_shared_if_possible) \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ $(NULL) test_loopback_SOURCES = loopback.c +test_loopback_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_loopback_LDADD = \ - $(testutils_shared_if_possible) \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ $(NULL) test_relay_SOURCES = relay.c +test_relay_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_relay_LDADD = \ - $(testutils_shared_if_possible) \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ $(NULL) test_dbus_daemon_SOURCES = dbus-daemon.c +test_dbus_daemon_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_dbus_daemon_LDADD = \ - $(testutils_shared_if_possible) \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ $(NULL) test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c +test_dbus_daemon_eavesdrop_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_dbus_daemon_eavesdrop_LDADD = \ - $(testutils_shared_if_possible) \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ $(NULL) -- cgit v1.2.1 From 3b4a09c04ee859846521e12184e3a11ca737c82d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 22 Aug 2013 18:03:24 +0100 Subject: NEWS for 1.6 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 150a5344..bef985ee 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,9 @@ Fixes: • If malloc() returns NULL in dbus_set_error(), don't va_end() a va_list that was never va_start()ed (fd.o #66300, Chengwei Yang) +• Fix a regression test on platforms with strict alignment (fd.o #67279, + Colin Walters) + D-Bus 1.6.12 (2013-06-13) == -- cgit v1.2.1 From 42e12d342e9a71d90d7caa303d8d0fcc22452546 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Sep 2013 13:05:21 +0100 Subject: run-with-tmp-session-bus.sh: create a unique temporary file per process This makes the regression tests OK to run in parallel. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker (cherry picked from commit 9d80d46a794e0770494aa517d1b94e7e6ea9e21d) --- test/name-test/.gitignore | 2 +- tools/run-with-tmp-session-bus.sh | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/test/name-test/.gitignore b/test/name-test/.gitignore index 09f7ad36..2bf313a5 100644 --- a/test/name-test/.gitignore +++ b/test/name-test/.gitignore @@ -3,7 +3,7 @@ Makefile Makefile.in echo-error-output.tmp -run-with-tmp-session-bus.conf +tmp-session-bus.*.conf test-ids test-names test-pending-call-dispatch diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh index c39999fb..3f5a8fa2 100755 --- a/tools/run-with-tmp-session-bus.sh +++ b/tools/run-with-tmp-session-bus.sh @@ -4,13 +4,16 @@ SCRIPTNAME=$0 WRAPPED_SCRIPT=$1 shift -die() +CONFIG_FILE=./tmp-session-bus.$$.conf + +die () { if ! test -z "$DBUS_SESSION_BUS_PID" ; then echo "killing message bus "$DBUS_SESSION_BUS_PID >&2 kill -9 $DBUS_SESSION_BUS_PID fi - echo $SCRIPTNAME: $* >&2 + echo "$SCRIPTNAME: $*" >&2 + rm -f "$CONFIG_FILE" exit 1 } @@ -21,7 +24,6 @@ fi ## convenient to be able to ctrl+C without leaking the message bus process trap 'die "Received SIGINT"' INT -CONFIG_FILE=./run-with-tmp-session-bus.conf SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files" ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'` echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2 @@ -73,4 +75,5 @@ sleep 2 ## be sure it really died kill -9 $DBUS_SESSION_BUS_PID > /dev/null 2>&1 || true +rm -f "$CONFIG_FILE" exit 0 -- cgit v1.2.1 From 50b64a0c79a35f2c4673152dc2be2280551d18f2 Mon Sep 17 00:00:00 2001 From: Ivan Romanov Date: Thu, 22 Aug 2013 19:11:23 +0100 Subject: Use iface instead of interface in function parameters Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66493 Reviewed-by: Simon McVittie (cherry picked from commit 0928169cf80bf767f7246ecaa52cc01e198bb15a) --- dbus/dbus-message.c | 62 ++++++++++++++++++++++++++--------------------------- dbus/dbus-message.h | 12 +++++------ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 71bcee60..a34ea1d1 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -1246,7 +1246,7 @@ dbus_message_new (int message_type) * * @param destination name that the message should be sent to or #NULL * @param path object path the message should be sent to - * @param interface interface to invoke method on, or #NULL + * @param iface interface to invoke method on, or #NULL * @param method method to invoke * * @returns a new DBusMessage, free with dbus_message_unref() @@ -1254,7 +1254,7 @@ dbus_message_new (int message_type) DBusMessage* dbus_message_new_method_call (const char *destination, const char *path, - const char *interface, + const char *iface, const char *method) { DBusMessage *message; @@ -1264,8 +1264,8 @@ dbus_message_new_method_call (const char *destination, _dbus_return_val_if_fail (destination == NULL || _dbus_check_is_valid_bus_name (destination), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_path (path), NULL); - _dbus_return_val_if_fail (interface == NULL || - _dbus_check_is_valid_interface (interface), NULL); + _dbus_return_val_if_fail (iface == NULL || + _dbus_check_is_valid_interface (iface), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_member (method), NULL); message = dbus_message_new_empty_header (); @@ -1275,7 +1275,7 @@ dbus_message_new_method_call (const char *destination, if (!_dbus_header_create (&message->header, DBUS_COMPILER_BYTE_ORDER, DBUS_MESSAGE_TYPE_METHOD_CALL, - destination, path, interface, method, NULL)) + destination, path, iface, method, NULL)) { dbus_message_unref (message); return NULL; @@ -1338,22 +1338,22 @@ dbus_message_new_method_return (DBusMessage *method_call) * specification defines the syntax of these fields). * * @param path the path to the object emitting the signal - * @param interface the interface the signal is emitted from + * @param iface the interface the signal is emitted from * @param name name of the signal * @returns a new DBusMessage, free with dbus_message_unref() */ DBusMessage* dbus_message_new_signal (const char *path, - const char *interface, + const char *iface, const char *name) { DBusMessage *message; _dbus_return_val_if_fail (path != NULL, NULL); - _dbus_return_val_if_fail (interface != NULL, NULL); + _dbus_return_val_if_fail (iface != NULL, NULL); _dbus_return_val_if_fail (name != NULL, NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_path (path), NULL); - _dbus_return_val_if_fail (_dbus_check_is_valid_interface (interface), NULL); + _dbus_return_val_if_fail (_dbus_check_is_valid_interface (iface), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_member (name), NULL); message = dbus_message_new_empty_header (); @@ -1363,7 +1363,7 @@ dbus_message_new_signal (const char *path, if (!_dbus_header_create (&message->header, DBUS_COMPILER_BYTE_ORDER, DBUS_MESSAGE_TYPE_SIGNAL, - NULL, path, interface, name, NULL)) + NULL, path, iface, name, NULL)) { dbus_message_unref (message); return NULL; @@ -3113,23 +3113,23 @@ dbus_message_get_path_decomposed (DBusMessage *message, * in the D-Bus specification. * * @param message the message - * @param interface the interface or #NULL to unset + * @param iface the interface or #NULL to unset * @returns #FALSE if not enough memory */ dbus_bool_t dbus_message_set_interface (DBusMessage *message, - const char *interface) + const char *iface) { _dbus_return_val_if_fail (message != NULL, FALSE); _dbus_return_val_if_fail (!message->locked, FALSE); - _dbus_return_val_if_fail (interface == NULL || - _dbus_check_is_valid_interface (interface), + _dbus_return_val_if_fail (iface == NULL || + _dbus_check_is_valid_interface (iface), FALSE); return set_or_delete_string_field (message, DBUS_HEADER_FIELD_INTERFACE, DBUS_TYPE_STRING, - interface); + iface); } /** @@ -3164,28 +3164,28 @@ dbus_message_get_interface (DBusMessage *message) * Checks if the message has an interface * * @param message the message - * @param interface the interface name + * @param iface the interface name * @returns #TRUE if the interface field in the header matches */ dbus_bool_t dbus_message_has_interface (DBusMessage *message, - const char *interface) + const char *iface) { const char *msg_interface; msg_interface = dbus_message_get_interface (message); if (msg_interface == NULL) { - if (interface == NULL) + if (iface == NULL) return TRUE; else return FALSE; } - if (interface == NULL) + if (iface == NULL) return FALSE; - if (strcmp (msg_interface, interface) == 0) + if (strcmp (msg_interface, iface) == 0) return TRUE; return FALSE; @@ -3477,13 +3477,13 @@ dbus_message_get_signature (DBusMessage *message) static dbus_bool_t _dbus_message_has_type_interface_member (DBusMessage *message, int type, - const char *interface, + const char *iface, const char *member) { const char *n; _dbus_assert (message != NULL); - _dbus_assert (interface != NULL); + _dbus_assert (iface != NULL); _dbus_assert (member != NULL); if (dbus_message_get_type (message) != type) @@ -3499,7 +3499,7 @@ _dbus_message_has_type_interface_member (DBusMessage *message, { n = dbus_message_get_interface (message); - if (n == NULL || strcmp (n, interface) == 0) + if (n == NULL || strcmp (n, iface) == 0) return TRUE; } @@ -3515,18 +3515,18 @@ _dbus_message_has_type_interface_member (DBusMessage *message, * protocol allows method callers to leave out the interface name. * * @param message the message - * @param interface the name to check (must not be #NULL) + * @param iface the name to check (must not be #NULL) * @param method the name to check (must not be #NULL) * * @returns #TRUE if the message is the specified method call */ dbus_bool_t dbus_message_is_method_call (DBusMessage *message, - const char *interface, + const char *iface, const char *method) { _dbus_return_val_if_fail (message != NULL, FALSE); - _dbus_return_val_if_fail (interface != NULL, FALSE); + _dbus_return_val_if_fail (iface != NULL, FALSE); _dbus_return_val_if_fail (method != NULL, FALSE); /* don't check that interface/method are valid since it would be * expensive, and not catch many common errors @@ -3534,7 +3534,7 @@ dbus_message_is_method_call (DBusMessage *message, return _dbus_message_has_type_interface_member (message, DBUS_MESSAGE_TYPE_METHOD_CALL, - interface, method); + iface, method); } /** @@ -3543,18 +3543,18 @@ dbus_message_is_method_call (DBusMessage *message, * has a different interface or member field, returns #FALSE. * * @param message the message - * @param interface the name to check (must not be #NULL) + * @param iface the name to check (must not be #NULL) * @param signal_name the name to check (must not be #NULL) * * @returns #TRUE if the message is the specified signal */ dbus_bool_t dbus_message_is_signal (DBusMessage *message, - const char *interface, + const char *iface, const char *signal_name) { _dbus_return_val_if_fail (message != NULL, FALSE); - _dbus_return_val_if_fail (interface != NULL, FALSE); + _dbus_return_val_if_fail (iface != NULL, FALSE); _dbus_return_val_if_fail (signal_name != NULL, FALSE); /* don't check that interface/name are valid since it would be * expensive, and not catch many common errors @@ -3562,7 +3562,7 @@ dbus_message_is_signal (DBusMessage *message, return _dbus_message_has_type_interface_member (message, DBUS_MESSAGE_TYPE_SIGNAL, - interface, signal_name); + iface, signal_name); } /** diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h index 5500492d..4fd44dab 100644 --- a/dbus/dbus-message.h +++ b/dbus/dbus-message.h @@ -71,13 +71,13 @@ DBusMessage* dbus_message_new (int message_type); DBUS_EXPORT DBusMessage* dbus_message_new_method_call (const char *bus_name, const char *path, - const char *interface, + const char *iface, const char *method); DBUS_EXPORT DBusMessage* dbus_message_new_method_return (DBusMessage *method_call); DBUS_EXPORT DBusMessage* dbus_message_new_signal (const char *path, - const char *interface, + const char *iface, const char *name); DBUS_EXPORT DBusMessage* dbus_message_new_error (DBusMessage *reply_to, @@ -108,12 +108,12 @@ dbus_bool_t dbus_message_has_path (DBusMessage *message, const char *object_path); DBUS_EXPORT dbus_bool_t dbus_message_set_interface (DBusMessage *message, - const char *interface); + const char *iface); DBUS_EXPORT const char* dbus_message_get_interface (DBusMessage *message); DBUS_EXPORT dbus_bool_t dbus_message_has_interface (DBusMessage *message, - const char *interface); + const char *iface); DBUS_EXPORT dbus_bool_t dbus_message_set_member (DBusMessage *message, const char *member); @@ -146,11 +146,11 @@ DBUS_EXPORT dbus_bool_t dbus_message_get_no_reply (DBusMessage *message); DBUS_EXPORT dbus_bool_t dbus_message_is_method_call (DBusMessage *message, - const char *interface, + const char *iface, const char *method); DBUS_EXPORT dbus_bool_t dbus_message_is_signal (DBusMessage *message, - const char *interface, + const char *iface, const char *signal_name); DBUS_EXPORT dbus_bool_t dbus_message_is_error (DBusMessage *message, -- cgit v1.2.1 From ad5b3128ba219c895ee084eb027a296b207df16b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Sep 2013 13:11:31 +0100 Subject: NEWS for 1.6 --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index bef985ee..167b5ffa 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,11 @@ Fixes: • Fix a regression test on platforms with strict alignment (fd.o #67279, Colin Walters) +• Avoid calling function parameters "interface" since certain Windows headers + have a namespace-polluting macro of that name (fd.o #66493, Ivan Romanov) + +• Make "make -j check" work (fd.o #68852, Simon McVittie) + D-Bus 1.6.12 (2013-06-13) == -- cgit v1.2.1 From 7d8895e4f49c78d6acb2486250753fbeeae6a610 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Sep 2013 13:11:45 +0100 Subject: NEWS --- NEWS | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/NEWS b/NEWS index f65ddf75..4f39d035 100644 --- a/NEWS +++ b/NEWS @@ -13,6 +13,12 @@ Build-time configuration changes: assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent with the Autotools build system. (fd.o #66142, Chengwei Yang) +Dependencies: + +• Full test coverage no longer requires dbus-glib, although the tests do not + exercise the shared library (only a static copy) if dbus-glib is missing. + (fd.o #68852, Simon McVittie) + Enhancements: • D-Bus Specification 0.22 @@ -31,6 +37,10 @@ Enhancements: • New API: dbus_setenv(), a simple wrapper around setenv(). Note that this is not thread-safe. (fd.o #39196, Simon) +• Windows-specific: + · "dbus-daemon --nofork" is allowed on Windows again. (fd.o #68852, + Simon McVittie) + Fixes: • Escape addresses containing non-ASCII characters correctly @@ -55,6 +65,11 @@ Fixes: • Assorted Doxygen fixes (fd.o #65755, Chengwei Yang) +• Various thread-safety improvements to static variables (fd.o #68610, + Simon McVittie) + +• Make "make -j check" work (fd.o #68852, Simon McVittie) + • Unix-specific: · dbus-run-session: clear some unwanted environment variables (fd.o #39196, Simon) @@ -66,6 +81,7 @@ Fixes: · Add support for looking up local TCPv4 clients' credentials on Windows XP via the undocumented AllocateAndGetTcpExTableFromStack function (fd.o #66060, Ralf Habacker) + · Fix insufficient dependency-tracking (fd.o #68505, Simon McVittie) • Internal changes: · add DBUS_ENABLE_ASSERT, DBUS_ENABLE_CHECKS for less confusing -- cgit v1.2.1 From dd81768ecb560f6f75483d5b51d278b424ed9c0c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 26 Jun 2013 12:27:09 +0100 Subject: Document that GNU make is required In theory the Autotools build system supports any "make" implementation, but there are no regular contributors who test with BSD make, so the inevitable result is that only GNU make actually works (fd.o #48277). Apparently there's only one GNUism at the moment, which is fixable, but that means repeating ourselves a bit more. If we instead document that GNU make is required, we can simplify the Makefiles over time by using extensions like $(patsubst), leading to a less error-prone build system. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48277 Signed-off-by: Simon McVittie Reviewed-by: Chengwei Yang --- README | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README b/README index fd832ca9..aea83300 100644 --- a/README +++ b/README @@ -66,7 +66,9 @@ Configuration dbus could be build by using autotools or cmake. When using autotools the configure step is initiated by running ./configure -with or without additional configuration flags. +with or without additional configuration flags. dbus requires GNU Make +(on BSD systems, this is typically called gmake) or a "make" implementation +with compatible extensions. When using cmake the configure step is initiated by running the cmake program with or without additional configuration flags. -- cgit v1.2.1 From 50674ed689a280d3100c843dfebf5b1f3e9928a4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 26 Jun 2013 12:33:29 +0100 Subject: Use GNU make features to reduce repetition Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48277 Signed-off-by: Simon McVittie Reviewed-by: Chengwei Yang --- doc/Makefile.am | 30 +++++++++--------------------- test/Makefile.am | 6 +----- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index aa5c7e1f..b9a4c106 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,34 +1,22 @@ apidir = @htmldir@/api -MAN_XML_FILES = \ - dbus-cleanup-sockets.1.xml \ - dbus-daemon.1.xml \ - dbus-launch.1.xml \ - dbus-monitor.1.xml \ - dbus-run-session.1.xml \ - dbus-send.1.xml \ - dbus-uuidgen.1.xml \ - $(NULL) - -if DBUS_XML_DOCS_ENABLED -man1_MANS = \ +man_pages = \ dbus-cleanup-sockets.1 \ dbus-daemon.1 \ dbus-launch.1 \ dbus-monitor.1 \ dbus-run-session.1 \ dbus-send.1 \ - dbus-uuidgen.1 + dbus-uuidgen.1 \ + $(NULL) + +MAN_XML_FILES = $(patsubst %.1,%.1.xml,$(man_pages)) + +if DBUS_XML_DOCS_ENABLED +man1_MANS = $(man_pages) endif -MAN_HTML_FILES = \ - dbus-cleanup-sockets.1.html \ - dbus-daemon.1.html \ - dbus-launch.1.html \ - dbus-monitor.1.html \ - dbus-run-session.1.html \ - dbus-send.1.html \ - dbus-uuidgen.1.html +MAN_HTML_FILES = $(patsubst %.1,%.1.html,$(man_pages)) DTDS = \ busconfig.dtd \ diff --git a/test/Makefile.am b/test/Makefile.am index 405aa1c2..eddcd644 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -370,10 +370,6 @@ imported_data = \ noinst_DATA = $(imported_data) CLEANFILES = $(noinst_DATA) -data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf - $(AM_V_at)$(MKDIR_P) data/valid-config-files - $(AM_V_GEN)cp $< $@ - -data/valid-config-files/system.conf: $(top_builddir)/bus/system.conf +$(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf $(AM_V_at)$(MKDIR_P) data/valid-config-files $(AM_V_GEN)cp $< $@ -- cgit v1.2.1 From 3357f484e07e0d6646ef060b25e0fcb3e3781d46 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Sep 2013 13:57:53 +0100 Subject: NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 4f39d035..02767921 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ Build-time configuration changes: Dependencies: +• GNU make is now (documented to be) required. (fd.o #48277, Simon McVittie) + • Full test coverage no longer requires dbus-glib, although the tests do not exercise the shared library (only a static copy) if dbus-glib is missing. (fd.o #68852, Simon McVittie) -- cgit v1.2.1 From fbeac8820acc60e3400a0a391c10b6c2bba7e8ba Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 27 Jun 2013 09:13:57 +0800 Subject: dbus-launch: unconditionally use SIGHUP and free memory on OOM In a previous patch, it check SIGHUP for windows, however, in fact there is dbus-launch-win.c supposed to be used on windows. So just use SIGHUP unconditionally. Also free memory on OOM, although this doesn't make much sense since this is a oneshort program, rather than a daemon. Signed-off-by: Chengwei Yang [fixed whitespace -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66068 Reviewed-by: Simon McVittie --- tools/dbus-launch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index ea24f5ce..15249759 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -451,9 +451,7 @@ signal_handler (int sig) { switch (sig) { -#ifdef SIGHUP case SIGHUP: -#endif case SIGINT: case SIGTERM: got_sighup = TRUE; @@ -769,7 +767,11 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, size_t len = strlen (argv[remaining_args+i-1])+1; args[i] = malloc (len); if (!args[i]) - goto oom; + { + while (i > 1) + free (args[--i]); + goto oom; + } strncpy (args[i], argv[remaining_args+i-1], len); } args[i] = NULL; -- cgit v1.2.1 From fc600b6a8f0dec5642b45c1026dee24c9adb9bc2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 4 Sep 2013 17:53:23 +0100 Subject: _dbus_babysitter_unref: avoid infinite loop if waitpid() returns EINTR If waitpid() failed with EINTR, we'd go back for another go, but because ret is nonzero, we'd skip the waitpid() and just keep looping. Also avoid an unnecessary "goto" in favour of a proper loop, to make it more clearly correct. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68945 Reviewed-by: Colin Walters --- dbus/dbus-spawn.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index ef00801c..6e42f554 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -308,15 +308,18 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) if (ret == 0) kill (sitter->sitter_pid, SIGKILL); - again: if (ret == 0) - ret = waitpid (sitter->sitter_pid, &status, 0); + { + do + { + ret = waitpid (sitter->sitter_pid, &status, 0); + } + while (_DBUS_UNLIKELY (ret < 0 && errno == EINTR)); + } if (ret < 0) { - if (errno == EINTR) - goto again; - else if (errno == ECHILD) + if (errno == ECHILD) _dbus_warn ("Babysitter process not available to be reaped; should not happen\n"); else _dbus_warn ("Unexpected error %d in waitpid() for babysitter: %s\n", -- cgit v1.2.1 From 7b3f2143fdcfcedb17d90631d5477921c2950241 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Sep 2013 16:37:08 +0100 Subject: 1.6.14 --- NEWS | 7 ++++++- configure.ac | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 167b5ffa..dc72a4c8 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,13 @@ -D-Bus 1.6.14 (UNRELEASED) +D-Bus 1.6.14 (2013-09-05) == +The “Restore Fatigue” release. + Fixes: +• Avoid an infinite busy-loop if a signal interrupts waitpid() + (fd.o #68945, Simon McVittie) + • Escape addresses containing non-ASCII characters correctly (fd.o #53499, Chengwei Yang) diff --git a/configure.ac b/configure.ac index dab29ee4..20746bb1 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [13]) +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]) -- cgit v1.2.1 From 0fbb33714621dc2553fcd4aba4fe721064081890 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 5 Sep 2013 17:26:18 +0100 Subject: 1.6.15 --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index dc72a4c8..6dbc603e 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.6.16 (UNRELEASED) +== + +… + D-Bus 1.6.14 (2013-09-05) == diff --git a/configure.ac b/configure.ac index 20746bb1..dfdbb482 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [14]) +m4_define([dbus_micro_version], [15]) 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]) -- cgit v1.2.1 From a548141b172a078dd0073d718da3fb655821860a Mon Sep 17 00:00:00 2001 From: Sviatoslav Chagaev Date: Tue, 10 Sep 2013 18:23:53 +0300 Subject: Fix file descriptor leak in _dbus_command_for_pid Fix a file descriptor not being closed when an error codepath is taken. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69182 Reviewed-by: Chengwei Yang [more specific commit message -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-util-unix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 6cff3fe2..bbc3f348 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -1144,6 +1144,7 @@ _dbus_command_for_pid (unsigned long pid, "Failed to read from \"%s\": %s", _dbus_string_get_const_data (&path), _dbus_strerror (errno)); + _dbus_close (fd, NULL); goto fail; } -- cgit v1.2.1 From f658047ec8453dc7a7ba5ebe66bf113050915da0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 6 Sep 2013 11:26:44 +0800 Subject: Fix pass wrong type of argument to function The last argument of function _dbus_transport_new_for_socket() is declared as const DBusString *. However, it is passed as a bool value. Although the value of FALSE equals NULL in fact, this is an incorrect use of function. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69165 Reviewed-by: Simon McVittie --- dbus/dbus-server-socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index ae4b602e..80847647 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -101,7 +101,7 @@ handle_new_client_fd_and_unlock (DBusServer *server, return TRUE; } - transport = _dbus_transport_new_for_socket (client_fd, &server->guid_hex, FALSE); + transport = _dbus_transport_new_for_socket (client_fd, &server->guid_hex, NULL); if (transport == NULL) { _dbus_close_socket (client_fd, NULL); -- cgit v1.2.1 From 37df7c316bf2ab4ed3a64910fc0030c095f7b5ab Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 6 Sep 2013 13:48:38 +0800 Subject: Use the argument of dbus_connection_set_route_peer_messages() The function dbus_connection_set_route_peer_messages() take a bool argument, however, in the implementation, it always hard-code to TRUE rather than take its bool argument. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69165 [amended commit message -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-connection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 66315b3f..b175a445 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -5435,7 +5435,7 @@ dbus_connection_set_route_peer_messages (DBusConnection *connection, _dbus_return_if_fail (connection != NULL); CONNECTION_LOCK (connection); - connection->route_peer_messages = TRUE; + connection->route_peer_messages = value; CONNECTION_UNLOCK (connection); } -- cgit v1.2.1 From 7a53684d422d10d5e89ff0dee7f3c7539de11341 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 10 Sep 2013 22:29:19 +0800 Subject: Check EINVAL for socketpair and retry without SOCK_CLOEXEC As the same as _dbus_open_socket() and _dbus_full_duplex_pipe(), socketpair() may fail with EINVAL if call with SOCK_CLOEXEC. Check for the failure and retry without SOCK_CLOEXEC, in addition, only call _dbus_fd_set_close_on_exec() if the socketpair failure happened. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69073 [trivial coding style fixes -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index e31c7355..b84ad0e9 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -887,16 +887,24 @@ _dbus_connect_exec (const char *path, { int fds[2]; pid_t pid; + int retval; + dbus_bool_t cloexec_done = 0; _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_verbose ("connecting to process %s\n", path); - if (socketpair (AF_UNIX, SOCK_STREAM #ifdef SOCK_CLOEXEC - |SOCK_CLOEXEC + retval = socketpair (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds); + cloexec_done = (retval >= 0); + + if (retval < 0 && (errno == EINVAL)) #endif - , 0, fds) < 0) + { + retval = socketpair (AF_UNIX, SOCK_STREAM, 0, fds); + } + + if (retval < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), @@ -905,8 +913,11 @@ _dbus_connect_exec (const char *path, return -1; } - _dbus_fd_set_close_on_exec (fds[0]); - _dbus_fd_set_close_on_exec (fds[1]); + if (!cloexec_done) + { + _dbus_fd_set_close_on_exec (fds[0]); + _dbus_fd_set_close_on_exec (fds[1]); + } pid = fork (); if (pid < 0) -- cgit v1.2.1 From c1288c5366f64b45280b4f8865e2efb716663ccd Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 10 Sep 2013 22:34:07 +0800 Subject: Allow EPROTOTYPE for SOCK_CLOEXEC but unsupported by socket/socketpair If SOCK_CLOEXEC is defined (usually because accept4 is implemented), check for EPROTOTYPE (the POSIX errno for invalid socket types) in addition to EINVAL as errno indicating whether socket and socketpair do not support SOCK_CLOEXEC (and other SOCK_* flags). [adapted by Chengwei Yang to give _dbus_connect_exec() the same treatment] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69073 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index b84ad0e9..8405a429 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -139,7 +139,7 @@ _dbus_open_socket (int *fd_p, cloexec_done = *fd_p >= 0; /* Check if kernel seems to be too old to know SOCK_CLOEXEC */ - if (*fd_p < 0 && errno == EINVAL) + if (*fd_p < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { *fd_p = socket (domain, type, protocol); @@ -898,7 +898,7 @@ _dbus_connect_exec (const char *path, retval = socketpair (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds); cloexec_done = (retval >= 0); - if (retval < 0 && (errno == EINVAL)) + if (retval < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { retval = socketpair (AF_UNIX, SOCK_STREAM, 0, fds); @@ -3066,7 +3066,7 @@ _dbus_full_duplex_pipe (int *fd1, retval = socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds); cloexec_done = retval >= 0; - if (retval < 0 && errno == EINVAL) + if (retval < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { retval = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); -- cgit v1.2.1 From 200a11ebbee468fa08d1badab0046a93a75195ef Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 12 Sep 2013 13:38:10 +0800 Subject: Check EINVAL for accept4() It was reported that accept4() will return -1 with errrno is EINVAL on arm platform, so check EINVAL for accept4() and retry accept(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69026 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 8405a429..92ce00ea 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1948,11 +1948,15 @@ _dbus_accept (int listen_fd) retry: #ifdef HAVE_ACCEPT4 - /* We assume that if accept4 is available SOCK_CLOEXEC is too */ + /* + * At compile-time, we assume that if accept4() is available in + * libc headers, SOCK_CLOEXEC is too. At runtime, it is still + * not necessarily true that either is supported by the running kernel. + */ client_fd = accept4 (listen_fd, &addr, &addrlen, SOCK_CLOEXEC); cloexec_done = client_fd >= 0; - if (client_fd < 0 && errno == ENOSYS) + if (client_fd < 0 && (errno == ENOSYS || errno == EINVAL)) #endif { client_fd = accept (listen_fd, &addr, &addrlen); -- cgit v1.2.1 From 0cea59aad50c75ee6125e6fc627c4f083489d40d Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 11 Sep 2013 15:27:38 +0800 Subject: Remove DBUS_COMPILATION from test source code DBUS_COMPILATION definition was moved to test/Makefile.am static_cppflags, so remove it from test source code. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Simon McVittie --- test/break-loader.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/break-loader.c b/test/break-loader.c index e62b8c20..1e406fc3 100644 --- a/test/break-loader.c +++ b/test/break-loader.c @@ -33,12 +33,10 @@ #include #include -#define DBUS_COMPILATION #include #include #include #include -#undef DBUS_COMPILATION static DBusString failure_dir; static int total_attempts; -- cgit v1.2.1 From dd71688e5d5fe2bdca8b3c0b090a40d053100a4f Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 4 Sep 2013 14:52:21 +0800 Subject: Fix dbus-daemon document about servicedir In dbus-daemon implementation, the servicedir are searched in order in which they appear in the config file. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66994 Reviewed-by: Simon McVittie --- doc/dbus-daemon.1.xml.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index 023bebae..c08cf2b2 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -397,7 +397,7 @@ which mechanisms are listed is not meaningful. Adds a directory to scan for .service files. Directories are -scanned starting with the last to appear in the config file +scanned starting with the first to appear in the config file (the first .service file found that provides a particular service will be used). -- cgit v1.2.1 From 1c95955cbc6e816dd50a9d66846c11b44d703a1f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 14:02:33 +0100 Subject: NEWS --- NEWS | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 6dbc603e..2a34fef5 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,23 @@ D-Bus 1.6.16 (UNRELEASED) == -… +The “Fortify Agility” release. + +Fixes: + +• Make dbus_connection_set_route_peer_messages(x, FALSE) behave as + documented. Previously, it assumed its second parameter was TRUE. + (fd.o #69165, Chengwei Yang) + +• Unix-specific: + · If accept4() fails with EINVAL, as it can on older Linux kernels + with newer glibc, try accept() instead of going into a busy-loop. + (fd.o #69026, Chengwei Yang) + · If socket() or socketpair() fails with EINVAL or EPROTOTYPE, + for instance on Hurd or older Linux with a new glibc, try without + SOCK_CLOEXEC. (fd.o #69073; Pino Toscano, Chengwei Yang) + · Fix a file descriptor leak on an error code path. + (fd.o #69182, Sviatoslav Chagaev) D-Bus 1.6.14 (2013-09-05) == -- cgit v1.2.1 From c627c4119f9c5831c314adfe470c8f7829fabbc3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 14:06:02 +0100 Subject: More NEWS --- NEWS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 230daefa..31e4157a 100644 --- a/NEWS +++ b/NEWS @@ -55,6 +55,8 @@ Fixes: • Escape addresses containing non-ASCII characters correctly (fd.o #53499, Chengwei Yang) +• Document search order correctly (fd.o #66994, Chengwei Yang) + • Don't crash on "dbus-send --session / x.y.z" which regressed in 1.7.4. (fd.o #65923, Chengwei Yang) @@ -106,7 +108,7 @@ Fixes: · improve verbose-mode output (fd.o #63047, Colin Walters) · consolidate Autotools and CMake build (fd.o #64875, Ralf Habacker) · fix various unused variables, unusual build configurations - etc. (fd.o #65712, #65990, #66005, #66257; Chengwei Yang) + etc. (fd.o #65712, #65990, #66005, #66257, #69165; Chengwei Yang) D-Bus 1.7.4 (2013-06-13) == -- cgit v1.2.1 From 8d2536e023026e295e5040739c1a2a9005cde76a Mon Sep 17 00:00:00 2001 From: Justin Lee Date: Thu, 30 May 2013 03:21:31 +0800 Subject: Remove obscure "low-latency" parts in the introduction of spec According to Wikipedia http://en.wikipedia.org/wiki/Latency_%28engineering%29#Packet-switched_networks latency means "the time from the source sending a packet to the destination receiving it". Therefore, latency is unrelated to whether the operation is asynchronous or synchronous. And also unrelated to whether it's one-way or round-trip. Latency exists for asynchronous and one-way transfer, because for current DBus implementations we need at least one context switch to transfer each message from the sender process to the receiver process. Emphasizing D-Bus is low-latency could encourage user to abuse/misuse the system. Mail disscusion: http://lists.freedesktop.org/archives/dbus/2013-May/015665.html Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65141 Reviewed-by: Simon McVittie --- doc/dbus-specification.xml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 673383a9..ce58fe86 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -175,23 +175,18 @@ Introduction - D-Bus is a system for low-latency, low-overhead, easy to use + D-Bus is a system for low-overhead, easy to use interprocess communication (IPC). In more detail: - - - D-Bus is low-latency because it is designed - to avoid round trips and allow asynchronous operation, much like - the X protocol. - - D-Bus is low-overhead because it uses a binary protocol, and does not have to convert to and from a text format such as XML. Because D-Bus is intended for potentially high-resolution same-machine IPC, not primarily for Internet IPC, - this is an interesting optimization. + this is an interesting optimization. D-Bus is also designed to + avoid round trips and allow asynchronous operation, much like + the X protocol. -- cgit v1.2.1 From efd8209d0530c73bf0a0a4fff8449e76840dcd39 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 14:16:50 +0100 Subject: NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 31e4157a..9733a990 100644 --- a/NEWS +++ b/NEWS @@ -27,6 +27,9 @@ Enhancements: · Document GetAdtAuditSessionData() and GetConnectionSELinuxSecurityContext() (fd.o #54445, Simon) · Fix example .service file (fd.o #66481, Chengwei Yang) + · Don't claim D-Bus is "low-latency" (lower than what?), just + give factual statements about it supporting async use + (fd.o #65141, Justin Lee) • Be thread-safe by default on all platforms, even if dbus_threads_init_default() has not been called. For compatibility with -- cgit v1.2.1 From 2cf320fc82593fd1b3c71688f770e443366780ec Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 23 Apr 2012 00:32:43 +0200 Subject: selinux: when dropping capabilities only include AUDIT caps if we have them When we drop capabilities we shouldn't assume we can keep CAP_AUDIT_WRITE unconditionally, since it will not be available when running in containers. This patch only adds CAP_AUDIT_WRITE to the list of caps we keep if we actually have it in the first place. This makes audit/selinux enabled D-Bus work in a Linux container. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49062 Acked-by: Thiago Macieira Acked-by: Colin Walters Reviewed-by: Simon McVittie --- bus/selinux.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bus/selinux.c b/bus/selinux.c index c36c94ec..7ae84d6d 100644 --- a/bus/selinux.c +++ b/bus/selinux.c @@ -1045,8 +1045,9 @@ _dbus_change_to_daemon_user (const char *user, int rc; capng_clear (CAPNG_SELECT_BOTH); - capng_update (CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, - CAP_AUDIT_WRITE); + if (capng_have_capability (CAPNG_PERMITTED, CAP_AUDIT_WRITE)) + capng_update (CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, + CAP_AUDIT_WRITE); rc = capng_change_id (uid, gid, CAPNG_DROP_SUPP_GRP); if (rc) { -- cgit v1.2.1 From ee0f28f6a575337fe6d0571f5935f82a601c37c9 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 13 Sep 2013 16:56:26 +0800 Subject: Use test binaries in build dir to do test When do autolaunch testing, libdbus will try to start dbus-launch in installed direcotry, if fail then fall back to dbus-launch in $PATH. dbus-launch does a relative better thing to start dbus-daemon in build directory, however, in most of case, the build $prefix is different from the real prefix where dbus-daemon installed. So dbus-daemon will fail to start due to can't find its config file. And then dbus-launch will fall back to finally the installed dbus-daemon. This patch fix this behavior and will start dbus-launch and dbus-daemon in build directory in test environment. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849 --- configure.ac | 3 +++ dbus/dbus-sysdeps-unix.c | 9 +++++++-- test/name-test/Makefile.am | 7 ++++++- tools/dbus-launch.c | 10 +++++++++- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index ab7b1e17..b6ff7690 100644 --- a/configure.ac +++ b/configure.ac @@ -1647,6 +1647,9 @@ AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, ["$DBUS_PWD/bus/dbus-daemon$EXEEXT"], [Full path to the daemon in the builddir]) AC_SUBST(TEST_BUS_BINARY) +AC_DEFINE_UNQUOTED(TEST_BUS_LAUNCH_BINARY, ["$DBUS_PWD/tools/dbus-launch$EXEEXT"], + [Full path to the dbus-launch in the builddir]) + ## Export the non-setuid external helper TEST_LAUNCH_HELPER_BINARY="$DBUS_PWD/bus/dbus-daemon-launch-helper-test$EXEEXT" AC_SUBST(TEST_LAUNCH_HELPER_BINARY) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 72697340..54c02721 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -3518,7 +3518,12 @@ _dbus_get_autolaunch_address (const char *scope, } i = 0; - argv[i] = "dbus-launch"; +#ifdef DBUS_ENABLE_EMBEDDED_TESTS + if (_dbus_getenv ("DBUS_USE_TEST_BINARY") != NULL) + argv[i] = TEST_BUS_LAUNCH_BINARY; + else +#endif + argv[i] = DBUS_BINDIR "/dbus-launch"; ++i; argv[i] = "--autolaunch"; ++i; @@ -3533,7 +3538,7 @@ _dbus_get_autolaunch_address (const char *scope, _dbus_assert (i == _DBUS_N_ELEMENTS (argv)); - retval = _read_subprocess_line_argv (DBUS_BINDIR "/dbus-launch", + retval = _read_subprocess_line_argv (argv[0], TRUE, argv, address, error); diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 54b02af0..931cb2c9 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -13,7 +13,12 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ ## so if adding tests not to be run in make check, don't add them to ## TESTS if DBUS_ENABLE_EMBEDDED_TESTS -TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ PYTHON=@PYTHON@ +TESTS_ENVIRONMENT = \ + DBUS_TOP_BUILDDIR=@abs_top_builddir@ \ + DBUS_TOP_SRCDIR=@abs_top_srcdir@ \ + PYTHON=@PYTHON@ \ + DBUS_TEST_DATA=@abs_top_builddir@/test/data \ + $(NULL) TESTS=run-test.sh run-test-systemserver.sh else TESTS= diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 15249759..14fa226d 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -1110,8 +1110,16 @@ main (int argc, char **argv) #ifdef DBUS_ENABLE_EMBEDDED_TESTS /* exec from testdir */ - if (getenv("DBUS_USE_TEST_BINARY") != NULL) + if (getenv ("DBUS_USE_TEST_BINARY") != NULL) { + if (config_file == NULL && getenv ("DBUS_TEST_DATA") != NULL) + { + ret = asprintf (&config_file, "%s/valid-config-files/session.conf", + getenv ("DBUS_TEST_DATA")); + } + if (ret == -1 && config_file != NULL) + free (config_file); + execl (TEST_BUS_BINARY, TEST_BUS_BINARY, "--fork", -- cgit v1.2.1 From 86c6dbd20b578e28f383ade7c9af1572e4169347 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 14:59:17 +0100 Subject: Don't assume that X11 autolaunch will work if DISPLAY is unset In practice, it won't; other forms of autolaunch (like Mac OS launchd) might, but we can't really assert either way. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=40352 Reviewed-by: Chengwei Yang [amended to reinstate use of dbus/dbus-sysdeps.h which was removed by 412538b3b9 -smcv] Signed-off-by: Simon McVittie --- test/name-test/test-autolaunch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/name-test/test-autolaunch.c b/test/name-test/test-autolaunch.c index 732e6dc7..8b5206a6 100644 --- a/test/name-test/test-autolaunch.c +++ b/test/name-test/test-autolaunch.c @@ -8,6 +8,7 @@ #endif #include +#include "dbus/dbus-sysdeps.h" int main (int argc, char *argv[]) @@ -22,14 +23,16 @@ main (int argc, char *argv[]) conn = dbus_bus_get (DBUS_BUS_SESSION, &error); #ifdef DBUS_ENABLE_X11_AUTOLAUNCH - if (dbus_error_is_set (&error)) + /* If X11 autolaunch was enabled, we expect dbus-launch to have worked. */ + if (_dbus_getenv ("DISPLAY") != NULL && dbus_error_is_set (&error)) { fprintf (stderr, "*** Failed to autolaunch session bus: %s\n", error.message); dbus_error_free (&error); return 1; } -#else +#endif + /* We don't necessarily expect it to *work* without X (although it might - * for instance on Mac OS it might have used launchd). Just check that the * results are consistent. */ @@ -39,7 +42,6 @@ main (int argc, char *argv[]) fprintf (stderr, "*** Autolaunched session bus, but an error was set!\n"); return 1; } -#endif if (!dbus_error_is_set (&error) && conn == NULL) { -- cgit v1.2.1 From ba58504ad266cd2b053ed0f923491889722cf8eb Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 4 Sep 2013 15:13:33 +0800 Subject: Make userdb cache as a built-in feature The disable-userdb-cache code path is never been fine tested and you could expect an extramely slow bus if you did that. And there are known bugs on fd.o if build without userdb cache. So to prevent user from using bus without userdb cache, it changed to a built-in feature, no longer optional now. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66947 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=15589 Reviewed-by: Simon McVittie --- configure.ac | 6 ------ dbus/dbus-userdb-util.c | 4 ---- dbus/dbus-userdb.c | 4 ---- 3 files changed, 14 deletions(-) diff --git a/configure.ac b/configure.ac index b6ff7690..da4ab5fb 100644 --- a/configure.ac +++ b/configure.ac @@ -153,7 +153,6 @@ AC_ARG_ENABLE(libaudit,AS_HELP_STRING([--enable-libaudit],[build audit daemon su AC_ARG_ENABLE(inotify, AS_HELP_STRING([--enable-inotify],[build with inotify support (linux only)]),enable_inotify=$enableval,enable_inotify=auto) AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support]),enable_kqueue=$enableval,enable_kqueue=auto) AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto) -AC_ARG_ENABLE(userdb-cache, AS_HELP_STRING([--enable-userdb-cache],[build with userdb-cache support]),enable_userdb_cache=$enableval,enable_userdb_cache=yes) AC_ARG_ENABLE(launchd, AS_HELP_STRING([--enable-launchd],[build with launchd auto-launch support]),enable_launchd=$enableval,enable_launchd=auto) AC_ARG_ENABLE(systemd, AS_HELP_STRING([--enable-systemd],[build with systemd at_console support]),enable_systemd=$enableval,enable_systemd=auto) @@ -316,10 +315,6 @@ AH_BOTTOM([ # define DBUS_ENABLE_CHECKS 1 #endif]) -if test x$enable_userdb_cache = xyes; then - AC_DEFINE(DBUS_ENABLE_USERDB_CACHE,1,[Build with caching of user data]) -fi - if test x$enable_compiler_coverage = xyes; then ## so that config.h changes when you toggle gcov support AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing]) @@ -1864,7 +1859,6 @@ echo " Building X11 code: ${have_x11} Building Doxygen docs: ${enable_doxygen_docs} Building XML docs: ${enable_xml_docs} - Building cache support: ${enable_userdb_cache} Building launchd support: ${have_launchd} Init scripts style: ${with_init_scripts} Abstract socket names: ${ac_cv_have_abstract_sockets} diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c index 62495d83..888a23e9 100644 --- a/dbus/dbus-userdb-util.c +++ b/dbus/dbus-userdb-util.c @@ -261,7 +261,6 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db, gid = n; } -#ifdef DBUS_ENABLE_USERDB_CACHE if (gid != DBUS_GID_UNSET) info = _dbus_hash_table_lookup_uintptr (db->groups, gid); else @@ -274,9 +273,6 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db, return info; } else -#else - if (1) -#endif { if (gid != DBUS_GID_UNSET) _dbus_verbose ("No cache for GID "DBUS_GID_FORMAT"\n", diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index b792cbe4..52f927a3 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -144,7 +144,6 @@ _dbus_user_database_lookup (DBusUserDatabase *db, uid = n; } -#ifdef DBUS_ENABLE_USERDB_CACHE if (uid != DBUS_UID_UNSET) info = _dbus_hash_table_lookup_uintptr (db->users, uid); else @@ -157,9 +156,6 @@ _dbus_user_database_lookup (DBusUserDatabase *db, return info; } else -#else - if (1) -#endif { if (uid != DBUS_UID_UNSET) _dbus_verbose ("No cache for UID "DBUS_UID_FORMAT"\n", -- cgit v1.2.1 From 430c6918ae6870b1d9bf2b820970d2380410d05d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 15:03:58 +0100 Subject: NEWS --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 9733a990..72f392c8 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,11 @@ Build-time configuration changes: to send SIGHUP to the dbus-daemon when its configuration changes. (fd.o #33001, Chengwei Yang) +• Compiling with --disable-userdb-cache is no longer supported; + it didn't work since at least 2008, and would lead to an extremely + slow dbus-daemon even it worked. (fd.o #15589, #17133, #66947; + Chengwei Yang) + • The DBUS_DISABLE_ASSERTS CMake option didn't actually disable most assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent with the Autotools build system. (fd.o #66142, Chengwei Yang) @@ -96,6 +101,9 @@ Fixes: · dbus-run-session: clear some unwanted environment variables (fd.o #39196, Simon) · dbus-run-session: compile on FreeBSD (fd.o #66197, Chengwei Yang) + · Don't fail the autolaunch test if there is no DISPLAY (fd.o #40352, Simon) + · Use dbus-launch from the builddir for testing, not the installed copy + (fd.o #37849, Chengwei Yang) • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' -- cgit v1.2.1 From 3b9c2817e9b849850d6074fab3a18717a6187523 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Sep 2013 17:39:37 +0100 Subject: dbus-sysdeps-win: don't include wspiapi.h This block provoked a warning on mingw-w64 because we were redefining _inline. According to Ralf's research, it was introduced in 452ff68a: Windows 2000 doesn't have getaddrinfo and related functions in ws2tcpip.h, but does have a shim implementation in wspiapi.h. At the time of 452ff68a, mingw32 didn't have wspiapi.h, so it's unclear why there was a __GNUC__ code path here. The "#define _inline" on that code path looks likely to be some sort of workaround for a faulty version of wspiapi.h? Current mingw-w64 does have wspiapi.h, so we enter the __GNUC__ code path and get the redefinition. dbus no longer supports Windows 2000, so we no longer need wspiapi.h at all, and can rely on XP or later. (Ralf's policy is to only support versions of Windows that are still supported by Microsoft, and Windows 2000 reached the end of its life-cycle in 2010.) Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- cmake/ConfigureChecks.cmake | 1 - cmake/config.h.cmake | 3 --- configure.ac | 2 -- dbus/dbus-sysdeps-win.c | 10 ---------- 4 files changed, 16 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 33a9cee2..47704726 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -11,7 +11,6 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c check_include_file(sys/wait.h HAVE_SYS_WAIT_H)# dbus-sysdeps-win.c check_include_file(time.h HAVE_TIME_H) # dbus-sysdeps-win.c check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c -check_include_file(wspiapi.h HAVE_WSPIAPI_H) # dbus-sysdeps-win.c check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c check_include_file(stdio.h HAVE_STDIO_H) # dbus-sysdeps.h check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-unix.c diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index f14b169e..d6ea64f2 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -124,9 +124,6 @@ /* Define to 1 if you have ws2tcpip.h */ #cmakedefine HAVE_WS2TCPIP_H -/* Define to 1 if you have wspiapi.h */ -#cmakedefine HAVE_WSPIAPI_H 1 - /* Define to 1 if you have unistd.h */ #cmakedefine HAVE_UNISTD_H 1 diff --git a/configure.ac b/configure.ac index da4ab5fb..f201b5b1 100644 --- a/configure.ac +++ b/configure.ac @@ -699,8 +699,6 @@ AC_CHECK_HEADERS(unistd.h) AC_CHECK_HEADERS(ws2tcpip.h) -AC_CHECK_HEADERS(wspiapi.h) - AC_CHECK_HEADERS(alloca.h) # Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index a77e5b58..1c974c50 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -77,16 +77,6 @@ extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); #include #endif -#ifdef HAVE_WSPIAPI_H -// needed for w2k compatibility (getaddrinfo/freeaddrinfo/getnameinfo) -#ifdef __GNUC__ -#define _inline -#include "wspiapi.h" -#else -#include -#endif -#endif // HAVE_WSPIAPI_H - #ifndef O_BINARY #define O_BINARY 0 #endif -- cgit v1.2.1 From 3c1938180bdca8fc658907f6f692186be2b81b77 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 12:43:40 +0100 Subject: Fix an incorrect sizeof. Fix an incorrect sizeof which leads to allocation of more memory than actually needed. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69329 [elide redundant "* sizeof (char)" which is 1 by definition -smcv] Reviewed-by: Simon McVittie --- tools/dbus-monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index a4b54782..7382f4bf 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -310,7 +310,7 @@ main (int argc, char *argv[]) filters = (char **) realloc (filters, numFilters * sizeof (char *)); if (filters == NULL) oom ("adding a new filter slot"); - filters[j] = (char *) malloc (filter_len * sizeof (char *)); + filters[j] = (char *) malloc (filter_len); if (filters[j] == NULL) oom ("adding a new filter"); snprintf (filters[j], filter_len, "%s,%s", EAVESDROPPING_RULE, arg); -- cgit v1.2.1 From 01a0bba9f76f125ba3616e8ddb131a127b863273 Mon Sep 17 00:00:00 2001 From: Sviatoslav Chagaev Date: Fri, 13 Sep 2013 18:54:27 +0300 Subject: Fix a NULL dereference on an error code path. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69327 Reviewed-by: Simon McVittie --- dbus/dbus-server-socket.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index ae4b602e..3209ceba 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -478,7 +478,10 @@ _dbus_server_new_for_tcp_socket (const char *host, if (server == NULL) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); - goto failed_4; + if (noncefile != NULL) + goto failed_4; + else + goto failed_2; } _dbus_string_free (&port_str); -- cgit v1.2.1 From 996b2968357f01d92d46c53ba59e9bd39ecd20eb Mon Sep 17 00:00:00 2001 From: Sviatoslav Chagaev Date: Fri, 13 Sep 2013 18:43:41 +0300 Subject: Fix incorrect sizeof in a Valgrind hint macro call. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69326 Reviewed-by: Simon McVittie --- dbus/dbus-mempool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-mempool.c b/dbus/dbus-mempool.c index e7445853..52466151 100644 --- a/dbus/dbus-mempool.c +++ b/dbus/dbus-mempool.c @@ -393,7 +393,7 @@ _dbus_mem_pool_dealloc (DBusMemPool *pool, freed = element; /* used for internal mempool administration */ - VALGRIND_MAKE_MEM_UNDEFINED (freed, sizeof (freed)); + VALGRIND_MAKE_MEM_UNDEFINED (freed, sizeof (*freed)); freed->next = pool->free_elements; pool->free_elements = freed; -- cgit v1.2.1 From 61889c8c11aa60928bf5bd317c4e1f2d97b77bf1 Mon Sep 17 00:00:00 2001 From: Vasiliy Balyasnyy Date: Mon, 16 Sep 2013 15:09:47 +0400 Subject: dbus-sysdeps-unix.c: undeclared ret2 variable if HAVE_WRITEV undefined. Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69409 --- dbus/dbus-sysdeps-unix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 92ce00ea..f47a5a2b 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -736,7 +736,7 @@ _dbus_write_two (int fd, } #else /* HAVE_WRITEV */ { - int ret1; + int ret1, ret2; ret1 = _dbus_write (fd, buffer1, start1, len1); if (ret1 == len1 && buffer2 != NULL) -- cgit v1.2.1 From 52b6106a3336ba092b5be837b3499b2a60bc8d5f Mon Sep 17 00:00:00 2001 From: Vasiliy Balyasnyy Date: Mon, 16 Sep 2013 15:14:33 +0400 Subject: dbus-mainloop.c: undeclared variable n_fds if define MAINLOOP_SPEW. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69410 Reviewed-by: Chengwei Yang Reviewed-by: Simon McVittie --- dbus/dbus-mainloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index 8b4da164..7ff9dc2c 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -654,7 +654,7 @@ _dbus_loop_iterate (DBusLoop *loop, timeout = MIN (timeout, _dbus_get_oom_wait ()); #if MAINLOOP_SPEW - _dbus_verbose (" polling on %d descriptors timeout %ld\n", n_fds, timeout); + _dbus_verbose (" polling on %d descriptors timeout %ld\n", _DBUS_N_ELEMENTS (ready_fds), timeout); #endif n_ready = _dbus_socket_set_poll (loop->socket_set, ready_fds, -- cgit v1.2.1 From 3b85dfcf77dc8fe40c8ab98163725d29e1d63706 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 14:58:24 +0100 Subject: NEWS for 1.6.x --- NEWS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS b/NEWS index 2a34fef5..e41971bd 100644 --- a/NEWS +++ b/NEWS @@ -9,6 +9,9 @@ Fixes: documented. Previously, it assumed its second parameter was TRUE. (fd.o #69165, Chengwei Yang) +• Fix a NULL pointer dereference on an unlikely error path + (fd.o #69327, Sviatoslav Chagaev) + • Unix-specific: · If accept4() fails with EINVAL, as it can on older Linux kernels with newer glibc, try accept() instead of going into a busy-loop. @@ -18,6 +21,8 @@ Fixes: SOCK_CLOEXEC. (fd.o #69073; Pino Toscano, Chengwei Yang) · Fix a file descriptor leak on an error code path. (fd.o #69182, Sviatoslav Chagaev) + · Fix compilation if writev() is unavailable (fd.o #69409, + Vasiliy Balyasnyy) D-Bus 1.6.14 (2013-09-05) == -- cgit v1.2.1 From b47d50623b6642f15737b750f941901e6168bf3d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 5 Jun 2013 19:43:13 +0100 Subject: Remove support for platforms with no 64-bit integer type This has been a soft requirement since 1.5.0; anyone on such platforms would have had to configure --without-64-bit, provoking a warning that instructed them to report a D-Bus bug with details of their platform. Nobody has done so, so if anyone still lacks a 64-bit integer type, they're on their own. (Also, I tried the build with --without-64-bit and it's full of fatal compiler warnings, so it's not clear that we're actually losing anything by removing this "feature".) Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65429 Reviewed-by: Chengwei Yang --- cmake/ConfigureChecks.cmake | 6 ++-- configure.ac | 38 +------------------- dbus/dbus-arch-deps.h.in | 8 +---- dbus/dbus-internals.h | 2 -- dbus/dbus-marshal-basic.c | 73 -------------------------------------- dbus/dbus-marshal-basic.h | 39 ++++++++------------ dbus/dbus-marshal-byteswap.c | 4 --- dbus/dbus-marshal-recursive-util.c | 25 ------------- dbus/dbus-message-util.c | 26 -------------- dbus/dbus-string.c | 20 ----------- dbus/dbus-types.h | 36 ++++--------------- 11 files changed, 25 insertions(+), 252 deletions(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 47704726..2794975e 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -51,25 +51,23 @@ check_type_size("__int64" SIZEOF___INT64) # DBUS_INT64_TYPE if(SIZEOF_INT EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "int") set (DBUS_INT64_CONSTANT "(val)") set (DBUS_UINT64_CONSTANT "(val##U)") elseif(SIZEOF_LONG EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "long") set (DBUS_INT64_CONSTANT "(val##L)") set (DBUS_UINT64_CONSTANT "(val##UL)") elseif(SIZEOF_LONG_LONG EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "long long") set (DBUS_INT64_CONSTANT "(val##LL)") set (DBUS_UINT64_CONSTANT "(val##ULL)") elseif(SIZEOF___INT64 EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "__int64") set (DBUS_INT64_CONSTANT "(val##i64)") set (DBUS_UINT64_CONSTANT "(val##ui64)") +else(SIZEOF_INT EQUAL 8) + message (FATAL_ERROR "Could not find a 64-bit integer type") endif(SIZEOF_INT EQUAL 8) # DBUS_INT32_TYPE diff --git a/configure.ac b/configure.ac index f201b5b1..f4c88262 100644 --- a/configure.ac +++ b/configure.ac @@ -355,12 +355,6 @@ 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]) @@ -399,33 +393,17 @@ $ac_cv_sizeof___int64) esac 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([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.]) + http://bugs.freedesktop.org/enter_bug.cgi?product=DBus&component=core]) ], dnl else [ DBUS_INT64_TYPE="$dbusint64" - DBUS_HAVE_INT64=1 DBUS_INT64_CONSTANT="$dbusint64_constant" DBUS_UINT64_CONSTANT="$dbusuint64_constant" if test x"$dbusint64_printf_modifier" != x; then @@ -437,7 +415,6 @@ platform needs it.]) AC_SUBST(DBUS_INT64_TYPE) AC_SUBST(DBUS_INT64_CONSTANT) AC_SUBST(DBUS_UINT64_CONSTANT) -AC_SUBST(DBUS_HAVE_INT64) ### see what 32-bit int is called AC_MSG_CHECKING([32-bit integer type]) @@ -1895,16 +1872,3 @@ fi if test x$enable_checks = xno; then echo "NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance." 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 --git a/dbus/dbus-arch-deps.h.in b/dbus/dbus-arch-deps.h.in index 45952cfb..dfc3589e 100644 --- a/dbus/dbus-arch-deps.h.in +++ b/dbus/dbus-arch-deps.h.in @@ -31,7 +31,7 @@ DBUS_BEGIN_DECLS -#if @DBUS_HAVE_INT64@ +/* D-Bus no longer supports platforms with no 64-bit integer type. */ #define DBUS_HAVE_INT64 1 _DBUS_GNUC_EXTENSION typedef @DBUS_INT64_TYPE@ dbus_int64_t; _DBUS_GNUC_EXTENSION typedef unsigned @DBUS_INT64_TYPE@ dbus_uint64_t; @@ -39,12 +39,6 @@ _DBUS_GNUC_EXTENSION typedef unsigned @DBUS_INT64_TYPE@ dbus_uint64_t; #define DBUS_INT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION @DBUS_INT64_CONSTANT@) #define DBUS_UINT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION @DBUS_UINT64_CONSTANT@) -#else -#undef DBUS_HAVE_INT64 -#undef DBUS_INT64_CONSTANT -#undef DBUS_UINT64_CONSTANT -#endif - typedef @DBUS_INT32_TYPE@ dbus_int32_t; typedef unsigned @DBUS_INT32_TYPE@ dbus_uint32_t; diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index e9ffb9e2..c5a3c9b8 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -230,10 +230,8 @@ char** _dbus_dup_string_array (const char **array); #define _DBUS_INT_MIN _DBUS_INT32_MIN #define _DBUS_INT_MAX _DBUS_INT32_MAX #define _DBUS_UINT_MAX _DBUS_UINT32_MAX -#ifdef DBUS_HAVE_INT64 #define _DBUS_INT64_MAX DBUS_INT64_CONSTANT (0x7fffffffffffffff) #define _DBUS_UINT64_MAX DBUS_UINT64_CONSTANT (0xffffffffffffffff) -#endif #define _DBUS_ONE_KILOBYTE 1024 #define _DBUS_ONE_MEGABYTE 1024 * _DBUS_ONE_KILOBYTE #define _DBUS_ONE_HOUR_IN_MILLISECONDS (1000 * 60 * 60) diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index cdbac587..eafc2a9a 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -58,12 +58,10 @@ _DBUS_ASSERT_ALIGNMENT (dbus_bool_t, <=, 4); _DBUS_STATIC_ASSERT (sizeof (double) == 8); _DBUS_ASSERT_ALIGNMENT (double, <=, 8); -#ifdef DBUS_HAVE_INT64 _DBUS_STATIC_ASSERT (sizeof (dbus_int64_t) == 8); _DBUS_ASSERT_ALIGNMENT (dbus_int64_t, <=, 8); _DBUS_STATIC_ASSERT (sizeof (dbus_uint64_t) == 8); _DBUS_ASSERT_ALIGNMENT (dbus_uint64_t, <=, 8); -#endif _DBUS_STATIC_ASSERT (sizeof (DBusBasicValue) >= 8); /* The alignment of a DBusBasicValue might conceivably be > 8 because of the @@ -120,15 +118,10 @@ pack_8_octets (DBusBasicValue value, { _dbus_assert (_DBUS_ALIGN_ADDRESS (data, 8) == data); -#ifdef DBUS_HAVE_INT64 if ((byte_order) == DBUS_LITTLE_ENDIAN) *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_LE (value.u64); else *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_BE (value.u64); -#else - *(DBus8ByteStruct*)data = value.eight; - swap_8_octets ((DBusBasicValue*)data, byte_order); -#endif } /** @@ -146,65 +139,16 @@ _dbus_pack_uint32 (dbus_uint32_t value, pack_4_octets (value, byte_order, data); } -#ifndef DBUS_HAVE_INT64 -/* from ORBit */ -static void -swap_bytes (unsigned char *data, - unsigned int len) -{ - unsigned char *p1 = data; - unsigned char *p2 = data + len - 1; - - while (p1 < p2) - { - unsigned char tmp = *p1; - *p1 = *p2; - *p2 = tmp; - - --p2; - ++p1; - } -} -#endif /* !DBUS_HAVE_INT64 */ - static void swap_8_octets (DBusBasicValue *value, int byte_order) { if (byte_order != DBUS_COMPILER_BYTE_ORDER) { -#ifdef DBUS_HAVE_INT64 value->u64 = DBUS_UINT64_SWAP_LE_BE (value->u64); -#else - swap_bytes (&value->bytes, 8); -#endif } } -#if 0 -static DBusBasicValue -unpack_8_octets (int byte_order, - const unsigned char *data) -{ - DBusBasicValue r; - - _dbus_assert (_DBUS_ALIGN_ADDRESS (data, 8) == data); - _dbus_assert (sizeof (r) == 8); - -#ifdef DBUS_HAVE_INT64 - if (byte_order == DBUS_LITTLE_ENDIAN) - r.u64 = DBUS_UINT64_FROM_LE (*(dbus_uint64_t*)data); - else - r.u64 = DBUS_UINT64_FROM_BE (*(dbus_uint64_t*)data); -#else - r.eight = *(DBus8ByteStruct*)data; - swap_8_octets (&r, byte_order); -#endif - - return r; -} -#endif - #ifndef _dbus_unpack_uint16 /** * Unpacks a 16 bit unsigned integer from a data pointer @@ -601,15 +545,10 @@ _dbus_marshal_read_basic (const DBusString *str, { volatile dbus_uint64_t *vp = value; pos = _DBUS_ALIGN_VALUE (pos, 8); -#ifdef DBUS_HAVE_INT64 if (byte_order != DBUS_COMPILER_BYTE_ORDER) *vp = DBUS_UINT64_SWAP_LE_BE (*(dbus_uint64_t*)(str_data + pos)); else *vp = *(dbus_uint64_t*)(str_data + pos); -#else - *vp = *(DBus8ByteStruct*) (str_data + pos); - swap_8_octets (vp, byte_order); -#endif pos += 8; } break; @@ -965,11 +904,7 @@ _dbus_swap_array (unsigned char *data, { while (d != end) { -#ifdef DBUS_HAVE_INT64 *((dbus_uint64_t*)d) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)d)); -#else - swap_8_bytes ((DBusBasicValue*) d); -#endif d += 8; } } @@ -1674,12 +1609,10 @@ _dbus_marshal_test (void) unsigned char array1[5] = { 3, 4, 0, 1, 9 }; dbus_int16_t array2[3] = { 124, 457, 780 }; dbus_int32_t array4[3] = { 123, 456, 789 }; -#ifdef DBUS_HAVE_INT64 dbus_int64_t array8[3] = { DBUS_INT64_CONSTANT (0x123ffffffff), DBUS_INT64_CONSTANT (0x456ffffffff), DBUS_INT64_CONSTANT (0x789ffffffff) }; dbus_int64_t *v_ARRAY_INT64; -#endif unsigned char *v_ARRAY_BYTE; dbus_int16_t *v_ARRAY_INT16; dbus_uint16_t *v_ARRAY_UINT16; @@ -1735,7 +1668,6 @@ _dbus_marshal_test (void) MARSHAL_TEST (UINT32, DBUS_BIG_ENDIAN, 0x12345678); MARSHAL_TEST (UINT32, DBUS_LITTLE_ENDIAN, 0x12345678); -#ifdef DBUS_HAVE_INT64 /* Marshal signed integers */ MARSHAL_TEST (INT64, DBUS_BIG_ENDIAN, DBUS_INT64_CONSTANT (-0x123456789abc7)); MARSHAL_TEST (INT64, DBUS_LITTLE_ENDIAN, DBUS_INT64_CONSTANT (-0x123456789abc7)); @@ -1743,7 +1675,6 @@ _dbus_marshal_test (void) /* Marshal unsigned integers */ MARSHAL_TEST (UINT64, DBUS_BIG_ENDIAN, DBUS_UINT64_CONSTANT (0x123456789abc7)); MARSHAL_TEST (UINT64, DBUS_LITTLE_ENDIAN, DBUS_UINT64_CONSTANT (0x123456789abc7)); -#endif /* DBUS_HAVE_INT64 */ /* Marshal byte */ MARSHAL_TEST (BYTE, DBUS_BIG_ENDIAN, 5); @@ -1785,10 +1716,8 @@ _dbus_marshal_test (void) MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_BIG_ENDIAN, array1); MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_LITTLE_ENDIAN, array1); -#ifdef DBUS_HAVE_INT64 MARSHAL_TEST_FIXED_ARRAY (INT64, DBUS_BIG_ENDIAN, array8); MARSHAL_TEST_FIXED_ARRAY (INT64, DBUS_LITTLE_ENDIAN, array8); -#endif #if 0 @@ -1796,7 +1725,6 @@ _dbus_marshal_test (void) * FIXME restore the set/pack tests */ -#ifdef DBUS_HAVE_INT64 /* set/pack 64-bit integers */ _dbus_string_set_length (&str, 8); @@ -1867,7 +1795,6 @@ _dbus_marshal_test (void) _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) == _dbus_unpack_uint64 (DBUS_BIG_ENDIAN, _dbus_string_get_const_data (&str))); -#endif /* DBUS_HAVE_INT64 */ /* set/pack 32-bit integers */ _dbus_string_set_length (&str, 4); diff --git a/dbus/dbus-marshal-basic.h b/dbus/dbus-marshal-basic.h index 034fdaba..9df67cb8 100644 --- a/dbus/dbus-marshal-basic.h +++ b/dbus/dbus-marshal-basic.h @@ -57,8 +57,6 @@ #endif /* HAVE_BYTESWAP_H */ -#ifdef DBUS_HAVE_INT64 - #ifdef HAVE_BYTESWAP_H #define DBUS_UINT64_SWAP_LE_BE_CONSTANT(val) bswap_64(val) #else /* HAVE_BYTESWAP_H */ @@ -80,7 +78,6 @@ (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00ff000000000000)) >> 40) | \ (((dbus_uint64_t) (val) & \ (dbus_uint64_t) DBUS_UINT64_CONSTANT (0xff00000000000000)) >> 56))) -#endif /* DBUS_HAVE_INT64 */ #endif /* HAVE_BYTESWAP_H */ @@ -90,10 +87,8 @@ #define DBUS_UINT32_SWAP_LE_BE(val) (DBUS_UINT32_SWAP_LE_BE_CONSTANT (val)) #define DBUS_INT32_SWAP_LE_BE(val) ((dbus_int32_t)DBUS_UINT32_SWAP_LE_BE_CONSTANT (val)) -#ifdef DBUS_HAVE_INT64 -# define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) -# define DBUS_INT64_SWAP_LE_BE(val) ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) -#endif /* DBUS_HAVE_INT64 */ +#define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) +#define DBUS_INT64_SWAP_LE_BE(val) ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) #ifdef WORDS_BIGENDIAN @@ -105,12 +100,10 @@ # define DBUS_UINT32_TO_BE(val) ((dbus_uint32_t) (val)) # define DBUS_INT32_TO_LE(val) (DBUS_INT32_SWAP_LE_BE (val)) # define DBUS_UINT32_TO_LE(val) (DBUS_UINT32_SWAP_LE_BE (val)) -# ifdef DBUS_HAVE_INT64 -# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) (val)) -# define DBUS_UINT64_TO_BE(val) ((dbus_uint64_t) (val)) -# define DBUS_INT64_TO_LE(val) (DBUS_INT64_SWAP_LE_BE (val)) -# define DBUS_UINT64_TO_LE(val) (DBUS_UINT64_SWAP_LE_BE (val)) -# endif /* DBUS_HAVE_INT64 */ +# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) (val)) +# define DBUS_UINT64_TO_BE(val) ((dbus_uint64_t) (val)) +# define DBUS_INT64_TO_LE(val) (DBUS_INT64_SWAP_LE_BE (val)) +# define DBUS_UINT64_TO_LE(val) (DBUS_UINT64_SWAP_LE_BE (val)) #else /* WORDS_BIGENDIAN */ @@ -122,12 +115,10 @@ # define DBUS_UINT32_TO_LE(val) ((dbus_uint32_t) (val)) # define DBUS_INT32_TO_BE(val) ((dbus_int32_t) DBUS_UINT32_SWAP_LE_BE (val)) # define DBUS_UINT32_TO_BE(val) (DBUS_UINT32_SWAP_LE_BE (val)) -# ifdef DBUS_HAVE_INT64 -# define DBUS_INT64_TO_LE(val) ((dbus_int64_t) (val)) -# define DBUS_UINT64_TO_LE(val) ((dbus_uint64_t) (val)) -# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val)) -# define DBUS_UINT64_TO_BE(val) (DBUS_UINT64_SWAP_LE_BE (val)) -# endif /* DBUS_HAVE_INT64 */ +# define DBUS_INT64_TO_LE(val) ((dbus_int64_t) (val)) +# define DBUS_UINT64_TO_LE(val) ((dbus_uint64_t) (val)) +# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val)) +# define DBUS_UINT64_TO_BE(val) (DBUS_UINT64_SWAP_LE_BE (val)) #endif /* The transformation is symmetric, so the FROM just maps to the TO. */ @@ -139,12 +130,10 @@ #define DBUS_UINT32_FROM_LE(val) (DBUS_UINT32_TO_LE (val)) #define DBUS_INT32_FROM_BE(val) (DBUS_INT32_TO_BE (val)) #define DBUS_UINT32_FROM_BE(val) (DBUS_UINT32_TO_BE (val)) -#ifdef DBUS_HAVE_INT64 -# define DBUS_INT64_FROM_LE(val) (DBUS_INT64_TO_LE (val)) -# define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val)) -# define DBUS_INT64_FROM_BE(val) (DBUS_INT64_TO_BE (val)) -# define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val)) -#endif /* DBUS_HAVE_INT64 */ +#define DBUS_INT64_FROM_LE(val) (DBUS_INT64_TO_LE (val)) +#define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val)) +#define DBUS_INT64_FROM_BE(val) (DBUS_INT64_TO_BE (val)) +#define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val)) #ifdef DBUS_DISABLE_ASSERT #define _dbus_unpack_uint16(byte_order, data) \ diff --git a/dbus/dbus-marshal-byteswap.c b/dbus/dbus-marshal-byteswap.c index 22d7e22b..e6711be6 100644 --- a/dbus/dbus-marshal-byteswap.c +++ b/dbus/dbus-marshal-byteswap.c @@ -73,11 +73,7 @@ byteswap_body_helper (DBusTypeReader *reader, case DBUS_TYPE_DOUBLE: { p = _DBUS_ALIGN_ADDRESS (p, 8); -#ifdef DBUS_HAVE_INT64 *((dbus_uint64_t*)p) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)p)); -#else - _dbus_swap_array (p, 1, 8); -#endif p += 8; } break; diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c index 6d62983f..4a42b47e 100644 --- a/dbus/dbus-marshal-recursive-util.c +++ b/dbus/dbus-marshal-recursive-util.c @@ -34,13 +34,7 @@ static void basic_value_zero (DBusBasicValue *value) { - -#ifdef DBUS_HAVE_INT64 value->u64 = 0; -#else - value->eight.first32 = 0; - value->eight.second32 = 0; -#endif } static dbus_bool_t @@ -56,12 +50,7 @@ basic_value_equal (int type, } else { -#ifdef DBUS_HAVE_INT64 return lhs->u64 == rhs->u64; -#else - return lhs->eight.first32 == rhs->eight.first32 && - lhs->eight.second32 == rhs->eight.second32; -#endif } } @@ -2337,7 +2326,6 @@ int32_read_multi (TestTypeNode *node, return TRUE; } -#ifdef DBUS_HAVE_INT64 static dbus_int64_t int64_from_seed (int seed) { @@ -2351,7 +2339,6 @@ int64_from_seed (int seed) return v; } -#endif static dbus_bool_t int64_write_value (TestTypeNode *node, @@ -2359,7 +2346,6 @@ int64_write_value (TestTypeNode *node, DBusTypeWriter *writer, int seed) { -#ifdef DBUS_HAVE_INT64 /* also used for uint64 */ dbus_int64_t v; @@ -2368,9 +2354,6 @@ int64_write_value (TestTypeNode *node, return _dbus_type_writer_write_basic (writer, node->klass->typecode, &v); -#else - return TRUE; -#endif } static dbus_bool_t @@ -2378,7 +2361,6 @@ int64_read_value (TestTypeNode *node, DBusTypeReader *reader, int seed) { -#ifdef DBUS_HAVE_INT64 /* also used for uint64 */ dbus_int64_t v; @@ -2390,9 +2372,6 @@ int64_read_value (TestTypeNode *node, _dbus_assert (v == int64_from_seed (seed)); return TRUE; -#else - return TRUE; -#endif } static dbus_bool_t @@ -2401,7 +2380,6 @@ int64_set_value (TestTypeNode *node, DBusTypeReader *realign_root, int seed) { -#ifdef DBUS_HAVE_INT64 /* also used for uint64 */ dbus_int64_t v; @@ -2410,9 +2388,6 @@ int64_set_value (TestTypeNode *node, return _dbus_type_reader_set_basic (reader, &v, realign_root); -#else - return TRUE; -#endif } #define MAX_SAMPLE_STRING_LEN 10 diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index a5ce5106..fb7e2600 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -754,10 +754,8 @@ message_iter_test (DBusMessage *message) dbus_uint16_t v_UINT16; dbus_int32_t v_INT32; dbus_uint32_t v_UINT32; -#ifdef DBUS_HAVE_INT64 dbus_int64_t v_INT64; dbus_uint64_t v_UINT64; -#endif unsigned char v_BYTE; dbus_bool_t v_BOOLEAN; @@ -830,14 +828,12 @@ verify_test_message (DBusMessage *message) int our_uint32_array_len; dbus_int32_t *our_int32_array = (void*)0xdeadbeef; int our_int32_array_len; -#ifdef DBUS_HAVE_INT64 dbus_int64_t our_int64; dbus_uint64_t our_uint64; dbus_int64_t *our_uint64_array = (void*)0xdeadbeef; int our_uint64_array_len; const dbus_int64_t *our_int64_array = (void*)0xdeadbeef; int our_int64_array_len; -#endif const double *our_double_array = (void*)0xdeadbeef; int our_double_array_len; const unsigned char *our_byte_array = (void*)0xdeadbeef; @@ -854,10 +850,8 @@ verify_test_message (DBusMessage *message) DBUS_TYPE_UINT16, &our_uint16, DBUS_TYPE_INT32, &our_int, DBUS_TYPE_UINT32, &our_uint, -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_INT64, &our_int64, DBUS_TYPE_UINT64, &our_uint64, -#endif DBUS_TYPE_STRING, &our_str, DBUS_TYPE_DOUBLE, &our_double, DBUS_TYPE_BOOLEAN, &our_bool, @@ -867,12 +861,10 @@ verify_test_message (DBusMessage *message) &our_uint32_array, &our_uint32_array_len, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &our_int32_array, &our_int32_array_len, -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, &our_uint64_array, &our_uint64_array_len, DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, &our_int64_array, &our_int64_array_len, -#endif DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, &our_double_array, &our_double_array_len, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, @@ -900,12 +892,10 @@ verify_test_message (DBusMessage *message) if (our_uint != 0x12300042) _dbus_assert_not_reached ("uints differ!"); -#ifdef DBUS_HAVE_INT64 if (our_int64 != DBUS_INT64_CONSTANT (-0x123456789abcd)) _dbus_assert_not_reached ("64-bit integers differ!"); if (our_uint64 != DBUS_UINT64_CONSTANT (0x123456789abcd)) _dbus_assert_not_reached ("64-bit unsigned integers differ!"); -#endif v_DOUBLE = 3.14159; if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double, v_DOUBLE)) @@ -937,7 +927,6 @@ verify_test_message (DBusMessage *message) our_int32_array[3] != -0x45678123) _dbus_assert_not_reached ("int array differs"); -#ifdef DBUS_HAVE_INT64 if (our_uint64_array_len != 4 || our_uint64_array[0] != 0x12345678 || our_uint64_array[1] != 0x23456781 || @@ -951,7 +940,6 @@ verify_test_message (DBusMessage *message) our_int64_array[2] != 0x34567812 || our_int64_array[3] != -0x45678123) _dbus_assert_not_reached ("int64 array differs"); -#endif /* DBUS_HAVE_INT64 */ if (our_double_array_len != 3) _dbus_assert_not_reached ("double array had wrong length"); @@ -1025,14 +1013,12 @@ _dbus_message_test (const char *test_data_dir) { 0x12345678, -0x23456781, 0x34567812, -0x45678123 }; const dbus_uint32_t *v_ARRAY_UINT32 = our_uint32_array; const dbus_int32_t *v_ARRAY_INT32 = our_int32_array; -#ifdef DBUS_HAVE_INT64 const dbus_uint64_t our_uint64_array[] = { 0x12345678, 0x23456781, 0x34567812, 0x45678123 }; const dbus_int64_t our_int64_array[] = { 0x12345678, -0x23456781, 0x34567812, -0x45678123 }; const dbus_uint64_t *v_ARRAY_UINT64 = our_uint64_array; const dbus_int64_t *v_ARRAY_INT64 = our_int64_array; -#endif const char *our_string_array[] = { "Foo", "bar", "", "woo woo woo woo" }; const char **v_ARRAY_STRING = our_string_array; const double our_double_array[] = { 0.1234, 9876.54321, -300.0 }; @@ -1049,10 +1035,8 @@ _dbus_message_test (const char *test_data_dir) dbus_uint16_t v_UINT16; dbus_int32_t v_INT32; dbus_uint32_t v_UINT32; -#ifdef DBUS_HAVE_INT64 dbus_int64_t v_INT64; dbus_uint64_t v_UINT64; -#endif unsigned char v_BYTE; unsigned char v2_BYTE; dbus_bool_t v_BOOLEAN; @@ -1201,10 +1185,8 @@ _dbus_message_test (const char *test_data_dir) v_UINT16 = 0x123; v_INT32 = -0x12345678; v_UINT32 = 0x12300042; -#ifdef DBUS_HAVE_INT64 v_INT64 = DBUS_INT64_CONSTANT (-0x123456789abcd); v_UINT64 = DBUS_UINT64_CONSTANT (0x123456789abcd); -#endif v_STRING = "Test string"; v_DOUBLE = 3.14159; v_BOOLEAN = TRUE; @@ -1219,10 +1201,8 @@ _dbus_message_test (const char *test_data_dir) DBUS_TYPE_UINT16, &v_UINT16, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_UINT32, &v_UINT32, -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_INT64, &v_INT64, DBUS_TYPE_UINT64, &v_UINT64, -#endif DBUS_TYPE_STRING, &v_STRING, DBUS_TYPE_DOUBLE, &v_DOUBLE, DBUS_TYPE_BOOLEAN, &v_BOOLEAN, @@ -1232,12 +1212,10 @@ _dbus_message_test (const char *test_data_dir) _DBUS_N_ELEMENTS (our_uint32_array), DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &v_ARRAY_INT32, _DBUS_N_ELEMENTS (our_int32_array), -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, &v_ARRAY_UINT64, _DBUS_N_ELEMENTS (our_uint64_array), DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, &v_ARRAY_INT64, _DBUS_N_ELEMENTS (our_int64_array), -#endif DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, &v_ARRAY_DOUBLE, _DBUS_N_ELEMENTS (our_double_array), DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &v_ARRAY_BYTE, @@ -1254,10 +1232,8 @@ _dbus_message_test (const char *test_data_dir) sig[i++] = DBUS_TYPE_UINT16; sig[i++] = DBUS_TYPE_INT32; sig[i++] = DBUS_TYPE_UINT32; -#ifdef DBUS_HAVE_INT64 sig[i++] = DBUS_TYPE_INT64; sig[i++] = DBUS_TYPE_UINT64; -#endif sig[i++] = DBUS_TYPE_STRING; sig[i++] = DBUS_TYPE_DOUBLE; sig[i++] = DBUS_TYPE_BOOLEAN; @@ -1267,12 +1243,10 @@ _dbus_message_test (const char *test_data_dir) sig[i++] = DBUS_TYPE_UINT32; sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_INT32; -#ifdef DBUS_HAVE_INT64 sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_UINT64; sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_INT64; -#endif sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_DOUBLE; sig[i++] = DBUS_TYPE_ARRAY; diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index 81140a6e..c4e2e7fc 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -938,29 +938,9 @@ _dbus_string_append (DBusString *str, #define ASSIGN_4_OCTETS(p, octets) \ *((dbus_uint32_t*)(p)) = *((dbus_uint32_t*)(octets)); -#ifdef DBUS_HAVE_INT64 /** assign 8 bytes from one string to another */ #define ASSIGN_8_OCTETS(p, octets) \ *((dbus_uint64_t*)(p)) = *((dbus_uint64_t*)(octets)); -#else -/** assign 8 bytes from one string to another */ -#define ASSIGN_8_OCTETS(p, octets) \ -do { \ - unsigned char *b; \ - \ - b = p; \ - \ - *b++ = octets[0]; \ - *b++ = octets[1]; \ - *b++ = octets[2]; \ - *b++ = octets[3]; \ - *b++ = octets[4]; \ - *b++ = octets[5]; \ - *b++ = octets[6]; \ - *b++ = octets[7]; \ - _dbus_assert (b == p + 8); \ -} while (0) -#endif /* DBUS_HAVE_INT64 */ /** * Inserts 2 bytes aligned on a 2 byte boundary diff --git a/dbus/dbus-types.h b/dbus/dbus-types.h index 57fc586a..021a55af 100644 --- a/dbus/dbus-types.h +++ b/dbus/dbus-types.h @@ -79,43 +79,23 @@ typedef dbus_uint32_t dbus_bool_t; /** * @typedef dbus_uint64_t * - * A 64-bit unsigned integer on all platforms that support it. - * If supported, #DBUS_HAVE_INT64 will be defined. - * - * C99 requires a 64-bit type and most likely all interesting - * compilers support one. GLib for example flat-out requires - * a 64-bit type. - * - * You probably want to just assume #DBUS_HAVE_INT64 is always defined. + * A 64-bit unsigned integer. */ /** * @typedef dbus_int64_t * - * A 64-bit signed integer on all platforms that support it. - * If supported, #DBUS_HAVE_INT64 will be defined. - * - * C99 requires a 64-bit type and most likely all interesting - * compilers support one. GLib for example flat-out requires - * a 64-bit type. - * - * You probably want to just assume #DBUS_HAVE_INT64 is always defined. + * A 64-bit signed integer. */ /** * @def DBUS_HAVE_INT64 * - * Defined if 64-bit integers are available. Will be defined - * on any platform you care about, unless you care about - * some truly ancient UNIX, or some bizarre embedded platform. + * Always defined. * - * C99 requires a 64-bit type and most likely all interesting - * compilers support one. GLib for example flat-out requires - * a 64-bit type. - * - * You should feel comfortable ignoring this macro and just using - * int64 unconditionally. - * + * In older libdbus versions, this would be undefined if there was no + * 64-bit integer type on that platform. libdbus no longer supports + * such platforms. */ /** @@ -136,7 +116,7 @@ typedef dbus_uint32_t dbus_bool_t; /** * An 8-byte struct you could use to access int64 without having - * int64 support + * int64 support. Use #dbus_int64_t or #dbus_uint64_t instead. */ typedef struct { @@ -162,10 +142,8 @@ typedef union dbus_int32_t i32; /**< as int32 */ dbus_uint32_t u32; /**< as int32 */ dbus_bool_t bool_val; /**< as boolean */ -#ifdef DBUS_HAVE_INT64 dbus_int64_t i64; /**< as int64 */ dbus_uint64_t u64; /**< as int64 */ -#endif DBus8ByteStruct eight; /**< as 8-byte struct */ double dbl; /**< as double */ unsigned char byt; /**< as byte */ -- cgit v1.2.1 From 6dea6c050dd2353678126138c0bdaebbfdc33b05 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 15:03:46 +0100 Subject: fix NEWS mis-merge --- NEWS | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 7dae9f94..b79d57cd 100644 --- a/NEWS +++ b/NEWS @@ -18,21 +18,6 @@ Build-time configuration changes: assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent with the Autotools build system. (fd.o #66142, Chengwei Yang) -• Fix a NULL pointer dereference on an unlikely error path - (fd.o #69327, Sviatoslav Chagaev) - -• Unix-specific: - · If accept4() fails with EINVAL, as it can on older Linux kernels - with newer glibc, try accept() instead of going into a busy-loop. - (fd.o #69026, Chengwei Yang) - · If socket() or socketpair() fails with EINVAL or EPROTOTYPE, - for instance on Hurd or older Linux with a new glibc, try without - SOCK_CLOEXEC. (fd.o #69073; Pino Toscano, Chengwei Yang) - · Fix a file descriptor leak on an error code path. - (fd.o #69182, Sviatoslav Chagaev) - · Fix compilation if writev() is unavailable (fd.o #69409, - Vasiliy Balyasnyy) - Dependencies: • GNU make is now (documented to be) required. (fd.o #48277, Simon McVittie) @@ -104,6 +89,9 @@ Fixes: • Make "make -j check" work (fd.o #68852, Simon McVittie) +• Fix a NULL pointer dereference on an unlikely error path + (fd.o #69327, Sviatoslav Chagaev) + • Unix-specific: · If accept4() fails with EINVAL, as it can on older Linux kernels with newer glibc, try accept() instead of going into a busy-loop. @@ -119,6 +107,8 @@ Fixes: · Don't fail the autolaunch test if there is no DISPLAY (fd.o #40352, Simon) · Use dbus-launch from the builddir for testing, not the installed copy (fd.o #37849, Chengwei Yang) + · Fix compilation if writev() is unavailable (fd.o #69409, + Vasiliy Balyasnyy) • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' -- cgit v1.2.1 From 9577e33c89211599e735b5b054ac1d7b84fb2bd8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 15:26:41 +0100 Subject: Revert "Fix an incorrect sizeof." to fix attribution This reverts commit 3c1938180bdca8fc658907f6f692186be2b81b77. --- tools/dbus-monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index 7382f4bf..a4b54782 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -310,7 +310,7 @@ main (int argc, char *argv[]) filters = (char **) realloc (filters, numFilters * sizeof (char *)); if (filters == NULL) oom ("adding a new filter slot"); - filters[j] = (char *) malloc (filter_len); + filters[j] = (char *) malloc (filter_len * sizeof (char *)); if (filters[j] == NULL) oom ("adding a new filter"); snprintf (filters[j], filter_len, "%s,%s", EAVESDROPPING_RULE, arg); -- cgit v1.2.1 From 990fd63f4ef5453ccfca54363cff0fa1d8547007 Mon Sep 17 00:00:00 2001 From: Sviatoslav Chagaev Date: Mon, 16 Sep 2013 12:43:40 +0100 Subject: Fix an incorrect sizeof. Fix an incorrect sizeof which leads to allocation of more memory than actually needed. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69329 [elide redundant "* sizeof (char)" which is 1 by definition -smcv] Reviewed-by: Simon McVittie --- tools/dbus-monitor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index a4b54782..7382f4bf 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -310,7 +310,7 @@ main (int argc, char *argv[]) filters = (char **) realloc (filters, numFilters * sizeof (char *)); if (filters == NULL) oom ("adding a new filter slot"); - filters[j] = (char *) malloc (filter_len * sizeof (char *)); + filters[j] = (char *) malloc (filter_len); if (filters[j] == NULL) oom ("adding a new filter"); snprintf (filters[j], filter_len, "%s,%s", EAVESDROPPING_RULE, arg); -- cgit v1.2.1 From 4d32787e9926627ef75bb607d8cd9fe2b332a802 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 15:30:13 +0100 Subject: NEWS --- NEWS | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b79d57cd..e87b7e4b 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,9 @@ Build-time configuration changes: Dependencies: +• Platforms with no 64-bit integer type are no longer supported. + (fd.o #65429, Simon McVittie) + • GNU make is now (documented to be) required. (fd.o #48277, Simon McVittie) • Full test coverage no longer requires dbus-glib, although the tests do not @@ -56,6 +59,9 @@ Fixes: • Avoid an infinite busy-loop if a signal interrupts waitpid() (fd.o #68945, Simon McVittie) +• Clean up memory for parent nodes when objects are unexported + (fd.o #60176, Thomas Fitzsimmons) + • Make dbus_connection_set_route_peer_messages(x, FALSE) behave as documented. Previously, it assumed its second parameter was TRUE. (fd.o #69165, Chengwei Yang) @@ -92,6 +98,12 @@ Fixes: • Fix a NULL pointer dereference on an unlikely error path (fd.o #69327, Sviatoslav Chagaev) +• Improve valgrind memory pool tracking (fd.o #69326, + Sviatoslav Chagaev) + +• Don't over-allocate memory in dbus-monitor (fd.o #69329, + Sviatoslav Chagaev) + • Unix-specific: · If accept4() fails with EINVAL, as it can on older Linux kernels with newer glibc, try accept() instead of going into a busy-loop. @@ -117,6 +129,8 @@ Fixes: Windows XP via the undocumented AllocateAndGetTcpExTableFromStack function (fd.o #66060, Ralf Habacker) · Fix insufficient dependency-tracking (fd.o #68505, Simon McVittie) + · Don't include wspiapi.h, fixing a compiler warning (fd.o #68852, + Simon McVittie) • Internal changes: · add DBUS_ENABLE_ASSERT, DBUS_ENABLE_CHECKS for less confusing @@ -124,7 +138,8 @@ Fixes: · improve verbose-mode output (fd.o #63047, Colin Walters) · consolidate Autotools and CMake build (fd.o #64875, Ralf Habacker) · fix various unused variables, unusual build configurations - etc. (fd.o #65712, #65990, #66005, #66257, #69165; Chengwei Yang) + etc. (fd.o #65712, #65990, #66005, #66257, #69165, #69410; + Chengwei Yang, Vasiliy Balyasnyy) D-Bus 1.7.4 (2013-06-13) == -- cgit v1.2.1 From 4d869cf5c2a3d763c475a40cfba69564385fdec4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 18:39:18 +0100 Subject: Remove BSD-style LOCAL_CREDS support It appears that this regressed back in 2009 (commit 7bf132c7) and doesn't compile. Also, with patches from Matt Fischer to make it compile again on QNX, it compiles but doesn't actually work on NetBSD, which was the platform for which this code was added. This might be for the reasons described in . NetBSD pkgsrc has a large unsubmitted patch to use LOCAL_PEEREID, which is analogous to Linux/OpenBSD SO_PEERCRED. So, I think we can safely assume that nobody is relying on this: either they implement one of our many other supported credentials-passing mechanisms, or they're patching it locally anyway. LOCAL_CREDS is not actually very good - it's awkward to use, and doesn't provide the pid, only the uid. Of the platforms known to implement it, QNX and NetBSD both have getpeereid() which provides just as much information, while FreeBSD and Dragonfly BSD both have SCM_CREDS which provides the pid too. So, let's just get rid of it. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60340 Reviewed-by: Colin Walters --- dbus/dbus-sysdeps-unix.c | 72 ++---------------------------------------------- 1 file changed, 2 insertions(+), 70 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 09ab92ab..2b667868 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -974,39 +974,6 @@ _dbus_connect_exec (const char *path, return fds[0]; } -/** - * Enables or disables the reception of credentials on the given socket during - * the next message transmission. This is only effective if the #LOCAL_CREDS - * system feature exists, in which case the other side of the connection does - * not have to do anything special to send the credentials. - * - * @param fd socket on which to change the #LOCAL_CREDS flag. - * @param on whether to enable or disable the #LOCAL_CREDS flag. - */ -static dbus_bool_t -_dbus_set_local_creds (int fd, dbus_bool_t on) -{ - dbus_bool_t retval = TRUE; - -#if defined(HAVE_CMSGCRED) - /* NOOP just to make sure only one codepath is used - * and to prefer CMSGCRED - */ -#elif defined(LOCAL_CREDS) - int val = on ? 1 : 0; - if (setsockopt (fd, 0, LOCAL_CREDS, &val, sizeof (val)) < 0) - { - _dbus_verbose ("Unable to set LOCAL_CREDS socket option on fd %d\n", fd); - retval = FALSE; - } - else - _dbus_verbose ("LOCAL_CREDS %s for further messages on fd %d\n", - on ? "enabled" : "disabled", fd); -#endif - - return retval; -} - /** * Creates a socket and binds it to the given path, * then listens on the socket. The socket is @@ -1132,15 +1099,6 @@ _dbus_listen_unix_socket (const char *path, return -1; } - if (!_dbus_set_local_creds (listen_fd, TRUE)) - { - dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to enable LOCAL_CREDS on socket \"%s\": %s", - path, _dbus_strerror (errno)); - close (listen_fd); - return -1; - } - if (!_dbus_set_fd_nonblocking (listen_fd, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); @@ -1226,14 +1184,6 @@ _dbus_listen_systemd_sockets (int **fds, for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++) { - if (!_dbus_set_local_creds (fd, TRUE)) - { - dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to enable LOCAL_CREDS on systemd socket: %s", - _dbus_strerror (errno)); - goto fail; - } - if (!_dbus_set_fd_nonblocking (fd, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); @@ -1692,12 +1642,6 @@ _dbus_read_credentials_socket (int client_fd, struct cmsghdr hdr; char cred[CMSG_SPACE (sizeof (struct cmsgcred))]; } cmsg; - -#elif defined(LOCAL_CREDS) - struct { - struct cmsghdr hdr; - struct sockcred cred; - } cmsg; #endif uid_read = DBUS_UID_UNSET; @@ -1715,12 +1659,6 @@ _dbus_read_credentials_socket (int client_fd, _dbus_credentials_clear (credentials); - /* Systems supporting LOCAL_CREDS are configured to have this feature - * enabled (if it does not conflict with HAVE_CMSGCRED) prior accepting - * the connection. Therefore, the received message must carry the - * credentials information without doing anything special. - */ - iov.iov_base = &buf; iov.iov_len = 1; @@ -1728,7 +1666,7 @@ _dbus_read_credentials_socket (int client_fd, msg.msg_iov = &iov; msg.msg_iovlen = 1; -#if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS) +#if defined(HAVE_CMSGCRED) _DBUS_ZERO(cmsg); msg.msg_control = (caddr_t) &cmsg; msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); @@ -1768,7 +1706,7 @@ _dbus_read_credentials_socket (int client_fd, return FALSE; } -#if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS) +#if defined(HAVE_CMSGCRED) if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)) || cmsg.hdr.cmsg_type != SCM_CREDS) { @@ -1806,12 +1744,6 @@ _dbus_read_credentials_socket (int client_fd, cred = (struct cmsgcred *) CMSG_DATA (&cmsg.hdr); pid_read = cred->cmcred_pid; uid_read = cred->cmcred_euid; -#elif defined(LOCAL_CREDS) - pid_read = DBUS_PID_UNSET; - uid_read = cmsg.cred.sc_uid; - /* Since we have already got the credentials from this socket, we can - * disable its LOCAL_CREDS flag if it was ever set. */ - _dbus_set_local_creds (client_fd, FALSE); #elif defined(HAVE_GETPEEREID) uid_t euid; gid_t egid; -- cgit v1.2.1 From 1da53c6d4a72061567430f4ab6b51f1b7fe1079e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 18:50:40 +0100 Subject: _dbus_read_credentials_socket: document where we use each mechanism Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60340 Reviewed-by: Colin Walters --- dbus/dbus-sysdeps-unix.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 2b667868..0a2b311d 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1720,6 +1720,14 @@ _dbus_read_credentials_socket (int client_fd, { #ifdef SO_PEERCRED + /* Supported by at least Linux and OpenBSD, with minor differences. + * + * This mechanism passes the process ID through and does not require + * the peer's cooperation, so we prefer it over all others. Notably, + * Linux also supports SCM_CREDENTIALS, which is similar to FreeBSD + * SCM_CREDS; it's implemented in GIO, but we don't use it in dbus at all, + * because this is much less fragile. + */ #ifdef __OpenBSD__ struct sockpeercred cr; #else @@ -1739,12 +1747,41 @@ _dbus_read_credentials_socket (int client_fd, cr_len, (int) sizeof (cr), _dbus_strerror (errno)); } #elif defined(HAVE_CMSGCRED) + /* We only check for HAVE_CMSGCRED, but we're really assuming that the + * presence of that struct implies SCM_CREDS. Supported by at least + * FreeBSD and DragonflyBSD. + * + * This mechanism requires the peer to help us (it has to send us a + * SCM_CREDS message) but it does pass the process ID through, + * which makes it better than getpeereid(). + */ struct cmsgcred *cred; cred = (struct cmsgcred *) CMSG_DATA (&cmsg.hdr); pid_read = cred->cmcred_pid; uid_read = cred->cmcred_euid; + + /* ---------------------------------------------------------------- + * When adding new mechanisms, please add them above this point + * if they support passing the process ID through, or below if not. + * ---------------------------------------------------------------- */ + #elif defined(HAVE_GETPEEREID) + /* getpeereid() originates from D.J. Bernstein and is fairly + * widely-supported. According to a web search, it might be present in + * any/all of: + * + * - AIX? + * - Blackberry? + * - Cygwin + * - FreeBSD 4.6+ (but we prefer SCM_CREDS: it carries the pid) + * - Mac OS X + * - Minix 3.1.8+ + * - MirBSD? + * - NetBSD 5.0+ (but LOCAL_PEEREID would be better: it carries the pid) + * - OpenBSD 3.0+ (but we prefer SO_PEERCRED: it carries the pid) + * - QNX? + */ uid_t euid; gid_t egid; if (getpeereid (client_fd, &euid, &egid) == 0) @@ -1756,6 +1793,9 @@ _dbus_read_credentials_socket (int client_fd, _dbus_verbose ("Failed to getpeereid() credentials: %s\n", _dbus_strerror (errno)); } #elif defined(HAVE_GETPEERUCRED) + /* Supported in at least Solaris >= 10. It should probably be higher + * up this list, because it carries the pid and we use this code path + * for audit data. */ ucred_t * ucred = NULL; if (getpeerucred (client_fd, &ucred) == 0) { @@ -1799,7 +1839,7 @@ _dbus_read_credentials_socket (int client_fd, } if (ucred != NULL) ucred_free (ucred); -#else /* !SO_PEERCRED && !HAVE_CMSGCRED && !HAVE_GETPEEREID && !HAVE_GETPEERUCRED */ +#else /* no supported mechanism */ _dbus_verbose ("Socket credentials not supported on this OS\n"); #endif } -- cgit v1.2.1 From 5ecbe018a07dfd5b1cce5eb0e431f7a5984517c7 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 19:18:10 +0100 Subject: bus-test: only expect GetConnectionUnixProcessID to succeed sometimes On platforms that use getpeereid(), this can't work. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60340 Reviewed-by: Colin Walters --- bus/dispatch.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bus/dispatch.c b/bus/dispatch.c index 35a4b72b..5fc0d112 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -1307,9 +1307,15 @@ check_get_connection_unix_process_id (BusContext *context, #endif else { +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__linux__) || \ + defined(__OpenBSD__) warn_unexpected (connection, message, "not this error"); goto out; +#else + _dbus_verbose ("does not support GetConnectionUnixProcessID but perhaps that's OK?\n"); +#endif } } else -- cgit v1.2.1 From 5212ea55c713f0b63874950de287059c87110873 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 18:51:34 +0100 Subject: Prefer getpeerucred() over getpeereid() if a platform has both We want the process ID, and getpeerucred() provides that. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60340 Reviewed-by: Colin Walters --- dbus/dbus-sysdeps-unix.c | 63 ++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 31 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 0a2b311d..17c8411c 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1761,37 +1761,6 @@ _dbus_read_credentials_socket (int client_fd, pid_read = cred->cmcred_pid; uid_read = cred->cmcred_euid; - /* ---------------------------------------------------------------- - * When adding new mechanisms, please add them above this point - * if they support passing the process ID through, or below if not. - * ---------------------------------------------------------------- */ - -#elif defined(HAVE_GETPEEREID) - /* getpeereid() originates from D.J. Bernstein and is fairly - * widely-supported. According to a web search, it might be present in - * any/all of: - * - * - AIX? - * - Blackberry? - * - Cygwin - * - FreeBSD 4.6+ (but we prefer SCM_CREDS: it carries the pid) - * - Mac OS X - * - Minix 3.1.8+ - * - MirBSD? - * - NetBSD 5.0+ (but LOCAL_PEEREID would be better: it carries the pid) - * - OpenBSD 3.0+ (but we prefer SO_PEERCRED: it carries the pid) - * - QNX? - */ - uid_t euid; - gid_t egid; - if (getpeereid (client_fd, &euid, &egid) == 0) - { - uid_read = euid; - } - else - { - _dbus_verbose ("Failed to getpeereid() credentials: %s\n", _dbus_strerror (errno)); - } #elif defined(HAVE_GETPEERUCRED) /* Supported in at least Solaris >= 10. It should probably be higher * up this list, because it carries the pid and we use this code path @@ -1839,6 +1808,38 @@ _dbus_read_credentials_socket (int client_fd, } if (ucred != NULL) ucred_free (ucred); + + /* ---------------------------------------------------------------- + * When adding new mechanisms, please add them above this point + * if they support passing the process ID through, or below if not. + * ---------------------------------------------------------------- */ + +#elif defined(HAVE_GETPEEREID) + /* getpeereid() originates from D.J. Bernstein and is fairly + * widely-supported. According to a web search, it might be present in + * any/all of: + * + * - AIX? + * - Blackberry? + * - Cygwin + * - FreeBSD 4.6+ (but we prefer SCM_CREDS: it carries the pid) + * - Mac OS X + * - Minix 3.1.8+ + * - MirBSD? + * - NetBSD 5.0+ (but LOCAL_PEEREID would be better: it carries the pid) + * - OpenBSD 3.0+ (but we prefer SO_PEERCRED: it carries the pid) + * - QNX? + */ + uid_t euid; + gid_t egid; + if (getpeereid (client_fd, &euid, &egid) == 0) + { + uid_read = euid; + } + else + { + _dbus_verbose ("Failed to getpeereid() credentials: %s\n", _dbus_strerror (errno)); + } #else /* no supported mechanism */ _dbus_verbose ("Socket credentials not supported on this OS\n"); #endif -- cgit v1.2.1 From 17fcbf45181e7d864631b9e714f7a7b72e2b006c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 13 Sep 2013 19:01:04 +0100 Subject: _dbus_read_credentials_socket: warn or fail at compile time if no support On a whitelist of OSs known to have working credentials-passing (currently FreeBSD, Linux, OpenBSD and NetBSD), it would be a regression for us to not have credentials-passing, so fail hard. On other OSs, raise a warning, which is not normally fatal but will alert developers on those platforms. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60340 Reviewed-by: Colin Walters --- dbus/dbus-sysdeps-unix.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 17c8411c..07080045 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1841,6 +1841,21 @@ _dbus_read_credentials_socket (int client_fd, _dbus_verbose ("Failed to getpeereid() credentials: %s\n", _dbus_strerror (errno)); } #else /* no supported mechanism */ + +#warning Socket credentials not supported on this Unix OS +#warning Please tell https://bugs.freedesktop.org/enter_bug.cgi?product=DBus + + /* Please add other operating systems known to support at least one of + * the mechanisms above to this list, keeping alphabetical order. + * Everything not in this list is best-effort. + */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__linux__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) +# error Credentials passing not working on this OS is a regression! +#endif + _dbus_verbose ("Socket credentials not supported on this OS\n"); #endif } -- cgit v1.2.1 From c91305ff271b8f1b8a86aae208f95107a3e56994 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 23 Sep 2013 11:26:08 +0100 Subject: NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index e87b7e4b..0786eaeb 100644 --- a/NEWS +++ b/NEWS @@ -121,6 +121,9 @@ Fixes: (fd.o #37849, Chengwei Yang) · Fix compilation if writev() is unavailable (fd.o #69409, Vasiliy Balyasnyy) + · Remove broken support for LOCAL_CREDS credentials passing, and + document where each credential-passing scheme is used (fd.o #60340, + Simon McVittie) • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' -- cgit v1.2.1 From 3984f7d2b607a1cdd9a9fa6148e9c24b8db5d0e9 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 25 Sep 2013 14:09:19 +0800 Subject: Use 'chmod' instead of 'chmod -c' chmod -c is not available on *BSD system, and '-v' is not available on OpenBSD, so just execute chmod without any option. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=35881 Reviewed-by: Simon McVittie --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index b049f4ef..5d02a179 100755 --- a/autogen.sh +++ b/autogen.sh @@ -16,7 +16,7 @@ DIE=0 if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then echo "Activating pre-commit hook." cp -av .git/hooks/pre-commit.sample .git/hooks/pre-commit - chmod -c +x .git/hooks/pre-commit + chmod +x .git/hooks/pre-commit fi (autoconf --version) < /dev/null > /dev/null 2>&1 || { -- cgit v1.2.1 From 6f47672f84b8ccfe7642aca1fd43eedcf2ef18f6 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 25 Sep 2013 14:17:21 +0800 Subject: Use 'cp' instead of 'cp -av' to fix portable issue Neither '-a' nor '-v' of 'cp' is available on OpenBSD 5.3, so use 'cp' instead to fix portable issue. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69789 Reviewed-by: Simon McVittie --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index 5d02a179..b9046879 100755 --- a/autogen.sh +++ b/autogen.sh @@ -15,7 +15,7 @@ DIE=0 if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then echo "Activating pre-commit hook." - cp -av .git/hooks/pre-commit.sample .git/hooks/pre-commit + cp .git/hooks/pre-commit.sample .git/hooks/pre-commit chmod +x .git/hooks/pre-commit fi -- cgit v1.2.1 From d56ca38ef68fc0271a844c75559370d61f4c97b6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 25 Sep 2013 13:43:22 +0100 Subject: NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 0786eaeb..31b3fb0a 100644 --- a/NEWS +++ b/NEWS @@ -124,6 +124,8 @@ Fixes: · Remove broken support for LOCAL_CREDS credentials passing, and document where each credential-passing scheme is used (fd.o #60340, Simon McVittie) + · Make autogen.sh work on *BSD by not assuming GNU coreutils functionality + (fd.o #35881, #69787; Chengwei Yang) • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' -- cgit v1.2.1 From fd5271f83996956ee326441f450ffd5e5e8e91d0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 26 Sep 2013 17:35:36 +0800 Subject: Fix build on NetBSD 6.1.1 with gcc 4.5.3 There are two build failure on NetBSD 6.1.1 with gcc 4.5.3, the first one is char to int, warning treated as error. The second one is a mismatch between format string and arguments. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69842 [adjusted commit message -smcv] Reviewed-by: Simon McVittie --- tools/dbus-launch.c | 2 +- tools/dbus-monitor.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 14fa226d..b071fcc5 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -132,7 +132,7 @@ read_machine_uuid_if_needed (void) goto out; /* rstrip the read uuid */ - while (len > 31 && isspace(uuid[len - 1])) + while (len > 31 && isspace((int) uuid[len - 1])) len--; if (len != 32) diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index 7382f4bf..cf17f642 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -106,6 +106,9 @@ monitor_filter_func (DBusConnection *connection, #ifdef __APPLE__ #define PROFILE_TIMED_FORMAT "%s\t%lu\t%d" +#elif defined(__NetBSD__) +#include +#define PROFILE_TIMED_FORMAT "%s\t%" PRId64 "\t%d" #else #define PROFILE_TIMED_FORMAT "%s\t%lu\t%lu" #endif -- cgit v1.2.1 From 580ed1c8fb3cbfb4a8071a7db8a802f14df3890b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 13:40:22 +0100 Subject: dbus-launch: avoid asprintf(), and die gracefully on out-of-memory asprintf() is a GNU extension (non-portable). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849 Reviewed-by: Chengwei Yang --- tools/dbus-launch.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index b071fcc5..3899d6d6 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -222,6 +222,26 @@ xstrdup (const char *str) return copy; } +static char * +concat2 (const char *a, + const char *b) +{ + size_t la, lb; + char *ret; + + la = strlen (a); + lb = strlen (b); + + ret = malloc (la + lb + 1); + + if (ret == NULL) + return NULL; + + memcpy (ret, a, la); + memcpy (ret + la, b, lb + 1); + return ret; +} + typedef enum { READ_STATUS_OK, /**< Read succeeded */ @@ -1114,11 +1134,15 @@ main (int argc, char **argv) { if (config_file == NULL && getenv ("DBUS_TEST_DATA") != NULL) { - ret = asprintf (&config_file, "%s/valid-config-files/session.conf", - getenv ("DBUS_TEST_DATA")); + config_file = concat2 (getenv ("DBUS_TEST_DATA"), + "/valid-config-files/session.conf"); + + if (config_file == NULL) + { + fprintf (stderr, "Out of memory\n"); + exit (1); + } } - if (ret == -1 && config_file != NULL) - free (config_file); execl (TEST_BUS_BINARY, TEST_BUS_BINARY, -- cgit v1.2.1 From f81cd4a18b9247760341c711a401947bad04698d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 13:47:19 +0100 Subject: When using dbus-launch for tests, fail hard if test binary is missing We want to test the version-under-test, not the system version. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849 Reviewed-by: Chengwei Yang --- tools/dbus-launch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 3899d6d6..050bd2fa 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -1154,8 +1154,9 @@ main (int argc, char **argv) NULL); fprintf (stderr, - "Failed to execute test message bus daemon %s: %s. Will try again with the system path.\n", + "Failed to execute test message bus daemon %s: %s.\n", TEST_BUS_BINARY, strerror (errno)); + exit (1); } #endif /* DBUS_ENABLE_EMBEDDED_TESTS */ -- cgit v1.2.1 From 57dc720b9f25dec999fcc53da982114098cefae9 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 12 Oct 2012 13:53:25 +0100 Subject: Add support for configuring --with-valgrind=auto This is the configuration I'd like to use for the "debug build" of dbus on Debian - if we use --with-valgrind=yes, we have to hard-code knowledge of which architectures do and don't have Valgrind in two places instead of just one. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=56925 Reviewed-by: Chengwei Yang --- configure.ac | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure.ac b/configure.ac index f4c88262..174308fb 100644 --- a/configure.ac +++ b/configure.ac @@ -1225,6 +1225,10 @@ AC_ARG_WITH([valgrind], [], [with_valgrind=no]) +AS_IF([test "x$with_valgrind" = xauto], + [PKG_CHECK_EXISTS([valgrind >= 3.6], + [with_valgrind=yes], [with_valgrind=no])]) + if test x$with_valgrind != xno; then PKG_CHECK_MODULES([VALGRIND], [valgrind >= 3.6]) AC_DEFINE([WITH_VALGRIND], [1], [Define to add Valgrind instrumentation]) -- cgit v1.2.1 From 0d15a9035a0be37ddd8c0bda3d3a613eb87c0b62 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 24 Sep 2013 21:25:01 +0800 Subject: Do not suggest user the next step after executed autogen.sh We assume that user/developer who building dbus from source code are familiar with the standard 'autogen.sh, configure, make, make install' build process, so print such a notice doesn't make a lot of sense. In addition, on *BSD platform, the pre-installed 'make' doesn't work at all since gnu make is required. However, it named to 'gmake' on *BSD platform. So the notice will makes new comer confused. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65415 Reviewed-by: Simon McVittie --- autogen.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/autogen.sh b/autogen.sh index b9046879..bff8257b 100755 --- a/autogen.sh +++ b/autogen.sh @@ -101,11 +101,5 @@ else fi if $run_configure; then - $srcdir/configure --enable-developer --config-cache "$@" || exit $? - echo - echo "Now type 'make' to compile $PROJECT." -else - echo - echo "Now run 'configure' and 'make' to compile $PROJECT." + $srcdir/configure --enable-developer --config-cache "$@" fi - -- cgit v1.2.1 From be2d249f71c8469c2e6a9af425fc4192b291f341 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 14:33:41 +0100 Subject: spec: system services' service description files have constrained names Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66608 Reviewed-by: Chengwei Yang --- doc/dbus-specification.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index ce58fe86..e6e75fde 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -4638,6 +4638,19 @@ names. + + On the well-known system bus, the name of a service description file + must be its well-known name plus .service, + for instance + com.example.ConfigurationDatabase.service. + + + + On the well-known session bus, services should follow the same + service description file naming convention as on the system bus, + but for backwards compatibility they are not required to do so. + + [FIXME the file format should be much better specified than "similar to .desktop entries" esp. since desktop entries are already -- cgit v1.2.1 From c2d6824232e8dbb182c9a57ec382ed8da8be5fa2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 14:36:21 +0100 Subject: spec: briefly describe Name, Exec and User keys Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66608 Reviewed-by: Chengwei Yang --- doc/dbus-specification.xml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index e6e75fde..51d6cb6f 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -4662,6 +4662,11 @@ Comment format + Service description files must contain a + D-BUS Service group with at least the keys + Name (the well-known name of the service) + and Exec (the command to be executed). +
Example service description file @@ -4672,6 +4677,14 @@
+ + + Additionally, service description files for the well-known system + bus on Unix must contain a User key, whose value + is the name of a user account (e.g. root). + The system service will be run as that user. + + When an application asks to start a service by name, the bus daemon tries to find a service that will own that name. It then tries to spawn the -- cgit v1.2.1 From 4b4d0f969bd42bfa0f26f3cd67bffe01782a0ced Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Oct 2013 10:36:39 +0100 Subject: NEWS --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 31b3fb0a..517cfdf5 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,10 @@ Build-time configuration changes: assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent with the Autotools build system. (fd.o #66142, Chengwei Yang) +• --with-valgrind=auto enables Valgrind instrumentation if and only if + valgrind headers are available. The default is still --with-valgrind=no. + (fd.o #56925, Simon McVittie) + Dependencies: • Platforms with no 64-bit integer type are no longer supported. @@ -38,6 +42,8 @@ Enhancements: · Don't claim D-Bus is "low-latency" (lower than what?), just give factual statements about it supporting async use (fd.o #65141, Justin Lee) + · Document the contents of .service files, and the fact that + system services' filenames are constrained (fd.o #66608, Simon) • Be thread-safe by default on all platforms, even if dbus_threads_init_default() has not been called. For compatibility with @@ -126,6 +132,8 @@ Fixes: Simon McVittie) · Make autogen.sh work on *BSD by not assuming GNU coreutils functionality (fd.o #35881, #69787; Chengwei Yang) + · dbus-monitor: be portable to NetBSD (fd.o #69842, Chengwei Yang) +  · dbus-launch: stop using non-portable asprintf (fd.o #37849, Simon) • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' -- cgit v1.2.1 From 1451f946c153fffe85c2a0a9d52446ff21b42fe8 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 26 Jun 2013 10:21:31 +0800 Subject: dbus-monitor: remove redundant match rules Currently, DBus Specification only consists of four message types, so to monitor all the types of message, no need to match all of them but just left it empty is OK. Signed-off-by: Chengwei Yang Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66107 Reviewed-by: Simon McVittie --- tools/dbus-monitor.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index cf17f642..1aa885f7 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -383,22 +383,7 @@ main (int argc, char *argv[]) else { dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='signal'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='method_call'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='method_return'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='error'", + EAVESDROPPING_RULE, &error); if (dbus_error_is_set (&error)) goto lose; -- cgit v1.2.1 From ecd4262cbfd5fb130b805686e8ceb1f0a4cbd52f Mon Sep 17 00:00:00 2001 From: Vasiliy Balyasnyy Date: Tue, 8 Oct 2013 13:36:38 +0400 Subject: dbus-message.c: unused variable bytes_read in _dbus_message_loader_get_buffer Bug: https://bugs.freedesktop.org/show_bug.cgi?id=70218 Reviewed-by: Simon McVittie --- dbus/dbus-message-internal.h | 3 +-- dbus/dbus-message-util.c | 10 +++++----- dbus/dbus-message.c | 6 ++---- dbus/dbus-transport-socket.c | 15 ++++----------- dbus/dbus-transport.c | 8 ++------ 5 files changed, 14 insertions(+), 28 deletions(-) diff --git a/dbus/dbus-message-internal.h b/dbus/dbus-message-internal.h index c1948732..5d6594e3 100644 --- a/dbus/dbus-message-internal.h +++ b/dbus/dbus-message-internal.h @@ -70,8 +70,7 @@ void _dbus_message_loader_unref (DBusMessageLoader void _dbus_message_loader_get_buffer (DBusMessageLoader *loader, DBusString **buffer); void _dbus_message_loader_return_buffer (DBusMessageLoader *loader, - DBusString *buffer, - int bytes_read); + DBusString *buffer); dbus_bool_t _dbus_message_loader_get_unix_fds (DBusMessageLoader *loader, int **fds, diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index fb7e2600..8f36dc0a 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -493,7 +493,7 @@ dbus_internal_do_not_use_try_message_data (const DBusString *data, _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_byte (buffer, _dbus_string_get_byte (data, i)); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } if (!check_loader_results (loader, expected_validity)) @@ -512,7 +512,7 @@ dbus_internal_do_not_use_try_message_data (const DBusString *data, _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_copy (data, 0, buffer, _dbus_string_get_length (buffer)); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } if (!check_loader_results (loader, expected_validity)) @@ -536,7 +536,7 @@ dbus_internal_do_not_use_try_message_data (const DBusString *data, if ((i+1) < len) _dbus_string_append_byte (buffer, _dbus_string_get_byte (data, i+1)); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } if (!check_loader_results (loader, expected_validity)) @@ -1327,7 +1327,7 @@ _dbus_message_test (const char *test_data_dir) _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_byte (buffer, data[i]); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } /* Write the body data one byte at a time */ @@ -1338,7 +1338,7 @@ _dbus_message_test (const char *test_data_dir) _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_byte (buffer, data[i]); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } #ifdef HAVE_UNIX_FD_PASSING diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 20c8be35..13edeb7b 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -3912,12 +3912,10 @@ _dbus_message_loader_get_buffer (DBusMessageLoader *loader, * * @param loader the loader. * @param buffer the buffer. - * @param bytes_read number of bytes that were read into the buffer. */ void _dbus_message_loader_return_buffer (DBusMessageLoader *loader, - DBusString *buffer, - int bytes_read) + DBusString *buffer) { _dbus_assert (loader->buffer_outstanding); _dbus_assert (buffer == &loader->data); @@ -4694,7 +4692,7 @@ dbus_message_demarshal (const char *str, _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_len (buffer, str, len); - _dbus_message_loader_return_buffer (loader, buffer, len); + _dbus_message_loader_return_buffer (loader, buffer); if (!_dbus_message_loader_queue_messages (loader)) goto fail_oom; diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index c7c62918..44c7af7d 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -748,29 +748,23 @@ do_reading (DBusTransport *transport) if (bytes_read > 0) { - int orig_len; - _dbus_message_loader_get_buffer (transport->loader, &buffer); - orig_len = _dbus_string_get_length (buffer); - if (!_dbus_auth_decode_data (transport->auth, &socket_transport->encoded_incoming, buffer)) { _dbus_verbose ("Out of memory decoding incoming data\n"); _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - orig_len); + buffer); oom = TRUE; goto out; } _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - orig_len); + buffer); _dbus_string_set_length (&socket_transport->encoded_incoming, 0); _dbus_string_compact (&socket_transport->encoded_incoming, 2048); @@ -789,7 +783,7 @@ do_reading (DBusTransport *transport) if (!_dbus_message_loader_get_unix_fds(transport->loader, &fds, &n_fds)) { _dbus_verbose ("Out of memory reading file descriptors\n"); - _dbus_message_loader_return_buffer (transport->loader, buffer, 0); + _dbus_message_loader_return_buffer (transport->loader, buffer); oom = TRUE; goto out; } @@ -812,8 +806,7 @@ do_reading (DBusTransport *transport) } _dbus_message_loader_return_buffer (transport->loader, - buffer, - bytes_read < 0 ? 0 : bytes_read); + buffer); } if (bytes_read < 0) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index e68a9f03..ecc31827 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -1045,9 +1045,7 @@ recover_unused_bytes (DBusTransport *transport) orig_len); _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - - orig_len); + buffer); _dbus_auth_delete_unused_bytes (transport->auth); @@ -1077,9 +1075,7 @@ recover_unused_bytes (DBusTransport *transport) orig_len); _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - - orig_len); + buffer); if (succeeded) _dbus_auth_delete_unused_bytes (transport->auth); -- cgit v1.2.1 From b430642bc2ddf39e791dc8d9145b2d7767957dba Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sun, 29 Sep 2013 18:10:33 +0800 Subject: fix off by one error message (#13305) This patch is based on the patch created by John (J5) Palmieri plus to fix array of string assignment. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=13305 Reviewed-by: Simon McVittie --- dbus/dbus-message.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 13edeb7b..9546da12 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -800,7 +800,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, va_list var_args) { DBusMessageRealIter *real = (DBusMessageRealIter *)iter; - int spec_type, msg_type, i; + int spec_type, msg_type, i, j; dbus_bool_t retval; _dbus_assert (_dbus_message_iter_check (real)); @@ -936,30 +936,30 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, /* Now go through and dup each string */ _dbus_type_reader_recurse (&real->u.reader, &array); - i = 0; - while (i < n_elements) + j = 0; + while (j < n_elements) { const char *s; _dbus_type_reader_read_basic (&array, (void *) &s); - str_array[i] = _dbus_strdup (s); - if (str_array[i] == NULL) + str_array[j] = _dbus_strdup (s); + if (str_array[j] == NULL) { dbus_free_string_array (str_array); _DBUS_SET_OOM (error); goto out; } - ++i; + ++j; if (!_dbus_type_reader_next (&array)) - _dbus_assert (i == n_elements); + _dbus_assert (j == n_elements); } _dbus_assert (_dbus_type_reader_get_current_type (&array) == DBUS_TYPE_INVALID); - _dbus_assert (i == n_elements); - _dbus_assert (str_array[i] == NULL); + _dbus_assert (j == n_elements); + _dbus_assert (str_array[j] == NULL); *str_array_p = str_array; *n_elements_p = n_elements; @@ -986,7 +986,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, if (!_dbus_type_reader_next (&real->u.reader) && spec_type != DBUS_TYPE_INVALID) { dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, - "Message has only %d arguments, but more were expected", i); + "Message has only %d arguments, but more were expected", i + 1); goto out; } -- cgit v1.2.1 From 2fefabaf64b332bc29ac3e492b74b6a71be911ea Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Oct 2013 13:26:17 +0100 Subject: 1.6.14 --- NEWS | 2 +- configure.ac | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index e41971bd..2fb182d0 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -D-Bus 1.6.16 (UNRELEASED) +D-Bus 1.6.16 (2013-10-08) == The “Fortify Agility” release. diff --git a/configure.ac b/configure.ac index dfdbb482..9169fbb9 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [15]) +m4_define([dbus_micro_version], [16]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=4 +LT_REVISION=5 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From 5b74af796c8f1d9f3f60594f22c6bfd4c097ad8b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Oct 2013 15:54:11 +0100 Subject: dbus-send: replace --address with --peer and --bus. --peer is a direct substitute for --address. With --bus dbus-send registers on bus given by ADDRESS, thus allowing messages to be sent to the bus. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48816 [adjusted to apply to current master -smcv] Reviewed-by: Simon McVittie --- tools/dbus-send.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/dbus-send.c b/tools/dbus-send.c index 2e37b089..d3ff2589 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -51,7 +51,7 @@ static const char *appname; static void usage (int ecode) { - fprintf (stderr, "Usage: %s [--help] [--system | --session | --address=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]\n", appname); + fprintf (stderr, "Usage: %s [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]\n", appname); exit (ecode); } @@ -241,6 +241,7 @@ main (int argc, char *argv[]) int message_type = DBUS_MESSAGE_TYPE_SIGNAL; const char *type_str = NULL; const char *address = NULL; + int is_bus = FALSE; int session_or_system = FALSE; appname = argv[0]; @@ -266,14 +267,28 @@ main (int argc, char *argv[]) type = DBUS_BUS_SESSION; session_or_system = TRUE; } - else if (strstr (arg, "--address=") == arg) + else if ((strstr (arg, "--bus=") == arg) || (strstr (arg, "--peer=") == arg) || (strstr (arg, "--address=") == arg)) { - if (*(strchr (arg, '=') + 1) == '\0') + if (arg[2] == 'b') /* bus */ { - fprintf (stderr, "\"--address=\" requires an ADDRESS\n"); - usage (1); + is_bus = TRUE; + } + else if (arg[2] == 'p') /* peer */ + { + is_bus = FALSE; + } + else /* address; keeping backwards compatibility */ + { + is_bus = FALSE; } + address = strchr (arg, '=') + 1; + + if (address[0] == '\0') + { + fprintf (stderr, "\"--peer=\" and \"--bus=\" require an ADDRESS\n"); + usage (1); + } } else if (strncmp (arg, "--print-reply", 13) == 0) { @@ -330,7 +345,7 @@ main (int argc, char *argv[]) if (session_or_system && (address != NULL)) { - fprintf (stderr, "\"--address\" may not be used with \"--system\" or \"--session\"\n"); + fprintf (stderr, "\"--peer\" and \"--bus\" may not be used with \"--system\" or \"--session\"\n"); usage (1); } @@ -372,6 +387,16 @@ main (int argc, char *argv[]) dbus_error_free (&error); exit (1); } + else if ((address != NULL) && is_bus) + { + if (!dbus_bus_register (connection, &error)) + { + fprintf (stderr, "Failed to register on connection to \"%s\" message bus: %s\n", + address, error.message); + dbus_error_free (&error); + exit (1); + } + } if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL) { -- cgit v1.2.1 From 47df159cc5b82d29588749b4dafedde33a8a3470 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 8 Oct 2013 21:59:37 +0800 Subject: Unify the way to find dbus-daemon test binary There are two ways to find the dbus-daemon for testing. The first one is defined as string at compile stage and the second one is export it from test environment. The first way has limitation that after defined, it's static string, so it's impossible to run installable check. So let's unify to the second way. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=37849 [added missing "}" -smcv] Reviewed-by: Simon McVittie --- cmake/config.h.cmake | 3 --- configure.ac | 4 --- test/name-test/Makefile.am | 1 + tools/dbus-launch.c | 62 ++++++++++++++++++++++++---------------------- 4 files changed, 34 insertions(+), 36 deletions(-) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index d6ea64f2..37355609 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -33,9 +33,6 @@ #define DBUS_TEST_EXEC "@DBUS_TEST_EXEC@" #define DBUS_EXEEXT "@EXEEXT@" -/* Full path to test file test/test-exit in builddir */ -#define TEST_BUS_BINARY "@TEST_BUS_BINARY@" - /* Some dbus features */ #cmakedefine DBUS_ENABLE_ANSI 1 #cmakedefine DBUS_ENABLE_VERBOSE_MODE 1 diff --git a/configure.ac b/configure.ac index 174308fb..923315e5 100644 --- a/configure.ac +++ b/configure.ac @@ -1617,10 +1617,6 @@ AC_DEFINE_UNQUOTED([DBUS_TEST_EXEC], ["$DBUS_TEST_EXEC"], AC_DEFINE_UNQUOTED([DBUS_EXEEXT], ["$EXEEXT"], [Extension for executables, typically empty or .exe]) -AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, ["$DBUS_PWD/bus/dbus-daemon$EXEEXT"], - [Full path to the daemon in the builddir]) -AC_SUBST(TEST_BUS_BINARY) - AC_DEFINE_UNQUOTED(TEST_BUS_LAUNCH_BINARY, ["$DBUS_PWD/tools/dbus-launch$EXEEXT"], [Full path to the dbus-launch in the builddir]) diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 931cb2c9..da41e58b 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -18,6 +18,7 @@ TESTS_ENVIRONMENT = \ DBUS_TOP_SRCDIR=@abs_top_srcdir@ \ PYTHON=@PYTHON@ \ DBUS_TEST_DATA=@abs_top_builddir@/test/data \ + DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \ $(NULL) TESTS=run-test.sh run-test-systemserver.sh else diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index 050bd2fa..7ecee63e 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -1129,35 +1129,39 @@ main (int argc, char **argv) verbose ("Calling exec()\n"); #ifdef DBUS_ENABLE_EMBEDDED_TESTS - /* exec from testdir */ - if (getenv ("DBUS_USE_TEST_BINARY") != NULL) - { - if (config_file == NULL && getenv ("DBUS_TEST_DATA") != NULL) - { - config_file = concat2 (getenv ("DBUS_TEST_DATA"), - "/valid-config-files/session.conf"); - - if (config_file == NULL) - { - fprintf (stderr, "Out of memory\n"); - exit (1); - } - } - - execl (TEST_BUS_BINARY, - TEST_BUS_BINARY, - "--fork", - "--print-pid", write_pid_fd_as_string, - "--print-address", write_address_fd_as_string, - config_file ? "--config-file" : "--session", - config_file, /* has to be last in this varargs list */ - NULL); - - fprintf (stderr, - "Failed to execute test message bus daemon %s: %s.\n", - TEST_BUS_BINARY, strerror (errno)); - exit (1); - } + { + const char *test_daemon; + /* exec from testdir */ + if (getenv ("DBUS_USE_TEST_BINARY") != NULL && + (test_daemon = getenv ("DBUS_TEST_DAEMON")) != NULL) + { + if (config_file == NULL && getenv ("DBUS_TEST_DATA") != NULL) + { + config_file = concat2 (getenv ("DBUS_TEST_DATA"), + "/valid-config-files/session.conf"); + + if (config_file == NULL) + { + fprintf (stderr, "Out of memory\n"); + exit (1); + } + } + + execl (test_daemon, + test_daemon, + "--fork", + "--print-pid", write_pid_fd_as_string, + "--print-address", write_address_fd_as_string, + config_file ? "--config-file" : "--session", + config_file, /* has to be last in this varargs list */ + NULL); + + fprintf (stderr, + "Failed to execute test message bus daemon %s: %s.\n", + test_daemon, strerror (errno)); + exit (1); + } + } #endif /* DBUS_ENABLE_EMBEDDED_TESTS */ execl (DBUS_DAEMONDIR"/dbus-daemon", -- cgit v1.2.1 From cd32cdde0ea8b953abca6e363a0b3998b9d7c06a Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 8 Oct 2013 20:55:03 +0800 Subject: Spec: document multiple .service files own the same well known name In current dbus-daemon(1) implement, system .serivce must named after its owned name, but this is not the case for session .service. For session service, the result of multiple .service files own the same well known name is undefined since readdir(3) doesn't return dirent in a defined sequence. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66608 [added some -smcv] Reviewed-by: Simon McVittie --- doc/dbus-specification.xml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 51d6cb6f..94de5da7 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -4689,9 +4689,28 @@ When an application asks to start a service by name, the bus daemon tries to find a service that will own that name. It then tries to spawn the executable associated with it. If this fails, it will report an - error. [FIXME what happens if two .service files offer the same service; - what kind of error is reported, should we have a way for the client to - choose one?] + error. + + + + On the well-known system bus, it is not possible for two .service files + in the same directory to offer the same service, because they are + constrained to have names that match the service name. + + + + On the well-known session bus, if two .service files in the same + directory offer the same service name, the result is undefined. + Distributors should avoid this situation, for instance by naming + session services' .service files according to their service name. + + + + If two .service files in different directories offer the same + service name, the one in the higher-priority directory is used: + for instance, on the system bus, .service files in + /usr/local/share/dbus-1/system-services take precedence over those + in /usr/share/dbus-1/system-services. The executable launched will have the environment variable -- cgit v1.2.1 From a96207da085b8fa3e2c15ab729d523a347459ea8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Oct 2013 17:33:56 +0100 Subject: 1.6.17 --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 2fb182d0..44415fc1 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +D-Bus 1.6.18 (UNRELEASED) +== + D-Bus 1.6.16 (2013-10-08) == diff --git a/configure.ac b/configure.ac index 9169fbb9..e7a672e0 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [16]) +m4_define([dbus_micro_version], [17]) 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]) -- cgit v1.2.1 From 867bdd890fc3e4da9246932461203a682ad6ec70 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 9 Oct 2013 08:50:37 +0800 Subject: launch-helper: fix error code parsing Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66728 Reviewed-by: Simon McVittie --- bus/activation-helper-bin.c | 5 ++++- bus/activation-helper.c | 2 +- bus/activation.c | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/bus/activation-helper-bin.c b/bus/activation-helper-bin.c index a360acc7..f5f16d2c 100644 --- a/bus/activation-helper-bin.c +++ b/bus/activation-helper-bin.c @@ -45,6 +45,9 @@ convert_error_to_exit_code (DBusError *error) return BUS_SPAWN_EXIT_CODE_SETUP_FAILED; if (dbus_error_has_name (error, DBUS_ERROR_SPAWN_SERVICE_INVALID)) + return BUS_SPAWN_EXIT_CODE_NAME_INVALID; + + if (dbus_error_has_name (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND)) return BUS_SPAWN_EXIT_CODE_SERVICE_NOT_FOUND; if (dbus_error_has_name (error, DBUS_ERROR_SPAWN_PERMISSIONS_INVALID)) @@ -65,7 +68,7 @@ convert_error_to_exit_code (DBusError *error) /* should we assert? */ fprintf(stderr, "%s: %s\n", error->name, error->message); - return BUS_SPAWN_EXIT_CODE_SETUP_FAILED; + return BUS_SPAWN_EXIT_CODE_GENERIC_FAILURE; } int diff --git a/bus/activation-helper.c b/bus/activation-helper.c index e3b3323c..394f3938 100644 --- a/bus/activation-helper.c +++ b/bus/activation-helper.c @@ -372,7 +372,7 @@ check_bus_name (const char *bus_name, _dbus_string_init_const (&str, bus_name); if (!_dbus_validate_bus_name (&str, 0, _dbus_string_get_length (&str))) { - dbus_set_error (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND, + dbus_set_error (error, DBUS_ERROR_SPAWN_SERVICE_INVALID, "bus name '%s' is not a valid bus name\n", bus_name); return FALSE; diff --git a/bus/activation.c b/bus/activation.c index e03b6fec..77357bea 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -1289,6 +1289,10 @@ handle_servicehelper_exit_error (int exit_code, { switch (exit_code) { + case BUS_SPAWN_EXIT_CODE_CONFIG_INVALID: + dbus_set_error (error, DBUS_ERROR_SPAWN_CONFIG_INVALID, + "Invalid configuration (missing or empty ?)"); + break; case BUS_SPAWN_EXIT_CODE_NO_MEMORY: dbus_set_error (error, DBUS_ERROR_NO_MEMORY, "Launcher could not run (out of memory)"); @@ -1325,6 +1329,7 @@ handle_servicehelper_exit_error (int exit_code, dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_SIGNALED, "Launched child was signaled, it probably crashed"); break; + case BUS_SPAWN_EXIT_CODE_GENERIC_FAILURE: default: dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_EXITED, "Launch helper exited with unknown return code %i", exit_code); -- cgit v1.2.1 From d842e6edd1790b091d2071fa3844baba59ec30df Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 9 Oct 2013 10:06:52 +0800 Subject: Remove unused key-word of DBus .service file Key-word "Group" of DBus .service file hasn't been used since it was introduced in 2007, so it's fine to remove it. https://bugs.freedesktop.org/show_bug.cgi?id=19158 Reviewed-by: Simon McVittie --- bus/desktop-file.h | 1 - 1 file changed, 1 deletion(-) diff --git a/bus/desktop-file.h b/bus/desktop-file.h index 58e78e8f..e405625c 100644 --- a/bus/desktop-file.h +++ b/bus/desktop-file.h @@ -34,7 +34,6 @@ #define DBUS_SERVICE_NAME "Name" #define DBUS_SERVICE_EXEC "Exec" #define DBUS_SERVICE_USER "User" -#define DBUS_SERVICE_GROUP "Group" #define DBUS_SERVICE_SYSTEMD_SERVICE "SystemdService" typedef struct BusDesktopFile BusDesktopFile; -- cgit v1.2.1 From 39673b945ca809d24797d237d1e2abc6f59ebe77 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 9 Oct 2013 11:17:20 +0100 Subject: Revert "dbus-send: replace --address"... to fix attribution This reverts commit 5b74af796c8f1d9f3f60594f22c6bfd4c097ad8b. --- tools/dbus-send.c | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/tools/dbus-send.c b/tools/dbus-send.c index d3ff2589..2e37b089 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -51,7 +51,7 @@ static const char *appname; static void usage (int ecode) { - fprintf (stderr, "Usage: %s [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]\n", appname); + fprintf (stderr, "Usage: %s [--help] [--system | --session | --address=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]\n", appname); exit (ecode); } @@ -241,7 +241,6 @@ main (int argc, char *argv[]) int message_type = DBUS_MESSAGE_TYPE_SIGNAL; const char *type_str = NULL; const char *address = NULL; - int is_bus = FALSE; int session_or_system = FALSE; appname = argv[0]; @@ -267,28 +266,14 @@ main (int argc, char *argv[]) type = DBUS_BUS_SESSION; session_or_system = TRUE; } - else if ((strstr (arg, "--bus=") == arg) || (strstr (arg, "--peer=") == arg) || (strstr (arg, "--address=") == arg)) + else if (strstr (arg, "--address=") == arg) { - if (arg[2] == 'b') /* bus */ + if (*(strchr (arg, '=') + 1) == '\0') { - is_bus = TRUE; - } - else if (arg[2] == 'p') /* peer */ - { - is_bus = FALSE; - } - else /* address; keeping backwards compatibility */ - { - is_bus = FALSE; - } - - address = strchr (arg, '=') + 1; - - if (address[0] == '\0') - { - fprintf (stderr, "\"--peer=\" and \"--bus=\" require an ADDRESS\n"); + fprintf (stderr, "\"--address=\" requires an ADDRESS\n"); usage (1); } + address = strchr (arg, '=') + 1; } else if (strncmp (arg, "--print-reply", 13) == 0) { @@ -345,7 +330,7 @@ main (int argc, char *argv[]) if (session_or_system && (address != NULL)) { - fprintf (stderr, "\"--peer\" and \"--bus\" may not be used with \"--system\" or \"--session\"\n"); + fprintf (stderr, "\"--address\" may not be used with \"--system\" or \"--session\"\n"); usage (1); } @@ -387,16 +372,6 @@ main (int argc, char *argv[]) dbus_error_free (&error); exit (1); } - else if ((address != NULL) && is_bus) - { - if (!dbus_bus_register (connection, &error)) - { - fprintf (stderr, "Failed to register on connection to \"%s\" message bus: %s\n", - address, error.message); - dbus_error_free (&error); - exit (1); - } - } if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL) { -- cgit v1.2.1 From b994830c7f6e201e8e8c3e6d8eaeb67191b9338a Mon Sep 17 00:00:00 2001 From: Andrey Mazo Date: Tue, 8 Oct 2013 15:54:11 +0100 Subject: dbus-send: replace --address with --peer and --bus. --peer is a direct substitute for --address. With --bus dbus-send registers on bus given by ADDRESS, thus allowing messages to be sent to the bus. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48816 [adjusted to apply to current master -smcv] Reviewed-by: Simon McVittie --- tools/dbus-send.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tools/dbus-send.c b/tools/dbus-send.c index 2e37b089..d3ff2589 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -51,7 +51,7 @@ static const char *appname; static void usage (int ecode) { - fprintf (stderr, "Usage: %s [--help] [--system | --session | --address=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]\n", appname); + fprintf (stderr, "Usage: %s [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] [contents ...]\n", appname); exit (ecode); } @@ -241,6 +241,7 @@ main (int argc, char *argv[]) int message_type = DBUS_MESSAGE_TYPE_SIGNAL; const char *type_str = NULL; const char *address = NULL; + int is_bus = FALSE; int session_or_system = FALSE; appname = argv[0]; @@ -266,14 +267,28 @@ main (int argc, char *argv[]) type = DBUS_BUS_SESSION; session_or_system = TRUE; } - else if (strstr (arg, "--address=") == arg) + else if ((strstr (arg, "--bus=") == arg) || (strstr (arg, "--peer=") == arg) || (strstr (arg, "--address=") == arg)) { - if (*(strchr (arg, '=') + 1) == '\0') + if (arg[2] == 'b') /* bus */ { - fprintf (stderr, "\"--address=\" requires an ADDRESS\n"); - usage (1); + is_bus = TRUE; + } + else if (arg[2] == 'p') /* peer */ + { + is_bus = FALSE; + } + else /* address; keeping backwards compatibility */ + { + is_bus = FALSE; } + address = strchr (arg, '=') + 1; + + if (address[0] == '\0') + { + fprintf (stderr, "\"--peer=\" and \"--bus=\" require an ADDRESS\n"); + usage (1); + } } else if (strncmp (arg, "--print-reply", 13) == 0) { @@ -330,7 +345,7 @@ main (int argc, char *argv[]) if (session_or_system && (address != NULL)) { - fprintf (stderr, "\"--address\" may not be used with \"--system\" or \"--session\"\n"); + fprintf (stderr, "\"--peer\" and \"--bus\" may not be used with \"--system\" or \"--session\"\n"); usage (1); } @@ -372,6 +387,16 @@ main (int argc, char *argv[]) dbus_error_free (&error); exit (1); } + else if ((address != NULL) && is_bus) + { + if (!dbus_bus_register (connection, &error)) + { + fprintf (stderr, "Failed to register on connection to \"%s\" message bus: %s\n", + address, error.message); + dbus_error_free (&error); + exit (1); + } + } if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL) { -- cgit v1.2.1 From faaa092f20fce37e8b8ceb57b388cd8e90f3d8de Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 9 Oct 2013 10:44:12 +0800 Subject: dbus-monitor: keep backwards compatibility eavesdropping as a match rule key introduced in DBus 1.5.6, and the privous implementation doesn't keep backwards compatibility with older dbus-daemon. And the reference dbus-daemon implementation just fail if unknwon key found in match rule, this is undefined hehavior in DBus Sepcification. Also there is a feature request for change this hehavior to "ignore unknown key in match rule", See https://bugs.freedesktop.org/show_bug.cgi?id=66114 Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66107 Reviewed-by: Simon McVittie --- tools/dbus-monitor.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index 1aa885f7..ff8390d7 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -367,26 +367,45 @@ main (int argc, char *argv[]) if (numFilters) { + size_t offset = 0; for (i = 0; i < j; i++) { - dbus_bus_add_match (connection, filters[i], &error); - if (dbus_error_is_set (&error)) + dbus_bus_add_match (connection, filters[i] + offset, &error); + if (dbus_error_is_set (&error) && i == 0 && offset == 0) + { + /* We might be talking to a pre-1.5.6 dbus-daemon + * which wouldn't understand eavesdrop=true. + * If this works, carry on with offset > 0 + * on the remaining iterations. */ + offset = strlen (EAVESDROPPING_RULE) + 1; + dbus_error_free (&error); + dbus_bus_add_match (connection, filters[i] + offset, &error); + } + + if (dbus_error_is_set (&error)) { fprintf (stderr, "Failed to setup match \"%s\": %s\n", filters[i], error.message); dbus_error_free (&error); exit (1); } - free(filters[i]); + free(filters[i]); } } else { dbus_bus_add_match (connection, - EAVESDROPPING_RULE, - &error); + EAVESDROPPING_RULE, + &error); if (dbus_error_is_set (&error)) - goto lose; + { + dbus_error_free (&error); + dbus_bus_add_match (connection, + "", + &error); + if (dbus_error_is_set (&error)) + goto lose; + } } if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) { -- cgit v1.2.1 From dc4d60d4a89747ef7311b7b3c12e70a421080569 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 9 Oct 2013 11:27:55 +0100 Subject: yet more NEWS --- NEWS | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 517cfdf5..07c58eb1 100644 --- a/NEWS +++ b/NEWS @@ -43,7 +43,8 @@ Enhancements: give factual statements about it supporting async use (fd.o #65141, Justin Lee) · Document the contents of .service files, and the fact that - system services' filenames are constrained (fd.o #66608, Simon) + system services' filenames are constrained + (fd.o #66608; Simon McVittie, Chengwei Yang) • Be thread-safe by default on all platforms, even if dbus_threads_init_default() has not been called. For compatibility with @@ -56,6 +57,12 @@ Enhancements: • New API: dbus_setenv(), a simple wrapper around setenv(). Note that this is not thread-safe. (fd.o #39196, Simon) +• Add dbus-send --peer=ADDRESS (connect to a given peer-to-peer connection, + like --address=ADDRESS in previous versions) and dbus-send --bus=ADDRESS + (connect to a given bus, like dbus-monitor --address=ADDRESS). + dbus-send --address still exists for backwards compatibility, + but is no longer documented. (fd.o #48816, Andrey Mazo) + • Windows-specific: · "dbus-daemon --nofork" is allowed on Windows again. (fd.o #68852, Simon McVittie) @@ -110,6 +117,9 @@ Fixes: • Don't over-allocate memory in dbus-monitor (fd.o #69329, Sviatoslav Chagaev) +• dbus-monitor can monitor dbus-daemon < 1.5.6 again + (fd.o #66107, Chengwei Yang) + • Unix-specific: · If accept4() fails with EINVAL, as it can on older Linux kernels with newer glibc, try accept() instead of going into a busy-loop. @@ -133,7 +143,9 @@ Fixes: · Make autogen.sh work on *BSD by not assuming GNU coreutils functionality (fd.o #35881, #69787; Chengwei Yang) · dbus-monitor: be portable to NetBSD (fd.o #69842, Chengwei Yang) -  · dbus-launch: stop using non-portable asprintf (fd.o #37849, Simon) + · dbus-launch: stop using non-portable asprintf (fd.o #37849, Simon) + · Improve error reporting from the setuid activation helper (fd.o #66728, + Chengwei Yang) • Windows-specific: · Remove unavailable command-line options from 'dbus-daemon --help' @@ -151,7 +163,7 @@ Fixes: · improve verbose-mode output (fd.o #63047, Colin Walters) · consolidate Autotools and CMake build (fd.o #64875, Ralf Habacker) · fix various unused variables, unusual build configurations - etc. (fd.o #65712, #65990, #66005, #66257, #69165, #69410; + etc. (fd.o #65712, #65990, #66005, #66257, #69165, #69410, #70218; Chengwei Yang, Vasiliy Balyasnyy) D-Bus 1.7.4 (2013-06-13) -- cgit v1.2.1 From 9e4f0bf0e114c37e30acd78ade61d2f6e92c625f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 9 Oct 2013 11:34:14 +0100 Subject: D-Bus 1.7.6, spec 0.22 --- NEWS | 4 +++- configure.ac | 2 +- doc/dbus-specification.xml | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 07c58eb1..7939cf6e 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ -D-Bus 1.7.6 (UNRELEASED) +D-Bus 1.7.6 (2013-10-09) == +The “CSI Shrewsbury” release. + Build-time configuration changes: • Directory change notification via dnotify on Linux is no longer diff --git a/configure.ac b/configure.ac index 923315e5..9a51c575 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [5]) +m4_define([dbus_micro_version], [6]) 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]) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 94de5da7..bc374b9b 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -7,7 +7,7 @@ D-Bus Specification Version 0.22 - (not yet released) + 2013-10-09 Havoc @@ -73,9 +73,12 @@ 0.22 - not yet released (commit log) + 2013-10-09 - + add GetConnectionCredentials, document + GetAtdAuditSessionData, document GetConnectionSELinuxSecurityContext, + document and correct .service file syntax and naming + 0.21 -- cgit v1.2.1 From bb024108b2a77eee7a88dc7e9d06609506de8034 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 9 Oct 2013 18:47:14 +0100 Subject: start 1.7.8 --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 7939cf6e..e1816eed 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +D-Bus 1.7.8 (UNRELEASED) +== + +... + D-Bus 1.7.6 (2013-10-09) == diff --git a/configure.ac b/configure.ac index 9a51c575..bfacd0a4 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [6]) +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]) -- cgit v1.2.1 From c8bc5f24b721bc03679c44669cf5e655c1e99b5f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 10 Oct 2013 13:14:01 +0100 Subject: start dbus-specification 0.23 --- doc/dbus-specification.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index bc374b9b..125001ad 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.22 - 2013-10-09 + Version 0.23 + (not yet released) Havoc @@ -71,6 +71,14 @@ + + 0.23 + not yet released + + + see commit log + + 0.22 2013-10-09 -- cgit v1.2.1 From 9f0366019d6f344c64b23a0cac29c175fed1673e Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 10 Oct 2013 00:45:15 +0200 Subject: Use TEST_LISTEN in incoming-listen.conf.in instead of unix only hardcoded address Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68506 Reviewed-by: Simon McVittie --- configure.ac | 1 + test/data/valid-config-files/incoming-limit.conf | 18 ------------------ test/data/valid-config-files/incoming-limit.conf.in | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 18 deletions(-) delete mode 100644 test/data/valid-config-files/incoming-limit.conf create mode 100644 test/data/valid-config-files/incoming-limit.conf.in diff --git a/configure.ac b/configure.ac index bfacd0a4..b29c8f09 100644 --- a/configure.ac +++ b/configure.ac @@ -1774,6 +1774,7 @@ dbus-1.pc dbus-1-uninstalled.pc test/data/valid-config-files/debug-allow-all.conf test/data/valid-config-files/debug-allow-all-sha1.conf +test/data/valid-config-files/incoming-limit.conf test/data/valid-config-files-system/debug-allow-all-pass.conf test/data/valid-config-files-system/debug-allow-all-fail.conf test/data/valid-service-files/org.freedesktop.DBus.TestSuite.PrivServer.service diff --git a/test/data/valid-config-files/incoming-limit.conf b/test/data/valid-config-files/incoming-limit.conf deleted file mode 100644 index abfab3f7..00000000 --- a/test/data/valid-config-files/incoming-limit.conf +++ /dev/null @@ -1,18 +0,0 @@ - - - - session - unix:tmpdir=/tmp - - - - - - - - - - - 1 - diff --git a/test/data/valid-config-files/incoming-limit.conf.in b/test/data/valid-config-files/incoming-limit.conf.in new file mode 100644 index 00000000..40ff2244 --- /dev/null +++ b/test/data/valid-config-files/incoming-limit.conf.in @@ -0,0 +1,18 @@ + + + + session + @TEST_LISTEN@ + + + + + + + + + + + 1 + -- cgit v1.2.1 From 5618696768805abfbc3741f60817584451648795 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 10 Oct 2013 11:55:36 -0400 Subject: test: Update build for previous commit It should now be in in_data so we find it in $(srcdir). --- test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index eddcd644..12d9ab49 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -246,6 +246,7 @@ in_data = \ data/valid-config-files-system/debug-allow-all-pass.conf.in \ data/valid-config-files/debug-allow-all-sha1.conf.in \ data/valid-config-files/debug-allow-all.conf.in \ + data/valid-config-files/incoming-limit.conf \ data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \ data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \ data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \ @@ -317,7 +318,6 @@ static_data = \ data/valid-config-files/basic.conf \ data/valid-config-files/basic.d/basic.conf \ data/valid-config-files/entities.conf \ - data/valid-config-files/incoming-limit.conf \ data/valid-config-files/many-rules.conf \ data/valid-config-files/system.d/test.conf \ data/valid-messages/array-of-array-of-uint32.message \ -- cgit v1.2.1 From 880209788c2d1a09e8dc10e2bb5b8f5fa6f80a5e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 10 Oct 2013 16:59:11 +0100 Subject: $(in_data) is meant to contain the .in files Reviewed-by: Colin Walters --- test/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 12d9ab49..870ce321 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -246,7 +246,7 @@ in_data = \ data/valid-config-files-system/debug-allow-all-pass.conf.in \ data/valid-config-files/debug-allow-all-sha1.conf.in \ data/valid-config-files/debug-allow-all.conf.in \ - data/valid-config-files/incoming-limit.conf \ + data/valid-config-files/incoming-limit.conf.in \ data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \ data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \ data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \ -- cgit v1.2.1 From cdff3bc41bb97ef16f6959d3135f5d4a03e90cd8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 23 Oct 2013 15:19:13 +0100 Subject: path_namespace='/' should match everything Bug: https://bugs.freedesktop.org/show_bug.cgi?id=70799 Reviewed-by: Philip Withnall Reviewed-by: Ryan Lortie --- bus/signals.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/bus/signals.c b/bus/signals.c index 28506d3f..a198c6e9 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -1836,8 +1836,11 @@ match_rule_matches (BusMatchRule *rule, * namespace, rather than just starting with that string, * by checking that the matched prefix is followed by a '/' * or the end of the path. + * + * Special case: the only valid path of length 1, "/", + * matches everything. */ - if (path[len] != '\0' && path[len] != '/') + if (len > 1 && path[len] != '\0' && path[len] != '/') return FALSE; } @@ -2719,6 +2722,7 @@ test_path_matching (void) static const char* path_namespace_should_match_message_1[] = { + "type='signal',path_namespace='/'", "type='signal',path_namespace='/foo'", "type='signal',path_namespace='/foo/TheObjectManager'", NULL @@ -2733,6 +2737,7 @@ path_namespace_should_not_match_message_1[] = { static const char* path_namespace_should_match_message_2[] = { + "type='signal',path_namespace='/'", "type='signal',path_namespace='/foo/TheObjectManager'", NULL }; @@ -2744,6 +2749,7 @@ path_namespace_should_not_match_message_2[] = { static const char* path_namespace_should_match_message_3[] = { + "type='signal',path_namespace='/'", NULL }; @@ -2753,12 +2759,25 @@ path_namespace_should_not_match_message_3[] = { NULL }; +static const char* +path_namespace_should_match_message_4[] = { + "type='signal',path_namespace='/'", + NULL +}; + +static const char* +path_namespace_should_not_match_message_4[] = { + "type='signal',path_namespace='/foo/TheObjectManager'", + NULL +}; + static void test_matching_path_namespace (void) { DBusMessage *message1; DBusMessage *message2; DBusMessage *message3; + DBusMessage *message4; message1 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); _dbus_assert (message1 != NULL); @@ -2775,6 +2794,11 @@ test_matching_path_namespace (void) if (!dbus_message_set_path (message3, "/foo/TheObjectManagerOther")) _dbus_assert_not_reached ("oom"); + message4 = dbus_message_new (DBUS_MESSAGE_TYPE_SIGNAL); + _dbus_assert (message4 != NULL); + if (!dbus_message_set_path (message4, "/")) + _dbus_assert_not_reached ("oom"); + check_matching (message1, 1, path_namespace_should_match_message_1, path_namespace_should_not_match_message_1); @@ -2784,7 +2808,11 @@ test_matching_path_namespace (void) check_matching (message3, 3, path_namespace_should_match_message_3, path_namespace_should_not_match_message_3); + check_matching (message4, 4, + path_namespace_should_match_message_4, + path_namespace_should_not_match_message_4); + dbus_message_unref (message4); dbus_message_unref (message3); dbus_message_unref (message2); dbus_message_unref (message1); -- cgit v1.2.1 From 33fcec4a47bfa9365a7004d00e308f05720d96cd Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 3 Dec 2012 17:31:37 +0000 Subject: _dbus_spawn_async_with_babysitter: correct documentation env is used as you'd expect now. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859 Reviewed-by: Chengwei Yang --- dbus/dbus-spawn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 8965b587..bd7aaf80 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1130,7 +1130,7 @@ babysit (pid_t grandchild_pid, * * @param sitter_p return location for babysitter or #NULL * @param argv the executable and arguments - * @param env the environment (not used on unix yet) + * @param env the environment, or #NULL to copy the parent's * @param child_setup function to call in child pre-exec() * @param user_data user data for setup function * @param error error object to be filled in if function fails -- cgit v1.2.1 From 8b8bbe4c8b4693681e8c5d45431d1798091f4bdc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 3 Dec 2012 17:43:31 +0000 Subject: dbus-spawn: correct a comment that falsely claimed thread-safety Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859 Reviewed-by: Chengwei Yang --- dbus/dbus-spawn.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index bd7aaf80..7c46935a 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -810,9 +810,14 @@ handle_watch (DBusWatch *watch, #define WRITE_END 1 -/* Avoids a danger in threaded situations (calling close() - * on a file descriptor twice, and another thread has - * re-opened it since the first close) +/* Avoids a danger in re-entrant situations (calling close() + * on a file descriptor twice, and another module has + * re-opened it since the first close). + * + * This previously claimed to be relevant for threaded situations, but by + * trivial inspection, it is not thread-safe. It doesn't actually + * matter, since this module is only used in the -util variant of the + * library, which is only used in single-threaded situations. */ static int close_and_invalidate (int *fd) -- cgit v1.2.1 From 576c34dbc0775450623f289f012fb938a84c58a8 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 11 Oct 2013 16:35:17 +0800 Subject: Correctly set number of arguments already handled At privous, which increments the number of arguments already handled in the last of loop, however, if there is any invalid argument, then it will "goto out" and the number of arguments already handled is now incorrect. A following patch will use the number of arguments already handled as a loop terminate condition, so it's good to fix it before. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21259 Reviewed-by: Simon McVittie --- dbus/dbus-message.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 9546da12..4f234d52 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -982,15 +982,16 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, } #endif + /* how many arguments already handled */ + i++; + spec_type = va_arg (var_args, int); if (!_dbus_type_reader_next (&real->u.reader) && spec_type != DBUS_TYPE_INVALID) { dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, - "Message has only %d arguments, but more were expected", i + 1); + "Message has only %d arguments, but more were expected", i); goto out; } - - i++; } retval = TRUE; -- cgit v1.2.1 From 4ea6eb76f470a45264ea077430f280568c620002 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 29 Oct 2013 22:20:00 +0800 Subject: Fix memory or unix fd may leak in dbus_message_iter_get_args_valist This is an aged bug since 2009, so let's fix it. Say if a previous parsing for unix fd or array of string successfully but then a later element parsing fail, then the unix fd or array of string leaked. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21259 Reviewed-by: Simon McVittie --- dbus/dbus-message.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 4f234d52..32ac37a2 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -784,8 +784,6 @@ _dbus_message_iter_check (DBusMessageRealIter *iter) * dbus_message_get_args() is the place to go for complete * documentation. * - * @todo This may leak memory and file descriptors if parsing fails. See #21259 - * * @see dbus_message_get_args * @param iter the message iter * @param error error to be filled in @@ -802,6 +800,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, DBusMessageRealIter *real = (DBusMessageRealIter *)iter; int spec_type, msg_type, i, j; dbus_bool_t retval; + va_list copy_args; _dbus_assert (_dbus_message_iter_check (real)); @@ -810,12 +809,17 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, spec_type = first_arg_type; i = 0; + /* copy var_args first, then we can do another iteration over it to + * free memory and close unix fds if parse failed at some point. + */ + va_copy (copy_args, var_args); + while (spec_type != DBUS_TYPE_INVALID) { msg_type = dbus_message_iter_get_arg_type (iter); if (msg_type != spec_type) - { + { dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, "Argument %d is specified to be of type \"%s\", but " "is actually of type \"%s\"\n", i, @@ -823,7 +827,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, _dbus_type_to_string (msg_type)); goto out; - } + } if (spec_type == DBUS_TYPE_UNIX_FD) { @@ -997,7 +1001,66 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, retval = TRUE; out: + /* there may memory or unix fd leak in the above iteration if parse failed. + * so we have another iteration over copy_args to free memory and close + * unix fds. + */ + if (!retval) + { + spec_type = first_arg_type; + j = 0; + + while (j < i) + { + if (spec_type == DBUS_TYPE_UNIX_FD) + { +#ifdef HAVE_UNIX_FD_PASSING + int *pfd; + + pfd = va_arg (copy_args, int *); + _dbus_assert(pfd); + if (*pfd >= 0) + { + _dbus_close (*pfd, NULL); + *pfd = -1; + } +#endif + } + else if (dbus_type_is_basic (spec_type)) + { + /* move the index forward */ + va_arg (copy_args, DBusBasicValue *); + } + else if (spec_type == DBUS_TYPE_ARRAY) + { + int spec_element_type; + + spec_element_type = va_arg (copy_args, int); + if (dbus_type_is_fixed (spec_element_type)) + { + /* move the index forward */ + va_arg (copy_args, const DBusBasicValue **); + va_arg (copy_args, int *); + } + else if (_DBUS_TYPE_IS_STRINGLIKE (spec_element_type)) + { + char ***str_array_p; + + str_array_p = va_arg (copy_args, char ***); + /* move the index forward */ + va_arg (copy_args, int *); + _dbus_assert (str_array_p != NULL); + dbus_free_string_array (*str_array_p); + *str_array_p = NULL; + } + } + + spec_type = va_arg (copy_args, int); + j++; + } + } + va_end (copy_args); return retval; } -- cgit v1.2.1 From 5852f76cb973ab66fead3a6e76cfa269811f78ca Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 29 Oct 2013 10:27:11 +0800 Subject: Test: add test cases for message parsing Add test cases for testing: * If more arguments than requested are present, the requested arguments are returned and the extra arguments are ignored. * If arguments parse failed, ensure we didn't leak any memory or unix fd Bug: https://bugs.freedesktop.org/show_bug.cgi?id=21259 [added a check for fd leaks around verify_test_message_args_ignored() -smcv] Reviewed-by: Simon McVittie --- dbus/dbus-message-util.c | 205 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index 8f36dc0a..f615af83 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -991,6 +991,161 @@ verify_test_message (DBusMessage *message) _dbus_assert_not_reached ("Didn't reach end of arguments"); } +static void +verify_test_message_args_ignored (DBusMessage *message) +{ + DBusMessageIter iter; + DBusError error = DBUS_ERROR_INIT; + dbus_uint32_t our_uint; + DBusInitialFDs *initial_fds; + + initial_fds = _dbus_check_fdleaks_enter (); + + /* parse with empty signature: "" */ + dbus_message_iter_init (message, &iter); + if (!dbus_message_iter_get_args (&iter, &error, + DBUS_TYPE_INVALID)) + { + _dbus_warn ("error: %s - %s\n", error.name, + (error.message != NULL) ? error.message : "no message"); + } + else + { + _dbus_assert (!dbus_error_is_set (&error)); + _dbus_verbose ("arguments ignored.\n"); + } + + /* parse with shorter signature: "u" */ + dbus_message_iter_init (message, &iter); + if (!dbus_message_iter_get_args (&iter, &error, + DBUS_TYPE_UINT32, &our_uint, + DBUS_TYPE_INVALID)) + { + _dbus_warn ("error: %s - %s\n", error.name, + (error.message != NULL) ? error.message : "no message"); + } + else + { + _dbus_assert (!dbus_error_is_set (&error)); + _dbus_verbose ("arguments ignored.\n"); + } + + _dbus_check_fdleaks_leave (initial_fds); +} + +static void +verify_test_message_memleak (DBusMessage *message) +{ + DBusMessageIter iter; + DBusError error = DBUS_ERROR_INIT; + dbus_uint32_t our_uint1; + dbus_uint32_t our_uint2; + dbus_uint32_t our_uint3; + char **our_string_array1; + int our_string_array_len1; + char **our_string_array2; + int our_string_array_len2; + int our_unix_fd1; + int our_unix_fd2; + DBusInitialFDs *initial_fds; + + initial_fds = _dbus_check_fdleaks_enter (); + + /* parse with wrong signature: "uashuu" */ + dbus_error_free (&error); + dbus_message_iter_init (message, &iter); + if (!dbus_message_iter_get_args (&iter, &error, + DBUS_TYPE_UINT32, &our_uint1, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &our_string_array1, &our_string_array_len1, +#ifdef HAVE_UNIX_FD_PASSING + DBUS_TYPE_UNIX_FD, &our_unix_fd1, +#endif + DBUS_TYPE_UINT32, &our_uint2, + DBUS_TYPE_UINT32, &our_uint3, + DBUS_TYPE_INVALID)) + { + _dbus_verbose ("expected error: %s - %s\n", error.name, + (error.message != NULL) ? error.message : "no message"); + /* ensure array of string and unix fd not leaked */ + _dbus_assert (our_string_array1 == NULL); +#ifdef HAVE_UNIX_FD_PASSING + _dbus_assert (our_unix_fd1 == -1); +#endif + } + else + { + _dbus_warn ("error: parse with wrong signature: 'uashuu'.\n"); + } + + /* parse with wrong signature: "uashuashu" */ + dbus_message_iter_init (message, &iter); + dbus_error_free (&error); + if (!dbus_message_iter_get_args (&iter, &error, + DBUS_TYPE_UINT32, &our_uint1, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &our_string_array1, &our_string_array_len1, +#ifdef HAVE_UNIX_FD_PASSING + DBUS_TYPE_UNIX_FD, &our_unix_fd1, +#endif + DBUS_TYPE_UINT32, &our_uint2, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &our_string_array2, &our_string_array_len2, +#ifdef HAVE_UNIX_FD_PASSING + DBUS_TYPE_UNIX_FD, &our_unix_fd2, +#endif + DBUS_TYPE_UINT32, &our_uint3, + DBUS_TYPE_INVALID)) + { + _dbus_verbose ("expected error: %s - %s\n", error.name, + (error.message != NULL) ? error.message : "no message"); + /* ensure array of string and unix fd not leaked */ + _dbus_assert (our_string_array1 == NULL); + _dbus_assert (our_string_array2 == NULL); +#ifdef HAVE_UNIX_FD_PASSING + _dbus_assert (our_unix_fd1 == -1); + _dbus_assert (our_unix_fd2 == -1); +#endif + } + else + { + _dbus_warn ("error: parse with wrong signature: 'uashuashu'.\n"); + } + + /* parse with correct signature: "uashuash" */ + dbus_message_iter_init (message, &iter); + dbus_error_free (&error); + if (!dbus_message_iter_get_args (&iter, &error, + DBUS_TYPE_UINT32, &our_uint1, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &our_string_array1, &our_string_array_len1, +#ifdef HAVE_UNIX_FD_PASSING + DBUS_TYPE_UNIX_FD, &our_unix_fd1, +#endif + DBUS_TYPE_UINT32, &our_uint2, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, + &our_string_array2, &our_string_array_len2, +#ifdef HAVE_UNIX_FD_PASSING + DBUS_TYPE_UNIX_FD, &our_unix_fd2, +#endif + DBUS_TYPE_INVALID)) + { + _dbus_warn ("error: %s - %s\n", error.name, + (error.message != NULL) ? error.message : "no message"); + _dbus_assert_not_reached ("Could not get arguments"); + } + else + { + dbus_free_string_array (our_string_array1); + dbus_free_string_array (our_string_array2); +#ifdef HAVE_UNIX_FD_PASSING + _dbus_close (our_unix_fd1, &error); + _dbus_close (our_unix_fd2, &error); +#endif + } + _dbus_check_fdleaks_leave (initial_fds); +} + /** * @ingroup DBusMessageInternals * Unit test for DBusMessage. @@ -1020,7 +1175,9 @@ _dbus_message_test (const char *test_data_dir) const dbus_uint64_t *v_ARRAY_UINT64 = our_uint64_array; const dbus_int64_t *v_ARRAY_INT64 = our_int64_array; const char *our_string_array[] = { "Foo", "bar", "", "woo woo woo woo" }; + const char *our_string_array1[] = { "foo", "Bar", "", "Woo woo Woo woo" }; const char **v_ARRAY_STRING = our_string_array; + const char **v1_ARRAY_STRING = our_string_array1; const double our_double_array[] = { 0.1234, 9876.54321, -300.0 }; const double *v_ARRAY_DOUBLE = our_double_array; const unsigned char our_byte_array[] = { 'a', 'b', 'c', 234 }; @@ -1035,6 +1192,7 @@ _dbus_message_test (const char *test_data_dir) dbus_uint16_t v_UINT16; dbus_int32_t v_INT32; dbus_uint32_t v_UINT32; + dbus_uint32_t v1_UINT32; dbus_int64_t v_INT64; dbus_uint64_t v_UINT64; unsigned char v_BYTE; @@ -1043,6 +1201,7 @@ _dbus_message_test (const char *test_data_dir) DBusMessageIter iter, array_iter, struct_iter; #ifdef HAVE_UNIX_FD_PASSING int v_UNIX_FD; + int v1_UNIX_FD; #endif char **decomposed; DBusInitialFDs *initial_fds; @@ -1194,6 +1353,7 @@ _dbus_message_test (const char *test_data_dir) v2_BYTE = 24; #ifdef HAVE_UNIX_FD_PASSING v_UNIX_FD = 1; + v1_UNIX_FD = 2; #endif dbus_message_append_args (message, @@ -1463,6 +1623,51 @@ _dbus_message_test (const char *test_data_dir) dbus_message_unref (message); + /* Check we should not leak array of string or unix fd, fd.o#21259 */ + message = dbus_message_new_method_call ("org.freedesktop.DBus.TestService", + "/org/freedesktop/TestPath", + "Foo.TestInterface", + "Method"); + + /* signature "uashuash" */ + dbus_message_append_args (message, + DBUS_TYPE_UINT32, &v_UINT32, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &v_ARRAY_STRING, + _DBUS_N_ELEMENTS (our_string_array), +#ifdef HAVE_UNIX_FD_PASSING + DBUS_TYPE_UNIX_FD, &v_UNIX_FD, +#endif + DBUS_TYPE_UINT32, &v1_UINT32, + DBUS_TYPE_ARRAY, DBUS_TYPE_STRING, &v1_ARRAY_STRING, + _DBUS_N_ELEMENTS (our_string_array1), +#ifdef HAVE_UNIX_FD_PASSING + DBUS_TYPE_UNIX_FD, &v1_UNIX_FD, +#endif + + DBUS_TYPE_INVALID); + + i = 0; + sig[i++] = DBUS_TYPE_UINT32; + sig[i++] = DBUS_TYPE_ARRAY; + sig[i++] = DBUS_TYPE_STRING; +#ifdef HAVE_UNIX_FD_PASSING + sig[i++] = DBUS_TYPE_UNIX_FD; +#endif + sig[i++] = DBUS_TYPE_UINT32; + sig[i++] = DBUS_TYPE_ARRAY; + sig[i++] = DBUS_TYPE_STRING; +#ifdef HAVE_UNIX_FD_PASSING + sig[i++] = DBUS_TYPE_UNIX_FD; +#endif + sig[i++] = DBUS_TYPE_INVALID; + + _dbus_assert (i < (int) _DBUS_N_ELEMENTS (sig)); + + verify_test_message_args_ignored (message); + verify_test_message_memleak (message); + + dbus_message_unref (message); + /* Load all the sample messages from the message factory */ { DBusMessageDataIter diter; -- cgit v1.2.1 From aa4b9d39bd04d18b57af9b247a326f6b7c328254 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 1 Nov 2013 16:23:27 +0800 Subject: Use SIGHUP without check in UNIX environment As Simon's comment https://bugs.freedesktop.org/show_bug.cgi?id=66068#c8 we can do this in UNIX environment. Reviewed-by: Simon McVittie --- bus/main.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/bus/main.c b/bus/main.c index 472458ed..e060baa8 100644 --- a/bus/main.c +++ b/bus/main.c @@ -61,7 +61,6 @@ signal_handler (int sig) { switch (sig) { -#ifdef SIGHUP case SIGHUP: { DBusString str; @@ -94,7 +93,6 @@ signal_handler (int sig) } } break; -#endif case SIGTERM: { @@ -642,9 +640,7 @@ main (int argc, char **argv) * no point in trying to make the handler portable to non-Unix. */ _dbus_set_signal_handler (SIGTERM, signal_handler); -#ifdef SIGHUP _dbus_set_signal_handler (SIGHUP, signal_handler); -#endif #endif /* DBUS_UNIX */ _dbus_verbose ("We are on D-Bus...\n"); -- cgit v1.2.1 From c3f20a67e623f7277a9ca5610fa8416d6ed5c04d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 11:43:57 +0000 Subject: dbus-spawn: draw a diagram There are enough pipes, fds and processes here that it's important to keep track of them. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859 --- dbus/dbus-spawn.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 7c46935a..3d8ed2e8 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -174,6 +174,48 @@ read_pid (int fd, * and the grandchild. The grandchild is our spawned process. The intermediate * child is a babysitter process; it keeps track of when the grandchild * exits/crashes, and reaps the grandchild. + * + * We automatically reap the babysitter process, killing it if necessary, + * when the DBusBabysitter's refcount goes to zero. + * + * Processes: + * + * main process + * | fork() A + * \- babysitter + * | fork () B + * \- grandchild --> exec --> spawned process + * + * IPC: + * child_err_report_pipe + * /-----------<---------<--------------\ + * | ^ + * v | + * main process babysitter grandchild + * ^ ^ + * v v + * \-------<->-------/ + * babysitter_pipe + * + * child_err_report_pipe is genuinely a pipe. + * The READ_END (also called error_pipe_from_child) is used in the main + * process. The WRITE_END (also called child_err_report_fd) is used in + * the grandchild process. + * + * On failure, the grandchild process sends CHILD_EXEC_FAILED + errno. + * On success, the pipe just closes (because it's close-on-exec) without + * sending any bytes. + * + * babysitter_pipe is mis-named: it's really a bidirectional socketpair. + * The [0] end (also called socket_to_babysitter) is used in the main + * process, the [1] end (also called parent_pipe) is used in the babysitter. + * + * If the fork() labelled B in the diagram above fails, the babysitter sends + * CHILD_FORK_FAILED + errno. + * On success, the babysitter sends CHILD_PID + the grandchild's pid. + * On SIGCHLD, the babysitter sends CHILD_EXITED + the exit status. + * The main process doesn't explicitly send anything, but when it exits, + * the babysitter gets POLLHUP or POLLERR. */ /* Messages from children to parents */ -- cgit v1.2.1 From 7c540d743db0d7b2f00d35782defcacda8b1479c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 28 Nov 2012 17:11:38 +0000 Subject: transaction_free: factor out Bug: https://bugs.freedesktop.org/show_bug.cgi?id=60859 Reviewed-by: Chengwei Yang [removed unused variable based on review -smcv] --- bus/connection.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bus/connection.c b/bus/connection.c index d69758c9..fddbc78a 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -2125,6 +2125,16 @@ bus_transaction_send (BusTransaction *transaction, return TRUE; } +static void +transaction_free (BusTransaction *transaction) +{ + _dbus_assert (transaction->connections == NULL); + + free_cancel_hooks (transaction); + + dbus_free (transaction); +} + static void connection_cancel_transaction (DBusConnection *connection, BusTransaction *transaction) @@ -2163,14 +2173,10 @@ bus_transaction_cancel_and_free (BusTransaction *transaction) while ((connection = _dbus_list_pop_first (&transaction->connections))) connection_cancel_transaction (connection, transaction); - _dbus_assert (transaction->connections == NULL); - _dbus_list_foreach (&transaction->cancel_hooks, cancel_hook_cancel, NULL); - free_cancel_hooks (transaction); - - dbus_free (transaction); + transaction_free (transaction); } static void @@ -2224,11 +2230,7 @@ bus_transaction_execute_and_free (BusTransaction *transaction) while ((connection = _dbus_list_pop_first (&transaction->connections))) connection_execute_transaction (connection, transaction); - _dbus_assert (transaction->connections == NULL); - - free_cancel_hooks (transaction); - - dbus_free (transaction); + transaction_free (transaction); } static void -- cgit v1.2.1 From 1e52889d2e64c6cc9085ba615420082bee18b611 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 9 Oct 2013 09:39:43 +0800 Subject: Remove unnecessary dbus_setenv() DBUS_ACTIVATION_ADDRESS changed to DBUS_STARTER_ADDRESS and DBUS_ACTIVATION_BUS_TYPE changed to DBUS_STARTER_BUS_TYPE since 2005 by this commit - 8873c90 So the dbus_setenv() which used to unset the above two wrong environment variables has no effect in fact. And giving that setenv(3) and putenv(3) are not threadsafe, so it's better to remove them. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68308 Reviewed-by: Ralf Habacker Reviewed-by: Simon McVittie Acked-by: Colin Walters --- dbus/dbus-bus.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 9d2095f9..0fd48311 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -294,12 +294,6 @@ init_connections_unlocked (void) * the above code will work right */ - if (!dbus_setenv ("DBUS_ACTIVATION_ADDRESS", NULL)) - return FALSE; - - if (!dbus_setenv ("DBUS_ACTIVATION_BUS_TYPE", NULL)) - return FALSE; - if (!_dbus_register_shutdown_func (addresses_shutdown_func, NULL)) return FALSE; -- cgit v1.2.1 From f110f0011600f80bb50a9037e5fdcf5296fc1fde Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 13 Sep 2013 20:37:56 +0800 Subject: Update configurable elements for dbus-daemon manual Update three configurable elements for dbus-daemon manual, , and , all of them are undocumented so far. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69125 Reviewed-by: Simon McVittie --- doc/dbus-daemon.1.xml.in | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index c08cf2b2..1a1e42cd 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -316,6 +316,37 @@ rather than the --fork command line option. If present, the bus daemon keeps its original umask when forking. This may be useful to avoid affecting the behavior of child processes. + + + <syslog> + + + + +If present, the bus daemon will log to syslog. + + + + <pidfile> + + + + +If present, the bus daemon will write its pid to the specified file. +The --nopidfile command-line option takes precedence over this setting. + + + + <allow_anonymous> + + + + +If present, connections that authenticated using the ANONYMOUS +mechanism will be authorized to connect. This option has no practical +effect unless the ANONYMOUS mechanism has also been enabled using the +<auth> element, described below. + <listen> -- cgit v1.2.1 From ec6ea1a6a8ad1d5e3c1280a55207e9b4f5742814 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 15 Oct 2013 13:04:53 +0800 Subject: DBusBabysitter: change executable to log_name DBusBabysitter->executable is defined as executable name to use in error messages. However, if servicehelper used, then the executable name is servicehelper. It's not much help because we couldn't figure out which service we're trying to activated if error happens. In the following patch, we'll use service name to be activated as the child log identifier and add a parameter to _dbus_spawn_async_with_babysitter() to pass the log identifier. Since this is not the case in test, so executable changed to log_name. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559 Reviewed-by: Simon McVittie --- bus/activation.c | 4 +++- dbus/dbus-spawn-win.c | 37 ++++++++++++++++++++++++------------- dbus/dbus-spawn.c | 44 ++++++++++++++++++++++++++++---------------- dbus/dbus-spawn.h | 1 + test/spawn-test.c | 2 +- 5 files changed, 57 insertions(+), 31 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index 77357bea..868ce05c 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -2104,7 +2104,9 @@ bus_activation_activate_service (BusActivation *activation, dbus_error_init (&tmp_error); - if (!_dbus_spawn_async_with_babysitter (&pending_activation->babysitter, argv, + if (!_dbus_spawn_async_with_babysitter (&pending_activation->babysitter, + service_name, + argv, envp, NULL, activation, &tmp_error)) diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index cd8ca666..7da7a431 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -68,7 +68,7 @@ struct DBusBabysitter HANDLE end_sync_event; #endif - char *executable; + char *log_name; DBusSpawnChildSetupFunc child_setup; void *user_data; @@ -258,7 +258,7 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) } #endif - dbus_free (sitter->executable); + dbus_free (sitter->log_name); dbus_free (sitter); } @@ -337,7 +337,7 @@ _dbus_babysitter_set_child_exit_error (DBusBabysitter *sitter, char *emsg = _dbus_win_error_string (sitter->spawn_errno); dbus_set_error (error, DBUS_ERROR_SPAWN_EXEC_FAILED, "Failed to execute program %s: %s", - sitter->executable, emsg); + sitter->log_name, emsg); _dbus_win_free_error_string (emsg); } else if (sitter->have_child_status) @@ -345,14 +345,14 @@ _dbus_babysitter_set_child_exit_error (DBusBabysitter *sitter, PING(); dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_EXITED, "Process %s exited with status %d", - sitter->executable, sitter->child_status); + sitter->log_name, sitter->child_status); } else { PING(); dbus_set_error (error, DBUS_ERROR_FAILED, "Process %s exited, status unknown", - sitter->executable); + sitter->log_name); } PING(); } @@ -593,10 +593,10 @@ babysitter (void *parameter) (*sitter->child_setup) (sitter->user_data); } - _dbus_verbose ("babysitter: spawning %s\n", sitter->executable); + _dbus_verbose ("babysitter: spawning %s\n", sitter->log_name); PING(); - sitter->child_handle = spawn_program (sitter->executable, + sitter->child_handle = spawn_program (sitter->log_name, sitter->argv, sitter->envp); PING(); @@ -642,6 +642,7 @@ babysitter (void *parameter) dbus_bool_t _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, + const char *log_name, char **argv, char **envp, DBusSpawnChildSetupFunc child_setup, @@ -653,6 +654,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, DWORD sitter_thread_id; _DBUS_ASSERT_ERROR_IS_CLEAR (error); + _dbus_assert (argv[0] != NULL); *sitter_p = NULL; @@ -667,8 +669,17 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, sitter->child_setup = child_setup; sitter->user_data = user_data; - sitter->executable = _dbus_strdup (argv[0]); - if (sitter->executable == NULL) + sitter->log_name = _dbus_strdup (log_name); + if (sitter->log_name == NULL && log_name != NULL) + { + _DBUS_SET_OOM (error); + goto out0; + } + + if (sitter->log_name == NULL) + sitter->log_name = _dbus_strdup (argv[0]); + + if (sitter->log_name == NULL) { _DBUS_SET_OOM (error); goto out0; @@ -804,7 +815,7 @@ check_spawn_nonexistent (void *data) /*** Test launching nonexistent binary */ argv[0] = "/this/does/not/exist/32542sdgafgafdg"; - if (_dbus_spawn_async_with_babysitter (&sitter, argv, NULL, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_nonexistent", argv, NULL, NULL, NULL, &error)) { @@ -857,7 +868,7 @@ check_spawn_segfault (void *data) return TRUE; } - if (_dbus_spawn_async_with_babysitter (&sitter, argv, NULL, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_segfault", argv, NULL, NULL, NULL, &error)) { @@ -912,7 +923,7 @@ check_spawn_exit (void *data) return TRUE; } - if (_dbus_spawn_async_with_babysitter (&sitter, argv, NULL, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_exit", argv, NULL, NULL, NULL, &error)) { @@ -967,7 +978,7 @@ check_spawn_and_kill (void *data) return TRUE; } - if (_dbus_spawn_async_with_babysitter (&sitter, argv, NULL, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_and_kill", argv, NULL, NULL, NULL, &error)) { diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 3d8ed2e8..a0ff2f4e 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -234,7 +234,8 @@ struct DBusBabysitter { int refcount; /**< Reference count */ - char *executable; /**< executable name to use in error messages */ + char *log_name; /**< the name under which to log messages about this + process being spawned */ int socket_to_babysitter; /**< Connection to the babysitter process */ int error_pipe_from_child; /**< Connection to the process that does the exec() */ @@ -388,7 +389,7 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) if (sitter->watches) _dbus_watch_list_free (sitter->watches); - dbus_free (sitter->executable); + dbus_free (sitter->log_name); dbus_free (sitter); } @@ -743,34 +744,34 @@ _dbus_babysitter_set_child_exit_error (DBusBabysitter *sitter, { dbus_set_error (error, DBUS_ERROR_SPAWN_EXEC_FAILED, "Failed to execute program %s: %s", - sitter->executable, _dbus_strerror (sitter->errnum)); + sitter->log_name, _dbus_strerror (sitter->errnum)); } else if (sitter->have_fork_errnum) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, "Failed to fork a new process %s: %s", - sitter->executable, _dbus_strerror (sitter->errnum)); + sitter->log_name, _dbus_strerror (sitter->errnum)); } else if (sitter->have_child_status) { if (WIFEXITED (sitter->status)) dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_EXITED, "Process %s exited with status %d", - sitter->executable, WEXITSTATUS (sitter->status)); + sitter->log_name, WEXITSTATUS (sitter->status)); else if (WIFSIGNALED (sitter->status)) dbus_set_error (error, DBUS_ERROR_SPAWN_CHILD_SIGNALED, "Process %s received signal %d", - sitter->executable, WTERMSIG (sitter->status)); + sitter->log_name, WTERMSIG (sitter->status)); else dbus_set_error (error, DBUS_ERROR_FAILED, "Process %s exited abnormally", - sitter->executable); + sitter->log_name); } else { dbus_set_error (error, DBUS_ERROR_FAILED, "Process %s exited, reason unknown", - sitter->executable); + sitter->log_name); } } @@ -1165,8 +1166,7 @@ babysit (pid_t grandchild_pid, } /** - * Spawns a new process. The executable name and argv[0] - * are the same, both are provided in argv[0]. The child_setup + * Spawns a new process. The child_setup * function is passed the given user_data and is run in the child * just before calling exec(). * @@ -1176,6 +1176,7 @@ babysit (pid_t grandchild_pid, * If sitter_p is #NULL, no babysitter is kept. * * @param sitter_p return location for babysitter or #NULL + * @log_name the name under which to log messages about this process being spawned * @param argv the executable and arguments * @param env the environment, or #NULL to copy the parent's * @param child_setup function to call in child pre-exec() @@ -1185,6 +1186,7 @@ babysit (pid_t grandchild_pid, */ dbus_bool_t _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, + const char *log_name, char **argv, char **env, DBusSpawnChildSetupFunc child_setup, @@ -1197,6 +1199,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, pid_t pid; _DBUS_ASSERT_ERROR_IS_CLEAR (error); + _dbus_assert (argv[0] != NULL); if (sitter_p != NULL) *sitter_p = NULL; @@ -1210,8 +1213,17 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, return FALSE; } - sitter->executable = _dbus_strdup (argv[0]); - if (sitter->executable == NULL) + sitter->log_name = _dbus_strdup (log_name); + if (sitter->log_name == NULL && log_name != NULL) + { + dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); + goto cleanup_and_fail; + } + + if (sitter->log_name == NULL) + sitter->log_name = _dbus_strdup (argv[0]); + + if (sitter->log_name == NULL) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto cleanup_and_fail; @@ -1418,7 +1430,7 @@ check_spawn_nonexistent (void *data) /*** Test launching nonexistent binary */ argv[0] = "/this/does/not/exist/32542sdgafgafdg"; - if (_dbus_spawn_async_with_babysitter (&sitter, argv, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_nonexistent", argv, NULL, NULL, NULL, &error)) { @@ -1467,7 +1479,7 @@ check_spawn_segfault (void *data) return TRUE; } - if (_dbus_spawn_async_with_babysitter (&sitter, argv, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_segfault", argv, NULL, NULL, NULL, &error)) { @@ -1518,7 +1530,7 @@ check_spawn_exit (void *data) return TRUE; } - if (_dbus_spawn_async_with_babysitter (&sitter, argv, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_exit", argv, NULL, NULL, NULL, &error)) { @@ -1569,7 +1581,7 @@ check_spawn_and_kill (void *data) return TRUE; } - if (_dbus_spawn_async_with_babysitter (&sitter, argv, + if (_dbus_spawn_async_with_babysitter (&sitter, "spawn_and_kill", argv, NULL, NULL, NULL, &error)) { diff --git a/dbus/dbus-spawn.h b/dbus/dbus-spawn.h index a8814fb9..e6baae97 100644 --- a/dbus/dbus-spawn.h +++ b/dbus/dbus-spawn.h @@ -39,6 +39,7 @@ typedef void (* DBusBabysitterFinishedFunc) (DBusBabysitter *sitter, void *user_data); dbus_bool_t _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, + const char *log_name, char **argv, char **env, DBusSpawnChildSetupFunc child_setup, diff --git a/test/spawn-test.c b/test/spawn-test.c index e6513fa6..723a4889 100644 --- a/test/spawn-test.c +++ b/test/spawn-test.c @@ -30,7 +30,7 @@ main (int argc, char **argv) argv_copy [i] = argv[i + 1]; argv_copy[argc - 1] = NULL; - if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy, NULL, setup_func, NULL, &error)) + if (!_dbus_spawn_async_with_babysitter (NULL, argv_copy[0], argv_copy, NULL, setup_func, NULL, &error)) { fprintf (stderr, "Could not launch application: \"%s\"\n", error.message); -- cgit v1.2.1 From 5be1e77829680ad1beac235d2f454570991ee36e Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 15 Oct 2013 13:27:51 +0800 Subject: Handle activated child stdout/stderr correctly in systemd environment In systemd environment, dbus-daemon will run as no-fork mode since this is the recommended practice of systemd. In that scenario, child activated by dbus-daemon will inherit dbus-daemon standard streams, includes stdin/stdout/stderr. stdin will be redirected to /dev/null by systemd and stdout/stderr will be catched by systemd log subsystem. Since the child inherit stdout/stderr from dbus-daemon, so from systemd journal log, the child log output will be identified with dbus-daemon identifier. So it's a little confusing. This patch redirects the child stdout/stderr to systemd journal stream, and with its owned service name as identifier. However, thing not fixed perfectly due to the socket ucred of the child is owned by dbus-daemon, so the pid isn't the real pid of the chile. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559 Reviewed-by: Simon McVittie --- configure.ac | 2 +- dbus/dbus-spawn.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b29c8f09..37e555b9 100644 --- a/configure.ac +++ b/configure.ac @@ -1143,7 +1143,7 @@ if test x$enable_systemd = xno ; then have_systemd=no; else PKG_CHECK_MODULES(SYSTEMD, - [libsystemd-login >= 32, libsystemd-daemon >= 32], + [libsystemd-login >= 32, libsystemd-daemon >= 32, libsystemd-journal >= 32], have_systemd=yes, have_systemd=no) fi diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index a0ff2f4e..0802d89d 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -38,6 +38,9 @@ #ifdef HAVE_ERRNO_H #include #endif +#ifdef HAVE_SYSTEMD +#include +#endif extern char **environ; @@ -1197,6 +1200,10 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, int child_err_report_pipe[2] = { -1, -1 }; int babysitter_pipe[2] = { -1, -1 }; pid_t pid; +#ifdef HAVE_SYSTEMD + int fd_out = -1; + int fd_err = -1; +#endif _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_assert (argv[0] != NULL); @@ -1283,7 +1290,13 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, } _DBUS_ASSERT_ERROR_IS_CLEAR (error); - + +#ifdef HAVE_SYSTEMD + /* this may fail, but not critical */ + fd_out = sd_journal_stream_fd (sitter->log_name, LOG_INFO, FALSE); + fd_err = sd_journal_stream_fd (sitter->log_name, LOG_WARNING, FALSE); +#endif + pid = fork (); if (pid < 0) @@ -1323,6 +1336,15 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, */ signal (SIGPIPE, SIG_IGN); +#ifdef HAVE_SYSTEMD + /* log to systemd journal */ + if (fd_out >= 0) + dup2 (fd_out, STDOUT_FILENO); + if (fd_err >= 0) + dup2 (fd_err, STDERR_FILENO); + close_and_invalidate (&fd_out); + close_and_invalidate (&fd_err); +#endif do_exec (child_err_report_pipe[WRITE_END], argv, env, @@ -1331,6 +1353,10 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, } else { +#ifdef HAVE_SYSTEMD + close_and_invalidate (&fd_out); + close_and_invalidate (&fd_err); +#endif babysit (grandchild_pid, babysitter_pipe[1]); _dbus_assert_not_reached ("Got to code after babysit()"); } @@ -1340,6 +1366,10 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, /* Close the uncared-about ends of the pipes */ close_and_invalidate (&child_err_report_pipe[WRITE_END]); close_and_invalidate (&babysitter_pipe[1]); +#ifdef HAVE_SYSTEMD + close_and_invalidate (&fd_out); + close_and_invalidate (&fd_err); +#endif sitter->socket_to_babysitter = babysitter_pipe[0]; babysitter_pipe[0] = -1; @@ -1369,6 +1399,10 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, close_and_invalidate (&child_err_report_pipe[WRITE_END]); close_and_invalidate (&babysitter_pipe[0]); close_and_invalidate (&babysitter_pipe[1]); +#ifdef HAVE_SYSTEMD + close_and_invalidate (&fd_out); + close_and_invalidate (&fd_err); +#endif if (sitter != NULL) _dbus_babysitter_unref (sitter); -- cgit v1.2.1 From e326e762e9f490e2609c122a09962fa77a282f81 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 12:43:07 +0000 Subject: Add comments describing how "compile with journald, run without" works --- dbus/dbus-spawn.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 0802d89d..af624e7c 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1292,7 +1292,10 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, _DBUS_ASSERT_ERROR_IS_CLEAR (error); #ifdef HAVE_SYSTEMD - /* this may fail, but not critical */ + /* This may fail, but it's not critical. + * In particular, if we were compiled with journald support but are now + * running on a non-systemd system, this is going to fail, so we + * have to cope gracefully. */ fd_out = sd_journal_stream_fd (sitter->log_name, LOG_INFO, FALSE); fd_err = sd_journal_stream_fd (sitter->log_name, LOG_WARNING, FALSE); #endif @@ -1337,7 +1340,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, signal (SIGPIPE, SIG_IGN); #ifdef HAVE_SYSTEMD - /* log to systemd journal */ + /* log to systemd journal if possible */ if (fd_out >= 0) dup2 (fd_out, STDOUT_FILENO); if (fd_err >= 0) -- cgit v1.2.1 From 1504b281e944fb41cc2319c411fef4881df58b3b Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 15 Oct 2013 13:23:09 +0800 Subject: Close unused inherited file descriptor Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68559 Reviewed-by: Simon McVittie --- dbus/dbus-spawn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index af624e7c..d1478f00 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1339,6 +1339,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, */ signal (SIGPIPE, SIG_IGN); + close_and_invalidate (&babysitter_pipe[1]); #ifdef HAVE_SYSTEMD /* log to systemd journal if possible */ if (fd_out >= 0) @@ -1356,6 +1357,7 @@ _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, } else { + close_and_invalidate (&child_err_report_pipe[WRITE_END]); #ifdef HAVE_SYSTEMD close_and_invalidate (&fd_out); close_and_invalidate (&fd_err); -- cgit v1.2.1 From f4606cf30763b5ae432c192cb589effc74336378 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 16:24:22 +0000 Subject: 1.6.18 --- NEWS | 9 ++++++++- configure.ac | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 44415fc1..306f45f9 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,13 @@ -D-Bus 1.6.18 (UNRELEASED) +D-Bus 1.6.18 (2013-11-01) == +The “sunflower plains” release. + +Fixes: + +• path_namespace='/' in match rules incorrectly matched nothing; it + now matches everything. (fd.o #70799, Simon McVittie) + D-Bus 1.6.16 (2013-10-08) == diff --git a/configure.ac b/configure.ac index e7a672e0..20b788d3 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [17]) +m4_define([dbus_micro_version], [18]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=10 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=5 +LT_REVISION=6 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From ba7b85711838cf9b9dfa30dde74a636393235c3e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 18:44:21 +0000 Subject: Start on 1.6.20 --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 306f45f9..de4656d4 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +D-Bus 1.6.19 (UNRELEASED) +== + D-Bus 1.6.18 (2013-11-01) == diff --git a/configure.ac b/configure.ac index 20b788d3..25996f5e 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [6]) -m4_define([dbus_micro_version], [18]) +m4_define([dbus_micro_version], [19]) 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]) -- cgit v1.2.1 From 6b3a169bb0d0c7464a861ce1d9a8af4946f62fb1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 18:49:48 +0000 Subject: Revert "start dbus-specification 0.23" This reverts commit c8bc5f24b721bc03679c44669cf5e655c1e99b5f. Nothing changed since 0.22. --- doc/dbus-specification.xml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 125001ad..bc374b9b 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.23 - (not yet released) + Version 0.22 + 2013-10-09 Havoc @@ -71,14 +71,6 @@ - - 0.23 - not yet released - - - see commit log - - 0.22 2013-10-09 -- cgit v1.2.1 From 983237258dc440419b863461fae15f31cce08639 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 27 Oct 2013 16:21:19 -0400 Subject: bus/selinux: Fix previous commit for CAP_AUDIT_WRITE retention As soon as capng_clear() is called, we won't appear to have CAP_AUDIT_WRITE. Fix this by checking for it before resetting the libcap state. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49062 Tested-by: Laurent Bigonville Reviewed-by: Laurent Bigonville Reviewed-by: Simon McVittie Reviewed-by: Lennart Poettering --- bus/selinux.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bus/selinux.c b/bus/selinux.c index 7ae84d6d..768e55ef 100644 --- a/bus/selinux.c +++ b/bus/selinux.c @@ -1043,9 +1043,15 @@ _dbus_change_to_daemon_user (const char *user, if (_dbus_geteuid () == 0) { int rc; + int have_audit_write; + have_audit_write = capng_have_capability (CAPNG_PERMITTED, CAP_AUDIT_WRITE); capng_clear (CAPNG_SELECT_BOTH); - if (capng_have_capability (CAPNG_PERMITTED, CAP_AUDIT_WRITE)) + /* Only attempt to retain CAP_AUDIT_WRITE if we had it when + * starting. See: + * https://bugs.freedesktop.org/show_bug.cgi?id=49062#c9 + */ + if (have_audit_write) capng_update (CAPNG_ADD, CAPNG_EFFECTIVE | CAPNG_PERMITTED, CAP_AUDIT_WRITE); rc = capng_change_id (uid, gid, CAPNG_DROP_SUPP_GRP); -- cgit v1.2.1 From fc7f0fa64265ac3a97f23a714db4399803fa71f5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 19:17:02 +0000 Subject: 1.7.8 --- NEWS | 26 +++++++++++++++++++++++++- configure.ac | 4 ++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index bd7f856e..972d3984 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,32 @@ -D-Bus 1.7.8 (UNRELEASED) +D-Bus 1.7.8 (2013-11-01) == +The “extreme hills” release. + +Dependencies: + +• If systemd support is enabled, libsystemd-journal is now required. + +Enhancements: + +• When activating a non-systemd service under systemd, annotate its + stdout/stderr with its bus name in the Journal. Known limitation: + because the socket is opened before forking, the process will still be + logged as if it had dbus-daemon's process ID and user ID. + (fd.o #68559, Chengwei Yang) + +• Document more configuration elements in dbus-daemon(1) + (fd.o #69125, Chengwei Yang) + Fixes: +• Don't leak string arrays or fds if dbus_message_iter_get_args_valist() + unpacks them and then encounters an error (fd.o #21259, Chengwei Yang) + +• If compiled with libaudit, retain CAP_AUDIT_WRITE so we can write + disallowed method calls to the audit log, fixing a regression in 1.7.6 + (fd.o #49062, Colin Walters) + • path_namespace='/' in match rules incorrectly matched nothing; it now matches everything. (fd.o #70799, Simon McVittie) diff --git a/configure.ac b/configure.ac index 37e555b9..f759cf48 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [7]) +m4_define([dbus_micro_version], [8]) 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]) @@ -37,7 +37,7 @@ LT_CURRENT=11 ## increment any time the source changes; set to ## 0 if you increment CURRENT -LT_REVISION=2 +LT_REVISION=3 ## increment if any interfaces have been added; set to 0 ## if any interfaces have been changed or removed. removal has -- cgit v1.2.1 From 727349248f908d5d2a523e65c0e0dca30b4996d2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 10 Oct 2013 13:14:01 +0100 Subject: start dbus-specification 0.23 --- doc/dbus-specification.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index bc374b9b..125001ad 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.22 - 2013-10-09 + Version 0.23 + (not yet released) Havoc @@ -71,6 +71,14 @@ + + 0.23 + not yet released + + + see commit log + + 0.22 2013-10-09 -- cgit v1.2.1 From c92dffe6ab4acd58eca4516eed7f762d683c0982 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 20:17:52 +0000 Subject: start on 1.7.10 --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 972d3984..825121f8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +D-Bus 1.7.10 (UNRELEASED) +== + D-Bus 1.7.8 (2013-11-01) == diff --git a/configure.ac b/configure.ac index f759cf48..bae18118 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [8]) +m4_define([dbus_micro_version], [9]) 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]) -- cgit v1.2.1 From 7c00ed22d9b5c33f5b33221e906946b11a9bde3b Mon Sep 17 00:00:00 2001 From: DreamNik Date: Sun, 29 Sep 2013 14:45:58 +0400 Subject: make_and_run_test_nodes: avoid undefined behaviour In code that looks like n[i] = v(&i), where v increments i, C leaves it undefined whether the old or new value of i is used to locate n[i]. As it happens, gcc used the pre-increment value of i, but MSVC used the post-increment value. Fix this by inserting a sequence point to disambiguate the intended order. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69924 Reviewed-by: Chengwei Yang Reviewed-by: Simon McVittie [wrote commit message, fixed whitespace -smcv] Signed-off-by: Simon McVittie --- dbus/dbus-marshal-recursive-util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c index 95124140..a2aaaf93 100644 --- a/dbus/dbus-marshal-recursive-util.c +++ b/dbus/dbus-marshal-recursive-util.c @@ -1785,10 +1785,13 @@ make_and_run_test_nodes (void) start_next_test ("All values in one big toplevel %d iteration\n", 1); { TestTypeNode *nodes[N_VALUES]; + TestTypeNode *node; i = 0; - while ((nodes[i] = value_generator (&i))) - ; + while ((node = value_generator (&i))) + { + nodes[i - 1] = node; + } run_test_nodes (nodes, N_VALUES); -- cgit v1.2.1 From c9ebd602c1fa57ef67977407289adfa497f881a4 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 4 Nov 2013 11:44:34 +0000 Subject: NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index de4656d4..95c3c10c 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,10 @@ D-Bus 1.6.19 (UNRELEASED) == +Fixes: + +• fix undefined behaviour in a regression test (fd.o #69924, DreamNik) + D-Bus 1.6.18 (2013-11-01) == -- cgit v1.2.1 From ba088208bc0c35ca418a097a8482c4a7705f4a43 Mon Sep 17 00:00:00 2001 From: osmond sun Date: Wed, 6 Nov 2013 00:53:18 +0800 Subject: selinux: Use selinux_set_mapping() to avoid hardcoded constants for policy Previous to the introduction of selinux_set_mapping(), DBus pulled constants generated from the system's policy at build time. But this means it's impossible to replace the system policy without rebuilding userspace components. This patch maps from arbitrary class/perm indices used by D-Bus and the policy values and handles all the translation at runtime on avc_has_perm() calls. Bug: https://bugs.freedesktop.org/attachment.cgi?id=88719 Reviewed-By: Colin Walters Tested-By: Colin Walters --- bus/bus.c | 2 +- bus/selinux.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bus/bus.c b/bus/bus.c index 307c1586..e24504c3 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -894,7 +894,7 @@ bus_context_new (const DBusString *config_file, if (!bus_selinux_full_init ()) { - bus_context_log (context, DBUS_SYSTEM_LOG_FATAL, "SELinux enabled but AVC initialization failed; check system log\n"); + bus_context_log (context, DBUS_SYSTEM_LOG_FATAL, "SELinux enabled but D-Bus initialization failed; check system log\n"); } if (!process_config_postinit (context, parser, error)) diff --git a/bus/selinux.c b/bus/selinux.c index 768e55ef..99994ca9 100644 --- a/bus/selinux.c +++ b/bus/selinux.c @@ -44,8 +44,6 @@ #include #include #include -#include -#include #include #include #include @@ -314,8 +312,27 @@ bus_selinux_pre_init (void) #endif } +/* + * Private Flask definitions; the order of these constants must + * exactly match that of the structure array below! + */ +/* security dbus class constants */ +#define SECCLASS_DBUS 1 + +/* dbus's per access vector constants */ +#define DBUS__ACQUIRE_SVC 1 +#define DBUS__SEND_MSG 2 + +#ifdef HAVE_SELINUX +static struct security_class_mapping dbus_map[] = { + { "dbus", { "acquire_svc", "send_msg", NULL } }, + { NULL } +}; +#endif /* HAVE_SELINUX */ + /** - * Initialize the user space access vector cache (AVC) for D-Bus and set up + * Establish dynamic object class and permission mapping and + * initialize the user space access vector cache (AVC) for D-Bus and set up * logging callbacks. */ dbus_bool_t @@ -334,6 +351,13 @@ bus_selinux_full_init (void) _dbus_verbose ("SELinux is enabled in this kernel.\n"); + if (selinux_set_mapping (dbus_map) < 0) + { + _dbus_warn ("Failed to set up security class mapping (selinux_set_mapping():%s).\n", + strerror (errno)); + return FALSE; + } + avc_entry_ref_init (&aeref); if (avc_init ("avc", &mem_cb, &log_cb, &thread_cb, &lock_cb) < 0) { -- cgit v1.2.1 From 03aeaccbffa97c9237b57ca067e3da7388862129 Mon Sep 17 00:00:00 2001 From: Radoslaw Pajak Date: Fri, 8 Nov 2013 13:51:32 +0100 Subject: fixed memory freeing if error during listing services Signed-off-by: Radoslaw Pajak Reviewed-by: Simon McVittie Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71526 --- bus/activation.c | 2 +- bus/services.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bus/activation.c b/bus/activation.c index fcb71337..ea48a26f 100644 --- a/bus/activation.c +++ b/bus/activation.c @@ -2179,7 +2179,7 @@ bus_activation_list_services (BusActivation *activation, error: for (j = 0; j < i; j++) - dbus_free (retval[i]); + dbus_free (retval[j]); dbus_free (retval); return FALSE; diff --git a/bus/services.c b/bus/services.c index 6f380fac..01a720ed 100644 --- a/bus/services.c +++ b/bus/services.c @@ -368,7 +368,7 @@ bus_registry_list_services (BusRegistry *registry, error: for (j = 0; j < i; j++) - dbus_free (retval[i]); + dbus_free (retval[j]); dbus_free (retval); return FALSE; -- cgit v1.2.1 From 4f1ed05afc1ed8088404993dedae57cd766cbbb6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Nov 2013 10:47:55 +0000 Subject: NEWS --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 95c3c10c..2bf70466 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,9 @@ D-Bus 1.6.19 (UNRELEASED) Fixes: +• don't leak memory on out-of-memory while listing activatable or + active services (fd.o #71526, Radoslaw Pajak) + • fix undefined behaviour in a regression test (fd.o #69924, DreamNik) D-Bus 1.6.18 (2013-11-01) -- cgit v1.2.1 From 7c86eb023b63d3b35d529509e30552fdaa0dbf7e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 12 Nov 2013 10:51:17 +0000 Subject: NEWS for the SELinux change --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index ccb83aed..6d7910ac 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,10 @@ Fixes: • fix undefined behaviour in a regression test (fd.o #69924, DreamNik) +• on SELinux systems, don't assume that SECCLASS_DBUS, DBUS__ACQUIRE_SVC + and DBUS__SEND_MSG are numerically equal to their values in the + reference policy (fd.o #88719, osmond sun) + D-Bus 1.7.8 (2013-11-01) == -- cgit v1.2.1 From eca9a5a29e287478625310630cecda8cc29310d8 Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Thu, 7 Nov 2013 18:00:46 -0600 Subject: Fix for MinGW build dbus-sysdeps-win.c makes use of a constant called PROCESS_QUERY_LIMITED_INFORMATION, which was added after Windows XP. There is code present to make sure the constant is not used when running on an XP system, but the constant is still required at build time. Unfortunately, the Windows headers provided by MinGW are old enough that they do not contain this constant, so building with MinGW fails. This patch adds a definition for the constant if one is not already present. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71366 Reviewed-by: Simon McVittie Reviewed-by: Ralf Habacker [altered comment to specify MinGW32 < 4, since mingw-w64 and MinGW 4.0+ do have this constant -smcv] --- dbus/dbus-sysdeps-win.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 1c974c50..74a4e84e 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -81,6 +81,11 @@ extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); #define O_BINARY 0 #endif +#ifndef PROCESS_QUERY_LIMITED_INFORMATION +/* MinGW32 < 4 does not define this value in its headers */ +#define PROCESS_QUERY_LIMITED_INFORMATION (0x1000) +#endif + typedef int socklen_t; -- cgit v1.2.1 From 951b9700d5ec21cd4ef86bbe59dc7976d14283ac Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 15 Nov 2013 09:20:31 +0800 Subject: Fix dbus_shutdown API document: returns --> frees https://bugs.freedesktop.org/show_bug.cgi?id=71627 Reviewed-by: Simon McVittie --- dbus/dbus-memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index d59e8f8c..22e80727 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -856,7 +856,7 @@ _dbus_register_shutdown_func_unlocked (DBusShutdownFunction func, * can be useful to free these internal data structures. * * dbus_shutdown() does NOT free memory that was returned - * to the application. It only returns libdbus-internal + * to the application. It only frees libdbus-internal * data structures. * * You MUST free all memory and release all reference counts -- cgit v1.2.1 From ac502b5cdd17f6819ec8d1f935871139767f0944 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 19 Nov 2013 18:13:01 +0800 Subject: Fix api doc for _dbus_spawn_async_with_babysitter Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71820 Reviewed-by: Simon McVittie --- dbus/dbus-spawn.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index d1478f00..653776b5 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -1179,7 +1179,7 @@ babysit (pid_t grandchild_pid, * If sitter_p is #NULL, no babysitter is kept. * * @param sitter_p return location for babysitter or #NULL - * @log_name the name under which to log messages about this process being spawned + * @param log_name the name under which to log messages about this process being spawned * @param argv the executable and arguments * @param env the environment, or #NULL to copy the parent's * @param child_setup function to call in child pre-exec() -- cgit v1.2.1 From 00993d3702dfdb00970ac62fa793aa60cd7c162e Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Mon, 25 Nov 2013 20:53:44 +0800 Subject: Remove duplicate checking for pkg-config Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71985 Reviewed-by: Simon McVittie --- configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac index bae18118..e37a6329 100644 --- a/configure.ac +++ b/configure.ac @@ -894,8 +894,6 @@ fi # unix:path=/foo or unix:abstract=/foo AC_SUBST(DBUS_PATH_OR_ABSTRACT) -PKG_PROG_PKG_CONFIG - #### Sort out XML library AC_CHECK_LIB(expat, XML_ParserCreate_MM, -- cgit v1.2.1 From 969f3918dcc4a4f6ad03dd078f9bb6a108846513 Mon Sep 17 00:00:00 2001 From: Robert Ancell Date: Fri, 18 Oct 2013 13:46:45 +1300 Subject: Support printing unix file descriptors in dbus-send/dbus-monitor Bug: https://bugs.freedesktop.org/show_bug.cgi?id=70592 Reviewed-by: Chengwei Yang Reviewed-by: Simon McVittie --- tools/dbus-print-message.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c index 75d00aca..e0dd2da6 100644 --- a/tools/dbus-print-message.c +++ b/tools/dbus-print-message.c @@ -346,7 +346,15 @@ print_iter (DBusMessageIter *iter, dbus_bool_t literal, int depth) printf("}\n"); break; } - + + case DBUS_TYPE_UNIX_FD: + { + int fd; + dbus_message_iter_get_basic (iter, &fd); + printf ("unix fd %d\n", fd); + break; + } + default: printf (" (dbus-monitor too dumb to decipher arg type '%c')\n", type); break; -- cgit v1.2.1 From 0fa46f68b8bbd2913ac9620328518fc5f9e16f85 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 14:16:13 +0100 Subject: Do not require messages without INTERFACE to be dispatched Previously, if we have interfaces: interface com.example.foo: method Ambiguous() interface com.example.bar: method Ambiguous() method Unambiguous() implementations were required to deliver a message with no INTERFACE and METHOD=Unambiguous to "bar". A message with no INTERFACE and METHOD=Ambiguous could either be delivered to "foo", delivered to "bar" or treated as an error. Relax this to allow an error for the unambiguous case, too, and strongly recommend specifying the interface (which is best-practice). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68597 Reviewed-by: Chengwei Yang Vaguely-acked-by: Thiago Macieira, David Zeuthen [and desrt objected that it didn't go far enough] Signed-off-by: Simon McVittie --- doc/dbus-specification.xml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 125001ad..865a8bff 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -1688,12 +1688,16 @@ A method call message is required to have a MEMBER header field indicating the name of the method. Optionally, the message has an - INTERFACE field giving the interface the method is a part of. In the - absence of an INTERFACE field, if two interfaces on the same object have - a method with the same name, it is undefined which of the two methods - will be invoked. Implementations may also choose to return an error in - this ambiguous case. However, if a method name is unique - implementations must not require an interface field. + INTERFACE field giving the interface the method is a part of. + Including the INTERFACE in all method call + messages is strongly recommended. + + + In the absence of an INTERFACE field, if two + or more interfaces on the same object have a method with the same + name, it is undefined which of those methods will be invoked. + Implementations may choose to either return an error, or deliver the + message as though it had an arbitrary one of those interfaces. Method call messages also include a PATH field -- cgit v1.2.1 From 8c388a5d213aa28f5d92a19150a697c5eba5554f Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Sep 2013 14:17:25 +0100 Subject: spec: explicitly mention filtering messages with no INTERFACE This is an important security measure. Without it, the system bus would not deliver its intended security properties. The actual implementation has always behaved like this, I think. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68597 Reviewed-by: Chengwei Yang --- doc/dbus-specification.xml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 865a8bff..629ab10c 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -1699,6 +1699,15 @@ Implementations may choose to either return an error, or deliver the message as though it had an arbitrary one of those interfaces. + + In some situations (such as the well-known system bus), messages + are filtered through an access-control list external to the + remote object implementation. If that filter rejects certain + messages by matching their interface, or accepts only messages + to specific interfaces, it must also reject messages that have no + INTERFACE: otherwise, malicious + applications could use this to bypass the filter. + Method call messages also include a PATH field indicating the object to invoke the method on. If the call is passing -- cgit v1.2.1 From 87f37d6d9860f3afe1a7b63cd5ba1411b817f5c0 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 20 Nov 2013 22:25:52 +0800 Subject: _dbus_append_address_from_socket(): escape value got from socket fd So far, this bug can be triggered in systemd environment, if the configured ListenStream for dbus.socket has characters must be escaped first. Then we'll get an error like "In D-Bus address, character '%c' should have been escaped\n" Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46013 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 07080045..b82c2bc7 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -4050,6 +4050,7 @@ _dbus_append_address_from_socket (int fd, } socket; char hostip[INET6_ADDRSTRLEN]; int size = sizeof (socket); + DBusString path_str; if (getsockname (fd, &socket.sa, &size)) goto err; @@ -4059,26 +4060,32 @@ _dbus_append_address_from_socket (int fd, case AF_UNIX: if (socket.un.sun_path[0]=='\0') { - if (_dbus_string_append_printf (address, "unix:abstract=%s", &(socket.un.sun_path[1]))) + _dbus_string_init_const (&path_str, &(socket.un.sun_path[1])); + if (_dbus_string_append (address, "unix:abstract=") && + _dbus_address_append_escaped (address, &path_str)) return TRUE; } else { - if (_dbus_string_append_printf (address, "unix:path=%s", socket.un.sun_path)) + _dbus_string_init_const (&path_str, socket.un.sun_path); + if (_dbus_string_append (address, "unix:path=") && + _dbus_address_append_escaped (address, &path_str)) return TRUE; } break; case AF_INET: if (inet_ntop (AF_INET, &socket.ipv4.sin_addr, hostip, sizeof (hostip))) if (_dbus_string_append_printf (address, "tcp:family=ipv4,host=%s,port=%u", - hostip, ntohs (socket.ipv4.sin_port))) + hostip, ntohs (socket.ipv4.sin_port))) return TRUE; break; #ifdef AF_INET6 case AF_INET6: + _dbus_string_init_const (&path_str, hostip); if (inet_ntop (AF_INET6, &socket.ipv6.sin6_addr, hostip, sizeof (hostip))) - if (_dbus_string_append_printf (address, "tcp:family=ipv6,host=%s,port=%u", - hostip, ntohs (socket.ipv6.sin6_port))) + if (_dbus_string_append_printf (address, "tcp:family=ipv6,port=%u,host=", + ntohs (socket.ipv6.sin6_port)) && + _dbus_address_append_escaped (address, &path_str)) return TRUE; break; #endif -- cgit v1.2.1 From 08e8ff0f3a8b87e42b2313ed4abc9bb2a317f118 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 2 Jul 2013 09:27:48 +0800 Subject: cmake: fix code style Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66453 Signed-off-by: Chengwei Yang Reviewed-by: Ralf Habacker --- cmake/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index fe111966..bf5ef2b1 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -540,18 +540,18 @@ message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} " message(" gcc coverage profiling: ${DBUS_GCOV_ENABLED} ") message(" Building unit tests: ${DBUS_BUILD_TESTS} ") message(" Building verbose mode: ${DBUS_ENABLE_VERBOSE_MODE} ") -message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ") +message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ") message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ") message(" Building bus stats API: ${DBUS_ENABLE_STATS} ") message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} ") message(" Building inotify support: ${DBUS_BUS_ENABLE_INOTIFY} ") -message(" Building kqueue support: ${DBUS_BUS_ENABLE_KQUEUE} ") +message(" Building kqueue support: ${DBUS_BUS_ENABLE_KQUEUE} ") message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} ") message(" Building XML docs: ${DBUS_ENABLE_XML_DOCS} ") message(" Daemon executable name: ${DBUS_DAEMON_NAME}") if (WIN32) message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") -message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ") +message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ") message(" Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ") else (WIN32) message(" System bus socket: ${DBUS_SYSTEM_SOCKET} ") -- cgit v1.2.1 From 726b28a03eddc999e447310b0b4499a6621588ad Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 2 Jul 2013 09:28:02 +0800 Subject: cmake: update README.cmake a bit Bug: https://bugs.freedesktop.org/show_bug.cgi?id=66453 Signed-off-by: Chengwei Yang Reviewed-by: Ralf Habacker --- README.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.cmake b/README.cmake index 4932e66b..c3c6a170 100644 --- a/README.cmake +++ b/README.cmake @@ -156,6 +156,18 @@ HAVE_CONSOLE_OWNER_FILE:BOOL=ON // Directory to check for console ownership DBUS_CONSOLE_OWNER_FILE:STRING=/dev/console +// Linux only: +// enable inotify as dir watch backend +DBUS_BUS_ENABLE_INOTIFY:BOOL=ON + +*BSD only: +// enable kqueue as dir watch backend +DBUS_BUS_ENABLE_KQUEUE:BOOL=ON + +not available on windows: +// enable abstract socket transport +DBUS_ENABLE_ABSTRACT_SOCKETS:BOOL=ON + x11 only: // Build with X11 auto launch support DBUS_BUILD_X11:BOOL=ON -- cgit v1.2.1 From 72c42279f63d0dd85df7a4ca2791e55f9f074a87 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 27 Nov 2013 16:40:22 +0000 Subject: NEWS --- NEWS | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/NEWS b/NEWS index ecd2f408..3cc46d2a 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,11 @@ D-Bus 1.7.10 (UNRELEASED) == +D-Bus Specification 0.23: + +• don't require messages with no INTERFACE to be dispatched + (fd.o #68597, Simon McVittie) + Fixes: • don't leak memory on out-of-memory while listing activatable or @@ -8,10 +13,18 @@ Fixes: • fix undefined behaviour in a regression test (fd.o #69924, DreamNik) +• escape Unix socket addresses correctly (fd.o #46013, Chengwei Yang) + • on SELinux systems, don't assume that SECCLASS_DBUS, DBUS__ACQUIRE_SVC and DBUS__SEND_MSG are numerically equal to their values in the reference policy (fd.o #88719, osmond sun) +• define PROCESS_QUERY_LIMITED_INFORMATION if missing from MinGW < 4 headers + (fd.o #71366, Matt Fischer) + +• support printing Unix file descriptors in dbus-send, dbus-monitor + (fd.o #70592, Robert Ancell) + D-Bus 1.7.8 (2013-11-01) == -- cgit v1.2.1 From 723da23545aa1b742c7ac37df6934040a805526b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 19 Feb 2013 13:45:50 +0000 Subject: specification: discuss "listenable" and "connectable" addresses The --with-dbus-session-bus-connect-address configure option and the DBUS_SESSION_BUS_CONNECT_ADDRESS CMake variable expect a connectable address, while the --with-dbus-session-bus-listen-address option and the DBUS_SESSION_BUS_LISTEN_ADDRESS variable expect a listenable address. DBUS_SYSTEM_BUS_DEFAULT_ADDRESS currently has to be an address that is simultaneously listenable and connectable. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61303 Reviewed-by: Chengwei Yang [fixed name of DBUS_SESSION_BUS_CONNECT_ADDRESS as per review -smcv] Signed-off-by: Simon McVittie --- doc/dbus-specification.xml | 91 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 86 insertions(+), 5 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 629ab10c..d1b8d473 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -2951,6 +2951,35 @@ unix:path=/tmp/dbus-test;unix:path=/tmp/dbus-test2 + + Some addresses are connectable. A connectable + address is one containing enough information for a client to connect + to it. For instance, tcp:host=127.0.0.1,port=4242 + is a connectable address. It is not necessarily possible to listen + on every connectable address: for instance, it is not possible to + listen on a unixexec: address. + + + + Some addresses are listenable. A listenable + address is one containing enough information for a server to listen on + it, producing a connectable address (which may differ from the + original address). Many listenable addresses are not connectable: + for instance, tcp:host=127.0.0.1 + is listenable, but not connectable (because it does not specify + a port number). + + + + Listening on an address that is not connectable will result in a + connectable address that is not the same as the listenable address. + For instance, listening on tcp:host=127.0.0.1 + might result in the connectable address + tcp:host=127.0.0.1,port=30958, + or listening on unix:tmpdir=/tmp + might result in the connectable address + unix:abstract=/tmp/dbus-U8OSdmf7. + @@ -2983,6 +3012,13 @@ Unix domain sockets are not available on Windows. + + Unix addresses that specify path or + abstract are both listenable and connectable. + Unix addresses that specify tmpdir are only + listenable: the corresponding connectable address will specify + either path or abstract. + Server Address Format @@ -3012,11 +3048,16 @@ abstract (string) - unique string (path) in the abstract namespace. If set, the "path" or "tempdir" key must not be set. + unique string (path) in the abstract namespace. If set, the "path" or "tmpdir" key must not be set. This key is only supported on platforms with "abstract Unix sockets", of which Linux is the only known example. + + Exactly one of the keys path, + abstract or + tmpdir must be provided. + @@ -3040,6 +3081,9 @@ launchd is not available on Microsoft Windows. + + launchd addresses are listenable and connectable. + Server Address Format @@ -3064,6 +3108,9 @@ + + The env key is required. + @@ -3086,6 +3133,11 @@ The systemd transport defines no parameter keys. + + systemd addresses are listenable, but not connectable. The + corresponding connectable address is the unix + or tcp address of the socket. + TCP Sockets @@ -3098,9 +3150,16 @@ over a network is unsecure. - Windows notes: Because of the tcp stack on Windows does not provide sending - credentials over a tcp connection, the EXTERNAL authentification - mechanismus does not work. + On Windows and most Unix platforms, the TCP stack is unable to transfer + credentials over a TCP connection, so the EXTERNAL authentication + mechanism does not work for this transport. + + + All tcp addresses are listenable. + tcp addresses in which both + host and port are + specified, and port is non-zero, + are also connectable. Server Address Format @@ -3172,6 +3231,12 @@ key-value pair and send it over the socket. After that, the transport behaves like an unsecured tcp transport. + + All nonce-tcp addresses are listenable. nonce-tcp addresses in which + host, port and + noncefile are all specified, + and port is nonzero, are also connectable. + Server Address Format @@ -3209,7 +3274,10 @@ noncefile (path) - file location containing the secret + File location containing the secret. + This is only meaningful in connectable addresses: + a listening D-Bus server that offers this transport + will always create a new nonce file. @@ -3232,6 +3300,10 @@ Executed subprocesses are not available on Windows. + + unixexec addresses are connectable, but are not + listenable. + Server Address Format @@ -3290,6 +3362,15 @@ The autolaunch transport provides a way for dbus clients to autodetect a running dbus session bus and to autolaunch a session bus if not present. + + On Unix, autolaunch addresses are connectable, + but not listenable. + + + On Windows, autolaunch addresses are both + connectable and listenable. + + Server Address Format -- cgit v1.2.1 From 00211794ed8e85cb49538ee32703f71566cb48f2 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 19 Feb 2013 15:40:06 +0000 Subject: _dbus_check_dir_is_private_to_user: check that we own it Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61303 Reviewed-by: Chengwei Yang Signed-off-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index b82c2bc7..19f5ea30 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1999,6 +1999,16 @@ _dbus_check_dir_is_private_to_user (DBusString *dir, DBusError *error) return FALSE; } + if (sb.st_uid != geteuid ()) + { + dbus_set_error (error, DBUS_ERROR_FAILED, + "%s directory is owned by user %lu, not %lu", + directory, + (unsigned long) sb.st_uid, + (unsigned long) geteuid ()); + return FALSE; + } + if ((S_IROTH & sb.st_mode) || (S_IWOTH & sb.st_mode) || (S_IRGRP & sb.st_mode) || (S_IWGRP & sb.st_mode)) { -- cgit v1.2.1 From 1794c245e2869c5f7d35f38c38b42f17c157541f Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 10 Dec 2013 17:11:25 +0800 Subject: Reload policy rules for completed connections The message bus which can monitor its conf dirs for changes and reload confs immediately if dir monitor enabled, for example, inotify in Linux, kqueue in *BSD. However, it doesn't apply policy rules change for completed connections, so to apply policy rules change, the client connection has to disconnect first and then re-connect to message bus. For imcomplete connections, it always has the latest review of policy rules. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=39463 Reviewed-by: Simon McVittie --- bus/bus.c | 12 ++++++++++++ bus/connection.c | 36 ++++++++++++++++++++++++++++++++++++ bus/connection.h | 2 ++ 3 files changed, 50 insertions(+) diff --git a/bus/bus.c b/bus/bus.c index e24504c3..a514e31d 100644 --- a/bus/bus.c +++ b/bus/bus.c @@ -526,6 +526,18 @@ process_config_every_time (BusContext *context, context->policy = bus_config_parser_steal_policy (parser); _dbus_assert (context->policy != NULL); + /* context->connections is NULL when creating new BusContext */ + if (context->connections) + { + _dbus_verbose ("Reload policy rules for completed connections\n"); + retval = bus_connections_reload_policy (context->connections, error); + if (!retval) + { + _DBUS_ASSERT_ERROR_IS_SET (error); + goto failed; + } + } + /* We have to build the address backward, so that * later in the config file have priority */ diff --git a/bus/connection.c b/bus/connection.c index fddbc78a..8d741d6f 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -1435,6 +1435,42 @@ fail: return FALSE; } +dbus_bool_t +bus_connections_reload_policy (BusConnections *connections, + DBusError *error) +{ + BusConnectionData *d; + DBusConnection *connection; + DBusList *link; + + _dbus_assert (connections != NULL); + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + for (link = _dbus_list_get_first_link (&(connections->completed)); + link; + link = _dbus_list_get_next_link (&(connections->completed), link)) + { + connection = link->data; + d = BUS_CONNECTION_DATA (connection); + _dbus_assert (d != NULL); + _dbus_assert (d->policy != NULL); + + bus_client_policy_unref (d->policy); + d->policy = bus_context_create_client_policy (connections->context, + connection, + error); + if (d->policy == NULL) + { + _dbus_verbose ("Failed to create security policy for connection %p\n", + connection); + _DBUS_ASSERT_ERROR_IS_SET (error); + return FALSE; + } + } + + return TRUE; +} + const char * bus_connection_get_name (DBusConnection *connection) { diff --git a/bus/connection.h b/bus/connection.h index c9360212..13c8b99f 100644 --- a/bus/connection.h +++ b/bus/connection.h @@ -45,6 +45,8 @@ void bus_connections_foreach_active (BusConnections void *data); BusContext* bus_connections_get_context (BusConnections *connections); void bus_connections_increment_stamp (BusConnections *connections); +dbus_bool_t bus_connections_reload_policy (BusConnections *connections, + DBusError *error); BusContext* bus_connection_get_context (DBusConnection *connection); BusConnections* bus_connection_get_connections (DBusConnection *connection); BusRegistry* bus_connection_get_registry (DBusConnection *connection); -- cgit v1.2.1 From 2d950f6e9a412da70e9f8bc956980abc949a5fe8 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 19 Feb 2013 16:39:38 +0000 Subject: Make sure tests run with a temporary XDG_RUNTIME_DIR We don't want the regression tests' "session" getting mixed up in system-wide "sessions". This doesn't actually matter yet, but it is likely to matter in future. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=61301 Reviewed-by: Chengwei Yang [merged with earlier line-wrapping of TESTS_ENVIRONMENT -smcv] Signed-off-by: Simon McVittie --- test/Makefile.am | 4 +++- test/name-test/Makefile.am | 2 ++ test/name-test/run-test-systemserver.sh | 5 +++++ test/name-test/run-test.sh | 5 +++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/Makefile.am b/test/Makefile.am index 870ce321..426a72e0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -149,11 +149,13 @@ endif DBUS_WITH_GLIB installcheck_tests = installcheck_environment = \ + XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR \ DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \ DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \ DBUS_TEST_SYSCONFDIR=$(DESTDIR)$(sysconfdir) TESTS_ENVIRONMENT = \ + XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR \ DBUS_BLOCK_ON_ABORT=1 \ DBUS_FATAL_WARNINGS=1 \ DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \ @@ -368,7 +370,7 @@ imported_data = \ $(NULL) noinst_DATA = $(imported_data) -CLEANFILES = $(noinst_DATA) +CLEANFILES = $(noinst_DATA) XDG_RUNTIME_DIR $(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf $(AM_V_at)$(MKDIR_P) data/valid-config-files diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index da41e58b..8ed1e160 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -19,7 +19,9 @@ TESTS_ENVIRONMENT = \ PYTHON=@PYTHON@ \ DBUS_TEST_DATA=@abs_top_builddir@/test/data \ DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \ + XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR \ $(NULL) + TESTS=run-test.sh run-test-systemserver.sh else TESTS= diff --git a/test/name-test/run-test-systemserver.sh b/test/name-test/run-test-systemserver.sh index afd1f045..90c03723 100755 --- a/test/name-test/run-test-systemserver.sh +++ b/test/name-test/run-test-systemserver.sh @@ -30,6 +30,11 @@ if test -n "$DBUS_TEST_MONITOR"; then dbus-monitor --session & fi +XDG_RUNTIME_DIR="$DBUS_TOP_BUILDDIR"/test/XDG_RUNTIME_DIR +test -d "$XDG_RUNTIME_DIR" || mkdir "$XDG_RUNTIME_DIR" +chmod 0700 "$XDG_RUNTIME_DIR" +export XDG_RUNTIME_DIR + echo "running test-expected-echo-fail" ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/tools/dbus-send --print-reply --dest=org.freedesktop.DBus.TestSuiteEchoService /org/freedesktop/TestSuite org.freedesktop.TestSuite.Echo string:hi >echo-error-output.tmp 2>&1 if ! grep -q 'DBus.Error' echo-error-output.tmp; then diff --git a/test/name-test/run-test.sh b/test/name-test/run-test.sh index cad5937e..84379c4a 100755 --- a/test/name-test/run-test.sh +++ b/test/name-test/run-test.sh @@ -30,6 +30,11 @@ if test -n "$DBUS_TEST_MONITOR"; then dbus-monitor --session & fi +XDG_RUNTIME_DIR="$DBUS_TOP_BUILDDIR"/test/XDG_RUNTIME_DIR +test -d "$XDG_RUNTIME_DIR" || mkdir "$XDG_RUNTIME_DIR" +chmod 0700 "$XDG_RUNTIME_DIR" +export XDG_RUNTIME_DIR + echo "running test-ids" ${DBUS_TOP_BUILDDIR}/libtool --mode=execute $DEBUG $DBUS_TOP_BUILDDIR/test/name-test/test-ids || die "test-ids failed" -- cgit v1.2.1 From 653790c9858180baf4259b38c7c9d5196e39114b Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Sun, 1 Dec 2013 19:40:21 +0800 Subject: kqueue: replace tab with space Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69332 [altered commit message to not say it fixes memory leaks -smcv] Reviewed-by: Simon McVittie --- bus/dir-watch-kqueue.c | 102 ++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c index c60560f0..065fabb3 100644 --- a/bus/dir-watch-kqueue.c +++ b/bus/dir-watch-kqueue.c @@ -73,12 +73,12 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data) { kq = -1; if (watch != NULL) - { - _dbus_loop_remove_watch (loop, watch); + { + _dbus_loop_remove_watch (loop, watch); _dbus_watch_invalidate (watch); _dbus_watch_unref (watch); - watch = NULL; - } + watch = NULL; + } pid = getpid (); _dbus_verbose ("Sending SIGHUP signal since kqueue has been closed\n"); (void) kill (pid, SIGHUP); @@ -99,32 +99,32 @@ _init_kqueue (BusContext *context) if (kq < 0) { _dbus_warn ("Cannot create kqueue; error '%s'\n", _dbus_strerror (errno)); - goto out; - } - - loop = bus_context_get_loop (context); - - watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE, - _handle_kqueue_watch, NULL, NULL); - - if (watch == NULL) - { - _dbus_warn ("Unable to create kqueue watch\n"); - close (kq); - kq = -1; - goto out; - } - - if (!_dbus_loop_add_watch (loop, watch)) - { - _dbus_warn ("Unable to add reload watch to main loop"); - _dbus_watch_invalidate (watch); - _dbus_watch_unref (watch); - watch = NULL; - close (kq); - kq = -1; - goto out; - } + goto out; + } + + loop = bus_context_get_loop (context); + + watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE, + _handle_kqueue_watch, NULL, NULL); + + if (watch == NULL) + { + _dbus_warn ("Unable to create kqueue watch\n"); + close (kq); + kq = -1; + goto out; + } + + if (!_dbus_loop_add_watch (loop, watch)) + { + _dbus_warn ("Unable to add reload watch to main loop"); + _dbus_watch_invalidate (watch); + _dbus_watch_unref (watch); + watch = NULL; + close (kq); + kq = -1; + goto out; + } } ret = 1; @@ -169,12 +169,12 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) if (dirs[j] && strcmp (new_dirs[i], dirs[j]) == 0) { new_fds[i] = fds[j]; - new_dirs[i] = dirs[j]; - fds[j] = -1; - dirs[j] = NULL; - break; - } - } + new_dirs[i] = dirs[j]; + fds[j] = -1; + dirs[j] = NULL; + break; + } + } } /* Any directory we find in "fds" with a nonzero fd must @@ -185,10 +185,10 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) if (fds[j] != -1) { close (fds[j]); - dbus_free (dirs[j]); - fds[j] = -1; - dirs[j] = NULL; - } + dbus_free (dirs[j]); + fds[j] = -1; + dirs[j] = NULL; + } } for (i = 0; new_dirs[i]; i++) @@ -196,8 +196,8 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) if (new_fds[i] == -1) { /* FIXME - less lame error handling for failing to add a watch; - * we may need to sleep. - */ + * we may need to sleep. + */ fd = open (new_dirs[i], O_RDONLY); if (fd < 0) { @@ -223,18 +223,18 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) goto out; } - new_fds[i] = fd; - new_dirs[i] = _dbus_strdup (new_dirs[i]); - if (!new_dirs[i]) + new_fds[i] = fd; + new_dirs[i] = _dbus_strdup (new_dirs[i]); + if (!new_dirs[i]) { /* FIXME have less lame handling for OOM, we just silently fail to - * watch. (In reality though, the whole OOM handling in dbus is - * stupid but we won't go into that in this comment =) ) - */ + * watch. (In reality though, the whole OOM handling in dbus is + * stupid but we won't go into that in this comment =) ) + */ close (fd); - new_fds[i] = -1; - } - } + new_fds[i] = -1; + } + } } num_fds = i; -- cgit v1.2.1 From 4e8032be4e6608163757b2ab926e44e5f784807d Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 3 Dec 2013 20:47:54 +0800 Subject: Fix memory leak for kqueue: shutdown kqueue correctly There are memory blocks leak when doing bus-test, both dispatch-sha1 and dispatch test cases complain memory blocks leak. This patch also fix fd leaks. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69332 Reviewed-by: Simon McVittie --- bus/dir-watch-kqueue.c | 87 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 13 deletions(-) diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c index 065fabb3..4cc780de 100644 --- a/bus/dir-watch-kqueue.c +++ b/bus/dir-watch-kqueue.c @@ -87,11 +87,49 @@ _handle_kqueue_watch (DBusWatch *watch, unsigned int flags, void *data) return TRUE; } +static void _shutdown_kqueue (void *data) +{ + int i; + + if (kq < 0) + return; + + for (i = 0; i < MAX_DIRS_TO_WATCH; i++) + { + if (fds[i] >= 0) + { + close (fds[i]); + fds[i] = -1; + } + if (dirs[i] != NULL) + { + /* dbus_free() is necessary to pass memleak check */ + dbus_free (dirs[i]); + dirs[i] = NULL; + } + } + + if (loop) + { + _dbus_loop_remove_watch (loop, watch); + _dbus_loop_unref (loop); + loop = NULL; + } + + if (watch) + { + _dbus_watch_invalidate (watch); + _dbus_watch_unref (watch); + watch = NULL; + } + + close (kq); + kq = -1; +} + static int _init_kqueue (BusContext *context) { - int ret = 0; - if (kq < 0) { @@ -103,6 +141,7 @@ _init_kqueue (BusContext *context) } loop = bus_context_get_loop (context); + _dbus_loop_ref (loop); watch = _dbus_watch_new (kq, DBUS_WATCH_READABLE, TRUE, _handle_kqueue_watch, NULL, NULL); @@ -110,27 +149,49 @@ _init_kqueue (BusContext *context) if (watch == NULL) { _dbus_warn ("Unable to create kqueue watch\n"); - close (kq); - kq = -1; - goto out; + goto out1; } if (!_dbus_loop_add_watch (loop, watch)) { _dbus_warn ("Unable to add reload watch to main loop"); - _dbus_watch_invalidate (watch); - _dbus_watch_unref (watch); - watch = NULL; - close (kq); - kq = -1; - goto out; + goto out2; + } + + if (!_dbus_register_shutdown_func (_shutdown_kqueue, NULL)) + { + _dbus_warn ("Unable to register shutdown function"); + goto out3; } } - ret = 1; + return 1; + +out3: + _dbus_loop_remove_watch (loop, watch); + +out2: + if (watch) + { + _dbus_watch_invalidate (watch); + _dbus_watch_unref (watch); + watch = NULL; + } + +out1: + if (kq >= 0) + { + close (kq); + kq = -1; + } + if (loop) + { + _dbus_loop_unref (loop); + loop = NULL; + } out: - return ret; + return 0; } void -- cgit v1.2.1 From 3ca8a53e336a1a829bae93c70fe617af6493201a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 18 Sep 2013 17:51:53 +0100 Subject: If sendmsg() with SCM_CREDS fails with EINVAL, retry with send() Perhaps some OSs accept and ignore attempts to send a SCM_CREDS message on a non-Unix socket, but GNU/kFreeBSD doesn't (and presumably FreeBSD doesn't either). Based on a patch by Svante Signell. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69492 Tested-by: Svante Signell Reviewed-by: Chengwei Yang --- dbus/dbus-sysdeps-unix.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 19f5ea30..c12f294e 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1572,13 +1572,19 @@ write_credentials_byte (int server_fd, |MSG_NOSIGNAL #endif ); -#else - bytes_written = send (server_fd, buf, 1, 0 -#if HAVE_DECL_MSG_NOSIGNAL - |MSG_NOSIGNAL + + /* If we HAVE_CMSGCRED, the OS still might not let us sendmsg() + * with a SOL_SOCKET/SCM_CREDS message - for instance, FreeBSD + * only allows that on AF_UNIX. Try just doing a send() instead. */ + if (bytes_written < 0 && errno == EINVAL) #endif - ); + { + bytes_written = send (server_fd, buf, 1, 0 +#if HAVE_DECL_MSG_NOSIGNAL + |MSG_NOSIGNAL #endif + ); + } if (bytes_written < 0 && errno == EINTR) goto again; -- cgit v1.2.1 From a6bb4b7be996b935ddc6a20d2fa8e5bb2a9e36f5 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 6 Jan 2014 15:55:35 +0000 Subject: _dbus_read_credentials_socket: look at all cmsg headers, not just the first If there are no cmsg headers, don't fail: this fixes receiving credentials on TCP sockets under at least GNU/kFreeBSD, and probably FreeBSD too. If there's more than one cmsg header, ignore any that don't look like valid SCM_CREDS. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69492 Tested-by: Svante Signell Reviewed-by: Chengwei Yang [added break, altered indentation in response to review -smcv] Signed-off-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index c12f294e..6fd1b764 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -1712,16 +1712,6 @@ _dbus_read_credentials_socket (int client_fd, return FALSE; } -#if defined(HAVE_CMSGCRED) - if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)) - || cmsg.hdr.cmsg_type != SCM_CREDS) - { - dbus_set_error (error, DBUS_ERROR_FAILED, - "Message from recvmsg() was not SCM_CREDS"); - return FALSE; - } -#endif - _dbus_verbose ("read credentials byte\n"); { @@ -1762,10 +1752,22 @@ _dbus_read_credentials_socket (int client_fd, * which makes it better than getpeereid(). */ struct cmsgcred *cred; + struct cmsghdr *cmsgp; - cred = (struct cmsgcred *) CMSG_DATA (&cmsg.hdr); - pid_read = cred->cmcred_pid; - uid_read = cred->cmcred_euid; + for (cmsgp = CMSG_FIRSTHDR (&msg); + cmsgp != NULL; + cmsgp = CMSG_NXTHDR (&msg, cmsgp)) + { + if (cmsgp->cmsg_type == SCM_CREDS && + cmsgp->cmsg_level == SOL_SOCKET && + cmsgp->cmsg_len >= CMSG_LEN (sizeof (struct cmsgcred))) + { + cred = (struct cmsgcred *) CMSG_DATA (cmsgp); + pid_read = cred->cmcred_pid; + uid_read = cred->cmcred_euid; + break; + } + } #elif defined(HAVE_GETPEERUCRED) /* Supported in at least Solaris >= 10. It should probably be higher -- cgit v1.2.1 From 14d72882c9b03bb5c2f96646847b4c9e431168b1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 1 Nov 2013 13:51:13 +0000 Subject: _dbus_listen_unix_socket: don't try to set SO_REUSEADDR On Hurd, the setsockopt() fails. Svante Signell confirmed that on at least Linux and kFreeBSD, SO_REUSEADDR "succeeds" on Unix sockets, but doesn't have any practical effect; so rather than making the failure not issue a warning, we might as well not bother with the syscall at all. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=69492 Reviewed-by: Chengwei Yang Signed-off-by: Simon McVittie --- dbus/dbus-sysdeps-unix.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 6fd1b764..ae42f56e 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -999,7 +999,6 @@ _dbus_listen_unix_socket (const char *path, int listen_fd; struct sockaddr_un addr; size_t path_len; - unsigned int reuseaddr; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -1074,13 +1073,6 @@ _dbus_listen_unix_socket (const char *path, strncpy (addr.sun_path, path, path_len); } - reuseaddr = 1; - if (setsockopt (listen_fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(reuseaddr))==-1) - { - _dbus_warn ("Failed to set socket option\"%s\": %s", - path, _dbus_strerror (errno)); - } - if (bind (listen_fd, (struct sockaddr*) &addr, _DBUS_STRUCT_OFFSET (struct sockaddr_un, sun_path) + path_len) < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), -- cgit v1.2.1 From b2a517040cd6f0fcc676abe833675d5473820226 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Mon, 11 Nov 2013 17:52:26 +0800 Subject: _dbus_auth_return_buffer(): remove unused argument The argument bytes_read of _dbus_auth_return_buffer() function isn't used at all, so remove it. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71477 Reviewed-by: Simon McVittie --- dbus/dbus-auth-script.c | 4 ++-- dbus/dbus-auth.c | 4 +--- dbus/dbus-auth.h | 3 +-- dbus/dbus-transport-socket.c | 3 +-- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index c1f0c88e..164743b0 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -584,11 +584,11 @@ _dbus_auth_script_run (const DBusString *filename) { _dbus_warn ("not enough memory to call bytes_received, or can't add bytes to auth object already in end state\n"); _dbus_string_free (&to_send); - _dbus_auth_return_buffer (auth, buffer, 0); + _dbus_auth_return_buffer (auth, buffer); goto out; } - _dbus_auth_return_buffer (auth, buffer, _dbus_string_get_length (&to_send)); + _dbus_auth_return_buffer (auth, buffer); } _dbus_string_free (&to_send); diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index a0f72773..6a07665f 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -2533,12 +2533,10 @@ _dbus_auth_get_buffer (DBusAuth *auth, * * @param auth the auth conversation * @param buffer the buffer being returned - * @param bytes_read number of new bytes added */ void _dbus_auth_return_buffer (DBusAuth *auth, - DBusString *buffer, - int bytes_read) + DBusString *buffer) { _dbus_assert (buffer == &auth->incoming); _dbus_assert (auth->buffer_outstanding); diff --git a/dbus/dbus-auth.h b/dbus/dbus-auth.h index ae3f3647..ba1975f7 100644 --- a/dbus/dbus-auth.h +++ b/dbus/dbus-auth.h @@ -55,8 +55,7 @@ void _dbus_auth_bytes_sent (DBusAuth *auth, void _dbus_auth_get_buffer (DBusAuth *auth, DBusString **buffer); void _dbus_auth_return_buffer (DBusAuth *auth, - DBusString *buffer, - int bytes_read); + DBusString *buffer); void _dbus_auth_get_unused_bytes (DBusAuth *auth, const DBusString **str); void _dbus_auth_delete_unused_bytes (DBusAuth *auth); diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 44c7af7d..774f4598 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -255,8 +255,7 @@ read_data_into_auth (DBusTransport *transport, bytes_read = _dbus_read_socket (socket_transport->fd, buffer, socket_transport->max_bytes_read_per_iteration); - _dbus_auth_return_buffer (transport->auth, buffer, - bytes_read > 0 ? bytes_read : 0); + _dbus_auth_return_buffer (transport->auth, buffer); if (bytes_read > 0) { -- cgit v1.2.1 From 854554c3a67b880ac92fa72c476b772cb5968b26 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Thu, 28 Nov 2013 09:17:38 +0800 Subject: BusTransaction: remove confusing getter of connections There is a DBusList* member of BusTransaction named "connections", while its getter function bus_transaction_get_connections() returns context->connections which in fact is a BusConnections pointer, this is quite confusing. Because this is what bus_context_get_connections() returns. This patch call out to bus_context_get_connections() directly and remove the then unused bus_transaction_get_connections(). https://bugs.freedesktop.org/show_bug.cgi?id=71597 Reviewed-by: Simon McVittie --- bus/connection.c | 6 ------ bus/connection.h | 1 - bus/dispatch.c | 2 +- bus/stats.c | 2 +- 4 files changed, 2 insertions(+), 9 deletions(-) diff --git a/bus/connection.c b/bus/connection.c index 8d741d6f..ea2d155a 100644 --- a/bus/connection.c +++ b/bus/connection.c @@ -2026,12 +2026,6 @@ bus_transaction_get_context (BusTransaction *transaction) return transaction->context; } -BusConnections* -bus_transaction_get_connections (BusTransaction *transaction) -{ - return bus_context_get_connections (transaction->context); -} - dbus_bool_t bus_transaction_send_from_driver (BusTransaction *transaction, DBusConnection *connection, diff --git a/bus/connection.h b/bus/connection.h index 13c8b99f..9f4f9aea 100644 --- a/bus/connection.h +++ b/bus/connection.h @@ -122,7 +122,6 @@ typedef void (* BusTransactionCancelFunction) (void *data); BusTransaction* bus_transaction_new (BusContext *context); BusContext* bus_transaction_get_context (BusTransaction *transaction); -BusConnections* bus_transaction_get_connections (BusTransaction *transaction); dbus_bool_t bus_transaction_send (BusTransaction *transaction, DBusConnection *connection, DBusMessage *message); diff --git a/bus/dispatch.c b/bus/dispatch.c index 5fc0d112..7a61953f 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -133,7 +133,7 @@ bus_dispatch_matches (BusTransaction *transaction, } /* Now dispatch to others who look interested in this message */ - connections = bus_transaction_get_connections (transaction); + connections = bus_context_get_connections (context); dbus_error_init (&tmp_error); matchmaker = bus_context_get_matchmaker (context); diff --git a/bus/stats.c b/bus/stats.c index ec768ec7..2bf86d66 100644 --- a/bus/stats.c +++ b/bus/stats.c @@ -48,7 +48,7 @@ bus_stats_handle_get_stats (DBusConnection *connection, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - connections = bus_transaction_get_connections (transaction); + connections = bus_context_get_connections (transaction->context); reply = _dbus_asv_new_method_return (message, &iter, &arr_iter); -- cgit v1.2.1 From f4618906b0dce251cdc3125b60239f7dd0df7183 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Mon, 2 Dec 2013 12:47:47 +0800 Subject: kqueue: open watched directories with close-on-exec flag [FreeBSD and OpenBSD contributors clarified that O_CLOEXEC has been supported for ~ 2 years on both, so for the moment we're assuming that every platform with kqueue also has working O_CLOEXEC. Please reopen the bug, with a tested patch that uses _dbus_fd_set_close_on_exec() instead, if this assumption turns out to be false. -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72213 Reviewed-by: Simon McVittie --- bus/dir-watch-kqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c index 4cc780de..33d5e95d 100644 --- a/bus/dir-watch-kqueue.c +++ b/bus/dir-watch-kqueue.c @@ -259,7 +259,7 @@ bus_set_watched_dirs (BusContext *context, DBusList **directories) /* FIXME - less lame error handling for failing to add a watch; * we may need to sleep. */ - fd = open (new_dirs[i], O_RDONLY); + fd = open (new_dirs[i], O_RDONLY | O_CLOEXEC); if (fd < 0) { if (errno != ENOENT) -- cgit v1.2.1 From 15a5b2637c73d8f6d30acf1517b00182f215eb35 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 6 Dec 2013 10:53:28 +0800 Subject: Ensure DBusError is set if _dbus_read_nonce() fail In _dbus_send_nonce() which call in _dbus_read_nonce() and assert on an error is set if _dbus_read_nonce() fail. However, in _dbus_read_nonce(), it may fail on fopen() and left error is unset. This will crash us if assertions hasn't been disabled. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72298 Reviewed-by: Simon McVittie --- dbus/dbus-nonce.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index ef037ef9..37f30f00 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -113,7 +113,15 @@ _dbus_read_nonce (const DBusString *fname, DBusString *nonce, DBusError* error) fp = fopen (_dbus_string_get_const_data (fname), "rb"); if (!fp) - return FALSE; + { + dbus_set_error (error, + _dbus_error_from_system_errno (), + "Failed to open %s for read: %s", + _dbus_string_get_const_data (fname), + _dbus_strerror_from_errno ()); + return FALSE; + } + nread = fread (buffer, 1, sizeof buffer - 1, fp); fclose (fp); if (!nread) -- cgit v1.2.1 From eeae8a6b1ca7375213ba06d311e10108794f21c3 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Fri, 6 Dec 2013 11:15:12 +0800 Subject: DBus Spec: replace tab with 8 spaces Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72301 Reviewed-by: Simon McVittie --- doc/dbus-specification.xml | 426 ++++++++++++++++++++++----------------------- 1 file changed, 213 insertions(+), 213 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index d1b8d473..5043849f 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -10,44 +10,44 @@ (not yet released) - Havoc - Pennington - - Red Hat, Inc. -
- hp@pobox.com -
-
+ Havoc + Pennington + + Red Hat, Inc. +
+ hp@pobox.com +
+
- Anders - Carlsson - - CodeFactory AB -
+ Anders + Carlsson + + CodeFactory AB +
andersca@codefactory.se
-
+ - Alexander - Larsson - - Red Hat, Inc. -
+ Alexander + Larsson + + Red Hat, Inc. +
alexl@redhat.com
-
+ - Sven - Herzberg - - Imendio AB -
+ Sven + Herzberg + + Imendio AB +
sven@imendio.com
-
+ Simon @@ -765,14 +765,14 @@ 0 (ASCII NUL) Not a valid type code, used to terminate signatures - BYTE - 121 (ASCII 'y') - 8-bit unsigned integer + BYTE + 121 (ASCII 'y') + 8-bit unsigned integer + + BOOLEAN + 98 (ASCII 'b') + Boolean value, 0 is FALSE and 1 is TRUE. Everything else is invalid. - BOOLEAN - 98 (ASCII 'b') - Boolean value, 0 is FALSE and 1 is TRUE. Everything else is invalid. - INT16 110 (ASCII 'n') 16-bit signed integer @@ -780,7 +780,7 @@ UINT16 113 (ASCII 'q') 16-bit unsigned integer - + INT32 105 (ASCII 'i') 32-bit signed integer @@ -788,7 +788,7 @@ UINT32 117 (ASCII 'u') 32-bit unsigned integer - + INT64 120 (ASCII 'x') 64-bit signed integer @@ -1109,7 +1109,7 @@ 8 - + VARIANT The marshaled SIGNATURE of a single @@ -1119,7 +1119,7 @@ 1 (alignment of the signature) - + DICT_ENTRY Identical to STRUCT. @@ -1136,7 +1136,7 @@ file descriptor in the array of file descriptors that accompany the message. 4 - + @@ -1528,12 +1528,12 @@ - Interface names must contain at least one '.' (period) + Interface names must contain at least one '.' (period) character (and thus at least two elements). - Interface names must not begin with a '.' (period) character. - Interface names must not exceed the maximum name length. + Interface names must not begin with a '.' (period) character. + Interface names must not exceed the maximum name length. @@ -1592,12 +1592,12 @@ - Bus names must contain at least one '.' (period) + Bus names must contain at least one '.' (period) character (and thus at least two elements). - Bus names must not begin with a '.' (period) character. - Bus names must not exceed the maximum name length. + Bus names must not begin with a '.' (period) character. + Bus names must not exceed the maximum name length. @@ -1635,12 +1635,12 @@ Member (i.e. method or signal) names: - Must only contain the ASCII characters + Must only contain the ASCII characters "[A-Z][a-z][0-9]_" and may not begin with a digit. - Must not contain the '.' (period) character. - Must not exceed the maximum name length. - Must be at least 1 byte in length. + Must not contain the '.' (period) character. + Must not exceed the maximum name length. + Must be at least 1 byte in length. @@ -1984,23 +1984,23 @@ Commands from the client to the server are as follows: - AUTH [mechanism] [initial-response] - CANCEL - BEGIN - DATA <data in hex encoding> - ERROR [human-readable error explanation] - NEGOTIATE_UNIX_FD - + AUTH [mechanism] [initial-response] + CANCEL + BEGIN + DATA <data in hex encoding> + ERROR [human-readable error explanation] + NEGOTIATE_UNIX_FD + From server to client are as follows: - REJECTED <space-separated list of mechanism names> - OK <GUID in hex> - DATA <data in hex encoding> - ERROR - AGREE_UNIX_FD - + REJECTED <space-separated list of mechanism names> + OK <GUID in hex> + DATA <data in hex encoding> + ERROR + AGREE_UNIX_FD + Unofficial extensions to the command set must begin with the letters @@ -2230,18 +2230,18 @@
- Example of successful magic cookie authentication - + Example of successful magic cookie authentication + (MAGIC_COOKIE is a made up mechanism) C: AUTH MAGIC_COOKIE 3138363935333137393635383634 S: OK 1234deadbeef C: BEGIN -
+
- Example of finding out mechanisms then picking one - + Example of finding out mechanisms then picking one + C: AUTH S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -2250,20 +2250,20 @@ S: OK 1234deadbeef C: BEGIN -
+
- Example of client sends unknown command then falls back to regular auth - + Example of client sends unknown command then falls back to regular auth + C: FOOBAR S: ERROR C: AUTH MAGIC_COOKIE 3736343435313230333039 S: OK 1234deadbeef C: BEGIN -
+
- Example of server doesn't support initial auth mechanism - + Example of server doesn't support initial auth mechanism + C: AUTH MAGIC_COOKIE 3736343435313230333039 S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -2272,10 +2272,10 @@ S: OK 1234deadbeef C: BEGIN -
+
- Example of wrong password or the like followed by successful retry - + Example of wrong password or the like followed by successful retry + C: AUTH MAGIC_COOKIE 3736343435313230333039 S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -2288,10 +2288,10 @@ S: OK 1234deadbeef C: BEGIN -
+
- Example of skey cancelled and restarted - + Example of skey cancelled and restarted + C: AUTH MAGIC_COOKIE 3736343435313230333039 S: REJECTED KERBEROS_V4 SKEY C: AUTH SKEY 7ab83f32ee @@ -2304,10 +2304,10 @@ S: OK 1234deadbeef C: BEGIN -
+
- Example of successful magic cookie authentication with successful negotiation of Unix FD passing - + Example of successful magic cookie authentication with successful negotiation of Unix FD passing + (MAGIC_COOKIE is a made up mechanism) C: AUTH MAGIC_COOKIE 3138363935333137393635383634 @@ -2316,10 +2316,10 @@ S: AGREE_UNIX_FD C: BEGIN -
+
- Example of successful magic cookie authentication with unsuccessful negotiation of Unix FD passing - + Example of successful magic cookie authentication with unsuccessful negotiation of Unix FD passing + (MAGIC_COOKIE is a made up mechanism) C: AUTH MAGIC_COOKIE 3138363935333137393635383634 @@ -2328,7 +2328,7 @@ S: ERROR C: BEGIN -
+
@@ -2997,17 +2997,17 @@ Unix Domain Sockets Unix domain sockets can be either paths in the file system or on Linux - kernels, they can be abstract which are similar to paths but - do not show up in the file system. + kernels, they can be abstract which are similar to paths but + do not show up in the file system. When a socket is opened by the D-Bus library it truncates the path - name right before the first trailing Nul byte. This is true for both - normal paths and abstract paths. Note that this is a departure from - previous versions of D-Bus that would create sockets with a fixed - length path name. Names which were shorter than the fixed length - would be padded by Nul bytes. + name right before the first trailing Nul byte. This is true for both + normal paths and abstract paths. Note that this is a departure from + previous versions of D-Bus that would create sockets with a fixed + length path name. Names which were shorter than the fixed length + would be padded by Nul bytes. Unix domain sockets are not available on Windows. @@ -3846,38 +3846,38 @@ Method, interface, property, and signal elements may have "annotations", which are generic key/value pairs of metadata. - They are similar conceptually to Java's annotations and C# attributes. + They are similar conceptually to Java's annotations and C# attributes. Well-known annotations: - - - Name - Values (separated by ,) - Description - - - - - org.freedesktop.DBus.Deprecated - true,false - Whether or not the entity is deprecated; defaults to false - - - org.freedesktop.DBus.GLib.CSymbol - (string) - The C symbol; may be used for methods and interfaces - - - org.freedesktop.DBus.Method.NoReply - true,false - If set, don't expect a reply to the method call; defaults to false. - - - org.freedesktop.DBus.Property.EmitsChangedSignal - true,invalidates,false - + + + Name + Values (separated by ,) + Description + + + + + org.freedesktop.DBus.Deprecated + true,false + Whether or not the entity is deprecated; defaults to false + + + org.freedesktop.DBus.GLib.CSymbol + (string) + The C symbol; may be used for methods and interfaces + + + org.freedesktop.DBus.Method.NoReply + true,false + If set, don't expect a reply to the method call; defaults to false. + + + org.freedesktop.DBus.Property.EmitsChangedSignal + true,invalidates,false + If set to false, the org.freedesktop.DBus.Properties.PropertiesChanged @@ -3902,8 +3902,8 @@ interface element. - - + + @@ -4016,11 +4016,11 @@ STRING Name to request - - 1 - UINT32 - Flags - + + 1 + UINT32 + Flags + @@ -4131,10 +4131,10 @@ - - DBUS_NAME_FLAG_ALLOW_REPLACEMENT - 0x1 - + + DBUS_NAME_FLAG_ALLOW_REPLACEMENT + 0x1 + If an application A specifies this flag and succeeds in becoming the owner of the name, and another application B @@ -4148,11 +4148,11 @@ application A as the owner. - - - DBUS_NAME_FLAG_REPLACE_EXISTING - 0x2 - + + + DBUS_NAME_FLAG_REPLACE_EXISTING + 0x2 + Try to replace the current owner if there is one. If this flag is not set the application will only become the owner of @@ -4161,11 +4161,11 @@ the current owner specified DBUS_NAME_FLAG_ALLOW_REPLACEMENT. - - - DBUS_NAME_FLAG_DO_NOT_QUEUE - 0x4 - + + + DBUS_NAME_FLAG_DO_NOT_QUEUE + 0x4 + Without this flag, if an application requests a name that is already owned, the application will be placed in a queue to @@ -4178,10 +4178,10 @@ became the name owner. - - - - + + + + The return code can be one of the following values: @@ -4195,41 +4195,41 @@ - + DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER - 1 The caller is now the primary owner of - the name, replacing any previous owner. Either the name had no - owner before, or the caller specified - DBUS_NAME_FLAG_REPLACE_EXISTING and the current owner specified + 1 The caller is now the primary owner of + the name, replacing any previous owner. Either the name had no + owner before, or the caller specified + DBUS_NAME_FLAG_REPLACE_EXISTING and the current owner specified DBUS_NAME_FLAG_ALLOW_REPLACEMENT. - - - DBUS_REQUEST_NAME_REPLY_IN_QUEUE - 2 + + + DBUS_REQUEST_NAME_REPLY_IN_QUEUE + 2 - The name already had an owner, + The name already had an owner, DBUS_NAME_FLAG_DO_NOT_QUEUE was not specified, and either the current owner did not specify DBUS_NAME_FLAG_ALLOW_REPLACEMENT or the requesting application did not specify DBUS_NAME_FLAG_REPLACE_EXISTING. - - - DBUS_REQUEST_NAME_REPLY_EXISTS 3 - The name already has an owner, - DBUS_NAME_FLAG_DO_NOT_QUEUE was specified, and either - DBUS_NAME_FLAG_ALLOW_REPLACEMENT was not specified by the - current owner, or DBUS_NAME_FLAG_REPLACE_EXISTING was not - specified by the requesting application. - - - DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER - 4 - The application trying to request ownership of a name is already the owner of it. - - - - + + + DBUS_REQUEST_NAME_REPLY_EXISTS 3 + The name already has an owner, + DBUS_NAME_FLAG_DO_NOT_QUEUE was specified, and either + DBUS_NAME_FLAG_ALLOW_REPLACEMENT was not specified by the + current owner, or DBUS_NAME_FLAG_REPLACE_EXISTING was not + specified by the requesting application. + + + DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER + 4 + The application trying to request ownership of a name is already the owner of it. + + + + @@ -4302,7 +4302,7 @@ - + DBUS_RELEASE_NAME_REPLY_RELEASED 1 The caller has released his claim on the given name. Either the caller was the primary owner of @@ -4310,21 +4310,21 @@ waiting in the queue for the name, or the caller was waiting in the queue for the name and has now been removed from the queue. - - - DBUS_RELEASE_NAME_REPLY_NON_EXISTENT - 2 - The given name does not exist on this bus. - - - DBUS_RELEASE_NAME_REPLY_NOT_OWNER - 3 - The caller was not the primary owner of this name, + + + DBUS_RELEASE_NAME_REPLY_NON_EXISTENT + 2 + The given name does not exist on this bus. + + + DBUS_RELEASE_NAME_REPLY_NOT_OWNER + 3 + The caller was not the primary owner of this name, and was also not waiting in the queue to own this name. - - - - + + + +
@@ -4486,7 +4486,7 @@ Match Rules - An important part of the message bus routing protocol is match + An important part of the message bus routing protocol is match rules. Match rules describe the messages that should be sent to a client, based on the contents of the message. Broadcast signals are only sent to clients which have a suitable match rule: this @@ -4773,14 +4773,14 @@ and Exec (the command to be executed).
- Example service description file - + Example service description file + # Sample service description file [D-BUS Service] Name=com.example.ConfigurationDatabase Exec=/usr/bin/sample-configd -
+
@@ -5362,16 +5362,16 @@ STRING Name with a new owner - - 1 - STRING - Old owner or empty string if none - - - 2 - STRING - New owner or empty string if none - + + 1 + STRING + Old owner or empty string if none + + + 2 + STRING + New owner or empty string if none + @@ -5471,11 +5471,11 @@ STRING Name of the service to start - - 1 - UINT32 - Flags (currently not used) - + + 1 + UINT32 + Flags (currently not used) + @@ -5513,7 +5513,7 @@ - + DBUS_START_REPLY_SUCCESS 1 The service was successfully started. @@ -5970,8 +5970,8 @@ Adds a match rule to match messages going through the message bus (see ). - If the bus does not have enough resources the org.freedesktop.DBus.Error.OOM - error is returned. + If the bus does not have enough resources the org.freedesktop.DBus.Error.OOM + error is returned.
@@ -6001,8 +6001,8 @@ Removes the first rule that matches (see ). - If the rule is not found the org.freedesktop.DBus.Error.MatchRuleNotFound - error is returned. + If the rule is not found the org.freedesktop.DBus.Error.MatchRuleNotFound + error is returned. @@ -6146,7 +6146,7 @@ One-to-One - + An application talking directly to another application, without going through a message bus. One-to-one connections may be "peer to peer" or "client to server." The D-Bus protocol has no concept of client @@ -6186,7 +6186,7 @@ Services normally guarantee some particular features, for example they may guarantee that they will request a specific name such as "com.example.Screensaver", have a singleton object - "/com/example/Application", and that object will implement the + "/com/example/Application", and that object will implement the interface "com.example.Screensaver.Control". -- cgit v1.2.1 From 7628af5924dc4359e8f1334070310aabf3901ada Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 10 Dec 2013 10:02:27 +0800 Subject: DBus Spec: add document of bind for tcp/nonce-tcp transport tcp/nonce-tcp transport has a "bind" key, which can be specified a hostname and will override hostname specified in "host" key. "bind" has a special value "*" which means ip address 0.0.0.0 and will cause dbus-daemon listen on all interfaces. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72301 Reviewed-by: Simon McVittie --- doc/dbus-specification.xml | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 5043849f..f1495559 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -3180,7 +3180,18 @@ host (string) - dns name or ip address + DNS name or IP address + + + bind + (string) + Used in a listenable address to configure the interface + on which the server will listen: either the IP address of one of + the local machine's interfaces (most commonly 127.0.0.1 + ), or a DNS name that resolves to one of those IP + addresses, or '*' to listen on all interfaces simultaneously. + If not specified, the default is the same value as "host". + port @@ -3256,7 +3267,13 @@ host (string) - dns name or ip address + DNS name or IP address + + + bind + (string) + The same as for tcp: addresses + port -- cgit v1.2.1 From a77f64d5e1b411b14a6768d63a2c677ae064a256 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Tue, 10 Dec 2013 10:06:23 +0800 Subject: dbus-daemon(1): align document about "bind" with DBus Spec Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72301 Reviewed-by: Simon McVittie --- doc/dbus-daemon.1.xml.in | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index 1a1e42cd..7b7f4a1b 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -392,12 +392,13 @@ DBUS_SESSION_BUS_ADDRESS is set. Example: <listen>tcp:host=localhost,port=0</listen> -tcp addresses also allow a bind=hostname option, which will override -the host option specifying what address to bind to, without changing -the address reported by the bus. The bind option can also take a -special name '*' to cause the bus to listen on all local address -(INADDR_ANY). The specified host should be a valid name of the local -machine or weird stuff will happen. +tcp/nonce-tcp addresses also allow a bind=hostname option, +used in a listenable address to configure the interface on which +the server will listen: either the hostname is the IP address of +one of the local machine's interfaces (most commonly 127.0.0.1), +or a DNS name that resolves to one of those IP addresses, or '*' +to listen on all interfaces simultaneously. If not specified, +the default is the same value as "host". Example: <listen>tcp:host=localhost,bind=*,port=0</listen> -- cgit v1.2.1 From 5cef4cbf5ae059443df4215887242ca07167669a Mon Sep 17 00:00:00 2001 From: Matt Fischer Date: Fri, 8 Nov 2013 16:08:39 -0600 Subject: Define WIN32_LEAN_AND_MEAN in Windows port somewhat cloyingly attempts to include by default, which causes problems if the rest of the program is trying to use the incompatible . The Windows sysdep header attempts to prevent this by forcibly defining the winsock header guard macro, so that it will not be included. However, this does not work on MinGW because it uses a different guard macro name. This patch changes the code to instead define WIN32_LEAN_AND_MEAN, which is a more portable way to ensure that will not be included. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71405 Reviewed-By: Ralf Habacker --- dbus/dbus-sysdeps-win.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 90d14de0..02e7a83f 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -27,7 +27,7 @@ #define DBUS_SYSDEPS_WIN_H extern void *_dbus_win_get_dll_hmodule (void); -#define _WINSOCKAPI_ +#define WIN32_LEAN_AND_MEAN #include "dbus-hash.h" #include "dbus-string.h" -- cgit v1.2.1 From ee4f946d0506a3c00fa9d5f2e3c947d48e9c4ea6 Mon Sep 17 00:00:00 2001 From: Chengwei Yang Date: Wed, 20 Nov 2013 11:30:59 +0800 Subject: Do not install systemd unit files if build without systemd If dbus buid without systemd (--disable-systemd or no systemd libs available when building), we expect not to install dbus systemd unit files because they're only for systemd environment. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71818 Reviewed-by: Simon McVittie --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e37a6329..b18c30f6 100644 --- a/configure.ac +++ b/configure.ac @@ -1497,7 +1497,7 @@ AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service if test "x$with_systemdsystemunitdir" != xno; then AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir]) fi -AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) +AM_CONDITIONAL(HAVE_SYSTEMD, [test "x$have_systemd" != "xno" -a -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ]) ##### Set up location for system bus socket if ! test -z "$with_system_socket"; then -- cgit v1.2.1 From 127ef144f34fcc89a6f113c23bc7c9f06811c9f0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 6 Jan 2014 18:40:26 +0000 Subject: 1.7.10 --- NEWS | 45 ++++++++++++++++++++++++++++++++++++++++++--- configure.ac | 2 +- doc/dbus-specification.xml | 10 ++++++---- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/NEWS b/NEWS index 3cc46d2a..a1dc4568 100644 --- a/NEWS +++ b/NEWS @@ -1,11 +1,29 @@ -D-Bus 1.7.10 (UNRELEASED) +D-Bus 1.7.10 (2014-01-06) == +The “weighted companion cube” release. + +This is a release candidate for D-Bus 1.8. + D-Bus Specification 0.23: • don't require messages with no INTERFACE to be dispatched (fd.o #68597, Simon McVittie) +• document "tcp:bind=..." and "nonce-tcp:bind=..." (fd.o #72301, + Chengwei Yang) + +• define "listenable" and "connectable" addresses, and discuss + the difference (fd.o #61303, Simon McVittie) + +Enhancements: + +• support printing Unix file descriptors in dbus-send, dbus-monitor + (fd.o #70592, Robert Ancell) + +• don't install systemd units if --disable-systemd is given + (fd.o #71818, Chengwei Yang) + Fixes: • don't leak memory on out-of-memory while listing activatable or @@ -22,8 +40,29 @@ Fixes: • define PROCESS_QUERY_LIMITED_INFORMATION if missing from MinGW < 4 headers (fd.o #71366, Matt Fischer) -• support printing Unix file descriptors in dbus-send, dbus-monitor - (fd.o #70592, Robert Ancell) +• define WIN32_LEAN_AND_MEAN to avoid conflicts between winsock.h and + winsock2.h (fd.o #71405, Matt Fischer) + +• do not return failure from _dbus_read_nonce() with no error set, + preventing a potential crash (fd.o #72298, Chengwei Yang) + +• on BSD systems, avoid some O(1)-per-process memory and fd leaks in kqueue, + preventing test failures (fd.o #69332, fd.o #72213; Chengwei Yang) + +• fix warning spam on Hurd by not trying to set SO_REUSEADDR on Unix sockets, + which doesn't do anything anyway on at least Linux and FreeBSD + (fd.o #69492, Simon McVittie) + +• fix use of TCP sockets on FreeBSD and Hurd by tolerating EINVAL from + sendmsg() with SCM_CREDS (retrying with plain send()), and looking + for credentials more correctly (fd.o #69492, Simon McVittie) + +• ensure that tests run with a temporary XDG_RUNTIME_DIR to avoid + getting mixed up in XDG/systemd "user sessions" (fd.o #61301, + Simon McVittie) + +• refresh cached policy rules for existing connections when bus + configuration changes (fd.o #39463, Chengwei Yang) D-Bus 1.7.8 (2013-11-01) == diff --git a/configure.ac b/configure.ac index b18c30f6..7d01653c 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [9]) +m4_define([dbus_micro_version], [10]) 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]) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index f1495559..8b83495f 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -7,7 +7,7 @@ D-Bus Specification Version 0.23 - (not yet released) + 2014-01-06 Havoc @@ -73,10 +73,12 @@ 0.23 - not yet released - + 2014-01-06 + SMcV, CY - see commit log + method call messages with no INTERFACE may be considered an error; + document tcp:bind=... and nonce-tcp:bind=...; define listenable + and connectable addresses -- cgit v1.2.1 From d511fd96e6eaff36c97056daac535eedf52820b6 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 6 Jan 2014 20:17:05 +0000 Subject: start 1.7.11 --- NEWS | 3 +++ configure.ac | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index a1dc4568..699ef1a8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +D-Bus 1.7.12 (UNRELEASED) +== + D-Bus 1.7.10 (2014-01-06) == diff --git a/configure.ac b/configure.ac index 7d01653c..794e1569 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [10]) +m4_define([dbus_micro_version], [11]) 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]) -- cgit v1.2.1 From fb16f80d457a66610f615b44158330bf7ba68697 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 6 Jan 2014 20:17:11 +0000 Subject: start spec 0.24 --- doc/dbus-specification.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index 8b83495f..bed4899c 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.23 - 2014-01-06 + Version 0.24 + (not yet released) Havoc @@ -71,6 +71,14 @@ + + 0.24 + (not yet released) + n/a + + see commit log + + 0.23 2014-01-06 -- cgit v1.2.1 From 710bd4a94488585300458733748a0f2462abdf57 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 12 Oct 2013 00:59:22 +0200 Subject: Skip unix only syslog test. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Simon McVittie --- test/internals/syslog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/internals/syslog.c b/test/internals/syslog.c index 2811b757..7e0eae79 100644 --- a/test/internals/syslog.c +++ b/test/internals/syslog.c @@ -51,6 +51,7 @@ static void test_syslog (Fixture *f, gconstpointer data) { +#ifndef G_OS_WIN32 if (g_test_trap_fork (0, 0)) { _dbus_init_system_log (FALSE); @@ -73,7 +74,7 @@ test_syslog (Fixture *f, g_test_trap_assert_passed (); g_test_trap_assert_stderr ("*" MESSAGE "42\n*" MESSAGE "666\n*"); - +#endif /* manual test (this is the best we can do on Windows) */ _dbus_init_system_log (FALSE); _dbus_system_log (DBUS_SYSTEM_LOG_INFO, MESSAGE "%d", 42); -- cgit v1.2.1 From 6e2ad3c8ca8e74df79843e05ae09d5461239dbea Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 6 Jan 2014 23:30:55 +0100 Subject: Use dbus provided version of va_copy(). Bug: https://bugs.freedesktop.org/show_bug.cgi?id=72840 Reviewed-by: Simon McVittie --- dbus/dbus-message.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 32ac37a2..c6953d02 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -812,7 +812,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, /* copy var_args first, then we can do another iteration over it to * free memory and close unix fds if parse failed at some point. */ - va_copy (copy_args, var_args); + DBUS_VA_COPY (copy_args, var_args); while (spec_type != DBUS_TYPE_INVALID) { -- cgit v1.2.1 From 497cc68c029b30aabb54de139425bf200a40d67a Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 7 Jan 2014 08:13:43 +0100 Subject: MSVC compile fix. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73345 Reviewed-by: Simon McVittie --- dbus/dbus-sysdeps-win.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 74a4e84e..1167e967 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -61,6 +61,7 @@ extern BOOL WINAPI ConvertStringSidToSidA (LPCSTR StringSid, PSID *Sid); extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); #include +#include #include #if HAVE_ERRNO_H -- cgit v1.2.1 From e09eb1268346e1d04529c5f3c4a74ed8a6949e09 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 24 Aug 2013 15:00:14 +0200 Subject: Add glib support to cmake buildsystem. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68506 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 6 ++++ cmake/modules/COPYING-CMAKE-SCRIPTS | 22 ++++++++++++++ cmake/modules/FindGLIB.cmake | 42 -------------------------- cmake/modules/FindGLib2.cmake | 60 +++++++++++++++++++++++++++++++++++++ cmake/modules/FindGObject.cmake | 52 ++++++++++++++++++++++++++++++++ cmake/test/CMakeLists.txt | 46 ++++++++++++++++++++++++++++ 6 files changed, 186 insertions(+), 42 deletions(-) create mode 100644 cmake/modules/COPYING-CMAKE-SCRIPTS delete mode 100644 cmake/modules/FindGLIB.cmake create mode 100644 cmake/modules/FindGLib2.cmake create mode 100644 cmake/modules/FindGObject.cmake diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index bf5ef2b1..adecfe13 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -109,6 +109,11 @@ option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) find_package(EXPAT) find_package(X11) +find_package(GLib2) +find_package(GObject) +if(GLIB2_FOUND AND GOBJECT_FOUND) + option (DBUS_WITH_GLIB "build with glib" ON) +endif() # analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac add_definitions(-D_GNU_SOURCE) @@ -539,6 +544,7 @@ message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} " message(" gcc coverage profiling: ${DBUS_GCOV_ENABLED} ") message(" Building unit tests: ${DBUS_BUILD_TESTS} ") +message(" Building with GLib: ${DBUS_WITH_GLIB} ") message(" Building verbose mode: ${DBUS_ENABLE_VERBOSE_MODE} ") message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ") message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ") diff --git a/cmake/modules/COPYING-CMAKE-SCRIPTS b/cmake/modules/COPYING-CMAKE-SCRIPTS new file mode 100644 index 00000000..53b6b71e --- /dev/null +++ b/cmake/modules/COPYING-CMAKE-SCRIPTS @@ -0,0 +1,22 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cmake/modules/FindGLIB.cmake b/cmake/modules/FindGLIB.cmake deleted file mode 100644 index 1fdaee95..00000000 --- a/cmake/modules/FindGLIB.cmake +++ /dev/null @@ -1,42 +0,0 @@ -# - Try to find the GLIB library -# Once done this will define -# -# GLIB_FOUND - system has GLIB -# GLIB_INCLUDES - the GLIB include directories -# GLIB_LIBRARIES - The libraries needed to use GLIB - -if (WIN32) - -INCLUDE(MacroGetenvWinPath) - -MACRO_GETENV_WIN_PATH(_program_FILES_DIR PROGRAMFILES) - -FIND_PATH(GLIB_INCLUDE_DIR glib.h - ${_program_FILES_DIR}/glib/include/glib-2.0 -) - - -# search for GLIB in the default install directory for applications (default of (n)make install) -FIND_LIBRARY(GLIB_LIBRARY NAMES glib-2.0 - PATHS - ${_program_FILES_DIR}/glib/lib -) - -if (GLIB_LIBRARY AND GLIB_INCLUDE_DIR) - set(GLIB_FOUND TRUE) - set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${GLIB_INCLUDES}) - set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${GLIB_LIBRARIES}) - -endif (GLIB_LIBRARY AND GLIB_INCLUDE_DIR) - -if (GLIB_FOUND) - if (NOT GLIB_FIND_QUIETLY) - message(STATUS "Found GLIB: ${GLIB_LIBRARY}") - endif (NOT GLIB_FIND_QUIETLY) -else (GLIB_FOUND) - if (GLIB_FIND_REQUIRED) - message(FATAL_ERROR "Could NOT find GLIB library") - endif (GLIB_FIND_REQUIRED) -endif (GLIB_FOUND) - -endif (WIN32) diff --git a/cmake/modules/FindGLib2.cmake b/cmake/modules/FindGLib2.cmake new file mode 100644 index 00000000..d72b2a09 --- /dev/null +++ b/cmake/modules/FindGLib2.cmake @@ -0,0 +1,60 @@ +# - Try to find the GLIB2 libraries +# Once done this will define +# +# GLIB2_FOUND - system has glib2 +# GLIB2_INCLUDE_DIR - the glib2 include directory +# GLIB2_LIBRARIES - glib2 library + +# Copyright (c) 2008 Laurent Montel, +# Copyright (c) 2013 Ralf Habacker, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + # Already in cache, be silent + set(GLIB2_FIND_QUIETLY TRUE) +endif(GLIB2_INCLUDE_DIR AND GLIB2_LIBRARIES) + +if (NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(PC_LibGLIB2 QUIET glib-2.0) +endif() + +find_path(GLIB2_MAIN_INCLUDE_DIR + NAMES glib.h + HINTS ${PC_LibGLIB2_INCLUDEDIR} + PATH_SUFFIXES glib-2.0) + +find_library(GLIB2_LIBRARY + NAMES glib-2.0 + HINTS ${PC_LibGLIB2_LIBDIR} +) + +find_library(GIO2_LIBRARY + NAMES gio-2.0 + HINTS ${PC_LibGLIB2_LIBDIR} +) + +set(GLIB2_LIBRARIES ${GLIB2_LIBRARY} ${GIO2_LIBRARY}) + +# search the glibconfig.h include dir under the same root where the library is found +get_filename_component(glib2LibDir "${GLIB2_LIBRARY}" PATH) + +find_path(GLIB2_INTERNAL_INCLUDE_DIR glibconfig.h + PATH_SUFFIXES glib-2.0/include + HINTS ${PC_LibGLIB2_INCLUDEDIR} "${glib2LibDir}" ${CMAKE_SYSTEM_LIBRARY_PATH}) + +set(GLIB2_INCLUDE_DIR "${GLIB2_MAIN_INCLUDE_DIR}") + +# not sure if this include dir is optional or required +# for now it is optional +if(GLIB2_INTERNAL_INCLUDE_DIR) + set(GLIB2_INCLUDE_DIR ${GLIB2_INCLUDE_DIR} "${GLIB2_INTERNAL_INCLUDE_DIR}") +endif(GLIB2_INTERNAL_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GLIB2 DEFAULT_MSG GLIB2_LIBRARIES GLIB2_MAIN_INCLUDE_DIR) + +mark_as_advanced(GLIB2_INCLUDE_DIR GLIB2_LIBRARIES) diff --git a/cmake/modules/FindGObject.cmake b/cmake/modules/FindGObject.cmake new file mode 100644 index 00000000..af0c9f73 --- /dev/null +++ b/cmake/modules/FindGObject.cmake @@ -0,0 +1,52 @@ +# - Try to find GObject +# Once done this will define +# +# GOBJECT_FOUND - system has GObject +# GOBJECT_INCLUDE_DIR - the GObject include directory +# GOBJECT_LIBRARIES - the libraries needed to use GObject +# GOBJECT_DEFINITIONS - Compiler switches required for using GObject + +# Copyright (c) 2011, Raphael Kubo da Costa +# Copyright (c) 2006, Tim Beaulen +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +FIND_PACKAGE(PkgConfig) +PKG_CHECK_MODULES(PC_GOBJECT gobject-2.0) +SET(GOBJECT_DEFINITIONS ${PC_GOBJECT_CFLAGS_OTHER}) + +FIND_PATH(GOBJECT_INCLUDE_DIR gobject.h + HINTS + ${PC_GOBJECT_INCLUDEDIR} + ${PC_GOBJECT_INCLUDE_DIRS} + PATH_SUFFIXES glib-2.0/gobject/ + ) + +FIND_LIBRARY(_GObjectLibs NAMES gobject-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) +FIND_LIBRARY(_GModuleLibs NAMES gmodule-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) +FIND_LIBRARY(_GThreadLibs NAMES gthread-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) +FIND_LIBRARY(_GLibs NAMES glib-2.0 + HINTS + ${PC_GOBJECT_LIBDIR} + ${PC_GOBJECT_LIBRARY_DIRS} + ) + +SET( GOBJECT_LIBRARIES ${_GObjectLibs} ${_GModuleLibs} ${_GThreadLibs} ${_GLibs} ) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GOBJECT DEFAULT_MSG GOBJECT_LIBRARIES GOBJECT_INCLUDE_DIR) + +MARK_AS_ADVANCED(GOBJECT_INCLUDE_DIR _GObjectLibs _GModuleLibs _GThreadLibs _GLibs) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 8657e4c7..c7265963 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -71,6 +71,51 @@ target_link_libraries(test-segfault ${DBUS_INTERNAL_LIBRARIES}) add_executable(test-sleep-forever ${test-sleep-forever_SOURCES}) target_link_libraries(test-sleep-forever ${DBUS_INTERNAL_LIBRARIES}) + +if(DBUS_WITH_GLIB) + message(STATUS "with glib test apps") + add_definitions( + ${GLIB2_DEFINITIONS} + ${GOBJECT_DEFINITIONS} + ) + include_directories( + ${GLIB2_INCLUDE_DIR} + ${GOBJECT_INCLUDE_DIR} + ${CMAKE_SOURCE_DIR}/../test + ) + set (TEST_LIBRARIES dbus-testutils ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES}) + + add_executable(test-corrupt ${CMAKE_SOURCE_DIR}/../test/corrupt.c) + target_link_libraries(test-corrupt ${TEST_LIBRARIES}) + + add_executable(test-dbus-daemon ${CMAKE_SOURCE_DIR}/../test/dbus-daemon.c) + target_link_libraries(test-dbus-daemon ${TEST_LIBRARIES}) + + add_executable(test-dbus-daemon-eavesdrop ${CMAKE_SOURCE_DIR}/../test/dbus-daemon-eavesdrop.c) + target_link_libraries(test-dbus-daemon-eavesdrop ${TEST_LIBRARIES}) + + add_executable(test-loopback ${CMAKE_SOURCE_DIR}/../test/loopback.c) + target_link_libraries(test-loopback ${TEST_LIBRARIES}) + + add_executable(test-marshal ${CMAKE_SOURCE_DIR}/../test/marshal.c) + target_link_libraries(test-marshal ${TEST_LIBRARIES}) + + add_executable(test-refs ${CMAKE_SOURCE_DIR}/../test/internals/refs.c) + target_link_libraries(test-refs ${TEST_LIBRARIES}) + + add_executable(test-relay ${CMAKE_SOURCE_DIR}/../test/relay.c) + target_link_libraries(test-relay ${TEST_LIBRARIES}) + + add_executable(test-syntax ${CMAKE_SOURCE_DIR}/../test/syntax.c) + target_link_libraries(test-syntax ${TEST_LIBRARIES}) + + add_executable(test-syslog ${CMAKE_SOURCE_DIR}/../test/internals/syslog.c) + target_link_libraries(test-syslog ${TEST_LIBRARIES}) + + add_executable(manual-authz ${CMAKE_SOURCE_DIR}/../test/manual-authz.c) + target_link_libraries(manual-authz ${TEST_LIBRARIES}) +endif() + ### keep these in creation order, i.e. uppermost dirs first set (TESTDIRS test/data @@ -81,6 +126,7 @@ set (TESTDIRS test/data/sha-1 test/data/valid-config-files test/data/valid-config-files/basic.d + test/data/valid-config-files/session.d test/data/valid-config-files/system.d test/data/valid-config-files-system test/data/valid-introspection-files -- cgit v1.2.1 From e74f0b1efa3f541faabb89c1bd97543d36696d16 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 2 Sep 2013 16:36:46 +0100 Subject: test/dbus-daemon, test/dbus-daemon-eavesdrop: allow external dbus-daemon It's easier to automate these tests if they launch their own dbus-daemon, but easier to debug them if they don't: you can launch a dbus-daemon separately, under gdb. However, tests that need a specially-configured dbus-daemon will have to be skipped. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68852 Reviewed-by: Ralf Habacker --- test/dbus-daemon-eavesdrop.c | 9 ++++++++- test/dbus-daemon.c | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c index 2c45f54e..bc5ba121 100644 --- a/test/dbus-daemon-eavesdrop.c +++ b/test/dbus-daemon-eavesdrop.c @@ -409,7 +409,14 @@ setup (Fixture *f, config = g_strdup ("--session"); } - address = spawn_dbus_daemon (dbus_daemon, config, &f->daemon_pid); + if (g_getenv ("DBUS_TEST_DAEMON_ADDRESS") != NULL) + { + address = g_strdup (g_getenv ("DBUS_TEST_DAEMON_ADDRESS")); + } + else + { + address = spawn_dbus_daemon (dbus_daemon, config, &f->daemon_pid); + } g_free (dbus_daemon); g_free (config); diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index 22ea23e3..c883425e 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -194,6 +194,14 @@ setup (Fixture *f, if (config != NULL && config->config_file != NULL) { + if (g_getenv ("DBUS_TEST_DAEMON_ADDRESS") != NULL) + { + g_message ("SKIP: cannot use DBUS_TEST_DAEMON_ADDRESS for " + "unusally-configured dbus-daemon"); + f->skip = TRUE; + return; + } + if (g_getenv ("DBUS_TEST_DATA") == NULL) { g_message ("SKIP: set DBUS_TEST_DATA to a directory containing %s", @@ -227,7 +235,14 @@ setup (Fixture *f, if (dbus_daemon == NULL) dbus_daemon = g_strdup ("dbus-daemon"); - address = spawn_dbus_daemon (dbus_daemon, arg, &f->daemon_pid); + if (g_getenv ("DBUS_TEST_DAEMON_ADDRESS") != NULL) + { + address = g_strdup (g_getenv ("DBUS_TEST_DAEMON_ADDRESS")); + } + else + { + address = spawn_dbus_daemon (dbus_daemon, arg, &f->daemon_pid); + } g_free (dbus_daemon); g_free (arg); -- cgit v1.2.1 From 9866c2d78588b699b0f51ff825263cbbc26fe3a5 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 8 Jan 2014 01:32:58 +0100 Subject: Remove obsolete cmake project tags in sub directories; we only have one project. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68506 Reviewed-by: Simon McVittie --- cmake/bus/CMakeLists.txt | 2 -- cmake/dbus/CMakeLists.txt | 2 -- cmake/test/CMakeLists.txt | 1 - cmake/tools/CMakeLists.txt | 2 -- 4 files changed, 7 deletions(-) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 9943584a..d2217bbb 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -1,5 +1,3 @@ -project(bus) - add_definitions(-DDBUS_COMPILATION) SET(EFENCE "") diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 0205f852..1d208647 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -1,5 +1,3 @@ -project(dbus-lib) - SET(DBUS_DIR ${CMAKE_SOURCE_DIR}/../dbus) configure_file(${DBUS_DIR}/dbus-arch-deps.h.in ${CMAKE_CURRENT_BINARY_DIR}/dbus-arch-deps.h ) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index c7265963..b3e03901 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -1,4 +1,3 @@ -project(test) add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS}) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 101c7e60..ddbd5bcf 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -1,5 +1,3 @@ -project(tools) - set (dbus_send_SOURCES ../../tools/dbus-print-message.c ../../tools/dbus-print-message.h -- cgit v1.2.1 From 720afc64b8cb531b2f8340db404adb79fe09ff74 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 10 Oct 2013 23:42:57 +0200 Subject: Use cmake build in executable suffix. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index adecfe13..db035201 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -353,9 +353,8 @@ endif(X11_FOUND) # test binary names if (WIN32) - # Automake calls this EXEEXT, and CMake doesn't have a standard name - # for it; follow Automake's naming convention so we can share .in files - set (EXEEXT ".exe") + # follow Automake's naming convention so we can share .in files + set (EXEEXT ${CMAKE_EXECUTABLE_SUFFIX}) endif(WIN32) if (MSVC_IDE) -- cgit v1.2.1 From 67a78c4ef6ada862b5dc584cc450db5694d882d3 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 8 Jan 2014 01:45:56 +0100 Subject: Define TEST_BUS_LAUNCH_BINARY for cmake to keep in sync with autotools. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Simon McVittie --- cmake/CMakeLists.txt | 1 + cmake/config.h.cmake | 1 + cmake/test/CMakeLists.txt | 4 ---- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index db035201..c8a68345 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -467,6 +467,7 @@ if (DBUS_BUILD_TESTS) set(DBUS_TEST_DATA ${CMAKE_BINARY_DIR}/test/data) set(TEST_SOCKET_DIR ${DBUS_SESSION_SOCKET_DIR} ) set(TEST_LAUNCH_HELPER_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-daemon-launch-helper-test) + set(TEST_BUS_LAUNCH_BINARY ${EXECUTABLE_OUTPUT_PATH}/dbus-launch${EXEEXT}) if (UNIX) set (TEST_LISTEN "unix:tmpdir=${TEST_SOCKET_DIR}") endif (UNIX) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 37355609..119ed396 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -32,6 +32,7 @@ // test binaries #define DBUS_TEST_EXEC "@DBUS_TEST_EXEC@" #define DBUS_EXEEXT "@EXEEXT@" +#cmakedefine TEST_BUS_LAUNCH_BINARY "@TEST_BUS_LAUNCH_BINARY@" /* Some dbus features */ #cmakedefine DBUS_ENABLE_ANSI 1 diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index b3e03901..e29a4993 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -194,7 +194,3 @@ FOREACH(FILE ${FILES}) MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n") ENDIF (CONFIG_VERBOSE) ENDFOREACH(FILE) - -# todo: for installation the TEST_..._BINARY variables must reflect the -# installation dir or has to be defined relative -# -- cgit v1.2.1 From 21ad24ada51fbb1defae07caae31cb5c888410f6 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 8 Jan 2014 02:03:14 +0100 Subject: Create session.conf and system.conf for test/data/valid-config-files from *.in files on cmake. We need to patch the listen address. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Simon McVittie --- cmake/test/CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index e29a4993..ba1b56b3 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -1,6 +1,8 @@ add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS}) +set(DBUS_SESSION_BUS_LISTEN_ADDRESS ${TEST_LISTEN}) + add_library(dbus-testutils STATIC ${CMAKE_SOURCE_DIR}/../test/test-utils.h ${CMAKE_SOURCE_DIR}/../test/test-utils.c @@ -184,12 +186,13 @@ ENDFOREACH(FILE_TYPE) MESSAGE(STATUS "Copying generated bus config files to test directory") set (OUTDIR ${CMAKE_BINARY_DIR}/test/data/valid-config-files) -FILE(GLOB FILES "${CMAKE_BINARY_DIR}/bus/*.conf" ) +FILE(GLOB FILES "${CMAKE_SOURCE_DIR}/../bus/*.conf.in" ) FILE(MAKE_DIRECTORY ${OUTDIR}) FOREACH(FILE ${FILES}) GET_FILENAME_COMPONENT(FILENAME ${FILE} NAME) + STRING(REGEX REPLACE "\\.in$" "" FILENAME ${FILENAME}) SET (TARGET ${OUTDIR}/${FILENAME}) - configure_file(${FILE} ${TARGET} COPYONLY) + configure_file(${FILE} ${TARGET} @ONLY) IF (CONFIG_VERBOSE) MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n") ENDIF (CONFIG_VERBOSE) -- cgit v1.2.1 From 05ed22c9264fe55868cfc975fa0d648ce6c7d3c1 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 10 Jan 2014 01:03:44 +0100 Subject: Fix mentioned files in Building section. --- README.win | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.win b/README.win index 4e4f7574..01032e1a 100644 --- a/README.win +++ b/README.win @@ -19,9 +19,7 @@ and mingw-w64|32 are known to work. Building -------- DBus can be built on windows using automake or cmake. See the -file README for more information. -Special cmake build instructions can be found in cmake/readme-cmake.txt - +file INSTALL for more information. windbus and dbus4win Ports -------------------------- -- cgit v1.2.1 From 79a7a30cdb06fbda283a652524978c87d0eca8d8 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 10 Jan 2014 01:07:28 +0100 Subject: Add 'check' cmake target to keep in sync with autotools. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Simon McVittie --- cmake/test/CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index ba1b56b3..6c1a62c0 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -197,3 +197,17 @@ FOREACH(FILE ${FILES}) MESSAGE("FROM: ${FILE}\nTO: ${TARGET}\n") ENDIF (CONFIG_VERBOSE) ENDFOREACH(FILE) + +add_custom_target(check + COMMAND ctest -R shell-test + COMMAND ctest -R test-printf + COMMAND ctest -R test-corrupt + COMMAND ctest -R test-dbus-daemon + COMMAND ctest -R test-dbus-daemon-eavesdrop + COMMAND ctest -R test-loopback + COMMAND ctest -R test-marshal + COMMAND ctest -R test-refs + COMMAND ctest -R test-relay + COMMAND ctest -R test-syntax + COMMAND ctest -R test-syslog +) \ No newline at end of file -- cgit v1.2.1 From 8e728f36d19b52d083680e618aa57171e828c5cd Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 10 Oct 2013 23:42:57 +0200 Subject: Use macros for test and helper executable targets on cmake build system. The new macros add_test_executables and add helper_executables provides a platform independent way for specifing dbus test and service applications. On native Windows and Linux/UNIX systems the test applications are directly runable. When cross compiling for Windows on Linux test applications could be executed on the Linux host system with the help of wine and activated binfmt_misc support for wine. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Simon McVittie --- cmake/bus/CMakeLists.txt | 11 ++---- cmake/dbus/CMakeLists.txt | 5 +-- cmake/modules/Macros.cmake | 27 ++++++++++++- cmake/test/CMakeLists.txt | 79 +++++++++++-------------------------- cmake/test/name-test/CMakeLists.txt | 40 ++++--------------- 5 files changed, 61 insertions(+), 101 deletions(-) diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index d2217bbb..56235315 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -106,10 +106,9 @@ if (DBUS_SERVICE) endif (DBUS_SERVICE) if (DBUS_ENABLE_EMBEDDED_TESTS) - add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c) - target_link_libraries(bus-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) + set(SOURCES ${BUS_SOURCES} ${BUS_DIR}/test-main.c) + add_test_executable(bus-test "${SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) set_target_properties(bus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) - add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_BINARY_DIR}/test/data) endif (DBUS_ENABLE_EMBEDDED_TESTS) if(MSVC) @@ -146,11 +145,9 @@ if(NOT WIN32) set_target_properties(dbus-daemon-launch-helper-test PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST") target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} ) - add_executable(bus-test-launch-helper ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) + set (SOURCES ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) + add_test_executable(bus-test-launch-helper "${SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") - target_link_libraries(bus-test-launch-helper ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} ) - add_test(bus-test-launch-helper ${EXECUTABLE_OUTPUT_PATH}/bus-test-launch-helper ) - endif(NOT WIN32) #### Init scripts fun diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 1d208647..cea22985 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -297,10 +297,7 @@ else(WIN32) endif(WIN32) if (DBUS_ENABLE_EMBEDDED_TESTS) - set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus") - ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c) - target_link_libraries(dbus-test ${DBUS_INTERNAL_LIBRARIES}) - add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data) + add_test_executable(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c ${DBUS_INTERNAL_LIBRARIES}) set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) ENDIF (DBUS_ENABLE_EMBEDDED_TESTS) diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index adb34b51..9a1519d6 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -1,4 +1,3 @@ - MACRO(TIMESTAMP RESULT) if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE DATE) @@ -10,3 +9,29 @@ MACRO(TIMESTAMP RESULT) EXECUTE_PROCESS(COMMAND "date" "+%Y%m%d%H%M" OUTPUT_VARIABLE ${RESULT}) endif () ENDMACRO() + +macro(add_test_executable _target _source) + add_executable(${_target} ${_source}) + target_link_libraries(${_target} ${ARGN}) + if (CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME STREQUAL "Windows") + # run tests with binfmt_misc + set(PREFIX "z:") + set(_env "DBUS_TEST_DAEMON=${PREFIX}${CMAKE_BINARY_DIR}/bin/dbus-daemon${EXEEXT}") + add_test(NAME ${_target} COMMAND $) + else() + set(PREFIX) + set(_env "DBUS_TEST_DAEMON=${CMAKE_BINARY_DIR}/bin/dbus-daemon${EXEEXT}") + add_test(NAME ${_target} COMMAND $) + endif() + list(APPEND _env "DBUS_SESSION_BUS_ADDRESS=") + list(APPEND _env "DBUS_FATAL_WARNINGS=1") + list(APPEND _env "DBUS_BLOCK_ON_ABORT=1") + list(APPEND _env "DBUS_TEST_DATA=${PREFIX}${CMAKE_BINARY_DIR}/test/data") + list(APPEND _env "DBUS_TEST_HOMEDIR=${PREFIX}${CMAKE_BINARY_DIR}/dbus") + set_tests_properties(${_target} PROPERTIES ENVIRONMENT "${_env}") +endmacro(add_test_executable) + +macro(add_helper_executable _target _source) + add_executable(${_target} ${_source}) + target_link_libraries(${_target} ${ARGN}) +endmacro(add_helper_executable) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 6c1a62c0..327b0924 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -47,31 +47,15 @@ set (test-sleep-forever_SOURCES ${CMAKE_SOURCE_DIR}/../test/test-sleep-forever.c ) -add_executable(test-service ${test-service_SOURCES}) -target_link_libraries(test-service dbus-testutils) - -add_executable(test-names ${test-names_SOURCES}) -target_link_libraries(test-names dbus-testutils) - -add_executable(shell-test ${shell-test_SOURCES}) -target_link_libraries(shell-test ${DBUS_INTERNAL_LIBRARIES}) -ADD_TEST(shell-test ${EXECUTABLE_OUTPUT_PATH}/shell-test${EXEEXT}) - -add_executable(test-shell-service ${test-shell-service_SOURCES}) -target_link_libraries(test-shell-service dbus-testutils) - -add_executable(spawn-test ${spawn-test_SOURCES}) -target_link_libraries(spawn-test ${DBUS_INTERNAL_LIBRARIES}) - -add_executable(test-exit ${test-exit_SOURCES}) -target_link_libraries(test-exit ${DBUS_INTERNAL_LIBRARIES}) - -add_executable(test-segfault ${test-segfault_SOURCES}) -target_link_libraries(test-segfault ${DBUS_INTERNAL_LIBRARIES}) - -add_executable(test-sleep-forever ${test-sleep-forever_SOURCES}) -target_link_libraries(test-sleep-forever ${DBUS_INTERNAL_LIBRARIES}) - +add_helper_executable(test-service ${test-service_SOURCES} dbus-testutils) +add_helper_executable(test-names ${test-names_SOURCES} dbus-testutils) +add_test_executable(shell-test ${shell-test_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_test_executable(test-printf ${CMAKE_SOURCE_DIR}/../test/internals/printf.c dbus-testutils) +add_helper_executable(test-shell-service ${test-shell-service_SOURCES} dbus-testutils) +add_helper_executable(spawn-test ${spawn-test_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-segfault ${test-segfault_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) if(DBUS_WITH_GLIB) message(STATUS "with glib test apps") @@ -84,37 +68,18 @@ if(DBUS_WITH_GLIB) ${GOBJECT_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/../test ) - set (TEST_LIBRARIES dbus-testutils ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES}) - - add_executable(test-corrupt ${CMAKE_SOURCE_DIR}/../test/corrupt.c) - target_link_libraries(test-corrupt ${TEST_LIBRARIES}) - - add_executable(test-dbus-daemon ${CMAKE_SOURCE_DIR}/../test/dbus-daemon.c) - target_link_libraries(test-dbus-daemon ${TEST_LIBRARIES}) - - add_executable(test-dbus-daemon-eavesdrop ${CMAKE_SOURCE_DIR}/../test/dbus-daemon-eavesdrop.c) - target_link_libraries(test-dbus-daemon-eavesdrop ${TEST_LIBRARIES}) - - add_executable(test-loopback ${CMAKE_SOURCE_DIR}/../test/loopback.c) - target_link_libraries(test-loopback ${TEST_LIBRARIES}) - - add_executable(test-marshal ${CMAKE_SOURCE_DIR}/../test/marshal.c) - target_link_libraries(test-marshal ${TEST_LIBRARIES}) - - add_executable(test-refs ${CMAKE_SOURCE_DIR}/../test/internals/refs.c) - target_link_libraries(test-refs ${TEST_LIBRARIES}) - - add_executable(test-relay ${CMAKE_SOURCE_DIR}/../test/relay.c) - target_link_libraries(test-relay ${TEST_LIBRARIES}) - - add_executable(test-syntax ${CMAKE_SOURCE_DIR}/../test/syntax.c) - target_link_libraries(test-syntax ${TEST_LIBRARIES}) - - add_executable(test-syslog ${CMAKE_SOURCE_DIR}/../test/internals/syslog.c) - target_link_libraries(test-syslog ${TEST_LIBRARIES}) - - add_executable(manual-authz ${CMAKE_SOURCE_DIR}/../test/manual-authz.c) - target_link_libraries(manual-authz ${TEST_LIBRARIES}) + set(TEST_LIBRARIES ${DBUS_INTERNAL_LIBRARIES} dbus-testutils ${GLIB2_LIBRARIES} ${GOBJECT_LIBRARIES}) + + add_test_executable(test-corrupt ${CMAKE_SOURCE_DIR}/../test/corrupt.c ${TEST_LIBRARIES}) + add_test_executable(test-dbus-daemon ${CMAKE_SOURCE_DIR}/../test/dbus-daemon.c ${TEST_LIBRARIES}) + add_test_executable(test-dbus-daemon-eavesdrop ${CMAKE_SOURCE_DIR}/../test/dbus-daemon-eavesdrop.c ${TEST_LIBRARIES}) + add_test_executable(test-loopback ${CMAKE_SOURCE_DIR}/../test/loopback.c ${TEST_LIBRARIES}) + add_test_executable(test-marshal ${CMAKE_SOURCE_DIR}/../test/marshal.c ${TEST_LIBRARIES}) + add_test_executable(test-refs ${CMAKE_SOURCE_DIR}/../test/internals/refs.c ${TEST_LIBRARIES}) + add_test_executable(test-relay ${CMAKE_SOURCE_DIR}/../test/relay.c ${TEST_LIBRARIES}) + add_test_executable(test-syntax ${CMAKE_SOURCE_DIR}/../test/syntax.c ${TEST_LIBRARIES}) + add_test_executable(test-syslog ${CMAKE_SOURCE_DIR}/../test/internals/syslog.c ${TEST_LIBRARIES}) + add_helper_executable(manual-authz ${CMAKE_SOURCE_DIR}/../test/manual-authz.c ${TEST_LIBRARIES}) endif() ### keep these in creation order, i.e. uppermost dirs first @@ -210,4 +175,4 @@ add_custom_target(check COMMAND ctest -R test-relay COMMAND ctest -R test-syntax COMMAND ctest -R test-syslog -) \ No newline at end of file +) diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index bf096ba7..befb28f9 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -4,36 +4,12 @@ set (NAMEtest-DIR ../../../test/name-test) add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS}) -add_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c) -target_link_libraries(test-pending-call-dispatch ${DBUS_INTERNAL_LIBRARIES}) -ADD_TEST(test-pending-call-dispatch ${EXECUTABLE_OUTPUT_PATH}/test-pending-call-dispatch) - -add_executable(test-pending-call-timeout ${NAMEtest-DIR}/test-pending-call-timeout.c) -target_link_libraries(test-pending-call-timeout ${DBUS_INTERNAL_LIBRARIES}) -ADD_TEST(test-pending-call-timeout ${EXECUTABLE_OUTPUT_PATH}/test-pending-call-timeout) - -add_executable(test-thread-init ${NAMEtest-DIR}/test-threads-init.c) -target_link_libraries(test-thread-init ${DBUS_INTERNAL_LIBRARIES}) -ADD_TEST(test-thread-init ${EXECUTABLE_OUTPUT_PATH}/test-thread-init) - -add_executable(test-ids ${NAMEtest-DIR}/test-ids.c) -target_link_libraries(test-ids ${DBUS_INTERNAL_LIBRARIES}) -ADD_TEST(test-ids ${EXECUTABLE_OUTPUT_PATH}/test-ids) - -add_executable(test-shutdown ${NAMEtest-DIR}/test-shutdown.c) -target_link_libraries(test-shutdown dbus-testutils) -ADD_TEST(test-shutdown ${EXECUTABLE_OUTPUT_PATH}/test-shutdown) - -add_executable(test-privserver ${NAMEtest-DIR}/test-privserver.c) -target_link_libraries(test-privserver dbus-testutils) -ADD_TEST(test-privserver ${EXECUTABLE_OUTPUT_PATH}/test-privserver) - -add_executable(test-privserver-client ${NAMEtest-DIR}/test-privserver-client.c) -target_link_libraries(test-privserver-client dbus-testutils) -ADD_TEST(test-privserver-client ${EXECUTABLE_OUTPUT_PATH}/test-privserver-client) - -add_executable(test-autolaunch ${NAMEtest-DIR}/test-autolaunch.c) -target_link_libraries(test-autolaunch dbus-testutils) -ADD_TEST(test-autolaunch ${EXECUTABLE_OUTPUT_PATH}/test-autolaunch) - +add_helper_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-pending-call-timeout ${NAMEtest-DIR}/test-pending-call-timeout.c ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-thread-init ${NAMEtest-DIR}/test-threads-init.c ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-ids ${NAMEtest-DIR}/test-ids.c ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-shutdown ${NAMEtest-DIR}/test-shutdown.c dbus-testutils) +add_helper_executable(test-privserver ${NAMEtest-DIR}/test-privserver.c dbus-testutils) +add_helper_executable(test-privserver-client ${NAMEtest-DIR}/test-privserver-client.c dbus-testutils) +add_helper_executable(test-autolaunch ${NAMEtest-DIR}/test-autolaunch.c dbus-testutils) endif (DBUS_ENABLE_EMBEDDED_TESTS) -- cgit v1.2.1 From 7457a4401188b50e30dccd2f99db9c6289d080a1 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 7 Jan 2014 12:23:10 +0000 Subject: tests: don't block and wait for a debugger on abort In general, I think developers running the tests would expect them to terminate rather than hanging. Developers who want to debug such an abort by attaching a debugger to a live process can still set DBUS_BLOCK_ON_ABORT in the environment. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Ralf Habacker --- cmake/modules/Macros.cmake | 1 - test/Makefile.am | 1 - 2 files changed, 2 deletions(-) diff --git a/cmake/modules/Macros.cmake b/cmake/modules/Macros.cmake index 9a1519d6..545f2e58 100644 --- a/cmake/modules/Macros.cmake +++ b/cmake/modules/Macros.cmake @@ -25,7 +25,6 @@ macro(add_test_executable _target _source) endif() list(APPEND _env "DBUS_SESSION_BUS_ADDRESS=") list(APPEND _env "DBUS_FATAL_WARNINGS=1") - list(APPEND _env "DBUS_BLOCK_ON_ABORT=1") list(APPEND _env "DBUS_TEST_DATA=${PREFIX}${CMAKE_BINARY_DIR}/test/data") list(APPEND _env "DBUS_TEST_HOMEDIR=${PREFIX}${CMAKE_BINARY_DIR}/dbus") set_tests_properties(${_target} PROPERTIES ENVIRONMENT "${_env}") diff --git a/test/Makefile.am b/test/Makefile.am index 426a72e0..09b94561 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -156,7 +156,6 @@ installcheck_environment = \ TESTS_ENVIRONMENT = \ XDG_RUNTIME_DIR=@abs_top_builddir@/test/XDG_RUNTIME_DIR \ - DBUS_BLOCK_ON_ABORT=1 \ DBUS_FATAL_WARNINGS=1 \ DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \ DBUS_TEST_DATA=@abs_top_builddir@/test/data \ -- cgit v1.2.1 From 46f591b2be6f2a05df8dc7251ea44a149ce519e1 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 10 Jan 2014 14:46:40 +0100 Subject: Fix compile error on opensuse 12.2 with systemd 44 and glibc-2.15. The specific systemd/glibc version do not include syslog.h by default. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73455 Reviewed-by: Simon McVittie --- dbus/dbus-spawn.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 653776b5..b95cad6e 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -39,6 +39,9 @@ #include #endif #ifdef HAVE_SYSTEMD +#ifdef HAVE_SYSLOG_H +#include +#endif #include #endif -- cgit v1.2.1 From fc3bf2f30472aa87b0e8eedb6aa3b0a78043cd8b Mon Sep 17 00:00:00 2001 From: Matt Hoosier Date: Thu, 9 Jan 2014 16:15:31 -0600 Subject: Don't forget allow_anonymous when merging configs The algorithm to collapse a subsidiary config file's data into the master data structure forgot to examine this flag. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73475 Reviewed-by: Chengwei Yang Reviewed-by: Simon McVittie --- bus/config-parser.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bus/config-parser.c b/bus/config-parser.c index 12a2d2e7..a6a8e1cf 100644 --- a/bus/config-parser.c +++ b/bus/config-parser.c @@ -318,6 +318,9 @@ merge_included (BusConfigParser *parser, if (included->keep_umask) parser->keep_umask = TRUE; + if (included->allow_anonymous) + parser->allow_anonymous = TRUE; + if (included->pidfile != NULL) { dbus_free (parser->pidfile); -- cgit v1.2.1 From 08e3ab8682e902eb4628dd070a85ec57003f0670 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 14 Jan 2014 11:07:39 +0000 Subject: NEWS --- NEWS | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/NEWS b/NEWS index 699ef1a8..090cfa25 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,36 @@ D-Bus 1.7.12 (UNRELEASED) == +Enhancements: + +• Enhance the CMake build system to check for GLib and compile/run + a subset of the regression tests (fd.o #41252, Ralf Habacker) + +Fixes: + +• don't rely on va_copy(), use DBUS_VA_COPY() wrapper (fd.o #72840, + Ralf Habacker) + +• fix compilation of systemd journal support on older systemd versions where + sd-journal.h doesn't include syslog.h (fd.o #73455, Ralf Habacker) + +• fix compilation on older MSVC versions by including stdlib.h + (fd.o #73455, Ralf Habacker) + +• Allow to appear in an included configuration file + (fd.o #73475, Matt Hoosier) + +Test behaviour changes: + +• If the tests crash with an assertion failure, they no longer default to + blocking for a debugger to be attached. Set DBUS_BLOCK_ON_ABORT in the + environment if you want the old behaviour. + +• To improve debuggability, the dbus-daemon and dbus-daemon-eavesdrop tests + can be run with an external dbus-daemon by setting + DBUS_TEST_DAEMON_ADDRESS in the environment. Test-cases that require + an unusually-configured dbus-daemon are skipped. + D-Bus 1.7.10 (2014-01-06) == -- cgit v1.2.1 From d1699118c9d739a922ad58343864f2c35b9f7b41 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Jan 2014 20:58:28 +0100 Subject: CMake warning--. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=41252 Reviewed-by: Simon McVittie --- cmake/ConfigureChecks.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 2794975e..d290b0f2 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -90,7 +90,7 @@ find_program(DOXYGEN doxygen) find_program(XMLTO xmlto) if(MSVC) - SET(DBUS_VA_COPY_FUNC "_DBUS_VA_COPY_ASSIGN";) + SET(DBUS_VA_COPY_FUNC "_DBUS_VA_COPY_ASSIGN") else(MSVC) write_file("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cmake_try_compile.c" "#include #include -- cgit v1.2.1 From 8875cdf025f649bfa287a5cc49e4dc0aa00c71dc Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 17 Jan 2014 15:58:43 +0000 Subject: Correct test for LIBTOOLIZE by quoting it Based on a patch from Roland . Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73278 --- autogen.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen.sh b/autogen.sh index bff8257b..91d4b09d 100755 --- a/autogen.sh +++ b/autogen.sh @@ -48,7 +48,7 @@ fi } LIBTOOLIZE=`which libtoolize` -if ! test -f $LIBTOOLIZE; then +if ! test -f "$LIBTOOLIZE"; then LIBTOOLIZE=`which glibtoolize` fi -- cgit v1.2.1 From 0cd0714994a94a433745ed9bb2150cddbda5b313 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 11 Jan 2014 20:51:27 +0100 Subject: Rename dbus-test to test-dbus to match common test application naming scheme. [reverted the dbus-specification part -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73495 Reviewed-by: Simon McVittie --- HACKING | 2 +- README.win | 4 ++-- cmake/dbus/CMakeLists.txt | 4 ++-- dbus/.gitignore | 2 +- dbus/Makefile.am | 6 +++--- dbus/dbus-test.c | 8 ++++---- doc/dbus-test-plan.xml | 6 +++--- test/Makefile.am | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/HACKING b/HACKING index 805fd2e0..8c993b66 100644 --- a/HACKING +++ b/HACKING @@ -267,7 +267,7 @@ Tests These are the test programs that are built if dbus is compiled using --enable-tests. -dbus/dbus-test +dbus/test-dbus This is the main unit test program that tests all aspects of the D-Bus client library. diff --git a/README.win b/README.win index 01032e1a..bd67c188 100644 --- a/README.win +++ b/README.win @@ -31,10 +31,10 @@ updated with windows specific stuff. Tests ----- - dbus library check - bin\dbus-test.exe \test\data + bin\test-dbus.exe \test\data - bus daemon check - bin\bus-test.exe \test\data + bin\test-bus.exe \test\data - check available names bin\test_names.exe diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index cea22985..a5481b78 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -297,8 +297,8 @@ else(WIN32) endif(WIN32) if (DBUS_ENABLE_EMBEDDED_TESTS) - add_test_executable(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c ${DBUS_INTERNAL_LIBRARIES}) - set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) + add_test_executable(test-dbus ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c ${DBUS_INTERNAL_LIBRARIES}) + set_target_properties(test-dbus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) ENDIF (DBUS_ENABLE_EMBEDDED_TESTS) if (UNIX) diff --git a/dbus/.gitignore b/dbus/.gitignore index 34eace4d..fd91ccee 100644 --- a/dbus/.gitignore +++ b/dbus/.gitignore @@ -4,7 +4,7 @@ Makefile Makefile.in *.lo *.la -dbus-test +test-dbus *.bb *.bbg *.gcov diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 0f9033d1..b2481073 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -312,13 +312,13 @@ noinst_PROGRAMS = if DBUS_ENABLE_EMBEDDED_TESTS # We can't actually run this til we've reached test/ -noinst_PROGRAMS += dbus-test +noinst_PROGRAMS += test-dbus endif -dbus_test_SOURCES= \ +test_dbus_SOURCES= \ dbus-test-main.c -dbus_test_LDADD = libdbus-internal.la +test_dbus_LDADD = libdbus-internal.la ## mop up the gcov files clean-local: diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c index b707ee22..5990d6ec 100644 --- a/dbus/dbus-test.c +++ b/dbus/dbus-test.c @@ -41,7 +41,7 @@ check_memleaks (void) { dbus_shutdown (); - printf ("%s: checking for memleaks\n", "dbus-test"); + printf ("%s: checking for memleaks\n", "test-dbus"); if (_dbus_get_malloc_blocks_outstanding () != 0) { _dbus_warn ("%d dbus_malloc blocks were not freed\n", @@ -60,7 +60,7 @@ run_test (const char *test_name, { if (!specific_test || strcmp (specific_test, test_name) == 0) { - printf ("%s: running %s tests\n", "dbus-test", test_name); + printf ("%s: running %s tests\n", "test-dbus", test_name); if (!test ()) die (test_name); @@ -76,7 +76,7 @@ run_data_test (const char *test_name, { if (!specific_test || strcmp (specific_test, test_name) == 0) { - printf ("%s: running %s tests\n", "dbus-test", test_name); + printf ("%s: running %s tests\n", "test-dbus", test_name); if (!test (test_data_dir)) die (test_name); @@ -165,7 +165,7 @@ dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *speci run_data_test ("auth", specific_test, _dbus_auth_test, test_data_dir); - printf ("%s: completed successfully\n", "dbus-test"); + printf ("%s: completed successfully\n", "test-dbus"); #else printf ("Not compiled with unit tests, not running any\n"); #endif diff --git a/doc/dbus-test-plan.xml b/doc/dbus-test-plan.xml index ee911149..ed918e55 100644 --- a/doc/dbus-test-plan.xml +++ b/doc/dbus-test-plan.xml @@ -48,7 +48,7 @@ Testing the D-Bus client library - The tests for the client library consist of the dbus-test + The tests for the client library consist of the test-dbus program which is a unit test for all aspects of the client library. Whenever a bug in the client library is found and fixed, a test is added to make sure that the bug won't occur again. @@ -58,7 +58,7 @@ The D-Bus client library consists of some data structures that are used internally; a linked list class, a hashtable class and - a string class. All aspects of those are tested by dbus-test. + a string class. All aspects of those are tested by test-dbus. @@ -104,7 +104,7 @@ the D-Bus Reference Manual. - The message test part of dbus-test is using the message + The message test part of test-dbus is using the message builder to build different kinds of messages, both valid, invalid, and invalid ones, to make sure that the loader won't crash or leak memory of any of those, and that the loader diff --git a/test/Makefile.am b/test/Makefile.am index 09b94561..b23eb99f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -76,7 +76,7 @@ TEST_BINARIES = \ TESTS = \ ../bus/bus-test$(EXEEXT) \ ../bus/bus-test-system$(EXEEXT) \ - ../dbus/dbus-test$(EXEEXT) \ + ../dbus/test-dbus$(EXEEXT) \ $(NULL) if DBUS_UNIX -- cgit v1.2.1 From e782b0806eed9f46164b8aa5da7c1b12109175bf Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 10 Jan 2014 02:17:22 +0100 Subject: Rename shell-test to test-shell to match common test application naming scheme. [Add its source file to SOURCES: this test was previously relying on the Automake feature that the default value of foo_bar_SOURCES is foo-bar.c. -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73495 Reviewed-by: Simon McVittie --- cmake/test/CMakeLists.txt | 6 +++--- test/.gitignore | 2 +- test/Makefile.am | 7 ++++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 327b0924..f1506738 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -27,7 +27,7 @@ set (test-shell-service_SOURCES ${CMAKE_SOURCE_DIR}/../test/test-shell-service.c ) -set (shell-test_SOURCES +set (test-shell_SOURCES ${CMAKE_SOURCE_DIR}/../test/shell-test.c ) @@ -49,7 +49,7 @@ set (test-sleep-forever_SOURCES add_helper_executable(test-service ${test-service_SOURCES} dbus-testutils) add_helper_executable(test-names ${test-names_SOURCES} dbus-testutils) -add_test_executable(shell-test ${shell-test_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_test_executable(test-shell ${test-shell_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_test_executable(test-printf ${CMAKE_SOURCE_DIR}/../test/internals/printf.c dbus-testutils) add_helper_executable(test-shell-service ${test-shell-service_SOURCES} dbus-testutils) add_helper_executable(spawn-test ${spawn-test_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) @@ -164,7 +164,7 @@ FOREACH(FILE ${FILES}) ENDFOREACH(FILE) add_custom_target(check - COMMAND ctest -R shell-test + COMMAND ctest -R test-shell COMMAND ctest -R test-printf COMMAND ctest -R test-corrupt COMMAND ctest -R test-dbus-daemon diff --git a/test/.gitignore b/test/.gitignore index 1337de64..814a35cc 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -21,7 +21,7 @@ test-segfault test-service test-sleep-forever decode-gcov -shell-test +test-shell test-shell-service test-names test-loopback diff --git a/test/Makefile.am b/test/Makefile.am index b23eb99f..ddb69b4f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -100,8 +100,9 @@ test_names_LDADD = libdbus-testutils-internal.la ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_shell_service_CPPFLAGS = $(static_cppflags) test_shell_service_LDADD = libdbus-testutils-internal.la -shell_test_CPPFLAGS = $(static_cppflags) -shell_test_LDADD = libdbus-testutils-internal.la +test_shell_SOURCES = shell-test.c +test_shell_CPPFLAGS = $(static_cppflags) +test_shell_LDADD = libdbus-testutils-internal.la spawn_test_CPPFLAGS = $(static_cppflags) spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la @@ -124,7 +125,7 @@ testexecdir = $(libdir)/dbus-1.0/test testexec_PROGRAMS = installable_tests = \ - shell-test \ + test-shell \ test-printf \ $(NULL) installable_manual_tests = \ -- cgit v1.2.1 From 54440baa2192abe889957a23e4448c599ce32260 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Sat, 11 Jan 2014 10:07:21 +0100 Subject: Rename spawn-test to test-spawn to match common test application naming scheme. [Same change as for shell-test in the previous commit. -smcv] Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73495 Reviewed-by: Simon McVittie --- cmake/test/CMakeLists.txt | 4 ++-- test/.gitignore | 2 +- test/Makefile.am | 7 ++++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index f1506738..5d5cb949 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -31,7 +31,7 @@ set (test-shell_SOURCES ${CMAKE_SOURCE_DIR}/../test/shell-test.c ) -set (spawn-test_SOURCES +set (test-spawn_SOURCES ${CMAKE_SOURCE_DIR}/../test/spawn-test.c ) @@ -52,7 +52,7 @@ add_helper_executable(test-names ${test-names_SOURCES} dbus-testutils) add_test_executable(test-shell ${test-shell_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_test_executable(test-printf ${CMAKE_SOURCE_DIR}/../test/internals/printf.c dbus-testutils) add_helper_executable(test-shell-service ${test-shell-service_SOURCES} dbus-testutils) -add_helper_executable(spawn-test ${spawn-test_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) +add_helper_executable(test-spawn ${test-spawn_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(test-exit ${test-exit_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(test-segfault ${test-segfault_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) add_helper_executable(test-sleep-forever ${test-sleep-forever_SOURCES} ${DBUS_INTERNAL_LIBRARIES}) diff --git a/test/.gitignore b/test/.gitignore index 814a35cc..71b3cec9 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -14,7 +14,7 @@ unbase64 *.da *.gcov break-loader -spawn-test +test-spawn test-corrupt test-exit test-segfault diff --git a/test/Makefile.am b/test/Makefile.am index ddb69b4f..af2a0a23 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -61,7 +61,7 @@ if DBUS_ENABLE_EMBEDDED_TESTS ## break-loader removed for now ## these binaries are used in tests but are not themselves tests TEST_BINARIES = \ - spawn-test \ + test-spawn \ test-exit \ test-names \ test-segfault \ @@ -103,8 +103,9 @@ test_shell_service_LDADD = libdbus-testutils-internal.la test_shell_SOURCES = shell-test.c test_shell_CPPFLAGS = $(static_cppflags) test_shell_LDADD = libdbus-testutils-internal.la -spawn_test_CPPFLAGS = $(static_cppflags) -spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la +test_spawn_SOURCES = spawn-test.c +test_spawn_CPPFLAGS = $(static_cppflags) +test_spawn_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_printf_SOURCES = internals/printf.c test_printf_CPPFLAGS = $(static_cppflags) -- cgit v1.2.1 From 3ce5d21edfe5ca4a97892e3144fcbb5979a54cf6 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 13 Jan 2014 20:45:37 +0100 Subject: Rename bus-test to test-bus to match common test application naming scheme. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73495 Reviewed-by: Simon McVittie --- bus/.gitignore | 2 +- bus/Makefile.am | 6 +++--- cmake/bus/CMakeLists.txt | 4 ++-- doc/dbus-test-plan.xml | 8 ++++---- test/.gitignore | 2 +- test/Makefile.am | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/bus/.gitignore b/bus/.gitignore index 861dc1f5..3c6def7c 100644 --- a/bus/.gitignore +++ b/bus/.gitignore @@ -13,7 +13,7 @@ dbus-daemon-launch-helper-test *.bbg *.da *.gcov -bus-test +test-bus rc.messagebus messagebus messagebus-config diff --git a/bus/Makefile.am b/bus/Makefile.am index cd0c67da..65073e48 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -169,7 +169,7 @@ if DBUS_ENABLE_EMBEDDED_TESTS ## even when not doing "make check" # run as a test by test/Makefile.am -noinst_PROGRAMS += bus-test bus-test-system +noinst_PROGRAMS += test-bus bus-test-system if DBUS_UNIX # run as a test by test/Makefile.am @@ -192,11 +192,11 @@ bus_test_system_SOURCES= \ bus_test_system_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_BUS_LIBS) -bus_test_SOURCES= \ +test_bus_SOURCES= \ $(BUS_SOURCES) \ test-main.c -bus_test_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_BUS_LIBS) +test_bus_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_BUS_LIBS) ## mop up the gcov files clean-local: diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 56235315..4da3a539 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -107,8 +107,8 @@ endif (DBUS_SERVICE) if (DBUS_ENABLE_EMBEDDED_TESTS) set(SOURCES ${BUS_SOURCES} ${BUS_DIR}/test-main.c) - add_test_executable(bus-test "${SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) - set_target_properties(bus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) + add_test_executable(test-bus "${SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) + set_target_properties(test-bus PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) endif (DBUS_ENABLE_EMBEDDED_TESTS) if(MSVC) diff --git a/doc/dbus-test-plan.xml b/doc/dbus-test-plan.xml index ed918e55..e3efd2cd 100644 --- a/doc/dbus-test-plan.xml +++ b/doc/dbus-test-plan.xml @@ -170,10 +170,10 @@ a socket. - - The bus-test program + + The test-bus program - The bus-test program is a program that is used to test various + The test-bus program is a program that is used to test various parts of the D-Bus bus daemon; robustness and that it conforms to the specifications. @@ -185,7 +185,7 @@ testing easier. - The bus-test program should test all major features of the + The test-bus program should test all major features of the bus, such as service registration, notification when things occurs and message matching. diff --git a/test/.gitignore b/test/.gitignore index 71b3cec9..de1dfe14 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -7,7 +7,7 @@ Makefile.in *.o echo-server echo-client -bus-test +test-bus unbase64 *.bb *.bbg diff --git a/test/Makefile.am b/test/Makefile.am index af2a0a23..3155e87f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -74,7 +74,7 @@ TEST_BINARIES = \ ## order, but we don't want to run them til we arrive in this directory, ## since they depend on stuff from this directory TESTS = \ - ../bus/bus-test$(EXEEXT) \ + ../bus/test-bus$(EXEEXT) \ ../bus/bus-test-system$(EXEEXT) \ ../dbus/test-dbus$(EXEEXT) \ $(NULL) -- cgit v1.2.1 From cf41239d6684efa3f5d648b1fa84c4fe07148691 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Jan 2014 18:45:39 +0100 Subject: Rename bus-test-system to test-bus-system to match common test application naming scheme. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73495 Reviewed-by: Simon McVittie --- bus/.gitignore | 2 +- bus/Makefile.am | 6 +++--- test/Makefile.am | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bus/.gitignore b/bus/.gitignore index 3c6def7c..ae0299d4 100644 --- a/bus/.gitignore +++ b/bus/.gitignore @@ -20,7 +20,7 @@ messagebus-config session.conf system.conf bus-test-launch-helper -bus-test-system +test-bus-system dbus.service dbus.socket org.freedesktop.dbus-session.plist diff --git a/bus/Makefile.am b/bus/Makefile.am index 65073e48..dc418e79 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -169,7 +169,7 @@ if DBUS_ENABLE_EMBEDDED_TESTS ## even when not doing "make check" # run as a test by test/Makefile.am -noinst_PROGRAMS += test-bus bus-test-system +noinst_PROGRAMS += test-bus test-bus-system if DBUS_UNIX # run as a test by test/Makefile.am @@ -180,7 +180,7 @@ endif DBUS_UNIX endif DBUS_ENABLE_EMBEDDED_TESTS -bus_test_system_SOURCES= \ +test_bus_system_SOURCES= \ $(XML_SOURCES) \ config-parser-common.c \ config-parser-common.h \ @@ -190,7 +190,7 @@ bus_test_system_SOURCES= \ utils.h \ test-system.c -bus_test_system_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_BUS_LIBS) +test_bus_system_LDADD=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_BUS_LIBS) test_bus_SOURCES= \ $(BUS_SOURCES) \ diff --git a/test/Makefile.am b/test/Makefile.am index 3155e87f..e3e1fa47 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -75,7 +75,7 @@ TEST_BINARIES = \ ## since they depend on stuff from this directory TESTS = \ ../bus/test-bus$(EXEEXT) \ - ../bus/bus-test-system$(EXEEXT) \ + ../bus/test-bus-system$(EXEEXT) \ ../dbus/test-dbus$(EXEEXT) \ $(NULL) -- cgit v1.2.1 From 7e373d4527286ae0ecdc4ccd2064293c61f3b907 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Jan 2014 18:52:22 +0100 Subject: Rename bus-test-launch-helper to test-bus-launch_helper to match common test application naming scheme. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73495 Reviewed-by: Simon McVittie --- bus/.gitignore | 2 +- bus/Makefile.am | 8 ++++---- cmake/bus/CMakeLists.txt | 4 ++-- test/Makefile.am | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bus/.gitignore b/bus/.gitignore index ae0299d4..d856369b 100644 --- a/bus/.gitignore +++ b/bus/.gitignore @@ -19,7 +19,7 @@ messagebus messagebus-config session.conf system.conf -bus-test-launch-helper +test-bus-launch-helper test-bus-system dbus.service dbus.socket diff --git a/bus/Makefile.am b/bus/Makefile.am index dc418e79..f335e30c 100644 --- a/bus/Makefile.am +++ b/bus/Makefile.am @@ -140,15 +140,15 @@ dbus_daemon_launch_helper_test_CPPFLAGS = \ ## we build yet another binary so we can do the OOM tests ## DO NOT INSTALL THIS FILE -bus_test_launch_helper_SOURCES= \ +test_bus_launch_helper_SOURCES= \ test-launch-helper.c \ $(LAUNCH_HELPER_SOURCES) -bus_test_launch_helper_LDADD= \ +test_bus_launch_helper_LDADD= \ $(top_builddir)/dbus/libdbus-internal.la \ $(DBUS_LAUNCHER_LIBS) -bus_test_launch_helper_CPPFLAGS = \ +test_bus_launch_helper_CPPFLAGS = \ $(AM_CPPFLAGS) \ -DACTIVATION_LAUNCHER_TEST \ -DACTIVATION_LAUNCHER_DO_OOM @@ -173,7 +173,7 @@ noinst_PROGRAMS += test-bus test-bus-system if DBUS_UNIX # run as a test by test/Makefile.am -noinst_PROGRAMS += bus-test-launch-helper +noinst_PROGRAMS += test-bus-launch-helper # this is used by the tests but is not,itself, a test noinst_PROGRAMS += dbus-daemon-launch-helper-test endif DBUS_UNIX diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 4da3a539..f5b41cd8 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -146,8 +146,8 @@ if(NOT WIN32) target_link_libraries(dbus-daemon-launch-helper-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY} ) set (SOURCES ${LAUNCH_HELPER_SOURCES} ${BUS_DIR}/test-launch-helper.c) - add_test_executable(bus-test-launch-helper "${SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) - set_target_properties(bus-test-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") + add_test_executable(test-bus-launch-helper "${SOURCES}" ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) + set_target_properties(test-bus-launch-helper PROPERTIES COMPILE_FLAGS "-DACTIVATION_LAUNCHER_TEST -DACTIVATION_LAUNCHER_DO_OOM") endif(NOT WIN32) #### Init scripts fun diff --git a/test/Makefile.am b/test/Makefile.am index e3e1fa47..cec5cdab 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -80,7 +80,7 @@ TESTS = \ $(NULL) if DBUS_UNIX -TESTS += ../bus/bus-test-launch-helper$(EXEEXT) +TESTS += ../bus/test-bus-launch-helper$(EXEEXT) endif else !DBUS_ENABLE_EMBEDDED_TESTS -- cgit v1.2.1 From 5dfc800644a6f3b2a4717082259712e3b5922843 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 10 Jan 2014 02:20:10 +0100 Subject: Let cmake 'make check' run test applications as test group. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=73495 Reviewed-by: Simon McVittie --- cmake/test/CMakeLists.txt | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/cmake/test/CMakeLists.txt b/cmake/test/CMakeLists.txt index 5d5cb949..9195eae7 100644 --- a/cmake/test/CMakeLists.txt +++ b/cmake/test/CMakeLists.txt @@ -164,15 +164,5 @@ FOREACH(FILE ${FILES}) ENDFOREACH(FILE) add_custom_target(check - COMMAND ctest -R test-shell - COMMAND ctest -R test-printf - COMMAND ctest -R test-corrupt - COMMAND ctest -R test-dbus-daemon - COMMAND ctest -R test-dbus-daemon-eavesdrop - COMMAND ctest -R test-loopback - COMMAND ctest -R test-marshal - COMMAND ctest -R test-refs - COMMAND ctest -R test-relay - COMMAND ctest -R test-syntax - COMMAND ctest -R test-syslog + COMMAND ctest -R ^test-.* ) -- cgit v1.2.1 From 41b3f5b86c6acd60708550b6b53c8e565e8c5eb3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 20 Jan 2014 13:40:30 +0000 Subject: Revert "start spec 0.24" It hasn't otherwise changed since 1.7.10. This reverts commit fb16f80d457a66610f615b44158330bf7ba68697. --- doc/dbus-specification.xml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index bed4899c..8b83495f 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@
D-Bus Specification - Version 0.24 - (not yet released) + Version 0.23 + 2014-01-06 Havoc @@ -71,14 +71,6 @@ - - 0.24 - (not yet released) - n/a - - see commit log - - 0.23 2014-01-06 -- cgit v1.2.1 From 6528b0973bb09b0b407a5e169fdcc519087cc58d Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 20 Jan 2014 14:25:48 +0000 Subject: D-Bus 1.8.0 --- NEWS | 40 +++++++++++++++++++++++++++++++++++----- configure.ac | 4 ++-- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 090cfa25..0adbc00a 100644 --- a/NEWS +++ b/NEWS @@ -1,12 +1,42 @@ -D-Bus 1.7.12 (UNRELEASED) +D-Bus 1.8.0 (2014-01-20) == -Enhancements: +The “Wolverine distrusts my printer” release. + +This starts a new stable branch. The 1.6.x branch is now considered to be +outdated, and will only receive fixes for serious bugs such as security +flaws. The 1.4.x and 1.2.x branches no longer have upstream support and +are unlikely to get any more releases, but if distributors still need to +support them, please share security patches via upstream. + +Summary of changes since 1.6.x: + +• libdbus always behaves as if dbus_threads_init_default() had been called + (thread-safety by default) +• new dbus-run-session tool, replacing certain misuses of dbus-launch +• dbus-monitor can talk to outdated versions of dbus-daemon again +• new org.freedesktop.DBus.GetConnectionCredentials method +• GetConnectionUnixProcessID also works correctly on Windows, returning + the Windows process ID +• GetConnectionWindowsSID returns the correct SID on Windows +• expat is required, libxml2 can no longer be used as a substitute +• the userDB cache is required, and cannot be disabled +• a 64-bit integer type (either int, long, long long or _int64) is required +• better systemd-journald integration on Linux +• fixed long-standing fd and array leaks when failing to parse a message +• fixed referenced-but-never-freed parent nodes (effectively memory leaks) + when using certain object-path allocation patterns, notably in Avahi +• better defaults for Windows support +• better CMake support +• better portability to mingw32, FreeBSD, NetBSD, QNX and Hurd +• the source language for the man pages is now Docbook XML + +Enhancements since 1.7.10: • Enhance the CMake build system to check for GLib and compile/run - a subset of the regression tests (fd.o #41252, Ralf Habacker) + a subset of the regression tests (fd.o #41252, #73495; Ralf Habacker) -Fixes: +Fixes since 1.7.10: • don't rely on va_copy(), use DBUS_VA_COPY() wrapper (fd.o #72840, Ralf Habacker) @@ -20,7 +50,7 @@ Fixes: • Allow to appear in an included configuration file (fd.o #73475, Matt Hoosier) -Test behaviour changes: +Test behaviour changes since 1.7.10: • If the tests crash with an assertion failure, they no longer default to blocking for a debugger to be attached. Set DBUS_BLOCK_ON_ABORT in the diff --git a/configure.ac b/configure.ac index 794e1569..ed77046a 100644 --- a/configure.ac +++ b/configure.ac @@ -2,8 +2,8 @@ dnl -*- mode: m4 -*- AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) -m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [11]) +m4_define([dbus_minor_version], [8]) +m4_define([dbus_micro_version], [0]) 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]) -- cgit v1.2.1