summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-03-31 14:51:51 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-03-31 14:51:51 +0000
commitf2e4718bf42f507684949ebf484aa94df42abbbe (patch)
tree7f6266a7e45144490b18eb6c71a953e8e0196eb9 /bus
parenta0f3687d650c8c73134f318820f4978a4ff3e9e2 (diff)
parent6528b0973bb09b0b407a5e169fdcc519087cc58d (diff)
downloaddbus-f2e4718bf42f507684949ebf484aa94df42abbbe.tar.gz
Merge tag 'dbus-1.8.0' into baserock/pedroalvarez/genivibaserock/v1.8.0
dbus-1.8.0
Diffstat (limited to 'bus')
-rw-r--r--bus/.gitignore6
-rw-r--r--bus/Makefile.am31
-rw-r--r--bus/activation-helper-bin.c5
-rw-r--r--bus/activation-helper.c33
-rw-r--r--bus/activation.c42
-rw-r--r--bus/bus.c16
-rw-r--r--bus/config-loader-libxml.c324
-rw-r--r--bus/config-parser-trivial.c4
-rw-r--r--bus/config-parser.c31
-rw-r--r--bus/connection.c64
-rw-r--r--bus/connection.h3
-rw-r--r--bus/dbus.service.in1
-rw-r--r--bus/desktop-file.c6
-rw-r--r--bus/desktop-file.h1
-rw-r--r--bus/dir-watch-dnotify.c93
-rw-r--r--bus/dir-watch-inotify.c20
-rw-r--r--bus/dir-watch-kqueue.c175
-rw-r--r--bus/dispatch.c15
-rw-r--r--bus/driver.c253
-rw-r--r--bus/expirelist.c4
-rw-r--r--bus/main.c49
-rw-r--r--bus/policy.c4
-rw-r--r--bus/policy.h2
-rw-r--r--bus/selinux.c61
-rw-r--r--bus/services.c2
-rw-r--r--bus/session.conf.in4
-rw-r--r--bus/signals.c38
-rw-r--r--bus/stats.c242
-rw-r--r--bus/test-launch-helper.c13
-rw-r--r--bus/test-main.c8
-rw-r--r--bus/test-system.c8
-rw-r--r--bus/test.c2
-rw-r--r--bus/test.h2
33 files changed, 618 insertions, 944 deletions
diff --git a/bus/.gitignore b/bus/.gitignore
index 861dc1f5..d856369b 100644
--- a/bus/.gitignore
+++ b/bus/.gitignore
@@ -13,14 +13,14 @@ dbus-daemon-launch-helper-test
*.bbg
*.da
*.gcov
-bus-test
+test-bus
rc.messagebus
messagebus
messagebus-config
session.conf
system.conf
-bus-test-launch-helper
-bus-test-system
+test-bus-launch-helper
+test-bus-system
dbus.service
dbus.socket
org.freedesktop.dbus-session.plist
diff --git a/bus/Makefile.am b/bus/Makefile.am
index 6cbc09a6..f335e30c 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
@@ -55,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 \
@@ -149,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,23 +164,23 @@ 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"
# run as a test by test/Makefile.am
-noinst_PROGRAMS += bus-test bus-test-system
+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
-endif DBUS_BUILD_TESTS
+endif DBUS_ENABLE_EMBEDDED_TESTS
-bus_test_system_SOURCES= \
+test_bus_system_SOURCES= \
$(XML_SOURCES) \
config-parser-common.c \
config-parser-common.h \
@@ -199,13 +190,13 @@ 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)
-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/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 ab9d6010..394f3938 100644
--- a/bus/activation-helper.c
+++ b/bus/activation-helper.c
@@ -40,6 +40,7 @@
#include <pwd.h>
#include <grp.h>
+#include <dbus/dbus-misc.h>
#include <dbus/dbus-shell.h>
#include <dbus/dbus-marshal-validate.h>
@@ -140,21 +141,12 @@ out_all:
return desktop_file;
}
-/* Cleares the environment, except for DBUS_VERBOSE and 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;
-#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");
-
#ifndef ACTIVATION_LAUNCHER_TEST
/* totally clear the environment */
if (!_dbus_clearenv ())
@@ -163,21 +155,12 @@ clear_environment (DBusError *error)
"could not clear environment\n");
return FALSE;
}
-#endif
-#ifdef DBUS_ENABLE_VERBOSE_MODE
- /* restore the debugging environment setting if set */
- if (debug_env)
- _dbus_setenv ("DBUS_VERBOSE", debug_env);
+ /* 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
- /* 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 */
- _dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system");
-
return TRUE;
}
@@ -389,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 3dfba787..fa6c1568 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,
@@ -1281,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 <user>?)");
+ break;
case BUS_SPAWN_EXIT_CODE_NO_MEMORY:
dbus_set_error (error, DBUS_ERROR_NO_MEMORY,
"Launcher could not run (out of memory)");
@@ -1317,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);
@@ -1759,7 +1772,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 +1986,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);
}
@@ -2090,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))
@@ -2170,7 +2186,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;
@@ -2223,7 +2239,7 @@ dbus_activation_systemd_failure (BusActivation *activation,
return TRUE;
}
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include <stdio.h>
@@ -2530,11 +2546,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-") ||
@@ -2570,4 +2592,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/bus.c b/bus/bus.c
index e80e7080..a514e31d 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;
@@ -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
* <listen> later in the config file have priority
*/
@@ -894,7 +906,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/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 <config.h>
-#include "config-parser.h"
-#include <dbus/dbus-internals.h>
-#include <libxml/xmlreader.h>
-#include <libxml/parser.h>
-#include <libxml/globals.h>
-#include <libxml/xmlmemory.h>
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#include <string.h>
-
-/* 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/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 <stdio.h>
#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 07e8fbb6..a6a8e1cf 100644
--- a/bus/config-parser.c
+++ b/bus/config-parser.c
@@ -30,6 +30,7 @@
#include "selinux.h"
#include <dbus/dbus-list.h>
#include <dbus/dbus-internals.h>
+#include <dbus/dbus-misc.h>
#include <dbus/dbus-sysdeps.h>
#include <string.h>
@@ -317,13 +318,23 @@ 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);
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);
@@ -413,9 +424,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
@@ -2735,7 +2746,7 @@ bus_config_parser_steal_service_context_table (BusConfigParser *parser)
return table;
}
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include <stdio.h>
typedef enum
@@ -3410,10 +3421,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))
@@ -3543,10 +3554,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))
@@ -3629,5 +3640,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/connection.c b/bus/connection.c
index d69758c9..ea2d155a 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)
{
@@ -1990,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,
@@ -2126,6 +2156,16 @@ bus_transaction_send (BusTransaction *transaction,
}
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 +2203,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 +2260,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
diff --git a/bus/connection.h b/bus/connection.h
index c9360212..9f4f9aea 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);
@@ -120,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/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
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))
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;
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 <config.h>
-
-#define _GNU_SOURCE
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-#include <dbus/dbus-internals.h>
-#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/dir-watch-inotify.c b/bus/dir-watch-inotify.c
index 2e9be988..49ebc721 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 <config.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
+/* QNX's inotify is broken, and requires stdint.h to be manually included first */
+#include <stdint.h>
#include <sys/inotify.h>
#include <sys/types.h>
#include <signal.h>
@@ -55,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;
}
diff --git a/bus/dir-watch-kqueue.c b/bus/dir-watch-kqueue.c
index ac6290cc..33d5e95d 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);
@@ -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)
{
@@ -99,38 +137,61 @@ _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);
+ _dbus_loop_ref (loop);
+
+ 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");
+ goto out1;
+ }
+
+ if (!_dbus_loop_add_watch (loop, watch))
+ {
+ _dbus_warn ("Unable to add reload watch to main loop");
+ goto out2;
+ }
+
+ if (!_dbus_register_shutdown_func (_shutdown_kqueue, NULL))
+ {
+ _dbus_warn ("Unable to register shutdown function");
+ goto out3;
+ }
+ }
+
+ return 1;
+
+out3:
+ _dbus_loop_remove_watch (loop, watch);
+
+out2:
+ if (watch)
+ {
+ _dbus_watch_invalidate (watch);
+ _dbus_watch_unref (watch);
+ watch = NULL;
}
- ret = 1;
+out1:
+ if (kq >= 0)
+ {
+ close (kq);
+ kq = -1;
+ }
+ if (loop)
+ {
+ _dbus_loop_unref (loop);
+ loop = NULL;
+ }
out:
- return ret;
+ return 0;
}
void
@@ -139,7 +200,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))
@@ -169,12 +230,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 +246,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,9 +257,9 @@ 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.
- */
- fd = open (new_dirs[i], O_RDONLY);
+ * we may need to sleep.
+ */
+ fd = open (new_dirs[i], O_RDONLY | O_CLOEXEC);
if (fd < 0)
{
if (errno != ENOENT)
@@ -223,18 +284,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;
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 7a96f9dc..7a61953f 100644
--- a/bus/dispatch.c
+++ b/bus/dispatch.c
@@ -34,6 +34,7 @@
#include "signals.h"
#include "test.h"
#include <dbus/dbus-internals.h>
+#include <dbus/dbus-misc.h>
#include <string.h>
#ifdef HAVE_UNIX_FD_PASSING
@@ -132,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);
@@ -428,7 +429,7 @@ bus_dispatch_remove_connection (DBusConnection *connection)
NULL);
}
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include <stdio.h>
@@ -1306,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
@@ -4466,7 +4473,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);
@@ -4907,4 +4914,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/driver.c b/bus/driver.c
index 574e0f3d..e95a79d9 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -32,12 +32,56 @@
#include "signals.h"
#include "stats.h"
#include "utils.h"
+
+#include <dbus/dbus-asv-util.h>
#include <dbus/dbus-string.h>
#include <dbus/dbus-internals.h>
#include <dbus/dbus-message.h>
#include <dbus/dbus-marshal-recursive.h>
#include <string.h>
+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,
@@ -841,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);
@@ -1262,40 +1300,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);
+ conn = bus_driver_get_conn_helper (connection, message, "UID", &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 UID 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)
@@ -1338,40 +1357,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);
+ conn = bus_driver_get_conn_helper (connection, message, "PID", &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 PID 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)
@@ -1414,40 +1414,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 +1470,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)
@@ -1557,6 +1519,80 @@ bus_driver_handle_get_connection_selinux_security_context (DBusConnection *conne
}
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,
DBusMessage *message,
@@ -1736,6 +1772,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 }
};
@@ -1964,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/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/main.c b/bus/main.c
index ca0be3ce..e060baa8 100644
--- a/bus/main.c
+++ b/bus/main.c
@@ -61,11 +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:
{
DBusString str;
@@ -91,11 +86,13 @@ 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;
-#endif
case SIGTERM:
{
@@ -113,7 +110,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);
}
}
@@ -125,7 +125,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]"
+ " [--nofork]"
+#ifdef DBUS_UNIX
+ " [--fork]"
+ " [--systemd-activation]"
+#endif
+ "\n");
exit (1);
}
@@ -399,19 +415,21 @@ main (int argc, char **argv)
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;
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");
@@ -622,12 +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
-#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/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/selinux.c b/bus/selinux.c
index 36287e9f..99994ca9 100644
--- a/bus/selinux.c
+++ b/bus/selinux.c
@@ -44,8 +44,6 @@
#include <syslog.h>
#include <selinux/selinux.h>
#include <selinux/avc.h>
-#include <selinux/av_permissions.h>
-#include <selinux/flask.h>
#include <signal.h>
#include <stdarg.h>
#include <stdio.h>
@@ -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)
{
@@ -936,8 +960,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 +976,18 @@ 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.
*/
+#ifdef HAVE_SELINUX
static void
bus_avc_print_stats (void)
{
+#ifdef DBUS_ENABLE_VERBOSE_MODE
struct avc_cache_stats cstats;
if (!selinux_enabled)
@@ -983,10 +1005,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 */
}
#endif /* HAVE_SELINUX */
-#endif /* DBUS_ENABLE_VERBOSE_MODE */
-
/**
* Destroy the AVC before we terminate.
@@ -1005,12 +1026,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
@@ -1051,10 +1067,17 @@ _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);
- capng_update (CAPNG_ADD, CAPNG_EFFECTIVE | 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);
if (rc)
{
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;
diff --git a/bus/session.conf.in b/bus/session.conf.in
index e121ff93..74d9d1fd 100644
--- a/bus/session.conf.in
+++ b/bus/session.conf.in
@@ -12,7 +12,7 @@
the behavior of child processes. -->
<keep_umask/>
- <listen>@DBUS_SESSION_BUS_DEFAULT_ADDRESS@</listen>
+ <listen>@DBUS_SESSION_BUS_LISTEN_ADDRESS@</listen>
<standard_session_servicedirs />
@@ -49,7 +49,7 @@
<limit name="max_outgoing_bytes">1000000000</limit>
<limit name="max_outgoing_unix_fds">250000000</limit>
<limit name="max_message_size">1000000000</limit>
- <limit name="max_message_unix_fds">4096</limit>
+ <limit name="max_message_unix_fds">@DEFAULT_MESSAGE_UNIX_FDS@</limit>
<limit name="service_start_timeout">120000</limit>
<limit name="auth_timeout">240000</limit>
<limit name="max_completed_connections">100000</limit>
diff --git a/bus/signals.c b/bus/signals.c
index 28506d3f..4c500c67 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
@@ -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;
}
@@ -1980,12 +1983,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);
@@ -2056,7 +2057,7 @@ bus_matchmaker_get_recipients (BusMatchmaker *matchmaker,
return TRUE;
}
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include "test.h"
#include <stdlib.h>
@@ -2719,6 +2720,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 +2735,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 +2747,7 @@ path_namespace_should_not_match_message_2[] = {
static const char*
path_namespace_should_match_message_3[] = {
+ "type='signal',path_namespace='/'",
NULL
};
@@ -2753,12 +2757,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 +2792,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 +2806,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);
@@ -2811,5 +2837,5 @@ bus_signals_test (const DBusString *test_data_dir)
return TRUE;
}
-#endif /* DBUS_BUILD_TESTS */
+#endif /* DBUS_ENABLE_EMBEDDED_TESTS */
diff --git a/bus/stats.c b/bus/stats.c
index 28fd49ba..2bf86d66 100644
--- a/bus/stats.c
+++ b/bus/stats.c
@@ -1,5 +1,8 @@
/* 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
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +24,7 @@
#include <config.h>
#include "stats.h"
+#include <dbus/dbus-asv-util.h>
#include <dbus/dbus-internals.h>
#include <dbus/dbus-connection-internal.h>
@@ -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,
@@ -191,49 +48,52 @@ 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 = 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))
@@ -289,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_string (&arr_iter, "UniqueName",
bus_connection_get_name (stats_connection)))
- goto oom;
+ {
+ _dbus_asv_abandon (&iter, &arr_iter);
+ goto oom;
+ }
/* DBusConnection per-connection stats */
@@ -317,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/bus/test-launch-helper.c b/bus/test-launch-helper.c
index ab36b6ec..e9ba412a 100644
--- a/bus/test-launch-helper.c
+++ b/bus/test-launch-helper.c
@@ -28,8 +28,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <dbus/dbus-internals.h>
+#include <dbus/dbus-misc.h>
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
static void
die (const char *failure)
{
@@ -56,7 +57,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 +98,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;
@@ -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);
@@ -137,7 +138,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 <dbus/dbus-message-internal.h>
#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 <dbus/dbus-sysdeps.h>
#include <dbus/dbus-internals.h>
-#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 <config.h>
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include "test.h"
#include <dbus/dbus-internals.h>
#include <dbus/dbus-list.h>
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 <dbus/dbus.h>
#include <dbus/dbus-string.h>