summaryrefslogtreecommitdiff
path: root/bus
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2013-10-09 12:22:03 +0100
committerSimon McVittie <smcv@debian.org>2013-10-09 12:22:03 +0100
commit46d1ea6379112b52d81efa0eb264321a0471c808 (patch)
tree080addcb860d6b9344f9435de45e727556bbd5aa /bus
parent20c1496fee4c06a5f268585ba67bd3a6f105fa78 (diff)
parent9e4f0bf0e114c37e30acd78ade61d2f6e92c625f (diff)
downloaddbus-46d1ea6379112b52d81efa0eb264321a0471c808.tar.gz
Imported Upstream version 1.7.6upstream/1.7.6
Diffstat (limited to 'bus')
-rw-r--r--bus/Makefile.am8
-rw-r--r--bus/Makefile.in42
-rw-r--r--bus/activation-helper-bin.c5
-rw-r--r--bus/activation-helper.c7
-rw-r--r--bus/activation.c17
-rw-r--r--bus/config-parser-trivial.c4
-rw-r--r--bus/config-parser.c13
-rw-r--r--bus/desktop-file.h1
-rw-r--r--bus/dir-watch-dnotify.c93
-rw-r--r--bus/dir-watch-inotify.c16
-rw-r--r--bus/dir-watch-kqueue.c2
-rw-r--r--bus/dispatch.c13
-rw-r--r--bus/driver.c94
-rw-r--r--bus/expirelist.c4
-rw-r--r--bus/main.c35
-rw-r--r--bus/policy.c4
-rw-r--r--bus/policy.h2
-rw-r--r--bus/selinux.c25
-rw-r--r--bus/signals.c8
-rw-r--r--bus/stats.c240
-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
25 files changed, 259 insertions, 407 deletions
diff --git a/bus/Makefile.am b/bus/Makefile.am
index 74c62e74..cd0c67da 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 \
@@ -168,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"
@@ -182,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/bus/Makefile.in b/bus/Makefile.in
index 81fb06f4..97ccfd6a 100644
--- a/bus/Makefile.in
+++ b/bus/Makefile.in
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.13.3 from Makefile.am.
+# Makefile.in generated by automake 1.14 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2013 Free Software Foundation, Inc.
@@ -85,13 +85,12 @@ dbus_daemon_exec_PROGRAMS = dbus-daemon$(EXEEXT)
@DBUS_UNIX_TRUE@libexec_PROGRAMS = dbus-daemon-launch-helper$(EXEEXT)
# run as a test by test/Makefile.am
-@DBUS_BUILD_TESTS_TRUE@am__append_1 = bus-test bus-test-system
+@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@am__append_1 = bus-test bus-test-system
# run as a test by test/Makefile.am
# this is used by the tests but is not,itself, a test
-@DBUS_BUILD_TESTS_TRUE@@DBUS_UNIX_TRUE@am__append_2 = \
-@DBUS_BUILD_TESTS_TRUE@@DBUS_UNIX_TRUE@ bus-test-launch-helper \
-@DBUS_BUILD_TESTS_TRUE@@DBUS_UNIX_TRUE@ dbus-daemon-launch-helper-test
+@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@@DBUS_UNIX_TRUE@am__append_2 = bus-test-launch-helper \
+@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@@DBUS_UNIX_TRUE@ dbus-daemon-launch-helper-test
@HAVE_SYSTEMD_TRUE@am__append_3 = \
@HAVE_SYSTEMD_TRUE@ dbus.service.in \
@HAVE_SYSTEMD_TRUE@ dbus.socket.in
@@ -123,24 +122,23 @@ am__installdirs = "$(DESTDIR)$(dbus_daemon_execdir)" \
"$(DESTDIR)$(libexecdir)" "$(DESTDIR)$(bindir)" \
"$(DESTDIR)$(initddir)" "$(DESTDIR)$(agentdir)" \
"$(DESTDIR)$(configdir)" "$(DESTDIR)$(systemdsystemunitdir)"
-@DBUS_BUILD_TESTS_TRUE@am__EXEEXT_1 = bus-test$(EXEEXT) \
-@DBUS_BUILD_TESTS_TRUE@ bus-test-system$(EXEEXT)
-@DBUS_BUILD_TESTS_TRUE@@DBUS_UNIX_TRUE@am__EXEEXT_2 = bus-test-launch-helper$(EXEEXT) \
-@DBUS_BUILD_TESTS_TRUE@@DBUS_UNIX_TRUE@ dbus-daemon-launch-helper-test$(EXEEXT)
+@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@am__EXEEXT_1 = bus-test$(EXEEXT) \
+@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ bus-test-system$(EXEEXT)
+@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@@DBUS_UNIX_TRUE@am__EXEEXT_2 = bus-test-launch-helper$(EXEEXT) \
+@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@@DBUS_UNIX_TRUE@ dbus-daemon-launch-helper-test$(EXEEXT)
PROGRAMS = $(dbus_daemon_exec_PROGRAMS) $(libexec_PROGRAMS) \
$(noinst_PROGRAMS)
am__bus_test_SOURCES_DIST = activation.c activation.h \
activation-exit-codes.h bus.c bus.h config-parser.c \
config-parser.h config-parser-common.c config-parser-common.h \
connection.c connection.h desktop-file.c desktop-file.h \
- dir-watch-default.c dir-watch-dnotify.c dir-watch-inotify.c \
- dir-watch-kqueue.c dir-watch.h dispatch.c dispatch.h driver.c \
- driver.h expirelist.c expirelist.h policy.c policy.h selinux.h \
+ dir-watch-default.c dir-watch-inotify.c dir-watch-kqueue.c \
+ dir-watch.h dispatch.c dispatch.h driver.c driver.h \
+ expirelist.c expirelist.h policy.c policy.h selinux.h \
selinux.c services.c services.h signals.c signals.h stats.c \
stats.h test.c test.h utils.c utils.h config-loader-expat.c \
test-main.c
-@DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_FALSE@@DBUS_BUS_ENABLE_INOTIFY_FALSE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@am__objects_1 = dir-watch-default.$(OBJEXT)
-@DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_TRUE@@DBUS_BUS_ENABLE_INOTIFY_FALSE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@am__objects_1 = dir-watch-dnotify.$(OBJEXT)
+@DBUS_BUS_ENABLE_INOTIFY_FALSE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@am__objects_1 = dir-watch-default.$(OBJEXT)
@DBUS_BUS_ENABLE_INOTIFY_TRUE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@am__objects_1 = dir-watch-inotify.$(OBJEXT)
@DBUS_BUS_ENABLE_KQUEUE_TRUE@am__objects_1 = \
@DBUS_BUS_ENABLE_KQUEUE_TRUE@ dir-watch-kqueue.$(OBJEXT)
@@ -189,9 +187,9 @@ am__dbus_daemon_SOURCES_DIST = activation.c activation.h \
activation-exit-codes.h bus.c bus.h config-parser.c \
config-parser.h config-parser-common.c config-parser-common.h \
connection.c connection.h desktop-file.c desktop-file.h \
- dir-watch-default.c dir-watch-dnotify.c dir-watch-inotify.c \
- dir-watch-kqueue.c dir-watch.h dispatch.c dispatch.h driver.c \
- driver.h expirelist.c expirelist.h policy.c policy.h selinux.h \
+ dir-watch-default.c dir-watch-inotify.c dir-watch-kqueue.c \
+ dir-watch.h dispatch.c dispatch.h driver.c driver.h \
+ expirelist.c expirelist.h policy.c policy.h selinux.h \
selinux.c services.c services.h signals.c signals.h stats.c \
stats.h test.c test.h utils.c utils.h config-loader-expat.c \
main.c
@@ -347,7 +345,6 @@ DBUS_DAEMONDIR = @DBUS_DAEMONDIR@
DBUS_DATADIR = @DBUS_DATADIR@
DBUS_GLIB_CFLAGS = @DBUS_GLIB_CFLAGS@
DBUS_GLIB_LIBS = @DBUS_GLIB_LIBS@
-DBUS_HAVE_INT64 = @DBUS_HAVE_INT64@
DBUS_INT16_TYPE = @DBUS_INT16_TYPE@
DBUS_INT32_TYPE = @DBUS_INT32_TYPE@
DBUS_INT64_CONSTANT = @DBUS_INT64_CONSTANT@
@@ -450,7 +447,6 @@ SHELL = @SHELL@
STRIP = @STRIP@
SYSTEMD_CFLAGS = @SYSTEMD_CFLAGS@
SYSTEMD_LIBS = @SYSTEMD_LIBS@
-TEST_BUS_BINARY = @TEST_BUS_BINARY@
TEST_LAUNCH_HELPER_BINARY = @TEST_LAUNCH_HELPER_BINARY@
TEST_LISTEN = @TEST_LISTEN@
TEST_SOCKET_DIR = @TEST_SOCKET_DIR@
@@ -566,8 +562,7 @@ config_DATA = \
@DBUS_ENABLE_LAUNCHD_TRUE@agentdir = $(LAUNCHD_AGENT_DIR)
@DBUS_ENABLE_LAUNCHD_TRUE@agent_DATA = org.freedesktop.dbus-session.plist
XML_SOURCES = config-loader-expat.c
-@DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_FALSE@@DBUS_BUS_ENABLE_INOTIFY_FALSE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@DIR_WATCH_SOURCE = dir-watch-default.c
-@DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_TRUE@@DBUS_BUS_ENABLE_INOTIFY_FALSE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@DIR_WATCH_SOURCE = dir-watch-dnotify.c
+@DBUS_BUS_ENABLE_INOTIFY_FALSE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@DIR_WATCH_SOURCE = dir-watch-default.c
@DBUS_BUS_ENABLE_INOTIFY_TRUE@@DBUS_BUS_ENABLE_KQUEUE_FALSE@DIR_WATCH_SOURCE = dir-watch-inotify.c
@DBUS_BUS_ENABLE_KQUEUE_TRUE@DIR_WATCH_SOURCE = dir-watch-kqueue.c
BUS_SOURCES = \
@@ -985,7 +980,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus_daemon_launch_helper_test-utils.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/desktop-file.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir-watch-default.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir-watch-dnotify.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir-watch-inotify.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dir-watch-kqueue.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dispatch.Po@am__quote@
@@ -1007,14 +1001,14 @@ distclean-compile:
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
.c.obj:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
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 8d7ae36f..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>
@@ -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;
@@ -371,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 fcb71337..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 <user>?)");
+ 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);
@@ -2232,7 +2237,7 @@ dbus_activation_systemd_failure (BusActivation *activation,
return TRUE;
}
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include <stdio.h>
@@ -2539,11 +2544,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-") ||
@@ -2579,4 +2590,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 <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 ff73ed03..12a2d2e7 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>
@@ -2742,7 +2743,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
@@ -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))
@@ -3636,5 +3637,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/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 d684831d..49ebc721 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;
}
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))
diff --git a/bus/dispatch.c b/bus/dispatch.c
index 7a96f9dc..5fc0d112 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
@@ -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 01e56fb9..e95a79d9 100644
--- a/bus/driver.c
+++ b/bus/driver.c
@@ -33,6 +33,7 @@
#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>
@@ -884,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);
@@ -1524,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,
@@ -1703,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 }
};
@@ -1931,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 970c1def..472458ed 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:
{
@@ -131,7 +127,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);
}
@@ -405,19 +417,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");
@@ -631,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/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..7ae84d6d 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,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 +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 */
}
#endif /* HAVE_SELINUX */
-#endif /* DBUS_ENABLE_VERBOSE_MODE */
-
/**
* Destroy the AVC before we terminate.
@@ -1005,12 +1002,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
@@ -1053,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)
{
diff --git a/bus/signals.c b/bus/signals.c
index 28506d3f..dab7154a 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
@@ -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);
@@ -2056,7 +2054,7 @@ bus_matchmaker_get_recipients (BusMatchmaker *matchmaker,
return TRUE;
}
-#ifdef DBUS_BUILD_TESTS
+#ifdef DBUS_ENABLE_EMBEDDED_TESTS
#include "test.h"
#include <stdlib.h>
@@ -2811,5 +2809,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..ec768ec7 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,
@@ -193,47 +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))
@@ -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>