diff options
author | Simon McVittie <smcv@debian.org> | 2013-10-09 12:22:03 +0100 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2013-10-09 12:22:03 +0100 |
commit | 46d1ea6379112b52d81efa0eb264321a0471c808 (patch) | |
tree | 080addcb860d6b9344f9435de45e727556bbd5aa | |
parent | 20c1496fee4c06a5f268585ba67bd3a6f105fa78 (diff) | |
parent | 9e4f0bf0e114c37e30acd78ade61d2f6e92c625f (diff) | |
download | dbus-46d1ea6379112b52d81efa0eb264321a0471c808.tar.gz |
Imported Upstream version 1.7.6upstream/1.7.6
159 files changed, 4966 insertions, 3310 deletions
diff --git a/Doxyfile.in b/Doxyfile.in index afac639b..f0a37eda 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -147,7 +147,6 @@ PREDEFINED = "DBUS_BEGIN_DECLS=" \ "DBUS_END_DECLS=" \ "DOXYGEN_SHOULD_SKIP_THIS" \ "DBUS_GNUC_DEPRECATED=" \ - "_DBUS_DEFINE_GLOBAL_LOCK(name)=" \ "_DBUS_GNUC_PRINTF(from,to)=" SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- @@ -56,7 +56,6 @@ Core library Optional: - libselinux (for SELinux integration) - - dnotify (for automatic service file reload) - doxygen (for API documentation) - xmlto or meinproc4 (for Spec & other XML documentation) diff --git a/Makefile.in b/Makefile.in index c6e9dca7..9a14867d 100644 --- a/Makefile.in +++ b/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. @@ -122,8 +122,8 @@ DIST_COMMON = $(srcdir)/tools/lcov.am INSTALL NEWS README AUTHORS \ $(top_srcdir)/test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \ $(top_srcdir)/test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \ $(top_srcdir)/test/data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \ - COPYING compile config.guess config.sub depcomp install-sh \ - missing ltmain.sh + COPYING compile config.guess config.sub install-sh missing \ + ltmain.sh subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/as-ac-expand.m4 \ @@ -314,7 +314,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@ @@ -417,7 +416,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@ @@ -561,8 +559,8 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) $(am__aclocal_m4_deps): config.h: stamp-h1 - @if test ! -f $@; then rm -f stamp-h1; else :; fi - @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi + @test -f $@ || rm -f stamp-h1 + @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1 stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 @@ -832,10 +830,16 @@ dist-xz: distdir $(am__post_remove_distdir) dist-tarZ: distdir + @echo WARNING: "Support for shar distribution archives is" \ + "deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__post_remove_distdir) dist-shar: distdir + @echo WARNING: "Support for distribution archives compressed with" \ + "legacy program 'compress' is deprecated." >&2 + @echo WARNING: "It will be removed altogether in Automake 2.0" >&2 shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__post_remove_distdir) @@ -1,6 +1,178 @@ +D-Bus 1.7.6 (2013-10-09) +== + +The “CSI Shrewsbury” release. + +Build-time configuration changes: + +• Directory change notification via dnotify on Linux is no longer + supported; it hadn't compiled successfully since 2010 in any case. + If you don't have inotify (Linux) or kqueue (*BSD), you will need + to send SIGHUP to the dbus-daemon when its configuration changes. + (fd.o #33001, Chengwei Yang) + +• Compiling with --disable-userdb-cache is no longer supported; + it didn't work since at least 2008, and would lead to an extremely + slow dbus-daemon even it worked. (fd.o #15589, #17133, #66947; + Chengwei Yang) + +• The DBUS_DISABLE_ASSERTS CMake option didn't actually disable most + assertions. It has been renamed to DBUS_DISABLE_ASSERT to be consistent + with the Autotools build system. (fd.o #66142, Chengwei Yang) + +• --with-valgrind=auto enables Valgrind instrumentation if and only if + valgrind headers are available. The default is still --with-valgrind=no. + (fd.o #56925, Simon McVittie) + +Dependencies: + +• Platforms with no 64-bit integer type are no longer supported. + (fd.o #65429, Simon McVittie) + +• GNU make is now (documented to be) required. (fd.o #48277, Simon McVittie) + +• Full test coverage no longer requires dbus-glib, although the tests do not + exercise the shared library (only a static copy) if dbus-glib is missing. + (fd.o #68852, Simon McVittie) + +Enhancements: + +• D-Bus Specification 0.22 + · Document GetAdtAuditSessionData() and + GetConnectionSELinuxSecurityContext() (fd.o #54445, Simon) + · Fix example .service file (fd.o #66481, Chengwei Yang) + · Don't claim D-Bus is "low-latency" (lower than what?), just + give factual statements about it supporting async use + (fd.o #65141, Justin Lee) + · Document the contents of .service files, and the fact that + system services' filenames are constrained + (fd.o #66608; Simon McVittie, Chengwei Yang) + +• Be thread-safe by default on all platforms, even if + dbus_threads_init_default() has not been called. For compatibility with + older libdbus, library users should continue to call + dbus_threads_init_default(): it is harmless to do so. + (fd.o #54972, Simon McVittie) + +• Add GetConnectionCredentials() method (fd.o #54445, Simon) + +• New API: dbus_setenv(), a simple wrapper around setenv(). + Note that this is not thread-safe. (fd.o #39196, Simon) + +• Add dbus-send --peer=ADDRESS (connect to a given peer-to-peer connection, + like --address=ADDRESS in previous versions) and dbus-send --bus=ADDRESS + (connect to a given bus, like dbus-monitor --address=ADDRESS). + dbus-send --address still exists for backwards compatibility, + but is no longer documented. (fd.o #48816, Andrey Mazo) + +• Windows-specific: + · "dbus-daemon --nofork" is allowed on Windows again. (fd.o #68852, + Simon McVittie) + +Fixes: + +• Avoid an infinite busy-loop if a signal interrupts waitpid() + (fd.o #68945, Simon McVittie) + +• Clean up memory for parent nodes when objects are unexported + (fd.o #60176, Thomas Fitzsimmons) + +• Make dbus_connection_set_route_peer_messages(x, FALSE) behave as + documented. Previously, it assumed its second parameter was TRUE. + (fd.o #69165, Chengwei Yang) + +• Escape addresses containing non-ASCII characters correctly + (fd.o #53499, Chengwei Yang) + +• Document <servicedir> search order correctly (fd.o #66994, Chengwei Yang) + +• Don't crash on "dbus-send --session / x.y.z" which regressed in 1.7.4. + (fd.o #65923, Chengwei Yang) + +• If malloc() returns NULL in _dbus_string_init() or similar, don't free + an invalid pointer if the string is later freed (fd.o #65959, Chengwei Yang) + +• If malloc() returns NULL in dbus_set_error(), don't va_end() a va_list + that was never va_start()ed (fd.o #66300, Chengwei Yang) + +• fix build failure with --enable-stats (fd.o #66004, Chengwei Yang) + +• fix a regression test on platforms with strict alignment (fd.o #67279, + Colin Walters) + +• Avoid calling function parameters "interface" since certain Windows headers + have a namespace-polluting macro of that name (fd.o #66493, Ivan Romanov) + +• Assorted Doxygen fixes (fd.o #65755, Chengwei Yang) + +• Various thread-safety improvements to static variables (fd.o #68610, + Simon McVittie) + +• Make "make -j check" work (fd.o #68852, Simon McVittie) + +• Fix a NULL pointer dereference on an unlikely error path + (fd.o #69327, Sviatoslav Chagaev) + +• Improve valgrind memory pool tracking (fd.o #69326, + Sviatoslav Chagaev) + +• Don't over-allocate memory in dbus-monitor (fd.o #69329, + Sviatoslav Chagaev) + +• dbus-monitor can monitor dbus-daemon < 1.5.6 again + (fd.o #66107, Chengwei Yang) + +• Unix-specific: + · If accept4() fails with EINVAL, as it can on older Linux kernels + with newer glibc, try accept() instead of going into a busy-loop. + (fd.o #69026, Chengwei Yang) + · If socket() or socketpair() fails with EINVAL or EPROTOTYPE, + for instance on Hurd or older Linux with a new glibc, try without + SOCK_CLOEXEC. (fd.o #69073; Pino Toscano, Chengwei Yang) + · Fix a file descriptor leak on an error code path. + (fd.o #69182, Sviatoslav Chagaev) + · dbus-run-session: clear some unwanted environment variables + (fd.o #39196, Simon) + · dbus-run-session: compile on FreeBSD (fd.o #66197, Chengwei Yang) + · Don't fail the autolaunch test if there is no DISPLAY (fd.o #40352, Simon) + · Use dbus-launch from the builddir for testing, not the installed copy + (fd.o #37849, Chengwei Yang) + · Fix compilation if writev() is unavailable (fd.o #69409, + Vasiliy Balyasnyy) + · Remove broken support for LOCAL_CREDS credentials passing, and + document where each credential-passing scheme is used (fd.o #60340, + Simon McVittie) + · Make autogen.sh work on *BSD by not assuming GNU coreutils functionality + (fd.o #35881, #69787; Chengwei Yang) + · dbus-monitor: be portable to NetBSD (fd.o #69842, Chengwei Yang) + · dbus-launch: stop using non-portable asprintf (fd.o #37849, Simon) + · Improve error reporting from the setuid activation helper (fd.o #66728, + Chengwei Yang) + +• Windows-specific: + · Remove unavailable command-line options from 'dbus-daemon --help' + (fd.o #42441, Ralf Habacker) + · Add support for looking up local TCPv4 clients' credentials on + Windows XP via the undocumented AllocateAndGetTcpExTableFromStack + function (fd.o #66060, Ralf Habacker) + · Fix insufficient dependency-tracking (fd.o #68505, Simon McVittie) + · Don't include wspiapi.h, fixing a compiler warning (fd.o #68852, + Simon McVittie) + +• Internal changes: + · add DBUS_ENABLE_ASSERT, DBUS_ENABLE_CHECKS for less confusing + conditionals (fd.o #66142, Chengwei Yang) + · improve verbose-mode output (fd.o #63047, Colin Walters) + · consolidate Autotools and CMake build (fd.o #64875, Ralf Habacker) + · fix various unused variables, unusual build configurations + etc. (fd.o #65712, #65990, #66005, #66257, #69165, #69410, #70218; + Chengwei Yang, Vasiliy Balyasnyy) + D-Bus 1.7.4 (2013-06-13) == +The “but is your thread-safety thread-safe?” release. + Security fixes: • CVE-2013-2168: Fix misuse of va_list that could be used as a denial @@ -27,6 +199,12 @@ Enhancements: • Improve dbus-send documentation and command-line parsing (fd.o #65424, Chengwei Yang) +Unix-specific: + · dbus-run-session: experimental new tool to start a temporary D-Bus + session, e.g. for regression tests or a text console, replacing + certain uses of dbus-launch which weren't really correct + (fd.o #39196, Simon) + Other fixes: • In dbus-daemon, don't crash if a .service file starts with key=value @@ -66,7 +66,9 @@ Configuration dbus could be build by using autotools or cmake. When using autotools the configure step is initiated by running ./configure -with or without additional configuration flags. +with or without additional configuration flags. dbus requires GNU Make +(on BSD systems, this is typically called gmake) or a "make" implementation +with compatible extensions. When using cmake the configure step is initiated by running the cmake program with or without additional configuration flags. @@ -88,13 +88,13 @@ FAQ The OpenWengo dbus-c++ binding has been ported to windows see in WinDBus svn (http://sf.net/projects/windbus) - The related test applicationa are running well. + The related test applications are running well. TODO ---- -Oktober 2010: +October 2010: - the code wrapped with DBUS_WIN_FIXME should be inspected if it required for windows @@ -1,4 +1,4 @@ -# generated automatically by aclocal 1.13.3 -*- Autoconf -*- +# generated automatically by aclocal 1.14 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. @@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.]) # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], -[am__api_version='1.13' +[am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.13.3], [], +m4_if([$1], [1.14], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,7 +51,7 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.13.3])dnl +[AM_AUTOMAKE_VERSION([1.14])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) @@ -418,6 +418,12 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- @@ -526,7 +532,48 @@ dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl -]) + +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: <http://www.gnu.org/software/coreutils/>. + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) + fi +fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further @@ -534,7 +581,6 @@ dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) - # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. @@ -682,38 +728,6 @@ AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) -# Copyright (C) 1999-2013 Free Software Foundation, Inc. -# -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# AM_PROG_CC_C_O -# -------------- -# Like AC_PROG_CC_C_O, but changed for automake. -AC_DEFUN([AM_PROG_CC_C_O], -[AC_REQUIRE([AC_PROG_CC_C_O])dnl -AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl -AC_REQUIRE_AUX_FILE([compile])dnl -# FIXME: we rely on the cache variable name because -# there is no other way. -set dummy $CC -am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` -eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o -if test "$am_t" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi -dnl Make sure AC_PROG_CC is never called again, or it will override our -dnl setting of CC. -m4_define([AC_PROG_CC], - [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) -]) - # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. @@ -790,6 +804,53 @@ AC_DEFUN([_AM_IF_OPTION], # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. +# _AM_PROG_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +AC_REQUIRE_AUX_FILE([compile])dnl +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) + +# Copyright (C) 1999-2013 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------------------------- @@ -15,8 +15,8 @@ DIE=0 if [ -f .git/hooks/pre-commit.sample -a ! -f .git/hooks/pre-commit ] ; then echo "Activating pre-commit hook." - cp -av .git/hooks/pre-commit.sample .git/hooks/pre-commit - chmod -c +x .git/hooks/pre-commit + cp .git/hooks/pre-commit.sample .git/hooks/pre-commit + chmod +x .git/hooks/pre-commit fi (autoconf --version) < /dev/null > /dev/null 2>&1 || { @@ -101,11 +101,5 @@ else fi if $run_configure; then - $srcdir/configure --enable-developer --config-cache "$@" || exit $? - echo - echo "Now type 'make' to compile $PROJECT." -else - echo - echo "Now run 'configure' and 'make' to compile $PROJECT." + $srcdir/configure --enable-developer --config-cache "$@" fi - 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 */ @@ -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"); @@ -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> @@ -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> diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index ed1df562..fe111966 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -19,6 +19,14 @@ autoversion(../configure.ac dbus) # used by file version info set (DBUS_PATCH_VERSION "0") +# set PACKAGE_... variables +autopackage( + dbus + ${DBUS_VERSION_STRING} + "http://dbus.freedesktop.org" + "https://bugs.freedesktop.org/enter_bug.cgi?product=dbus" +) + include(Macros) TIMESTAMP(DBUS_BUILD_TIMESTAMP) @@ -64,7 +72,7 @@ set(EXPANDED_SYSCONFDIR ${DBUS_INSTALL_DIR}/etc) set(EXPANDED_DATADIR ${DBUS_INSTALL_DIR}/${DBUS_DATADIR}) set(DBUS_MACHINE_UUID_FILE ${DBUS_INSTALL_DIR}/lib/dbus/machine-id) set(DBUS_BINDIR ${EXPANDED_BINDIR}) -set(DBUS_DAEMONDIR ${EXPANDED_BINDIR}) +set(DBUS_DAEMONDIR ${EXPANDED_BINDIR}) #enable building of shared library @@ -95,10 +103,7 @@ if(NOT WIN32) include (FindThreads) endif(NOT WIN32) -#AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) -option (DBUS_DISABLE_ASSERTS "Disable assertion checking" OFF) - -option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) +option (DBUS_DISABLE_ASSERT "Disable assertion checking" OFF) option (DBUS_ENABLE_STATS "enable bus daemon usage statistics" OFF) @@ -106,7 +111,7 @@ find_package(EXPAT) find_package(X11) # analogous to AC_USE_SYSTEM_EXTENSIONS in configure.ac -add_definitions(-D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE) +add_definitions(-D_GNU_SOURCE) # do config checks INCLUDE(ConfigureChecks.cmake) @@ -161,12 +166,12 @@ if(WIN32) endif(MSVC) endif(WIN32) -if (UNIX AND NOT DBUS_DISABLE_ASSERTS) +if (UNIX AND NOT DBUS_DISABLE_ASSERT) # required for backtrace SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wl,--export-dynamic") SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wl,--export-dynamic") add_definitions(-DDBUS_BUILT_R_DYNAMIC) -endif (UNIX AND NOT DBUS_DISABLE_ASSERTS) +endif (UNIX AND NOT DBUS_DISABLE_ASSERT) SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") @@ -231,11 +236,12 @@ ENABLE_TESTING() ########### command line options ############### # TODO: take check from configure.in -#AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE) option (DBUS_BUILD_TESTS "enable unit test code" ON) if(DBUS_BUILD_TESTS) - add_definitions(-DDBUS_BUILD_TESTS -DDBUS_ENABLE_EMBEDDED_TESTS) + set (DBUS_ENABLE_EMBEDDED_TESTS ON) + set (DBUS_ENABLE_MODULAR_TESTS ON) + add_definitions(-DDBUS_ENABLE_EMBEDDED_TESTS -DDBUS_ENABLE_MODULAR_TESTS) endif(DBUS_BUILD_TESTS) option (DBUS_USE_OUTPUT_DEBUG_STRING "enable win32 debug port for message output" OFF) @@ -248,7 +254,6 @@ if(WIN32) option (DBUS_SERVICE "enable dbus service installer" OFF) endif(WIN32) -#AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) option (DBUS_ENABLE_ANSI "enable -ansi -pedantic gcc flags" OFF) if(DBUS_ENABLE_ANSI) if(NOT MSVC) @@ -258,14 +263,11 @@ if(DBUS_ENABLE_ANSI) endif(NOT MSVC) endif(DBUS_ENABLE_ANSI) -#AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE) option (DBUS_ENABLE_VERBOSE_MODE "support verbose debug mode" ON) -#AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes) option (DBUS_DISABLE_CHECKS "Disable public API sanity checking" OFF) if(NOT MSVC) - #AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no) option (DBUS_GCOV_ENABLED "compile with coverage profiling instrumentation (gcc only)" OFF) if(DBUS_GCOV_ENABLED) add_definitions(-fprofile-arcs -ftest-coverage) @@ -275,21 +277,27 @@ if(NOT MSVC) endif(DBUS_GCOV_ENABLED) endif(NOT MSVC) -#AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto) -# -> moved before include(ConfigureChecks.cmake) - -#AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto) -#selinux missing - -#AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto) if("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") - option (DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX "build with dnotify support (linux only)" ON) # add a check ! + option (DBUS_BUS_ENABLE_INOTIFY "build with inotify support (linux only)" ON) + if(DBUS_BUS_ENABLE_INOTIFY) + check_include_file(sys/inotify.h HAVE_SYS_INOTIFY_H) + if(NOT HAVE_SYS_INOTIFY_H) + message(FATAL_ERROR "sys/inotify.h not found!") + endif(NOT HAVE_SYS_INOTIFY_H) + endif(DBUS_BUS_ENABLE_INOTIFY) +elseif("${CMAKE_SYSTEM_NAME}" MATCHES ".*BSD") + option (DBUS_BUS_ENABLE_KQUEUE "build with kqueue support (FreeBSD only)" ON) + if(DBUS_BUS_ENABLE_KQUEUE) + # cmake check a header by compiling a test program with + # the header, sys/event.h needs stdint.h and sys/types.h + # to work. + check_include_files("stdint.h;sys/types.h;sys/event.h" HAVE_SYS_EVENT_H) + if(NOT HAVE_SYS_EVENT_H) + message(FATAL_ERROR "sys/event.h not found!") + endif(NOT HAVE_SYS_EVENT_H) + endif(DBUS_BUS_ENABLE_KQUEUE) endif("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") -#AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support (FreeBSD only)]),enable_kqueue=$enableval,enable_kqueue=auto) -#missing - -#AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto) STRING(TOUPPER ${CMAKE_SYSTEM_NAME} sysname) if("${sysname}" MATCHES ".*SOLARIS.*") option (HAVE_CONSOLE_OWNER_FILE "enable console owner file (solaris only)" ON) @@ -298,24 +306,14 @@ if("${sysname}" MATCHES ".*SOLARIS.*") endif(HAVE_CONSOLE_OWNER_FILE) endif("${sysname}" MATCHES ".*SOLARIS.*") -#AC_ARG_WITH(xml, AS_HELP_STRING([--with-xml=[libxml/expat]],[XML library to use])) -if(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) - message(FATAL "Neither expat nor libxml2 found!") -endif(NOT LIBXML2_FOUND AND NOT EXPAT_FOUND) +if(NOT EXPAT_FOUND) + message(FATAL_ERROR "expat not found!") +endif(NOT EXPAT_FOUND) SET(XML_LIB "Expat") SET(XML_LIBRARY ${EXPAT_LIBRARIES}) SET(XML_INCLUDE_DIR ${EXPAT_INCLUDE_DIR}) -#AC_ARG_WITH(init-scripts, AS_HELP_STRING([--with-init-scripts=[redhat]],[Style of init scripts to install])) -#AC_ARG_WITH(session-socket-dir, AS_HELP_STRING([--with-session-socket-dir=[dirname]],[Where to put sockets for the per-login-session message bus])) -#AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check])) -#AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon])) -#AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon])) -#AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip])) -#AC_ARG_WITH(console-owner-file, AS_HELP_STRING([--with-console-owner-file=[filename]],[file whose owner determines current console owner])) -#AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)])) -#AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon])) # all missing or hardcoded for now # 'hidden' ones @@ -387,7 +385,7 @@ endif (MSVC_IDE) else (NOT $ENV{TMP} STREQUAL "") if (WIN32) #Should never happen, both TMP and TEMP seem always set on Windows - message(FATAL "Could not determine a usable temporary directory") + message(FATAL_ERROR "Could not determine a usable temporary directory") else(WIN32) set (DBUS_SESSION_SOCKET_DIR /tmp) endif(WIN32) @@ -395,17 +393,6 @@ endif (MSVC_IDE) endif (NOT $ENV{TEMP} STREQUAL "") endif (NOT $ENV{TMPDIR} STREQUAL "") -#AC_ARG_WITH(test-socket-dir, AS_HELP_STRING([--with-test-socket-dir=[dirname]],[Where to put sockets for make check])) - -#AC_ARG_WITH(system-pid-file, AS_HELP_STRING([--with-system-pid-file=[pidfile]],[PID file for systemwide daemon])) - -#if ! test -z "$with_system_pid_file"; then -# DBUS_SYSTEM_PID_FILE=$with_system_pid_file -#elif test x$operating_system = xredhat ; then -# DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/messagebus.pid -#else -# DBUS_SYSTEM_PID_FILE=${EXPANDED_LOCALSTATEDIR}/run/dbus/pid -#fi # TODO: fix redhet if (WIN32) # bus-test expects a non empty string @@ -414,18 +401,12 @@ else (WIN32) set (DBUS_SYSTEM_PID_FILE ${EXPANDED_LOCALSTATEDIR}/run/dbus/pid) endif (WIN32) -#AC_ARG_WITH(system-socket, AS_HELP_STRING([--with-system-socket=[filename]],[UNIX domain socket for systemwide daemon])) - -#AC_ARG_WITH(console-auth-dir, AS_HELP_STRING([--with-console-auth-dir=[dirname]],[directory to check for console ownerhip])) - if (WIN32) set (DBUS_CONSOLE_AUTH_DIR "") else (WIN32) set (DBUS_CONSOLE_AUTH_DIR "/var/run/console/") endif (WIN32) -#AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)])) - set (DBUS_USER ) # In Autotools this has a different default on QNX, but there seems little @@ -497,7 +478,9 @@ set(DBUS_INTERNAL_LIBRARIES dbus-internal) # important note: DBUS_INTERNAL_xxxxx_DEFINITIONS must *not* be set when building dbus-1 library set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC) set (DBUS_INTERNAL_LIBRARY_DEFINITIONS "-DDBUS_STATIC_BUILD") -set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD") +# For now, the CMake build system doesn't support replacing the internal +# main loop with dbus-glib +set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD -DDBUS_COMPILATION -DDBUS_TEST_USE_INTERNAL") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) @@ -536,7 +519,6 @@ message(" install exec_prefix: ${exec_prefix} " message(" install libdir: ${EXPANDED_LIBDIR} ") message(" install bindir: ${EXPANDED_BINDIR} ") message(" install sysconfdir: ${EXPANDED_SYSCONFDIR} ") -#message(" install localstatedir: ${EXPANDED_LOCALSTATEDIR} ") message(" install datadir: ${EXPANDED_DATADIR} ") message(" source code location: ${DBUS_SOURCE_DIR} ") message(" build dir: ${CMAKE_BINARY_DIR} ") @@ -555,28 +537,23 @@ message(" Doxygen: ${DOXYGEN} " message(" Docbook Generator: ${DOCBOOK_GENERATOR_NAME} ") -#message(" Maintainer mode: ${USE_MAINTAINER_MODE} ") message(" gcc coverage profiling: ${DBUS_GCOV_ENABLED} ") message(" Building unit tests: ${DBUS_BUILD_TESTS} ") message(" Building verbose mode: ${DBUS_ENABLE_VERBOSE_MODE} ") -message(" Building w/o assertions: ${DBUS_DISABLE_ASSERTS} ") +message(" Building w/o assertions: ${DBUS_DISABLE_ASSERT} ") message(" Building w/o checks: ${DBUS_DISABLE_CHECKS} ") message(" Building bus stats API: ${DBUS_ENABLE_STATS} ") message(" installing system libs: ${DBUS_INSTALL_SYSTEM_LIBS} ") -#message(" Building SELinux support: ${have_selinux} ") -#message(" Building dnotify support: ${have_dnotify} ") +message(" Building inotify support: ${DBUS_BUS_ENABLE_INOTIFY} ") +message(" Building kqueue support: ${DBUS_BUS_ENABLE_KQUEUE} ") message(" Building Doxygen docs: ${DBUS_ENABLE_DOXYGEN_DOCS} ") message(" Building XML docs: ${DBUS_ENABLE_XML_DOCS} ") -#message(" Gettext libs (empty OK): ${INTLLIBS} ") -message(" Using XML parser: ${XML_LIB} ") message(" Daemon executable name: ${DBUS_DAEMON_NAME}") if (WIN32) message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") message(" Session bus listens on: ${DBUS_SESSION_BUS_LISTEN_ADDRESS} ") message(" Session clients connect to: ${DBUS_SESSION_BUS_CONNECT_ADDRESS} ") else (WIN32) -#message(" Init scripts style: ${with_init_scripts} ") -#message(" Abstract socket names: ${have_abstract_sockets} ") message(" System bus socket: ${DBUS_SYSTEM_SOCKET} ") message(" System bus address: ${DBUS_SYSTEM_BUS_DEFAULT_ADDRESS} ") message(" System bus PID file: ${DBUS_SYSTEM_PID_FILE} ") @@ -595,9 +572,9 @@ if (DBUS_BUILD_TESTS) message("NOTE: building with unit tests increases the size of the installed library and renders it insecure.") endif(DBUS_BUILD_TESTS) -if (DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERTS) +if (DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERT) message("NOTE: building with unit tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)") -endif(DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERTS) +endif(DBUS_BUILD_TESTS AND DBUS_DISABLE_ASSERT) if (DBUS_GCOV_ENABLED) message("NOTE: building with coverage profiling is definitely for developers only.") @@ -607,9 +584,9 @@ if (DBUS_ENABLE_VERBOSE_MODE) message("NOTE: building with verbose mode increases library size, may slightly increase security risk, and decreases performance.") endif(DBUS_ENABLE_VERBOSE_MODE) -if(NOT DBUS_DISABLE_ASSERTS) +if(NOT DBUS_DISABLE_ASSERT) message("NOTE: building with assertions increases library size and decreases performance.") -endif(NOT DBUS_DISABLE_ASSERTS) +endif(NOT DBUS_DISABLE_ASSERT) if (DBUS_DISABLE_CHECKS) message("NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-BUS, but will slightly decrease D-BUS library size and _very_ slightly improve performance.") diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 33a9cee2..2794975e 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -11,7 +11,6 @@ check_include_file(sys/time.h HAVE_SYS_TIME_H)# dbus-sysdeps-win.c check_include_file(sys/wait.h HAVE_SYS_WAIT_H)# dbus-sysdeps-win.c check_include_file(time.h HAVE_TIME_H) # dbus-sysdeps-win.c check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)# dbus-sysdeps-win.c -check_include_file(wspiapi.h HAVE_WSPIAPI_H) # dbus-sysdeps-win.c check_include_file(unistd.h HAVE_UNISTD_H) # dbus-sysdeps-util-win.c check_include_file(stdio.h HAVE_STDIO_H) # dbus-sysdeps.h check_include_file(sys/syslimits.h HAVE_SYS_SYSLIMITS_H) # dbus-sysdeps-unix.c @@ -52,25 +51,23 @@ check_type_size("__int64" SIZEOF___INT64) # DBUS_INT64_TYPE if(SIZEOF_INT EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "int") set (DBUS_INT64_CONSTANT "(val)") set (DBUS_UINT64_CONSTANT "(val##U)") elseif(SIZEOF_LONG EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "long") set (DBUS_INT64_CONSTANT "(val##L)") set (DBUS_UINT64_CONSTANT "(val##UL)") elseif(SIZEOF_LONG_LONG EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "long long") set (DBUS_INT64_CONSTANT "(val##LL)") set (DBUS_UINT64_CONSTANT "(val##ULL)") elseif(SIZEOF___INT64 EQUAL 8) - set (DBUS_HAVE_INT64 1) set (DBUS_INT64_TYPE "__int64") set (DBUS_INT64_CONSTANT "(val##i64)") set (DBUS_UINT64_CONSTANT "(val##ui64)") +else(SIZEOF_INT EQUAL 8) + message (FATAL_ERROR "Could not find a 64-bit integer type") endif(SIZEOF_INT EQUAL 8) # DBUS_INT32_TYPE diff --git a/cmake/Doxyfile.cmake b/cmake/Doxyfile.cmake deleted file mode 100644 index e00984e7..00000000 --- a/cmake/Doxyfile.cmake +++ /dev/null @@ -1,182 +0,0 @@ -# Doxyfile 0.1 - -#--------------------------------------------------------------------------- -# General configuration options -#--------------------------------------------------------------------------- -PROJECT_NAME = D-Bus -PROJECT_NUMBER = @VERSION@ -OUTPUT_DIRECTORY = api -OUTPUT_LANGUAGE = English -EXTRACT_ALL = NO -EXTRACT_PRIVATE = NO -EXTRACT_STATIC = NO -HIDE_UNDOC_MEMBERS = NO -HIDE_UNDOC_CLASSES = NO -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = -INTERNAL_DOCS = NO -STRIP_CODE_COMMENTS = YES -CASE_SENSE_NAMES = YES -SHORT_NAMES = NO -HIDE_SCOPE_NAMES = NO -VERBATIM_HEADERS = YES -SHOW_INCLUDE_FILES = YES -JAVADOC_AUTOBRIEF = YES -INHERIT_DOCS = YES -INLINE_INFO = YES -SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 8 -GENERATE_TODOLIST = YES -GENERATE_TESTLIST = YES -GENERATE_BUGLIST = YES -ALIASES = -ENABLED_SECTIONS = -MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = YES -SHOW_USED_FILES = YES -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- -QUIET = YES -WARNINGS = YES -WARN_IF_UNDOCUMENTED = YES -WARN_FORMAT = -WARN_LOGFILE = -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- -INPUT = @top_srcdir@/dbus -FILE_PATTERNS = *.c *.h -RECURSIVE = YES -#EXCLUDE = test - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = Makefile.* ChangeLog CHANGES CHANGES.* README \ - README.* *.png AUTHORS DESIGN DESIGN.* *.desktop \ - DESKTOP* COMMENTS HOWTO magic NOTES TODO THANKS - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -IMAGE_PATH = -INPUT_FILTER = -FILTER_SOURCE_FILES = NO -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- -SOURCE_BROWSER = YES -INLINE_SOURCES = NO -REFERENCED_BY_RELATION = YES -REFERENCES_RELATION = YES -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- -ALPHABETICAL_INDEX = NO -COLS_IN_ALPHA_INDEX = 5 -IGNORE_PREFIX = -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- -GENERATE_HTML = YES -HTML_OUTPUT = -HTML_HEADER = -HTML_FOOTER = -HTML_STYLESHEET = -HTML_ALIGN_MEMBERS = YES -GENERATE_HTMLHELP = NO -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = NO -ENUM_VALUES_PER_LINE = 4 -GENERATE_TREEVIEW = NO -TREEVIEW_WIDTH = 250 -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- -GENERATE_LATEX = NO -LATEX_OUTPUT = -COMPACT_LATEX = NO -PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = -PDF_HYPERLINKS = NO -USE_PDFLATEX = NO -LATEX_BATCHMODE = NO -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- -GENERATE_RTF = NO -RTF_OUTPUT = -COMPACT_RTF = NO -RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- -GENERATE_MAN = YES -MAN_OUTPUT = man -MAN_EXTENSION = .3dbus -MAN_LINKS = YES -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- -GENERATE_XML = NO -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- -ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = YES -EXPAND_ONLY_PREDEF = YES -SEARCH_INCLUDES = YES -INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = "DBUS_BEGIN_DECLS=" \ - "DBUS_END_DECLS=" \ - "DOXYGEN_SHOULD_SKIP_THIS" \ - "DBUS_GNUC_DEPRECATED=" \ - "_DBUS_DEFINE_GLOBAL_LOCK(name)=" \ - "_DBUS_GNUC_PRINTF(from,to)=" \ - "DBUS_EXPORT=" -SKIP_FUNCTION_MACROS = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to external references -#--------------------------------------------------------------------------- -TAGFILES = -GENERATE_TAGFILE = -ALLEXTERNALS = NO -PERL_PATH = -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES -HAVE_DOT = NO -CLASS_GRAPH = YES -COLLABORATION_GRAPH = YES -TEMPLATE_RELATIONS = YES -HIDE_UNDOC_RELATIONS = YES -INCLUDE_GRAPH = YES -INCLUDED_BY_GRAPH = YES -GRAPHICAL_HIERARCHY = YES -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 640 -MAX_DOT_GRAPH_HEIGHT = 1024 -GENERATE_LEGEND = YES -DOT_CLEANUP = YES -#--------------------------------------------------------------------------- -# Configuration::addtions related to the search engine -#--------------------------------------------------------------------------- -SEARCHENGINE = NO diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index f2ea55eb..9943584a 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -31,9 +31,13 @@ ENDFOREACH(FILE) SET (XML_SOURCES ${BUS_DIR}/config-loader-expat.c) -# after next cvs update -#set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-default.c) -set (DIR_WATCH_SOURCE ) +if (DBUS_BUS_ENABLE_INOTIFY) + set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-inotify.c) +elseif (DBUS_BUS_ENABLE_KQUEUE) + set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-kqueue.c) +else (DBUS_BUS_ENABLE_INOTIFY) + set (DIR_WATCH_SOURCE ${BUS_DIR}/dir-watch-default.c) +endif (DBUS_BUS_ENABLE_INOTIFY) set (BUS_SOURCES ${BUS_DIR}/activation.c @@ -42,14 +46,13 @@ set (BUS_SOURCES ${BUS_DIR}/bus.h ${BUS_DIR}/config-parser.c ${BUS_DIR}/config-parser.h - ${BUS_DIR}/config-parser-common.c - ${BUS_DIR}/config-parser-common.h + ${BUS_DIR}/config-parser-common.c + ${BUS_DIR}/config-parser-common.h # ${BUS_DIR}/config-parser-trivial.c ${BUS_DIR}/connection.c ${BUS_DIR}/connection.h ${BUS_DIR}/desktop-file.c ${BUS_DIR}/desktop-file.h - ${BUS_DIR}/dir-watch-default.c ${BUS_DIR}/dir-watch.h ${BUS_DIR}/dispatch.c ${BUS_DIR}/dispatch.h @@ -77,7 +80,7 @@ if(DBUS_ENABLE_STATS) ${BUS_DIR}/stats.c ${BUS_DIR}/stats.h ) -endif() +endif(DBUS_ENABLE_STATS) include_directories(${XML_INCLUDE_DIR}) @@ -104,12 +107,12 @@ if (DBUS_SERVICE) install_targets(/bin dbus-service ) endif (DBUS_SERVICE) -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) add_executable(bus-test ${BUS_SOURCES} ${BUS_DIR}/test-main.c) target_link_libraries(bus-test ${DBUS_INTERNAL_LIBRARIES} ${XML_LIBRARY}) set_target_properties(bus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) add_test(bus-test ${EXECUTABLE_OUTPUT_PATH}/bus-test ${CMAKE_BINARY_DIR}/test/data) -endif (DBUS_BUILD_TESTS) +endif (DBUS_ENABLE_EMBEDDED_TESTS) if(MSVC) project_source_group(${GROUP_CODE} bus_test_SOURCES dummy) diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index 91cf0806..37355609 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -6,6 +6,12 @@ /* indicate that we are building with cmake */ #define DBUS_CMAKE 1 +@AUTOPACKAGE_CONFIG_H_TEMPLATE@ + +/* + * Variables defined by AC_DEFINE in ../configure.ac + * should be placed in this file +*/ #cmakedefine HAVE_GNUC_VARARGS 1 #cmakedefine DBUS_CONSOLE_AUTH_DIR "@DBUS_CONSOLE_AUTH_DIR@" @@ -18,16 +24,8 @@ #cmakedefine DBUS_SESSION_BUS_CONNECT_ADDRESS "@DBUS_SESSION_BUS_CONNECT_ADDRESS@" #cmakedefine DBUS_MACHINE_UUID_FILE "@DBUS_MACHINE_UUID_FILE@" #cmakedefine DBUS_DAEMONDIR "@DBUS_DAEMONDIR@" -#cmakedefine PACKAGE "@PACKAGE@" -/* Version number of package */ -#cmakedefine DBUS_MAJOR_VERSION @DBUS_MAJOR_VERSION@ -#cmakedefine DBUS_MINOR_VERSION @DBUS_MINOR_VERSION@ -#cmakedefine DBUS_MICRO_VERSION @DBUS_MICRO_VERSION@ -#cmakedefine DBUS_VERSION ((@DBUS_MAJOR_VERSION@ << 16) | (@DBUS_MINOR_VERSION@ << 8) | (@DBUS_MICRO_VERSION@)) -#cmakedefine DBUS_VERSION_STRING "@DBUS_VERSION_STRING@" -#cmakedefine DBUS_ENABLE_STATS -#define VERSION DBUS_VERSION_STRING +#cmakedefine DBUS_ENABLE_STATS #define TEST_LISTEN "@TEST_LISTEN@" @@ -35,15 +33,17 @@ #define DBUS_TEST_EXEC "@DBUS_TEST_EXEC@" #define DBUS_EXEEXT "@EXEEXT@" -/* Full path to test file test/test-exit in builddir */ -#define TEST_BUS_BINARY "@TEST_BUS_BINARY@" - /* Some dbus features */ -#cmakedefine DBUS_BUILD_TESTS 1 #cmakedefine DBUS_ENABLE_ANSI 1 #cmakedefine DBUS_ENABLE_VERBOSE_MODE 1 -#cmakedefine DBUS_DISABLE_ASSERTS 1 +#cmakedefine DBUS_DISABLE_ASSERT 1 +#ifndef DBUS_DISABLE_ASSERT +# define DBUS_ENABLE_ASSERT 1 +#endif #cmakedefine DBUS_DISABLE_CHECKS 1 +#ifndef DBUS_DISABLE_CHECKS +# define DBUS_ENABLE_CHECKS 1 +#endif /* xmldocs */ /* doxygen */ #cmakedefine DBUS_GCOV_ENABLED 1 @@ -63,7 +63,6 @@ #endif /* selinux */ -#cmakedefine DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 1 /* kqueue */ #cmakedefine HAVE_CONSOLE_OWNER_FILE 1 #define DBUS_CONSOLE_OWNER_FILE "@DBUS_CONSOLE_OWNER_FILE@" @@ -122,9 +121,6 @@ /* Define to 1 if you have ws2tcpip.h */ #cmakedefine HAVE_WS2TCPIP_H -/* Define to 1 if you have wspiapi.h */ -#cmakedefine HAVE_WSPIAPI_H 1 - /* Define to 1 if you have unistd.h */ #cmakedefine HAVE_UNISTD_H 1 diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 6b2d0635..0205f852 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -149,6 +149,7 @@ set (DBUS_SHARED_HEADERS ### should be underscore-prefixed but don't really need ### to be unless they move to DBUS_SHARED_SOURCES later) set (DBUS_UTIL_SOURCES + ${DBUS_DIR}/dbus-asv-util.c ${DBUS_DIR}/dbus-auth-script.c ${DBUS_DIR}/dbus-auth-util.c ${DBUS_DIR}/dbus-credentials-util.c @@ -165,14 +166,15 @@ set (DBUS_UTIL_SOURCES ${DBUS_DIR}/dbus-sysdeps-util.c ) -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) set (DBUS_UTIL_SOURCES ${DBUS_UTIL_SOURCES} ${DBUS_DIR}/dbus-test.c ) -endif (DBUS_BUILD_TESTS) +endif (DBUS_ENABLE_EMBEDDED_TESTS) set (DBUS_UTIL_HEADERS + ${DBUS_DIR}/dbus-asv-util.h ${DBUS_DIR}/dbus-auth-script.h ${DBUS_DIR}/dbus-mainloop.h ${DBUS_DIR}/dbus-message-factory.h @@ -296,13 +298,13 @@ else(WIN32) target_link_libraries(dbus-internal ${CMAKE_THREAD_LIBS_INIT} rt) endif(WIN32) -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) set (TESTS_ENVIRONMENT "DBUS_TEST_DATA=${CMAKE_SOURCE_DIR}/test/data DBUS_TEST_HOMEDIR=${CMAKE_BUILD_DIR}/dbus") ADD_EXECUTABLE(dbus-test ${CMAKE_SOURCE_DIR}/../dbus/dbus-test-main.c) target_link_libraries(dbus-test ${DBUS_INTERNAL_LIBRARIES}) add_test(dbus-test ${EXECUTABLE_OUTPUT_PATH}/dbus-test ${CMAKE_SOURCE_DIR}/../test/data) set_target_properties(dbus-test PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) -ENDIF (DBUS_BUILD_TESTS) +ENDIF (DBUS_ENABLE_EMBEDDED_TESTS) if (UNIX) # set version info diff --git a/cmake/doc/CMakeLists.txt b/cmake/doc/CMakeLists.txt index dee9431b..7fdfc219 100644 --- a/cmake/doc/CMakeLists.txt +++ b/cmake/doc/CMakeLists.txt @@ -6,9 +6,10 @@ endif(DOXYGEN_EXECUTABLE) if (DBUS_ENABLE_DOXYGEN_DOCS) set (top_srcdir ${CMAKE_SOURCE_DIR}/..) - configure_file(${CMAKE_SOURCE_DIR}/Doxyfile.cmake ${CMAKE_BINARY_DIR}/Doxyfile ) + configure_file(${CMAKE_SOURCE_DIR}/../Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile ) add_custom_target(doc COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) endif (DBUS_ENABLE_DOXYGEN_DOCS) @@ -21,6 +22,7 @@ find_program(XMLTO_EXECUTABLE xmlto) if (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) OPTION(DBUS_ENABLE_XML_DOCS "build XML documentation (requires xmlto or meinproc4)" ON) + ADD_CUSTOM_TARGET(xmldoc ALL) endif (MEINPROC4_EXECUTABLE OR XMLTO_EXECUTABLE) if (XMLTO_EXECUTABLE) @@ -48,6 +50,7 @@ if (DBUS_ENABLE_XML_DOCS) macro (DOCBOOK _sources _format) get_filename_component(_infile ${_sources} ABSOLUTE) get_filename_component(_name ${_infile} NAME) + set(_deps ${CMAKE_SOURCE_DIR}/CMakeLists.txt ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt) if (${_format} STREQUAL "man") string(REPLACE ".xml" "" _outname ${_name}) @@ -60,16 +63,18 @@ macro (DOCBOOK _sources _format) set(_outfile ${CMAKE_CURRENT_BINARY_DIR}/${_outname}) if (EXISTS ${_sources}) if (MEINPROC4_EXECUTABLE) - ADD_CUSTOM_TARGET(${_outname} ALL - ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} - DEPENDS ${_infile} + ADD_CUSTOM_COMMAND( + OUTPUT ${_outfile} + COMMAND ${MEINPROC4_EXECUTABLE} --stylesheet ${STYLESHEET} -o ${_outfile} ${_infile} + DEPENDS ${_infile} ${STYLESHEET} ${_deps} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif () if (XMLTO_EXECUTABLE) - ADD_CUSTOM_TARGET(${_outname} ALL - ${XMLTO_EXECUTABLE} -vv ${_format} ${_infile} - DEPENDS ${_infile} + ADD_CUSTOM_COMMAND( + OUTPUT ${_outfile} + COMMAND ${XMLTO_EXECUTABLE} -vv ${_format} ${_infile} + DEPENDS ${_infile} ${_deps} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) endif () @@ -81,7 +86,8 @@ macro (DOCBOOK _sources _format) else () MESSAGE(STATUS "skipping xml doc generating for ${_infile}, file not found") endif () - + ADD_CUSTOM_TARGET(${_outname} DEPENDS ${_outfile}) + ADD_DEPENDENCIES(xmldoc ${_outname}) endmacro (DOCBOOK) ### copy tests to builddir so that generated tests and static tests @@ -125,11 +131,11 @@ DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml html-nochunks) DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml html-nochunks) if (UNIX) DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-daemon.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-monitor.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-send.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-launch.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-uuidgen.1.xml man) - DOCBOOK(${CMAKE_SOURCE_DIR}/../doc/dbus-cleanup-sockets.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-monitor.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-send.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-launch.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-uuidgen.1.xml man) + DOCBOOK(${CMAKE_BINARY_DIR}/doc/dbus-cleanup-sockets.1.xml man) endif() # # handle html index file diff --git a/cmake/modules/MacrosAutotools.cmake b/cmake/modules/MacrosAutotools.cmake index ff30eaf9..68e8ae51 100644 --- a/cmake/modules/MacrosAutotools.cmake +++ b/cmake/modules/MacrosAutotools.cmake @@ -23,6 +23,66 @@ macro(autoversion config prefix) endmacro() # +# Defines package related variables (PACKAGE_..., PACKAGE and VERSION) +# as done by autotools. +# +# Additional it defines a cmake variable named PACKAGE_CONFIG_H_TEMPLATE +# which could be placed in config.h templates to have those variables +# defined at code level like shown below: +# +# config.h.template +# ... +# @AUTOPACKAGE_CONFIG_H_TEMPLATE@ +# ... +# +macro(autopackage name version url support_url) + # Define to the full name of this package. + set(PACKAGE_NAME ${name}) + + # Define to the version of this package. + set(PACKAGE_VERSION ${version}) + + # Define to the home page for this package. + set(PACKAGE_URL ${url}) + + # Define to the address where bug reports for this package should be sent. + set(PACKAGE_BUGREPORT ${support_url}) + + # Define to the full name and version of this package. + set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") + + # Define to the one symbol short name of this package. + set(PACKAGE_TARNAME ${PACKAGE_NAME}) + + set(PACKAGE ${name}) + set(VERSION ${DBUS_VERSION_STRING}) + + set(AUTOPACKAGE_CONFIG_H_TEMPLATE "/* generated by cmake macro autopackage */\n +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT \"@PACKAGE_BUGREPORT@\" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME \"@PACKAGE_NAME@\" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING \"@PACKAGE_STRING@\" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME \"@PACKAGE_TARNAME@\" + +/* Define to the home page for this package. */ +#define PACKAGE_URL \"@PACKAGE_URL@\" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION \"@PACKAGE_VERSION@\" + +/* defined by autotools package */ +#define PACKAGE \"@PACKAGE@\" +#define VERSION \"@VERSION@\" +") +endmacro(autopackage) + +# # parses config.h template and create cmake equivalent # not implemented yet # diff --git a/cmake/test/name-test/CMakeLists.txt b/cmake/test/name-test/CMakeLists.txt index 80b9908b..bf096ba7 100644 --- a/cmake/test/name-test/CMakeLists.txt +++ b/cmake/test/name-test/CMakeLists.txt @@ -1,8 +1,8 @@ -if (DBUS_BUILD_TESTS) +if (DBUS_ENABLE_EMBEDDED_TESTS) set (NAMEtest-DIR ../../../test/name-test) -add_definitions(-DDBUS_COMPILATION) +add_definitions(${DBUS_INTERNAL_CLIENT_DEFINITIONS}) add_executable(test-pending-call-dispatch ${NAMEtest-DIR}/test-pending-call-dispatch.c) target_link_libraries(test-pending-call-dispatch ${DBUS_INTERNAL_LIBRARIES}) @@ -36,4 +36,4 @@ add_executable(test-autolaunch ${NAMEtest-DIR}/test-autolaunch.c) target_link_libraries(test-autolaunch dbus-testutils) ADD_TEST(test-autolaunch ${EXECUTABLE_OUTPUT_PATH}/test-autolaunch) -endif (DBUS_BUILD_TESTS) +endif (DBUS_ENABLE_EMBEDDED_TESTS) diff --git a/config.guess b/config.guess index 120cc0d2..b79252d6 100755 --- a/config.guess +++ b/config.guess @@ -2,7 +2,7 @@ # Attempt to guess a canonical system name. # Copyright 1992-2013 Free Software Foundation, Inc. -timestamp='2013-05-16' +timestamp='2013-06-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -995,6 +995,12 @@ EOF ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; diff --git a/config.h.in b/config.h.in index 6ca0e9ac..c127fd20 100644 --- a/config.h.in +++ b/config.h.in @@ -9,18 +9,12 @@ /* Directory for installing the binaries */ #undef DBUS_BINDIR -/* Define to build test code into the library and binaries */ -#undef DBUS_BUILD_TESTS - /* Define to build X11 functionality */ #undef DBUS_BUILD_X11 /* whether -export-dynamic was passed to libtool */ #undef DBUS_BUILT_R_DYNAMIC -/* Use dnotify on Linux */ -#undef DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX - /* Use inotify */ #undef DBUS_BUS_ENABLE_INOTIFY @@ -66,9 +60,6 @@ /* Define to enable bus daemon usage statistics */ #undef DBUS_ENABLE_STATS -/* Build with caching of user data */ -#undef DBUS_ENABLE_USERDB_CACHE - /* Support a verbose mode */ #undef DBUS_ENABLE_VERBOSE_MODE @@ -362,16 +353,10 @@ /* Define to 1 if you have the <ws2tcpip.h> header file. */ #undef HAVE_WS2TCPIP_H -/* Define to 1 if you have the <wspiapi.h> header file. */ -#undef HAVE_WSPIAPI_H - /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR -/* Define to 1 if your C compiler doesn't accept -c and -o together. */ -#undef NO_MINUS_C_MINUS_O - /* Name of package */ #undef PACKAGE @@ -417,8 +402,8 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* Full path to the daemon in the builddir */ -#undef TEST_BUS_BINARY +/* Full path to the dbus-launch in the builddir */ +#undef TEST_BUS_LAUNCH_BINARY /* Listening address for regression tests */ #undef TEST_LISTEN @@ -499,3 +484,12 @@ #ifndef __cplusplus #undef inline #endif + + +/* explicitly define these macros to get less confusing conditions */ +#ifndef DBUS_DISABLE_ASSERT +# define DBUS_ENABLE_ASSERT 1 +#endif +#ifndef DBUS_DISABLE_CHECKS +# define DBUS_ENABLE_CHECKS 1 +#endif @@ -2,7 +2,7 @@ # Configuration validation subroutine script. # Copyright 1992-2013 Free Software Foundation, Inc. -timestamp='2013-04-24' +timestamp='2013-08-10' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -257,7 +257,7 @@ case $basic_machine in | avr | avr32 \ | be32 | be64 \ | bfin \ - | c4x | clipper \ + | c4x | c8051 | clipper \ | d10v | d30v | dlx | dsp16xx \ | epiphany \ | fido | fr30 | frv \ @@ -372,7 +372,7 @@ case $basic_machine in | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ - | clipper-* | craynv-* | cydra-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ @@ -794,7 +794,7 @@ case $basic_machine in os=-mingw64 ;; mingw32) - basic_machine=i386-pc + basic_machine=i686-pc os=-mingw32 ;; mingw32ce) @@ -830,7 +830,7 @@ case $basic_machine in basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) - basic_machine=i386-pc + basic_machine=i686-pc os=-msys ;; mvs) @@ -1546,6 +1546,9 @@ case $basic_machine in c4x-* | tic4x-*) os=-coff ;; + c8051-*) + os=-elf + ;; hexagon-*) os=-elf ;; @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for dbus 1.7.4. +# Generated by GNU Autoconf 2.69 for dbus 1.7.6. # # Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=dbus>. # @@ -591,8 +591,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='dbus' PACKAGE_TARNAME='dbus' -PACKAGE_VERSION='1.7.4' -PACKAGE_STRING='dbus 1.7.4' +PACKAGE_VERSION='1.7.6' +PACKAGE_STRING='dbus 1.7.6' PACKAGE_BUGREPORT='https://bugs.freedesktop.org/enter_bug.cgi?product=dbus' PACKAGE_URL='' @@ -642,7 +642,6 @@ DBUS_SESSION_SOCKET_DIR TEST_LISTEN TEST_SOCKET_DIR TEST_LAUNCH_HELPER_BINARY -TEST_BUS_BINARY DBUS_TEST_EXEC DBUS_TEST_DATA DBUS_LIBEXECDIR @@ -711,8 +710,6 @@ DBUS_BUS_ENABLE_KQUEUE_FALSE DBUS_BUS_ENABLE_KQUEUE_TRUE HAVE_LINUX_EPOLL_FALSE HAVE_LINUX_EPOLL_TRUE -DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_FALSE -DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_TRUE DBUS_BUS_ENABLE_INOTIFY_FALSE DBUS_BUS_ENABLE_INOTIFY_TRUE HAVE_SELINUX_FALSE @@ -723,7 +720,6 @@ XML_CFLAGS DBUS_PATH_OR_ABSTRACT DBUS_INT16_TYPE DBUS_INT32_TYPE -DBUS_HAVE_INT64 DBUS_UINT64_CONSTANT DBUS_INT64_CONSTANT DBUS_INT64_TYPE @@ -743,14 +739,14 @@ DBUS_WITH_GLIB_FALSE DBUS_WITH_GLIB_TRUE DBUS_ENABLE_MODULAR_TESTS_FALSE DBUS_ENABLE_MODULAR_TESTS_TRUE +DBUS_WITH_DBUS_GLIB_FALSE +DBUS_WITH_DBUS_GLIB_TRUE DBUS_GLIB_LIBS DBUS_GLIB_CFLAGS GLIB_LIBS GLIB_CFLAGS DBUS_ENABLE_EMBEDDED_TESTS_FALSE DBUS_ENABLE_EMBEDDED_TESTS_TRUE -DBUS_BUILD_TESTS_FALSE -DBUS_BUILD_TESTS_TRUE DBUS_STATIC_BUILD_CPPFLAGS DBUS_CYGWIN_FALSE DBUS_CYGWIN_TRUE @@ -920,11 +916,9 @@ enable_doxygen_docs enable_abstract_sockets enable_selinux enable_libaudit -enable_dnotify enable_inotify enable_kqueue enable_console_owner_file -enable_userdb_cache enable_launchd enable_systemd with_init_scripts @@ -940,8 +934,8 @@ with_dbus_daemondir enable_embedded_tests enable_modular_tests enable_tests +with_dbus_glib enable_installed_tests -with_64_bit enable_epoll with_valgrind enable_x11_autolaunch @@ -1518,7 +1512,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures dbus 1.7.4 to adapt to many kinds of systems. +\`configure' configures dbus 1.7.6 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1592,7 +1586,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of dbus 1.7.4:";; + short | recursive ) echo "Configuration of dbus 1.7.6:";; esac cat <<\_ACEOF @@ -1630,12 +1624,10 @@ Optional Features: use abstract socket namespace (linux only) --enable-selinux build with SELinux support --enable-libaudit build audit daemon support for SELinux - --enable-dnotify build with dnotify support (linux only) --enable-inotify build with inotify support (linux only) --enable-kqueue build with kqueue support --enable-console-owner-file enable console owner file - --enable-userdb-cache build with userdb-cache support --enable-launchd build with launchd auto-launch support --enable-systemd build with systemd at_console support --enable-embedded-tests enable unit test code in the library and binaries @@ -1679,8 +1671,7 @@ Optional Packages: --with-dbus-user=<user> User for running the DBUS daemon (messagebus) --with-dbus-daemondir=dirname Directory for installing the DBUS daemon - --without-64-bit If you have to use this option, please report it as - a bug + --with-dbus-glib Use dbus-glib for regression tests --with-valgrind Add instrumentation to help valgrind to understand our allocator --with-x use the X Window System @@ -1792,7 +1783,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -dbus configure 1.7.4 +dbus configure 1.7.6 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2511,7 +2502,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by dbus $as_me 1.7.4, which was +It was created by dbus $as_me 1.7.6, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2965,7 +2956,7 @@ ac_config_headers="$ac_config_headers config.h" -am__api_version='1.13' +am__api_version='1.14' # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or @@ -3451,7 +3442,7 @@ fi # Define the identity of the package. PACKAGE='dbus' - VERSION='1.7.4' + VERSION='1.7.6' cat >>confdefs.h <<_ACEOF @@ -3618,6 +3609,47 @@ $as_echo "$am_cv_prog_tar_ustar" >&6; } +# POSIX will say in a future version that running "rm -f" with no argument +# is OK; and we want to be able to make that assumption in our Makefile +# recipes. So use an aggressive probe to check that the usage we want is +# actually supported "in the wild" to an acceptable degree. +# See automake bug#10828. +# To make any issue more visible, cause the running configure to be aborted +# by default if the 'rm' program in use doesn't match our expectations; the +# user can still override this though. +if rm -f && rm -fr && rm -rf; then : OK; else + cat >&2 <<'END' +Oops! + +Your 'rm' program seems unable to run without file operands specified +on the command line, even when the '-f' option is present. This is contrary +to the behaviour of most rm programs out there, and not conforming with +the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542> + +Please tell bug-automake@gnu.org about your system, including the value +of your $PATH and any error possibly output before this message. This +can help us improve future automake versions. + +END + if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then + echo 'Configuration will proceed anyway, since you have set the' >&2 + echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 + echo >&2 + else + cat >&2 <<'END' +Aborting the configuration process, to ensure you take notice of the issue. + +You can download and install GNU coreutils to get an 'rm' implementation +that behaves properly: <http://www.gnu.org/software/coreutils/>. + +If you want to complete the configuration process using your problematic +'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM +to "yes", and re-run configure. + +END + as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5 + fi +fi GETTEXT_PACKAGE=dbus-1 @@ -3722,8 +3754,8 @@ LT_AGE=8 DBUS_MAJOR_VERSION=1 DBUS_MINOR_VERSION=7 -DBUS_MICRO_VERSION=4 -DBUS_VERSION=1.7.4 +DBUS_MICRO_VERSION=6 +DBUS_VERSION=1.7.6 @@ -4518,6 +4550,65 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5 +$as_echo_n "checking whether $CC understands -c and -o together... " >&6; } +if ${am_cv_prog_cc_c_o+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5 + ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5 +$as_echo "$am_cv_prog_cc_c_o" >&6; } +if test "$am_cv_prog_cc_c_o" != yes; then + # Losing compiler, so override with the script. + # FIXME: It is wrong to rewrite CC. + # But if we don't then we get into trouble of one sort or another. + # A longer-term fix would be to have automake use am__CC in this case, + # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" + CC="$am_aux_dir/compile $CC" +fi +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" @@ -4710,131 +4801,6 @@ else fi -if test "x$CC" != xcc; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 -$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 -$as_echo_n "checking whether cc understands -c and -o together... " >&6; } -fi -set dummy $CC; ac_cc=`$as_echo "$2" | - sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` -if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -# Make sure it works both with $CC and with simple cc. -# We do the test twice because some compilers refuse to overwrite an -# existing .o file with -o, though they will create one. -ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' -rm -f conftest2.* -if { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && - test -f conftest2.$ac_objext && { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; -then - eval ac_cv_prog_cc_${ac_cc}_c_o=yes - if test "x$CC" != xcc; then - # Test first that cc exists at all. - if { ac_try='cc -c conftest.$ac_ext >&5' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' - rm -f conftest2.* - if { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && - test -f conftest2.$ac_objext && { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; - then - # cc works too. - : - else - # cc exists but doesn't like -o. - eval ac_cv_prog_cc_${ac_cc}_c_o=no - fi - fi - fi -else - eval ac_cv_prog_cc_${ac_cc}_c_o=no -fi -rm -f core conftest* - -fi -if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - -$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h - -fi - -# FIXME: we rely on the cache variable name because -# there is no other way. -set dummy $CC -am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` -eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o -if test "$am_t" != yes; then - # Losing compiler, so override with the script. - # FIXME: It is wrong to rewrite CC. - # But if we don't then we get into trouble of one sort or another. - # A longer-term fix would be to have automake use am__CC in this case, - # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" - CC="$am_aux_dir/compile $CC" -fi - ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' @@ -16788,13 +16754,6 @@ else enable_libaudit=auto fi -# Check whether --enable-dnotify was given. -if test "${enable_dnotify+set}" = set; then : - enableval=$enable_dnotify; enable_dnotify=$enableval -else - enable_dnotify=auto -fi - # Check whether --enable-inotify was given. if test "${enable_inotify+set}" = set; then : enableval=$enable_inotify; enable_inotify=$enableval @@ -16816,13 +16775,6 @@ else enable_console_owner_file=auto fi -# Check whether --enable-userdb-cache was given. -if test "${enable_userdb_cache+set}" = set; then : - enableval=$enable_userdb_cache; enable_userdb_cache=$enableval -else - enable_userdb_cache=yes -fi - # Check whether --enable-launchd was given. if test "${enable_launchd+set}" = set; then : enableval=$enable_launchd; enable_launchd=$enableval @@ -16931,16 +16883,7 @@ fi # DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files -# and also some stuff in the test/ subdir. DBUS_BUILD_TESTS was an older -# name for this. - if test "x$enable_embedded_tests" = xyes; then - DBUS_BUILD_TESTS_TRUE= - DBUS_BUILD_TESTS_FALSE='#' -else - DBUS_BUILD_TESTS_TRUE='#' - DBUS_BUILD_TESTS_FALSE= -fi - +# and also some stuff in the test/ subdir. if test "x$enable_embedded_tests" = xyes; then DBUS_ENABLE_EMBEDDED_TESTS_TRUE= DBUS_ENABLE_EMBEDDED_TESTS_FALSE='#' @@ -16953,9 +16896,6 @@ if test "x$enable_embedded_tests" = xyes; then $as_echo "#define DBUS_ENABLE_EMBEDDED_TESTS 1" >>confdefs.h - -$as_echo "#define DBUS_BUILD_TESTS 1" >>confdefs.h - fi # DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API. @@ -16972,7 +16912,8 @@ $as_echo "#define GLIB_VERSION_MAX_ALLOWED GLIB_VERSION_2_32" >>confdefs.h with_glib=yes -if test "x$enable_modular_tests" != xno; then +if test "x$enable_modular_tests" != xno; then : + pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GLIB" >&5 @@ -17052,7 +16993,22 @@ else $as_echo "yes" >&6; } : fi - # If dbus-gmain.[ch] returned to libdbus then we wouldn't need this + +else + with_glib=no +fi + +# Not required, because we can use internal APIs (but that makes the +# "installable tests" less useful as integration tests) + +# Check whether --with-dbus_glib was given. +if test "${with_dbus_glib+set}" = set; then : + withval=$with_dbus_glib; +else + with_dbus_glib=auto +fi + +if test "x$with_dbus_glib" != xno; then : pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBUS_GLIB" >&5 @@ -17110,21 +17066,17 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } - if test "x$enable_modular_tests" = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires dbus-glib" >&5 -$as_echo "$as_me: Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires dbus-glib" >&6;} - as_fn_error $? "$DBUS_GLIB_ERRORS" "$LINENO" 5 - else # assumed to be "auto" - with_glib=no - fi + if test "x$with_dbus_glib" = xyes; then : + as_fn_error $? "$DBUS_GLIB_ERRORS" "$LINENO" 5 +else + with_dbus_glib=no +fi elif test $pkg_failed = untried; then - if test "x$enable_modular_tests" = xyes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires dbus-glib" >&5 -$as_echo "$as_me: Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires dbus-glib" >&6;} - as_fn_error $? "$DBUS_GLIB_ERRORS" "$LINENO" 5 - else # assumed to be "auto" - with_glib=no - fi + if test "x$with_dbus_glib" = xyes; then : + as_fn_error $? "$DBUS_GLIB_ERRORS" "$LINENO" 5 +else + with_dbus_glib=no +fi else DBUS_GLIB_CFLAGS=$pkg_cv_DBUS_GLIB_CFLAGS DBUS_GLIB_LIBS=$pkg_cv_DBUS_GLIB_LIBS @@ -17133,6 +17085,15 @@ $as_echo "yes" >&6; } : fi fi + if test "x$with_dbus_glib" != xno; then + DBUS_WITH_DBUS_GLIB_TRUE= + DBUS_WITH_DBUS_GLIB_FALSE='#' +else + DBUS_WITH_DBUS_GLIB_TRUE='#' + DBUS_WITH_DBUS_GLIB_FALSE= +fi + + if test "x$enable_modular_tests" != xno; then $as_echo "#define DBUS_ENABLE_MODULAR_TESTS 1" >>confdefs.h @@ -17729,6 +17690,11 @@ $as_echo "#define DBUS_DISABLE_ASSERT 1" >>confdefs.h DISABLE_UNUSED_WARNINGS="unused-label" R_DYNAMIC_LDFLAG="" + if test x$enable_embedded_tests = xyes; then + DISABLE_UNUSED_WARNINGS="$DISABLE_UNUSED_WARNINGS \ + unused-but-set-variable unused-variable \ + unused-function" + fi else # -rdynamic is needed for glibc's backtrace_symbols to work. # No clue how much overhead this adds, but it's useful @@ -17754,11 +17720,7 @@ $as_echo "#define G_DISABLE_CHECKS 1" >>confdefs.h DISABLE_UNUSED_WARNINGS="unused-label" fi -if test x$enable_userdb_cache = xyes; then -$as_echo "#define DBUS_ENABLE_USERDB_CACHE 1" >>confdefs.h - -fi if test x$enable_compiler_coverage = xyes; then ## so that config.h changes when you toggle gcov support @@ -18038,15 +18000,6 @@ _ACEOF - -# Check whether --with-64-bit was given. -if test "${with_64_bit+set}" = set; then : - withval=$with_64_bit; -else - with_64_bit=yes -fi - - ### See what our 64 bit type is called { $as_echo "$as_me:${as_lineno-$LINENO}: checking 64-bit integer type" >&5 $as_echo_n "checking 64-bit integer type... " >&6; } @@ -18085,34 +18038,18 @@ $ac_cv_sizeof___int64) ;; esac -if test "x$with_64_bit" = xno; then : - - DBUS_INT64_TYPE="no_int64_type_detected" - DBUS_HAVE_INT64=0 - DBUS_INT64_CONSTANT= - DBUS_UINT64_CONSTANT= - { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled via --without-64-bit" >&5 -$as_echo "disabled via --without-64-bit" >&6; } - -elif test -z "$dbusint64"; then : +if test -z "$dbusint64"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } as_fn_error $? "Could not find a 64-bit integer type. Please report a bug here with details of your platform and compiler: - http://bugs.freedesktop.org/enter_bug.cgi?product=DBus&component=core - -To compile D-Bus with all 64-bit integer types removed (not recommended), use -the option \"--without-64-bit\". - -This option is likely to be removed in future, unless you report that your -platform needs it." "$LINENO" 5 + http://bugs.freedesktop.org/enter_bug.cgi?product=DBus&component=core" "$LINENO" 5 else DBUS_INT64_TYPE="$dbusint64" - DBUS_HAVE_INT64=1 DBUS_INT64_CONSTANT="$dbusint64_constant" DBUS_UINT64_CONSTANT="$dbusuint64_constant" if test x"$dbusint64_printf_modifier" != x; then @@ -18131,7 +18068,6 @@ fi - ### see what 32-bit int is called { $as_echo "$as_me:${as_lineno-$LINENO}: checking 32-bit integer type" >&5 $as_echo_n "checking 32-bit integer type... " >&6; } @@ -19006,19 +18942,6 @@ fi done -for ac_header in wspiapi.h -do : - ac_fn_c_check_header_mongrel "$LINENO" "wspiapi.h" "ac_cv_header_wspiapi_h" "$ac_includes_default" -if test "x$ac_cv_header_wspiapi_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_WSPIAPI_H 1 -_ACEOF - -fi - -done - - for ac_header in alloca.h do : ac_fn_c_check_header_mongrel "$LINENO" "alloca.h" "ac_cv_header_alloca_h" "$ac_includes_default" @@ -20208,32 +20131,6 @@ else fi -# dnotify checks -if test x$enable_dnotify = xno ; then - have_dnotify=no; -else - if test x$have_inotify = xno -a x$host_os = xlinux-gnu -o x$host_os = xlinux; then - have_dnotify=yes; - else - have_dnotify=no; - fi -fi - -if test x$have_dnotify = xyes; then - -$as_echo "#define DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX 1" >>confdefs.h - -fi - - if test x$have_dnotify = xyes; then - DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_TRUE= - DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_FALSE='#' -else - DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_TRUE='#' - DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_FALSE= -fi - - # For simplicity, we require the userland API for epoll_create1 at # compile-time (glibc 2.9), but we'll run on kernels that turn out # not to have it at runtime. @@ -20726,6 +20623,19 @@ else fi +if test "x$with_valgrind" = xauto; then : + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"valgrind >= 3.6\""; } >&5 + ($PKG_CONFIG --exists --print-errors "valgrind >= 3.6") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + with_valgrind=yes +else + with_valgrind=no +fi +fi + if test x$with_valgrind != xno; then pkg_failed=no @@ -22660,11 +22570,10 @@ _ACEOF cat >>confdefs.h <<_ACEOF -#define TEST_BUS_BINARY "$DBUS_PWD/bus/dbus-daemon$EXEEXT" +#define TEST_BUS_LAUNCH_BINARY "$DBUS_PWD/tools/dbus-launch$EXEEXT" _ACEOF - ## Export the non-setuid external helper TEST_LAUNCH_HELPER_BINARY="$DBUS_PWD/bus/dbus-daemon-launch-helper-test$EXEEXT" @@ -22984,14 +22893,14 @@ if test -z "${DBUS_CYGWIN_TRUE}" && test -z "${DBUS_CYGWIN_FALSE}"; then as_fn_error $? "conditional \"DBUS_CYGWIN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${DBUS_BUILD_TESTS_TRUE}" && test -z "${DBUS_BUILD_TESTS_FALSE}"; then - as_fn_error $? "conditional \"DBUS_BUILD_TESTS\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${DBUS_ENABLE_EMBEDDED_TESTS_TRUE}" && test -z "${DBUS_ENABLE_EMBEDDED_TESTS_FALSE}"; then as_fn_error $? "conditional \"DBUS_ENABLE_EMBEDDED_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${DBUS_WITH_DBUS_GLIB_TRUE}" && test -z "${DBUS_WITH_DBUS_GLIB_FALSE}"; then + as_fn_error $? "conditional \"DBUS_WITH_DBUS_GLIB\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi if test -z "${DBUS_ENABLE_MODULAR_TESTS_TRUE}" && test -z "${DBUS_ENABLE_MODULAR_TESTS_FALSE}"; then as_fn_error $? "conditional \"DBUS_ENABLE_MODULAR_TESTS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -23013,10 +22922,6 @@ if test -z "${DBUS_BUS_ENABLE_INOTIFY_TRUE}" && test -z "${DBUS_BUS_ENABLE_INOTI as_fn_error $? "conditional \"DBUS_BUS_ENABLE_INOTIFY\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_TRUE}" && test -z "${DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX_FALSE}"; then - as_fn_error $? "conditional \"DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${HAVE_LINUX_EPOLL_TRUE}" && test -z "${HAVE_LINUX_EPOLL_FALSE}"; then as_fn_error $? "conditional \"HAVE_LINUX_EPOLL\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 @@ -23466,7 +23371,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by dbus $as_me 1.7.4, which was +This file was extended by dbus $as_me 1.7.6, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -23532,7 +23437,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -dbus config.status 1.7.4 +dbus config.status 1.7.6 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -25875,19 +25780,18 @@ echo " Building embedded tests: ${enable_embedded_tests} Building modular tests: ${enable_modular_tests} - with GLib: ${with_glib} + - with dbus-glib: ${with_dbus_glib} Building verbose mode: ${enable_verbose_mode} Building assertions: ${enable_asserts} Building checks: ${enable_checks} Building bus stats API: ${enable_stats} Building SELinux support: ${have_selinux} Building inotify support: ${have_inotify} - Building dnotify support: ${have_dnotify} Building kqueue support: ${have_kqueue} Building systemd support: ${have_systemd} Building X11 code: ${have_x11} Building Doxygen docs: ${enable_doxygen_docs} Building XML docs: ${enable_xml_docs} - Building cache support: ${enable_userdb_cache} Building launchd support: ${have_launchd} Init scripts style: ${with_init_scripts} Abstract socket names: ${ac_cv_have_abstract_sockets} @@ -25926,26 +25830,3 @@ fi if test x$enable_checks = xno; then echo "NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance." fi - -if test "x$DBUS_HAVE_INT64" = x0; then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You have disabled 64-bit integers via --without-64-bit. - - This removes parts of the standard D-Bus API and ABI (the 't' and 'x' - typecodes, the dbus_int64_t and dbus_uint64_t types, etc.) and should only be - used if your compiler lacks support for 64-bit integers. Please report a bug - with details of your platform and compiler. - - This option is likely to be removed in future, unless the D-Bus developers - receive reports that it is still needed. - " >&5 -$as_echo "$as_me: WARNING: You have disabled 64-bit integers via --without-64-bit. - - This removes parts of the standard D-Bus API and ABI (the 't' and 'x' - typecodes, the dbus_int64_t and dbus_uint64_t types, etc.) and should only be - used if your compiler lacks support for 64-bit integers. Please report a bug - with details of your platform and compiler. - - This option is likely to be removed in future, unless the D-Bus developers - receive reports that it is still needed. - " >&2;} -fi diff --git a/configure.ac b/configure.ac index 8edbf18d..9a51c575 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_PREREQ([2.63]) m4_define([dbus_major_version], [1]) m4_define([dbus_minor_version], [7]) -m4_define([dbus_micro_version], [4]) +m4_define([dbus_micro_version], [6]) m4_define([dbus_version], [dbus_major_version.dbus_minor_version.dbus_micro_version]) AC_INIT([dbus],[dbus_version],[https://bugs.freedesktop.org/enter_bug.cgi?product=dbus],[dbus]) @@ -150,11 +150,9 @@ AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs],[build DOXYGE AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto) AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto) AC_ARG_ENABLE(libaudit,AS_HELP_STRING([--enable-libaudit],[build audit daemon support for SELinux]),enable_libaudit=$enableval,enable_libaudit=auto) -AC_ARG_ENABLE(dnotify, AS_HELP_STRING([--enable-dnotify],[build with dnotify support (linux only)]),enable_dnotify=$enableval,enable_dnotify=auto) AC_ARG_ENABLE(inotify, AS_HELP_STRING([--enable-inotify],[build with inotify support (linux only)]),enable_inotify=$enableval,enable_inotify=auto) AC_ARG_ENABLE(kqueue, AS_HELP_STRING([--enable-kqueue],[build with kqueue support]),enable_kqueue=$enableval,enable_kqueue=auto) AC_ARG_ENABLE(console-owner-file, AS_HELP_STRING([--enable-console-owner-file],[enable console owner file]),enable_console_owner_file=$enableval,enable_console_owner_file=auto) -AC_ARG_ENABLE(userdb-cache, AS_HELP_STRING([--enable-userdb-cache],[build with userdb-cache support]),enable_userdb_cache=$enableval,enable_userdb_cache=yes) AC_ARG_ENABLE(launchd, AS_HELP_STRING([--enable-launchd],[build with launchd auto-launch support]),enable_launchd=$enableval,enable_launchd=auto) AC_ARG_ENABLE(systemd, AS_HELP_STRING([--enable-systemd],[build with systemd at_console support]),enable_systemd=$enableval,enable_systemd=auto) @@ -193,16 +191,12 @@ AC_ARG_ENABLE([tests], []) # DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files -# and also some stuff in the test/ subdir. DBUS_BUILD_TESTS was an older -# name for this. -AM_CONDITIONAL([DBUS_BUILD_TESTS], [test "x$enable_embedded_tests" = xyes]) +# and also some stuff in the test/ subdir. AM_CONDITIONAL([DBUS_ENABLE_EMBEDDED_TESTS], [test "x$enable_embedded_tests" = xyes]) if test "x$enable_embedded_tests" = xyes; then AC_DEFINE([DBUS_ENABLE_EMBEDDED_TESTS], [1], [Define to build test code into the library and binaries]) - AC_DEFINE([DBUS_BUILD_TESTS], [1], - [Define to build test code into the library and binaries]) fi # DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API. @@ -215,7 +209,8 @@ AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_32], [Prevent post-2.32 AP with_glib=yes -if test "x$enable_modular_tests" != xno; then +AS_IF([test "x$enable_modular_tests" != xno], + [ PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.24, gio-2.0 >= 2.24], [], [if test "x$enable_modular_tests" = xyes; then @@ -224,16 +219,25 @@ if test "x$enable_modular_tests" != xno; then else # assumed to be "auto" with_glib=no fi]) - # If dbus-gmain.[ch] returned to libdbus then we wouldn't need this - PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1], + ], + [with_glib=no]) + +# Not required, because we can use internal APIs (but that makes the +# "installable tests" less useful as integration tests) +AC_ARG_WITH([dbus_glib], + [AS_HELP_STRING([--with-dbus-glib], [Use dbus-glib for regression tests])], + [], + [with_dbus_glib=auto]) +AS_IF([test "x$with_dbus_glib" != xno], + [PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1], [], - [if test "x$enable_modular_tests" = xyes; then - AC_MSG_NOTICE([Full test coverage (--enable-modular-tests=yes or --enable-tests=yes) requires dbus-glib]) - AC_MSG_ERROR([$DBUS_GLIB_ERRORS]) - else # assumed to be "auto" - with_glib=no - fi]) -fi + [AS_IF([test "x$with_dbus_glib" = xyes], + dnl specifically requested, but not found + [AC_MSG_ERROR([$DBUS_GLIB_ERRORS])], + dnl else: assumed to be "auto" + [with_dbus_glib=no])])]) +AM_CONDITIONAL([DBUS_WITH_DBUS_GLIB], [test "x$with_dbus_glib" != xno]) + if test "x$enable_modular_tests" != xno; then AC_DEFINE([DBUS_ENABLE_MODULAR_TESTS], [1], [Define to build independent test binaries]) @@ -278,6 +282,11 @@ if test x$enable_asserts = xno; then AC_DEFINE(DBUS_DISABLE_ASSERT,1,[Disable assertion checking]) DISABLE_UNUSED_WARNINGS="unused-label" R_DYNAMIC_LDFLAG="" + if test x$enable_embedded_tests = xyes; then + DISABLE_UNUSED_WARNINGS="$DISABLE_UNUSED_WARNINGS \ + unused-but-set-variable unused-variable \ + unused-function" + fi else # -rdynamic is needed for glibc's backtrace_symbols to work. # No clue how much overhead this adds, but it's useful @@ -297,9 +306,14 @@ if test x$enable_checks = xno; then DISABLE_UNUSED_WARNINGS="unused-label" fi -if test x$enable_userdb_cache = xyes; then - AC_DEFINE(DBUS_ENABLE_USERDB_CACHE,1,[Build with caching of user data]) -fi +AH_BOTTOM([ +/* explicitly define these macros to get less confusing conditions */ +#ifndef DBUS_DISABLE_ASSERT +# define DBUS_ENABLE_ASSERT 1 +#endif +#ifndef DBUS_DISABLE_CHECKS +# define DBUS_ENABLE_CHECKS 1 +#endif]) if test x$enable_compiler_coverage = xyes; then ## so that config.h changes when you toggle gcov support @@ -341,12 +355,6 @@ AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long long) AC_CHECK_SIZEOF(__int64) -AC_ARG_WITH([64-bit], - [AS_HELP_STRING([--without-64-bit], - [If you have to use this option, please report it as a bug])], - [], - [with_64_bit=yes]) - ### See what our 64 bit type is called AC_MSG_CHECKING([64-bit integer type]) @@ -385,33 +393,17 @@ $ac_cv_sizeof___int64) esac AS_IF( - [test "x$with_64_bit" = xno], - [ - DBUS_INT64_TYPE="no_int64_type_detected" - DBUS_HAVE_INT64=0 - DBUS_INT64_CONSTANT= - DBUS_UINT64_CONSTANT= - AC_MSG_RESULT([disabled via --without-64-bit]) - ], - dnl else if [test -z "$dbusint64"], [AC_MSG_RESULT([not found]) AC_MSG_ERROR([Could not find a 64-bit integer type. Please report a bug here with details of your platform and compiler: - http://bugs.freedesktop.org/enter_bug.cgi?product=DBus&component=core - -To compile D-Bus with all 64-bit integer types removed (not recommended), use -the option "--without-64-bit". - -This option is likely to be removed in future, unless you report that your -platform needs it.]) + http://bugs.freedesktop.org/enter_bug.cgi?product=DBus&component=core]) ], dnl else [ DBUS_INT64_TYPE="$dbusint64" - DBUS_HAVE_INT64=1 DBUS_INT64_CONSTANT="$dbusint64_constant" DBUS_UINT64_CONSTANT="$dbusuint64_constant" if test x"$dbusint64_printf_modifier" != x; then @@ -423,7 +415,6 @@ platform needs it.]) AC_SUBST(DBUS_INT64_TYPE) AC_SUBST(DBUS_INT64_CONSTANT) AC_SUBST(DBUS_UINT64_CONSTANT) -AC_SUBST(DBUS_HAVE_INT64) ### see what 32-bit int is called AC_MSG_CHECKING([32-bit integer type]) @@ -685,8 +676,6 @@ AC_CHECK_HEADERS(unistd.h) AC_CHECK_HEADERS(ws2tcpip.h) -AC_CHECK_HEADERS(wspiapi.h) - AC_CHECK_HEADERS(alloca.h) # Add -D_POSIX_PTHREAD_SEMANTICS if on Solaris @@ -1051,24 +1040,6 @@ fi AM_CONDITIONAL(DBUS_BUS_ENABLE_INOTIFY, test x$have_inotify = xyes) -# dnotify checks -if test x$enable_dnotify = xno ; then - have_dnotify=no; -else - if test x$have_inotify = xno -a x$host_os = xlinux-gnu -o x$host_os = xlinux; then - have_dnotify=yes; - else - have_dnotify=no; - fi -fi - -dnl check if dnotify backend is enabled -if test x$have_dnotify = xyes; then - AC_DEFINE(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX,1,[Use dnotify on Linux]) -fi - -AM_CONDITIONAL(DBUS_BUS_ENABLE_DNOTIFY_ON_LINUX, test x$have_dnotify = xyes) - # For simplicity, we require the userland API for epoll_create1 at # compile-time (glibc 2.9), but we'll run on kernels that turn out # not to have it at runtime. @@ -1254,6 +1225,10 @@ AC_ARG_WITH([valgrind], [], [with_valgrind=no]) +AS_IF([test "x$with_valgrind" = xauto], + [PKG_CHECK_EXISTS([valgrind >= 3.6], + [with_valgrind=yes], [with_valgrind=no])]) + if test x$with_valgrind != xno; then PKG_CHECK_MODULES([VALGRIND], [valgrind >= 3.6]) AC_DEFINE([WITH_VALGRIND], [1], [Define to add Valgrind instrumentation]) @@ -1642,9 +1617,8 @@ AC_DEFINE_UNQUOTED([DBUS_TEST_EXEC], ["$DBUS_TEST_EXEC"], AC_DEFINE_UNQUOTED([DBUS_EXEEXT], ["$EXEEXT"], [Extension for executables, typically empty or .exe]) -AC_DEFINE_UNQUOTED(TEST_BUS_BINARY, ["$DBUS_PWD/bus/dbus-daemon$EXEEXT"], - [Full path to the daemon in the builddir]) -AC_SUBST(TEST_BUS_BINARY) +AC_DEFINE_UNQUOTED(TEST_BUS_LAUNCH_BINARY, ["$DBUS_PWD/tools/dbus-launch$EXEEXT"], + [Full path to the dbus-launch in the builddir]) ## Export the non-setuid external helper TEST_LAUNCH_HELPER_BINARY="$DBUS_PWD/bus/dbus-daemon-launch-helper-test$EXEEXT" @@ -1848,19 +1822,18 @@ echo " Building embedded tests: ${enable_embedded_tests} Building modular tests: ${enable_modular_tests} - with GLib: ${with_glib} + - with dbus-glib: ${with_dbus_glib} Building verbose mode: ${enable_verbose_mode} Building assertions: ${enable_asserts} Building checks: ${enable_checks} Building bus stats API: ${enable_stats} Building SELinux support: ${have_selinux} Building inotify support: ${have_inotify} - Building dnotify support: ${have_dnotify} Building kqueue support: ${have_kqueue} Building systemd support: ${have_systemd} Building X11 code: ${have_x11} Building Doxygen docs: ${enable_doxygen_docs} Building XML docs: ${enable_xml_docs} - Building cache support: ${enable_userdb_cache} Building launchd support: ${have_launchd} Init scripts style: ${with_init_scripts} Abstract socket names: ${ac_cv_have_abstract_sockets} @@ -1899,16 +1872,3 @@ fi if test x$enable_checks = xno; then echo "NOTE: building without checks for arguments passed to public API makes it harder to debug apps using D-Bus, but will slightly decrease D-Bus library size and _very_ slightly improve performance." fi - -if test "x$DBUS_HAVE_INT64" = x0; then - AC_MSG_WARN([You have disabled 64-bit integers via --without-64-bit. - - This removes parts of the standard D-Bus API and ABI (the 't' and 'x' - typecodes, the dbus_int64_t and dbus_uint64_t types, etc.) and should only be - used if your compiler lacks support for 64-bit integers. Please report a bug - with details of your platform and compiler. - - This option is likely to be removed in future, unless the D-Bus developers - receive reports that it is still needed. - ]) -fi diff --git a/dbus/Makefile.am b/dbus/Makefile.am index 90c2c901..0f9033d1 100644 --- a/dbus/Makefile.am +++ b/dbus/Makefile.am @@ -39,7 +39,7 @@ dbus_res_ldflag = -Wl,$(dbus_res) no_undefined = -no-undefined export_symbols = -libdbus_1_la_DEPENDENCIES = $(dbus_res) +EXTRA_libdbus_1_la_DEPENDENCIES = $(dbus_res) intllibs = else @@ -237,6 +237,8 @@ DBUS_SHARED_SOURCES= \ ### should be underscore-prefixed but don't really need ### to be unless they move to DBUS_SHARED_SOURCES later) DBUS_UTIL_SOURCES= \ + dbus-asv-util.c \ + dbus-asv-util.h \ dbus-auth-script.c \ dbus-auth-script.h \ dbus-auth-util.c \ @@ -308,7 +310,7 @@ endif noinst_PROGRAMS = -if DBUS_BUILD_TESTS +if DBUS_ENABLE_EMBEDDED_TESTS # We can't actually run this til we've reached test/ noinst_PROGRAMS += dbus-test endif diff --git a/dbus/Makefile.in b/dbus/Makefile.in index 2158e4d7..08425d2a 100644 --- a/dbus/Makefile.in +++ b/dbus/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. @@ -80,8 +80,6 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@DBUS_WIN_FALSE@libdbus_1_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \ -@DBUS_WIN_FALSE@ $(am__append_3) @HAVE_LINUX_EPOLL_TRUE@am__append_1 = dbus-socket-set-epoll.c # This must be a separate convenience library, otherwise libtool notices @@ -94,7 +92,7 @@ host_triplet = @host@ noinst_PROGRAMS = $(am__EXEEXT_1) # We can't actually run this til we've reached test/ -@DBUS_BUILD_TESTS_TRUE@am__append_5 = dbus-test +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@am__append_5 = dbus-test subdir = dbus DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(srcdir)/versioninfo.rc.in $(srcdir)/dbus-arch-deps.h.in \ @@ -144,6 +142,7 @@ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(dbusincludedir)" \ "$(DESTDIR)$(dbusarchincludedir)" LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) am__DEPENDENCIES_1 = +libdbus_1_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__append_3) am__libdbus_1_la_SOURCES_DIST = dbus-address.c dbus-auth.c dbus-auth.h \ dbus-bus.c dbus-connection.c dbus-connection-internal.h \ dbus-credentials.c dbus-credentials.h dbus-errors.c \ @@ -277,14 +276,14 @@ am__libdbus_internal_la_SOURCES_DIST = dbus-address.c dbus-auth.c \ dbus-sysdeps-win.c dbus-sysdeps-win.h \ dbus-sysdeps-thread-win.c dbus-transport-win.c \ dbus-transport-win.h dbus-sysdeps.c dbus-sysdeps.h \ - dbus-valgrind-internal.h dbus-auth-script.c dbus-auth-script.h \ - dbus-auth-util.c dbus-credentials-util.c dbus-mainloop.c \ - dbus-mainloop.h dbus-marshal-byteswap-util.c \ - dbus-marshal-recursive-util.c dbus-marshal-validate-util.c \ - dbus-message-factory.c dbus-message-factory.h \ - dbus-message-util.c dbus-shell.c dbus-shell.h \ - dbus-sysdeps-util-unix.c dbus-userdb-util.c dbus-spawn.c \ - dbus-socket-set-epoll.c dbus-sysdeps-util-win.c \ + dbus-valgrind-internal.h dbus-asv-util.c dbus-asv-util.h \ + dbus-auth-script.c dbus-auth-script.h dbus-auth-util.c \ + dbus-credentials-util.c dbus-mainloop.c dbus-mainloop.h \ + dbus-marshal-byteswap-util.c dbus-marshal-recursive-util.c \ + dbus-marshal-validate-util.c dbus-message-factory.c \ + dbus-message-factory.h dbus-message-util.c dbus-shell.c \ + dbus-shell.h dbus-sysdeps-util-unix.c dbus-userdb-util.c \ + dbus-spawn.c dbus-socket-set-epoll.c dbus-sysdeps-util-win.c \ dbus-spawn-win.c dbus-socket-set.h dbus-socket-set.c \ dbus-socket-set-poll.c dbus-spawn.h dbus-string-util.c \ dbus-sysdeps-util.c dbus-test.c dbus-test.h @@ -356,7 +355,8 @@ am__objects_12 = libdbus_internal_la-dbus-dataslot.lo \ @DBUS_WIN_TRUE@ libdbus_internal_la-dbus-sysdeps-util-win.lo \ @DBUS_WIN_TRUE@ libdbus_internal_la-dbus-spawn-win.lo \ @DBUS_WIN_TRUE@ $(am__objects_13) -am__objects_15 = libdbus_internal_la-dbus-auth-script.lo \ +am__objects_15 = libdbus_internal_la-dbus-asv-util.lo \ + libdbus_internal_la-dbus-auth-script.lo \ libdbus_internal_la-dbus-auth-util.lo \ libdbus_internal_la-dbus-credentials-util.lo \ libdbus_internal_la-dbus-mainloop.lo \ @@ -374,7 +374,7 @@ am__objects_15 = libdbus_internal_la-dbus-auth-script.lo \ am_libdbus_internal_la_OBJECTS = $(am__objects_8) $(am__objects_12) \ $(am__objects_15) libdbus_internal_la_OBJECTS = $(am_libdbus_internal_la_OBJECTS) -@DBUS_BUILD_TESTS_TRUE@am__EXEEXT_1 = dbus-test$(EXEEXT) +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@am__EXEEXT_1 = dbus-test$(EXEEXT) PROGRAMS = $(noinst_PROGRAMS) am_dbus_test_OBJECTS = dbus-test-main.$(OBJEXT) dbus_test_OBJECTS = $(am_dbus_test_OBJECTS) @@ -490,7 +490,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@ @@ -593,7 +592,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@ @@ -698,7 +696,7 @@ lib_LTLIBRARIES = libdbus-1.la @DBUS_WIN_TRUE@no_undefined = -no-undefined @DBUS_WIN_FALSE@export_symbols = -export-symbols-regex "^[^_].*" @DBUS_WIN_TRUE@export_symbols = -@DBUS_WIN_TRUE@libdbus_1_la_DEPENDENCIES = $(dbus_res) +@DBUS_WIN_TRUE@EXTRA_libdbus_1_la_DEPENDENCIES = $(dbus_res) @DBUS_WIN_FALSE@intllibs = @LTLIBINTL@ @DBUS_WIN_TRUE@intllibs = @DBUS_WIN_FALSE@DBUS_LIB_arch_sources = \ @@ -867,6 +865,8 @@ DBUS_SHARED_SOURCES = \ ### should be underscore-prefixed but don't really need ### to be unless they move to DBUS_SHARED_SOURCES later) DBUS_UTIL_SOURCES = \ + dbus-asv-util.c \ + dbus-asv-util.h \ dbus-auth-script.c \ dbus-auth-script.h \ dbus-auth-util.c \ @@ -1101,6 +1101,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-dbus-watch.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_1_la-sd-daemon.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-address.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-asv-util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-auth-script.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-auth-util.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_internal_la-dbus-auth.Plo@am__quote@ @@ -1183,14 +1184,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 $@ $< @@ -1983,6 +1984,13 @@ libdbus_internal_la-dbus-sysdeps.lo: dbus-sysdeps.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_internal_la-dbus-sysdeps.lo `test -f 'dbus-sysdeps.c' || echo '$(srcdir)/'`dbus-sysdeps.c +libdbus_internal_la-dbus-asv-util.lo: dbus-asv-util.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_internal_la-dbus-asv-util.lo -MD -MP -MF $(DEPDIR)/libdbus_internal_la-dbus-asv-util.Tpo -c -o libdbus_internal_la-dbus-asv-util.lo `test -f 'dbus-asv-util.c' || echo '$(srcdir)/'`dbus-asv-util.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_internal_la-dbus-asv-util.Tpo $(DEPDIR)/libdbus_internal_la-dbus-asv-util.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus-asv-util.c' object='libdbus_internal_la-dbus-asv-util.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_internal_la-dbus-asv-util.lo `test -f 'dbus-asv-util.c' || echo '$(srcdir)/'`dbus-asv-util.c + libdbus_internal_la-dbus-auth-script.lo: dbus-auth-script.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_internal_la-dbus-auth-script.lo -MD -MP -MF $(DEPDIR)/libdbus_internal_la-dbus-auth-script.Tpo -c -o libdbus_internal_la-dbus-auth-script.lo `test -f 'dbus-auth-script.c' || echo '$(srcdir)/'`dbus-auth-script.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_internal_la-dbus-auth-script.Tpo $(DEPDIR)/libdbus_internal_la-dbus-auth-script.Plo diff --git a/dbus/dbus-address.c b/dbus/dbus-address.c index 90484dc1..c4cfbbe5 100644 --- a/dbus/dbus-address.c +++ b/dbus/dbus-address.c @@ -104,15 +104,15 @@ dbus_bool_t _dbus_address_append_escaped (DBusString *escaped, const DBusString *unescaped) { - const char *p; - const char *end; + const unsigned char *p; + const unsigned char *end; dbus_bool_t ret; int orig_len; ret = FALSE; orig_len = _dbus_string_get_length (escaped); - p = _dbus_string_get_const_data (unescaped); + p = (const unsigned char *) _dbus_string_get_const_data (unescaped); end = p + _dbus_string_get_length (unescaped); while (p != end) { @@ -648,7 +648,7 @@ dbus_address_unescape_value (const char *value, /** @} */ /* End of public API */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -678,7 +678,9 @@ static const EscapeTest escape_tests[] = { { "Z", "Z" }, { "a", "a" }, { "i", "i" }, - { "z", "z" } + { "z", "z" }, + /* Bug: https://bugs.freedesktop.org/show_bug.cgi?id=53499 */ + { "%c3%b6", "\xc3\xb6" } }; static const char* invalid_escaped_values[] = { diff --git a/dbus/dbus-arch-deps.h.in b/dbus/dbus-arch-deps.h.in index 45952cfb..dfc3589e 100644 --- a/dbus/dbus-arch-deps.h.in +++ b/dbus/dbus-arch-deps.h.in @@ -31,7 +31,7 @@ DBUS_BEGIN_DECLS -#if @DBUS_HAVE_INT64@ +/* D-Bus no longer supports platforms with no 64-bit integer type. */ #define DBUS_HAVE_INT64 1 _DBUS_GNUC_EXTENSION typedef @DBUS_INT64_TYPE@ dbus_int64_t; _DBUS_GNUC_EXTENSION typedef unsigned @DBUS_INT64_TYPE@ dbus_uint64_t; @@ -39,12 +39,6 @@ _DBUS_GNUC_EXTENSION typedef unsigned @DBUS_INT64_TYPE@ dbus_uint64_t; #define DBUS_INT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION @DBUS_INT64_CONSTANT@) #define DBUS_UINT64_CONSTANT(val) (_DBUS_GNUC_EXTENSION @DBUS_UINT64_CONSTANT@) -#else -#undef DBUS_HAVE_INT64 -#undef DBUS_INT64_CONSTANT -#undef DBUS_UINT64_CONSTANT -#endif - typedef @DBUS_INT32_TYPE@ dbus_int32_t; typedef unsigned @DBUS_INT32_TYPE@ dbus_uint32_t; diff --git a/dbus/dbus-asv-util.c b/dbus/dbus-asv-util.c new file mode 100644 index 00000000..583e41fa --- /dev/null +++ b/dbus/dbus-asv-util.c @@ -0,0 +1,260 @@ +/* dbus-asv-util.c - utility functions for a{sv} + * + * Copyright © 2011-2012 Nokia Corporation + * Copyright © 2012-2013 Collabora Ltd. + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include <config.h> + +#include <dbus/dbus.h> + +#include "dbus/dbus-asv-util.h" + +/** + * Convenience function to create a method-call reply whose type is a{sv} + * (map from string to variant). + * + * Append values with 0 or more sequences of _dbus_asv_open_entry(), + * appending a value to var_iter, and _dbus_asv_close_entry(), + * then close the a{sv} with _dbus_asv_close() or _dbus_asv_abandon(). + * + * This must be paired with a call to _dbus_asv_close() or _dbus_asv_abandon(). + * + * @param message a method call message + * @param iter an iterator which will be initialized to append to the message + * @param arr_iter an iterator which will be initialized to append to the array + * @returns a new message, or #NULL if not enough memory + */ +DBusMessage * +_dbus_asv_new_method_return (DBusMessage *message, + DBusMessageIter *iter, + DBusMessageIter *arr_iter) +{ + DBusMessage *reply = dbus_message_new_method_return (message); + + if (reply == NULL) + return NULL; + + dbus_message_iter_init_append (reply, iter); + + if (!dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, "{sv}", + arr_iter)) + { + dbus_message_unref (reply); + return NULL; + } + + return reply; +} + +/* + * Open a new entry in an a{sv} (map from string to variant). + * + * This must be paired with a call to either _dbus_asv_close_entry() + * or _dbus_asv_abandon_entry(). + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param entry_iter will be initialized to append to the dict-entry + * @param key a UTF-8 key for the map + * @param type the type of the variant value, e.g. DBUS_TYPE_STRING_AS_STRING + * @param var_iter will be initialized to append (i.e. write) to the variant + * @returns #TRUE on success, or #FALSE if not enough memory + */ +static dbus_bool_t +_dbus_asv_open_entry (DBusMessageIter *arr_iter, + DBusMessageIter *entry_iter, + const char *key, + const char *type, + DBusMessageIter *var_iter) +{ + if (!dbus_message_iter_open_container (arr_iter, DBUS_TYPE_DICT_ENTRY, + NULL, entry_iter)) + return FALSE; + + if (!dbus_message_iter_append_basic (entry_iter, DBUS_TYPE_STRING, &key)) + { + dbus_message_iter_abandon_container (arr_iter, entry_iter); + return FALSE; + } + + if (!dbus_message_iter_open_container (entry_iter, DBUS_TYPE_VARIANT, + type, var_iter)) + { + dbus_message_iter_abandon_container (arr_iter, entry_iter); + return FALSE; + } + + return TRUE; +} + +/* + * Closes an a{sv} entry after successfully appending the value. + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param entry_iter the iterator appending to the dict-entry, will be closed + * @param var_iter the iterator appending to the variant, will be closed + * @returns #TRUE on success, or #FALSE if not enough memory + */ +static dbus_bool_t +_dbus_asv_close_entry (DBusMessageIter *arr_iter, + DBusMessageIter *entry_iter, + DBusMessageIter *var_iter) +{ + if (!dbus_message_iter_close_container (entry_iter, var_iter)) + { + dbus_message_iter_abandon_container (arr_iter, entry_iter); + return FALSE; + } + + if (!dbus_message_iter_close_container (arr_iter, entry_iter)) + return FALSE; + + return TRUE; +} + +/** + * Closes an a{sv} after successfully appending all values. + * + * If this function fails, you must abandon iter and whatever + * larger data structure (message, etc.) the a{sv} was embedded in. + * + * @param iter the iterator which is appending to the message or other data structure containing the a{sv} + * @param arr_iter the iterator appending to the array, will be closed + * @returns #TRUE on success, or #FALSE if not enough memory + */ +dbus_bool_t +_dbus_asv_close (DBusMessageIter *iter, + DBusMessageIter *arr_iter) +{ + return dbus_message_iter_close_container (iter, arr_iter); +} + +/* + * Closes an a{sv} entry after unsuccessfully appending a value. + * You must also abandon the a{sv} itself (for instance with + * _dbus_asv_abandon()), and abandon whatever larger data structure + * the a{sv} was embedded in. + * + * @param iter the iterator which is appending to the message or other data structure containing the a{sv} + * @param arr_iter the iterator appending to the array, will be closed + * @returns #TRUE on success, or #FALSE if not enough memory + */ +static void +_dbus_asv_abandon_entry (DBusMessageIter *arr_iter, + DBusMessageIter *entry_iter, + DBusMessageIter *var_iter) +{ + dbus_message_iter_abandon_container (entry_iter, var_iter); + dbus_message_iter_abandon_container (arr_iter, entry_iter); +} + +/** + * Closes an a{sv} after unsuccessfully appending a value. + * + * You must also abandon whatever larger data structure (message, etc.) + * the a{sv} was embedded in. + * + * @param iter the iterator which is appending to the message or other data structure containing the a{sv} + * @param arr_iter the iterator appending to the array, will be closed + */ +void +_dbus_asv_abandon (DBusMessageIter *iter, + DBusMessageIter *arr_iter) +{ + dbus_message_iter_abandon_container (iter, arr_iter); +} + +/** + * Create a new entry in an a{sv} (map from string to variant) + * with a 32-bit unsigned integer value. + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param key a UTF-8 key for the map + * @param value the value + * @returns #TRUE on success, or #FALSE if not enough memory + */ +dbus_bool_t +_dbus_asv_add_uint32 (DBusMessageIter *arr_iter, + const char *key, + dbus_uint32_t value) +{ + DBusMessageIter entry_iter, var_iter; + + if (!_dbus_asv_open_entry (arr_iter, &entry_iter, key, + DBUS_TYPE_UINT32_AS_STRING, &var_iter)) + return FALSE; + + if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_UINT32, + &value)) + { + _dbus_asv_abandon_entry (arr_iter, &entry_iter, &var_iter); + return FALSE; + } + + if (!_dbus_asv_close_entry (arr_iter, &entry_iter, &var_iter)) + return FALSE; + + return TRUE; +} + +/** + * Create a new entry in an a{sv} (map from string to variant) + * with a UTF-8 string value. + * + * If this function fails, the a{sv} must be abandoned, for instance + * with _dbus_asv_abandon(). + * + * @param arr_iter the iterator which is appending to the array + * @param key a UTF-8 key for the map + * @param value the value + * @returns #TRUE on success, or #FALSE if not enough memory + */ +dbus_bool_t +_dbus_asv_add_string (DBusMessageIter *arr_iter, + const char *key, + const char *value) +{ + DBusMessageIter entry_iter, var_iter; + + if (!_dbus_asv_open_entry (arr_iter, &entry_iter, key, + DBUS_TYPE_STRING_AS_STRING, &var_iter)) + return FALSE; + + if (!dbus_message_iter_append_basic (&var_iter, DBUS_TYPE_STRING, + &value)) + { + _dbus_asv_abandon_entry (arr_iter, &entry_iter, &var_iter); + return FALSE; + } + + if (!_dbus_asv_close_entry (arr_iter, &entry_iter, &var_iter)) + return FALSE; + + return TRUE; +} diff --git a/dbus/dbus-asv-util.h b/dbus/dbus-asv-util.h new file mode 100644 index 00000000..0337260a --- /dev/null +++ b/dbus/dbus-asv-util.h @@ -0,0 +1,46 @@ +/* dbus-asv-util.h - utility functions for a{sv} + * + * Copyright © 2011-2012 Nokia Corporation + * Copyright © 2012-2013 Collabora Ltd. + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#ifndef DBUS_ASV_UTIL_H +#define DBUS_ASV_UTIL_H + +#include <dbus/dbus-internals.h> + +DBUS_BEGIN_DECLS + +DBusMessage *_dbus_asv_new_method_return (DBusMessage *message, + DBusMessageIter *iter, + DBusMessageIter *arr_iter); +dbus_bool_t _dbus_asv_close (DBusMessageIter *iter, + DBusMessageIter *arr_iter); +void _dbus_asv_abandon (DBusMessageIter *iter, + DBusMessageIter *arr_iter); + +dbus_bool_t _dbus_asv_add_uint32 (DBusMessageIter *arr_iter, + const char *key, + dbus_uint32_t value); +dbus_bool_t _dbus_asv_add_string (DBusMessageIter *arr_iter, + const char *key, + const char *value); + +#endif diff --git a/dbus/dbus-auth-script.c b/dbus/dbus-auth-script.c index cbdd748f..c1f0c88e 100644 --- a/dbus/dbus-auth-script.c +++ b/dbus/dbus-auth-script.c @@ -22,7 +22,7 @@ */ #include <config.h> -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-auth-script.h" #include "dbus-auth.h" @@ -800,4 +800,4 @@ _dbus_auth_script_run (const DBusString *filename) } /** @} */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-auth-util.c b/dbus/dbus-auth-util.c index 776e8e27..e88d6696 100644 --- a/dbus/dbus-auth-util.c +++ b/dbus/dbus-auth-util.c @@ -33,7 +33,7 @@ /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include "dbus-auth-script.h" #include <stdio.h> @@ -167,4 +167,4 @@ _dbus_auth_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-auth.c b/dbus/dbus-auth.c index d2c37a7a..a0f72773 100644 --- a/dbus/dbus-auth.c +++ b/dbus/dbus-auth.c @@ -2238,8 +2238,8 @@ process_command (DBusAuth *auth) /** * Creates a new auth conversation object for the server side. - * See doc/dbus-sasl-profile.txt for full details on what - * this object does. + * See http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * for full details on what this object does. * * @returns the new object or #NULL if no memory */ @@ -2284,8 +2284,8 @@ _dbus_auth_server_new (const DBusString *guid) /** * Creates a new auth conversation object for the client side. - * See doc/dbus-sasl-profile.txt for full details on what - * this object does. + * See http://dbus.freedesktop.org/doc/dbus-specification.html#auth-protocol + * for full details on what this object does. * * @returns the new object or #NULL if no memory */ diff --git a/dbus/dbus-bus.c b/dbus/dbus-bus.c index 6f81c74a..9d2095f9 100644 --- a/dbus/dbus-bus.c +++ b/dbus/dbus-bus.c @@ -28,6 +28,7 @@ #include "dbus-internals.h" #include "dbus-message.h" #include "dbus-marshal-validate.h" +#include "dbus-misc.h" #include "dbus-threads-internal.h" #include "dbus-connection-internal.h" #include "dbus-string.h" @@ -95,19 +96,6 @@ static DBusBusType activation_bus_type = DBUS_BUS_STARTER; static dbus_bool_t initialized = FALSE; -/** - * Lock for globals in this file - */ -_DBUS_DEFINE_GLOBAL_LOCK (bus); - -/** - * Global lock covering all BusData on any connection. The bet is - * that some lock contention is better than more memory - * for a per-connection lock, but it's tough to imagine it mattering - * either way. - */ -_DBUS_DEFINE_GLOBAL_LOCK (bus_datas); - static void addresses_shutdown_func (void *data) { @@ -306,10 +294,10 @@ init_connections_unlocked (void) * the above code will work right */ - if (!_dbus_setenv ("DBUS_ACTIVATION_ADDRESS", NULL)) + if (!dbus_setenv ("DBUS_ACTIVATION_ADDRESS", NULL)) return FALSE; - if (!_dbus_setenv ("DBUS_ACTIVATION_BUS_TYPE", NULL)) + if (!dbus_setenv ("DBUS_ACTIVATION_BUS_TYPE", NULL)) return FALSE; if (!_dbus_register_shutdown_func (addresses_shutdown_func, @@ -330,7 +318,11 @@ bus_data_free (void *data) if (bd->is_well_known) { int i; - _DBUS_LOCK (bus); + + if (!_DBUS_LOCK (bus)) + _dbus_assert_not_reached ("global locks should have been initialized " + "when we attached bus data"); + /* We may be stored in more than one slot */ /* This should now be impossible - these slots are supposed to * be cleared on disconnect, so should not need to be cleared on @@ -401,8 +393,13 @@ void _dbus_bus_notify_shared_connection_disconnected_unlocked (DBusConnection *connection) { int i; - - _DBUS_LOCK (bus); + + if (!_DBUS_LOCK (bus)) + { + /* If it was in bus_connections, we would have initialized global locks + * when we added it. So, it can't be. */ + return; + } /* We are expecting to have the connection saved in only one of these * slots, but someone could in a pathological case set system and session @@ -436,7 +433,12 @@ internal_bus_get (DBusBusType type, connection = NULL; - _DBUS_LOCK (bus); + if (!_DBUS_LOCK (bus)) + { + _DBUS_SET_OOM (error); + /* do not "goto out", that would try to unlock */ + return NULL; + } if (!init_connections_unlocked ()) { @@ -506,8 +508,10 @@ internal_bus_get (DBusBusType type, */ dbus_connection_set_exit_on_disconnect (connection, TRUE); - - _DBUS_LOCK (bus_datas); + + if (!_DBUS_LOCK (bus_datas)) + _dbus_assert_not_reached ("global locks were initialized already"); + bd = ensure_bus_data (connection); _dbus_assert (bd != NULL); /* it should have been created on register, so OOM not possible */ @@ -554,7 +558,7 @@ out: * * @param type bus type * @param error address where an error can be returned. - * @returns a #DBusConnection with new ref + * @returns a #DBusConnection with new ref or #NULL on error */ DBusConnection * dbus_bus_get (DBusBusType type, @@ -660,7 +664,12 @@ dbus_bus_register (DBusConnection *connection, message = NULL; reply = NULL; - _DBUS_LOCK (bus_datas); + if (!_DBUS_LOCK (bus_datas)) + { + _DBUS_SET_OOM (error); + /* do not "goto out", that would try to unlock */ + return FALSE; + } bd = ensure_bus_data (connection); if (bd == NULL) @@ -769,8 +778,12 @@ dbus_bus_set_unique_name (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (unique_name != NULL, FALSE); - _DBUS_LOCK (bus_datas); - + if (!_DBUS_LOCK (bus_datas)) + { + /* do not "goto out", that would try to unlock */ + return FALSE; + } + bd = ensure_bus_data (connection); if (bd == NULL) goto out; @@ -812,8 +825,13 @@ dbus_bus_get_unique_name (DBusConnection *connection) _dbus_return_val_if_fail (connection != NULL, NULL); - _DBUS_LOCK (bus_datas); - + if (!_DBUS_LOCK (bus_datas)) + { + /* We'd have initialized locks when we gave it its unique name, if it + * had one. Don't "goto out", that would try to unlock. */ + return NULL; + } + bd = ensure_bus_data (connection); if (bd == NULL) goto out; diff --git a/dbus/dbus-connection-internal.h b/dbus/dbus-connection-internal.h index 3d37f188..2842f2f4 100644 --- a/dbus/dbus-connection-internal.h +++ b/dbus/dbus-connection-internal.h @@ -115,7 +115,7 @@ void _dbus_connection_get_stats (DBusConnection *connection, dbus_uint32_t *out_peak_fds); -/* if DBUS_BUILD_TESTS */ +/* if DBUS_ENABLE_EMBEDDED_TESTS */ const char* _dbus_connection_get_address (DBusConnection *connection); /* This _dbus_bus_* stuff doesn't really belong here, but dbus-bus-internal.h seems diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c index 66315b3f..f0b6871e 100644 --- a/dbus/dbus-connection.c +++ b/dbus/dbus-connection.c @@ -203,26 +203,19 @@ * @{ */ -#ifdef DBUS_ENABLE_VERBOSE_MODE static void _dbus_connection_trace_ref (DBusConnection *connection, int old_refcount, int new_refcount, const char *why) { +#ifdef DBUS_ENABLE_VERBOSE_MODE static int enabled = -1; _dbus_trace_ref ("DBusConnection", connection, old_refcount, new_refcount, why, "DBUS_CONNECTION_TRACE", &enabled); -} -#else -#define _dbus_connection_trace_ref(c,o,n,w) \ - do \ - {\ - (void) (o); \ - (void) (n); \ - } while (0) #endif +} /** * Internal struct representing a message filter function @@ -336,8 +329,8 @@ struct DBusConnection #ifndef DBUS_DISABLE_CHECKS unsigned int have_connection_lock : 1; /**< Used to check locking */ #endif - -#ifndef DBUS_DISABLE_CHECKS + +#if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) int generation; /**< _dbus_current_generation that should correspond to this connection */ #endif }; @@ -446,7 +439,7 @@ _dbus_connection_wakeup_mainloop (DBusConnection *connection) (*connection->wakeup_main_function) (connection->wakeup_main_data); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Gets the locks so we can examine them * @@ -490,9 +483,9 @@ _dbus_connection_queue_received_message_link (DBusConnection *connection, DBusPendingCall *pending; dbus_uint32_t reply_serial; DBusMessage *message; - - _dbus_assert (_dbus_transport_get_is_authenticated (connection->transport)); - + + _dbus_assert (_dbus_transport_peek_is_authenticated (connection->transport)); + _dbus_list_append_link (&connection->incoming_messages, link); message = link->data; @@ -1354,7 +1347,7 @@ _dbus_connection_new_for_transport (DBusTransport *transport) connection->disconnected_message_arrived = FALSE; connection->disconnected_message_processed = FALSE; -#ifndef DBUS_DISABLE_CHECKS +#if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) connection->generation = _dbus_current_generation; #endif @@ -1531,7 +1524,7 @@ _dbus_connection_handle_watch (DBusWatch *watch, return retval; } -_DBUS_DEFINE_GLOBAL_LOCK (shared_connections); +/* Protected by _DBUS_LOCK (shared_connections) */ static DBusHashTable *shared_connections = NULL; static DBusList *shared_connections_no_guid = NULL; @@ -1555,9 +1548,14 @@ static void shared_connections_shutdown (void *data) { int n_entries; - - _DBUS_LOCK (shared_connections); - + + if (!_DBUS_LOCK (shared_connections)) + { + /* We'd have initialized locks before adding anything, so there + * can't be anything there. */ + return; + } + /* This is a little bit unpleasant... better ideas? */ while ((n_entries = _dbus_hash_table_get_n_entries (shared_connections)) > 0) { @@ -1571,7 +1569,8 @@ shared_connections_shutdown (void *data) _DBUS_UNLOCK (shared_connections); close_connection_on_shutdown (connection); - _DBUS_LOCK (shared_connections); + if (!_DBUS_LOCK (shared_connections)) + _dbus_assert_not_reached ("global locks were already initialized"); /* The connection should now be dead and not in our hash ... */ _dbus_assert (_dbus_hash_table_get_n_entries (shared_connections) < n_entries); @@ -1590,7 +1589,8 @@ shared_connections_shutdown (void *data) { _DBUS_UNLOCK (shared_connections); close_connection_on_shutdown (connection); - _DBUS_LOCK (shared_connections); + if (!_DBUS_LOCK (shared_connections)) + _dbus_assert_not_reached ("global locks were already initialized"); connection = _dbus_list_pop_first (&shared_connections_no_guid); } } @@ -1607,8 +1607,13 @@ connection_lookup_shared (DBusAddressEntry *entry, _dbus_verbose ("checking for existing connection\n"); *result = NULL; - - _DBUS_LOCK (shared_connections); + + if (!_DBUS_LOCK (shared_connections)) + { + /* If it was shared, we'd have initialized global locks when we put + * it in shared_connections. */ + return FALSE; + } if (shared_connections == NULL) { @@ -1706,7 +1711,8 @@ connection_record_shared_unlocked (DBusConnection *connection, if (guid == NULL) { - _DBUS_LOCK (shared_connections); + if (!_DBUS_LOCK (shared_connections)) + return FALSE; if (!_dbus_list_prepend (&shared_connections_no_guid, connection)) { @@ -1733,8 +1739,14 @@ connection_record_shared_unlocked (DBusConnection *connection, dbus_free (guid_key); return FALSE; } - - _DBUS_LOCK (shared_connections); + + if (!_DBUS_LOCK (shared_connections)) + { + dbus_free (guid_in_connection); + dbus_free (guid_key); + return FALSE; + } + _dbus_assert (shared_connections != NULL); if (!_dbus_hash_table_insert_string (shared_connections, @@ -1765,9 +1777,14 @@ connection_forget_shared_unlocked (DBusConnection *connection) if (!connection->shareable) return; - - _DBUS_LOCK (shared_connections); - + + if (!_DBUS_LOCK (shared_connections)) + { + /* If it was shared, we'd have initialized global locks when we put + * it in the table; so it can't be there. */ + return; + } + if (connection->server_guid != NULL) { _dbus_verbose ("dropping connection to %s out of the shared table\n", @@ -2150,7 +2167,7 @@ _dbus_connection_close_if_only_one_ref (DBusConnection *connection) * relatively long time for memory, if they were only willing to block * briefly then we retry for memory at a rapid rate. * - * @timeout_milliseconds the timeout requested for blocking + * @param timeout_milliseconds the timeout requested for blocking */ static void _dbus_memory_pause_based_on_timeout (int timeout_milliseconds) @@ -2683,6 +2700,7 @@ _dbus_connection_last_unref (DBusConnection *connection) dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); dbus_connection_set_wakeup_main_function (connection, NULL, NULL, NULL); dbus_connection_set_unix_user_function (connection, NULL, NULL, NULL); + dbus_connection_set_windows_user_function (connection, NULL, NULL, NULL); _dbus_watch_list_free (connection->watches); connection->watches = NULL; @@ -2952,9 +2970,9 @@ dbus_connection_get_is_authenticated (DBusConnection *connection) dbus_bool_t res; _dbus_return_val_if_fail (connection != NULL, FALSE); - + CONNECTION_LOCK (connection); - res = _dbus_transport_get_is_authenticated (connection->transport); + res = _dbus_transport_try_to_authenticate (connection->transport); CONNECTION_UNLOCK (connection); return res; @@ -3938,7 +3956,7 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) link = _dbus_list_pop_first_link (&connection->incoming_messages); connection->n_incoming -= 1; - _dbus_verbose ("Message %p (%s %s %s %s '%s') removed from incoming queue %p, %d incoming\n", + _dbus_verbose ("Message %p (%s %s %s %s sig:'%s' serial:%u) removed from incoming queue %p, %d incoming\n", link->data, dbus_message_type_to_string (dbus_message_get_type (link->data)), dbus_message_get_path (link->data) ? @@ -3951,6 +3969,7 @@ _dbus_connection_pop_message_link_unlocked (DBusConnection *connection) dbus_message_get_member (link->data) : "no member", dbus_message_get_signature (link->data), + dbus_message_get_serial (link->data), connection, connection->n_incoming); _dbus_message_trace_ref (link->data, -1, -1, @@ -5148,10 +5167,10 @@ dbus_connection_get_unix_user (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (uid != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_unix_user (connection->transport, @@ -5184,10 +5203,10 @@ dbus_connection_get_unix_process_id (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (pid != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_unix_process_id (connection->transport, @@ -5205,7 +5224,8 @@ dbus_connection_get_unix_process_id (DBusConnection *connection, * connection. * * @param connection the connection - * @param data return location for audit data + * @param data return location for audit data + * @param data_size return location for length of audit data * @returns #TRUE if audit data is filled in with a valid ucred pointer */ dbus_bool_t @@ -5218,10 +5238,10 @@ dbus_connection_get_adt_audit_session_data (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (data != NULL, FALSE); _dbus_return_val_if_fail (data_size != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_adt_audit_session_data (connection->transport, @@ -5314,10 +5334,10 @@ dbus_connection_get_windows_user (DBusConnection *connection, _dbus_return_val_if_fail (connection != NULL, FALSE); _dbus_return_val_if_fail (windows_sid_p != NULL, FALSE); - + CONNECTION_LOCK (connection); - if (!_dbus_transport_get_is_authenticated (connection->transport)) + if (!_dbus_transport_try_to_authenticate (connection->transport)) result = FALSE; else result = _dbus_transport_get_windows_user (connection->transport, @@ -5435,7 +5455,7 @@ dbus_connection_set_route_peer_messages (DBusConnection *connection, _dbus_return_if_fail (connection != NULL); CONNECTION_LOCK (connection); - connection->route_peer_messages = TRUE; + connection->route_peer_messages = value; CONNECTION_UNLOCK (connection); } @@ -5852,8 +5872,8 @@ dbus_connection_list_registered (DBusConnection *connection, return retval; } -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (connection_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (connection_slots)); /** * Allocates an integer ID to be used for storing application-specific @@ -5873,7 +5893,6 @@ dbus_bool_t dbus_connection_allocate_data_slot (dbus_int32_t *slot_p) { return _dbus_data_slot_allocator_alloc (&slot_allocator, - &_DBUS_LOCK_NAME (connection_slots), slot_p); } @@ -6044,7 +6063,7 @@ dbus_connection_get_max_message_size (DBusConnection *connection) * result in disconnecting the connection. * * @param connection a #DBusConnection - * @param size maximum message unix fds the connection can receive + * @param n maximum message unix fds the connection can receive */ void dbus_connection_set_max_message_unix_fds (DBusConnection *connection, @@ -6142,7 +6161,7 @@ dbus_connection_get_max_received_size (DBusConnection *connection) * The semantics are analogous to those of dbus_connection_set_max_received_size(). * * @param connection the connection - * @param size the maximum size in bytes of all outstanding messages + * @param n the maximum size in bytes of all outstanding messages */ void dbus_connection_set_max_received_unix_fds (DBusConnection *connection, @@ -6259,7 +6278,7 @@ dbus_connection_get_outgoing_unix_fds (DBusConnection *connection) return res; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Returns the address of the transport object of this connection * diff --git a/dbus/dbus-credentials-util.c b/dbus/dbus-credentials-util.c index 59cdcb83..d2d164f7 100644 --- a/dbus/dbus-credentials-util.c +++ b/dbus/dbus-credentials-util.c @@ -33,7 +33,7 @@ /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> #include <string.h> @@ -203,4 +203,4 @@ _dbus_credentials_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-dataslot.c b/dbus/dbus-dataslot.c index 0369612e..e37c9dd5 100644 --- a/dbus/dbus-dataslot.c +++ b/dbus/dbus-dataslot.c @@ -43,13 +43,14 @@ * @param allocator the allocator to initialize */ dbus_bool_t -_dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator) +_dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator, + DBusGlobalLock lock) { allocator->allocated_slots = NULL; allocator->n_allocated_slots = 0; allocator->n_used_slots = 0; - allocator->lock_loc = NULL; - + allocator->lock = lock; + return TRUE; } @@ -61,29 +62,17 @@ _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator) * is allocated and stored at *slot_id_p. * * @param allocator the allocator - * @param mutex_loc the location lock for this allocator * @param slot_id_p address to fill with the slot ID * @returns #TRUE on success */ dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, - DBusRMutex **mutex_loc, dbus_int32_t *slot_id_p) { dbus_int32_t slot; - _dbus_rmutex_lock (*mutex_loc); - - if (allocator->n_allocated_slots == 0) - { - _dbus_assert (allocator->lock_loc == NULL); - allocator->lock_loc = mutex_loc; - } - else if (allocator->lock_loc != mutex_loc) - { - _dbus_warn_check_failed ("D-Bus threads were initialized after first using the D-Bus library. If your application does not directly initialize threads or use D-Bus, keep in mind that some library or plugin may have used D-Bus or initialized threads behind your back. You can often fix this problem by calling dbus_init_threads() or dbus_g_threads_init() early in your main() method, before D-Bus is used.\n"); - _dbus_assert_not_reached ("exiting"); - } + if (!_dbus_lock (allocator->lock)) + return FALSE; if (*slot_id_p >= 0) { @@ -146,7 +135,7 @@ _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, slot, allocator, allocator->n_allocated_slots, allocator->n_used_slots); out: - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); return slot >= 0; } @@ -165,8 +154,10 @@ void _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, dbus_int32_t *slot_id_p) { - _dbus_rmutex_lock (*(allocator->lock_loc)); - + if (!_dbus_lock (allocator->lock)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated this slot"); + _dbus_assert (*slot_id_p < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[*slot_id_p].slot_id == *slot_id_p); _dbus_assert (allocator->allocated_slots[*slot_id_p].refcount > 0); @@ -175,7 +166,7 @@ _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, if (allocator->allocated_slots[*slot_id_p].refcount > 0) { - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); return; } @@ -190,19 +181,12 @@ _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, if (allocator->n_used_slots == 0) { - DBusRMutex **mutex_loc = allocator->lock_loc; - dbus_free (allocator->allocated_slots); allocator->allocated_slots = NULL; allocator->n_allocated_slots = 0; - allocator->lock_loc = NULL; - - _dbus_rmutex_unlock (*mutex_loc); - } - else - { - _dbus_rmutex_unlock (*(allocator->lock_loc)); } + + _dbus_unlock (allocator->lock); } /** @@ -247,10 +231,13 @@ _dbus_data_slot_list_set (DBusDataSlotAllocator *allocator, * be e.g. realloc()ing allocated_slots. We avoid doing this if asserts * are disabled, since then the asserts are empty. */ - _dbus_rmutex_lock (*(allocator->lock_loc)); + if (!_dbus_lock (allocator->lock)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated this slot"); + _dbus_assert (slot < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[slot].slot_id == slot); - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); #endif if (slot >= list->n_slots) @@ -304,11 +291,14 @@ _dbus_data_slot_list_get (DBusDataSlotAllocator *allocator, * be e.g. realloc()ing allocated_slots. We avoid doing this if asserts * are disabled, since then the asserts are empty. */ - _dbus_rmutex_lock (*(allocator->lock_loc)); + if (!_dbus_lock (allocator->lock)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated this slot"); + _dbus_assert (slot >= 0); _dbus_assert (slot < allocator->n_allocated_slots); _dbus_assert (allocator->allocated_slots[slot].slot_id == slot); - _dbus_rmutex_unlock (*(allocator->lock_loc)); + _dbus_unlock (allocator->lock); #endif if (slot >= list->n_slots) @@ -358,7 +348,7 @@ _dbus_data_slot_list_free (DBusDataSlotList *list) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> @@ -384,17 +374,12 @@ _dbus_data_slot_test (void) int i; DBusFreeFunction old_free_func; void *old_data; - DBusRMutex *mutex; - - if (!_dbus_data_slot_allocator_init (&allocator)) + + if (!_dbus_data_slot_allocator_init (&allocator, _DBUS_LOCK_server_slots)) _dbus_assert_not_reached ("no memory for allocator"); _dbus_data_slot_list_init (&list); - _dbus_rmutex_new_at_location (&mutex); - if (mutex == NULL) - _dbus_assert_not_reached ("failed to alloc mutex"); - #define N_SLOTS 100 i = 0; @@ -405,8 +390,8 @@ _dbus_data_slot_test (void) * here. */ dbus_int32_t tmp = -1; - - _dbus_data_slot_allocator_alloc (&allocator, &mutex, &tmp); + + _dbus_data_slot_allocator_alloc (&allocator, &tmp); if (tmp != i) _dbus_assert_not_reached ("did not allocate slots in numeric order\n"); @@ -471,9 +456,7 @@ _dbus_data_slot_test (void) ++i; } - _dbus_rmutex_free_at_location (&mutex); - return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-dataslot.h b/dbus/dbus-dataslot.h index 3d9d5edd..1e04fcbc 100644 --- a/dbus/dbus-dataslot.h +++ b/dbus/dbus-dataslot.h @@ -57,9 +57,11 @@ struct DBusDataSlotAllocator DBusAllocatedSlot *allocated_slots; /**< Allocated slots */ int n_allocated_slots; /**< number of slots malloc'd */ int n_used_slots; /**< number of slots used */ - DBusRMutex **lock_loc; /**< location of thread lock */ + DBusGlobalLock lock; /**< index of thread lock */ }; +#define _DBUS_DATA_SLOT_ALLOCATOR_INIT(x) { NULL, 0, 0, x } + /** * Data structure that stores the actual user data set at a given * slot. @@ -70,9 +72,9 @@ struct DBusDataSlotList int n_slots; /**< Slots we have storage for in data_slots */ }; -dbus_bool_t _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator); +dbus_bool_t _dbus_data_slot_allocator_init (DBusDataSlotAllocator *allocator, + DBusGlobalLock lock); dbus_bool_t _dbus_data_slot_allocator_alloc (DBusDataSlotAllocator *allocator, - DBusRMutex **mutex_loc, int *slot_id_p); void _dbus_data_slot_allocator_free (DBusDataSlotAllocator *allocator, int *slot_id_p); diff --git a/dbus/dbus-errors.c b/dbus/dbus-errors.c index db3305b9..a0571a50 100644 --- a/dbus/dbus-errors.c +++ b/dbus/dbus-errors.c @@ -235,7 +235,7 @@ dbus_error_free (DBusError *error) * must ensure the name and message are global data that won't be * freed. You probably want dbus_set_error() instead, in most cases. * - * @param error the error.or #NULL + * @param error the error or #NULL * @param name the error name (not copied!!!) * @param message the error message (not copied!!!) */ @@ -379,7 +379,6 @@ dbus_set_error (DBusError *error, message_from_error (name))) { _dbus_string_free (&str); - va_end (args); goto nomem; } } diff --git a/dbus/dbus-hash.c b/dbus/dbus-hash.c index c4c6f935..c80835aa 100644 --- a/dbus/dbus-hash.c +++ b/dbus/dbus-hash.c @@ -1401,7 +1401,7 @@ _dbus_hash_table_get_n_entries (DBusHashTable *table) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> @@ -1828,4 +1828,4 @@ _dbus_hash_test (void) return ret; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-internals.c b/dbus/dbus-internals.c index 0e5d807e..e2482597 100644 --- a/dbus/dbus-internals.c +++ b/dbus/dbus-internals.c @@ -163,26 +163,11 @@ */ /** - * @def _DBUS_DEFINE_GLOBAL_LOCK - * - * Defines a global lock variable with the given name. - * The lock must be added to the list to initialize - * in dbus_threads_init(). - */ - -/** - * @def _DBUS_DECLARE_GLOBAL_LOCK - * - * Expands to declaration of a global lock defined - * with _DBUS_DEFINE_GLOBAL_LOCK. - * The lock must be added to the list to initialize - * in dbus_threads_init(). - */ - -/** * @def _DBUS_LOCK * - * Locks a global lock + * Locks a global lock, initializing it first if necessary. + * + * @returns #FALSE if not enough memory */ /** @@ -347,25 +332,22 @@ _dbus_verbose_init (void) */ static char *_dbus_file_path_extract_elements_from_tail(const char *file,int level) { - static int prefix = -1; + int prefix = 0; + char *p = (char *)file + strlen(file); + int i = 0; - if (prefix == -1) + for (;p >= file;p--) { - char *p = (char *)file + strlen(file); - int i = 0; - prefix = 0; - for (;p >= file;p--) + if (DBUS_IS_DIR_SEPARATOR(*p)) { - if (DBUS_IS_DIR_SEPARATOR(*p)) + if (++i >= level) { - if (++i >= level) - { - prefix = p-file+1; - break; - } - } - } + prefix = p-file+1; + break; + } + } } + return (char *)file+prefix; } @@ -847,7 +829,7 @@ _dbus_read_uuid_file (const DBusString *filename, } } -_DBUS_DEFINE_GLOBAL_LOCK (machine_uuid); +/* Protected by _DBUS_LOCK (machine_uuid) */ static int machine_uuid_initialized_generation = 0; static DBusGUID machine_uuid; @@ -866,7 +848,9 @@ _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str) { dbus_bool_t ok; - _DBUS_LOCK (machine_uuid); + if (!_DBUS_LOCK (machine_uuid)) + return FALSE; + if (machine_uuid_initialized_generation != _dbus_current_generation) { DBusError error = DBUS_ERROR_INIT; @@ -874,7 +858,7 @@ _dbus_get_local_machine_uuid_encoded (DBusString *uuid_str) if (!_dbus_read_local_machine_uuid (&machine_uuid, FALSE, &error)) { -#ifndef DBUS_BUILD_TESTS +#ifndef DBUS_ENABLE_EMBEDDED_TESTS /* For the test suite, we may not be installed so just continue silently * here. But in a production build, we want to be nice and loud about * this. @@ -953,7 +937,7 @@ _dbus_real_assert_not_reached (const char *explanation, } #endif /* DBUS_DISABLE_ASSERT */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static dbus_bool_t run_failing_each_malloc (int n_mallocs, const char *description, @@ -1048,6 +1032,6 @@ _dbus_test_oom_handling (const char *description, return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** @} */ diff --git a/dbus/dbus-internals.h b/dbus/dbus-internals.h index 382630da..c5a3c9b8 100644 --- a/dbus/dbus-internals.h +++ b/dbus/dbus-internals.h @@ -230,10 +230,8 @@ char** _dbus_dup_string_array (const char **array); #define _DBUS_INT_MIN _DBUS_INT32_MIN #define _DBUS_INT_MAX _DBUS_INT32_MAX #define _DBUS_UINT_MAX _DBUS_UINT32_MAX -#ifdef DBUS_HAVE_INT64 #define _DBUS_INT64_MAX DBUS_INT64_CONSTANT (0x7fffffffffffffff) #define _DBUS_UINT64_MAX DBUS_UINT64_CONSTANT (0xffffffffffffffff) -#endif #define _DBUS_ONE_KILOBYTE 1024 #define _DBUS_ONE_MEGABYTE 1024 * _DBUS_ONE_KILOBYTE #define _DBUS_ONE_HOUR_IN_MILLISECONDS (1000 * 60 * 60) @@ -266,7 +264,7 @@ void _dbus_verbose_bytes_of_string (const DBusString *str, extern const char *_dbus_no_memory_message; #define _DBUS_SET_OOM(error) dbus_set_error_const ((error), DBUS_ERROR_NO_MEMORY, _dbus_no_memory_message) -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* Memory debugging */ void _dbus_set_fail_alloc_counter (int until_next_fail); int _dbus_get_fail_alloc_counter (void); @@ -290,38 +288,46 @@ dbus_bool_t _dbus_test_oom_handling (const char *description, #define _dbus_decrement_fail_alloc_counter() (FALSE) #define _dbus_disable_mem_pools() (FALSE) #define _dbus_get_malloc_blocks_outstanding (0) -#endif /* !DBUS_BUILD_TESTS */ +#endif /* !DBUS_ENABLE_EMBEDDED_TESTS */ typedef void (* DBusShutdownFunction) (void *data); -dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction function, - void *data); +dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction function, + void *data); +dbus_bool_t _dbus_register_shutdown_func_unlocked (DBusShutdownFunction function, + void *data); extern int _dbus_current_generation; -/* Thread initializers */ -#define _DBUS_LOCK_NAME(name) _dbus_lock_##name -#define _DBUS_DECLARE_GLOBAL_LOCK(name) extern DBusRMutex *_dbus_lock_##name -#define _DBUS_DEFINE_GLOBAL_LOCK(name) DBusRMutex *_dbus_lock_##name -#define _DBUS_LOCK(name) _dbus_rmutex_lock (_dbus_lock_##name) -#define _DBUS_UNLOCK(name) _dbus_rmutex_unlock (_dbus_lock_##name) - -/* index 0-4 */ -_DBUS_DECLARE_GLOBAL_LOCK (list); -_DBUS_DECLARE_GLOBAL_LOCK (connection_slots); -_DBUS_DECLARE_GLOBAL_LOCK (pending_call_slots); -_DBUS_DECLARE_GLOBAL_LOCK (server_slots); -_DBUS_DECLARE_GLOBAL_LOCK (message_slots); -/* index 5-9 */ -_DBUS_DECLARE_GLOBAL_LOCK (bus); -_DBUS_DECLARE_GLOBAL_LOCK (bus_datas); -_DBUS_DECLARE_GLOBAL_LOCK (shutdown_funcs); -_DBUS_DECLARE_GLOBAL_LOCK (system_users); -_DBUS_DECLARE_GLOBAL_LOCK (message_cache); -/* index 10-11 */ -_DBUS_DECLARE_GLOBAL_LOCK (shared_connections); -_DBUS_DECLARE_GLOBAL_LOCK (machine_uuid); - -#define _DBUS_N_GLOBAL_LOCKS (12) +/* The weird case convention is to avoid having to change all the callers, + * which would be quite a mega-patch. */ +typedef enum +{ + /* index 0-4 */ + _DBUS_LOCK_list, + _DBUS_LOCK_connection_slots, + _DBUS_LOCK_pending_call_slots, + _DBUS_LOCK_server_slots, + _DBUS_LOCK_message_slots, + /* index 5-9 */ + _DBUS_LOCK_bus, + _DBUS_LOCK_bus_datas, + _DBUS_LOCK_shutdown_funcs, + _DBUS_LOCK_system_users, + _DBUS_LOCK_message_cache, + /* index 10-12 */ + _DBUS_LOCK_shared_connections, + _DBUS_LOCK_machine_uuid, + _DBUS_LOCK_sysdeps, + + _DBUS_N_GLOBAL_LOCKS +} DBusGlobalLock; + +dbus_bool_t _dbus_lock (DBusGlobalLock lock) _DBUS_GNUC_WARN_UNUSED_RESULT; +void _dbus_unlock (DBusGlobalLock lock); + +#define _DBUS_LOCK_NAME(name) _DBUS_LOCK_##name +#define _DBUS_LOCK(name) _dbus_lock (_DBUS_LOCK_##name) +#define _DBUS_UNLOCK(name) _dbus_unlock (_DBUS_LOCK_##name) dbus_bool_t _dbus_threads_init_debug (void); diff --git a/dbus/dbus-keyring.c b/dbus/dbus-keyring.c index 3b9ce315..f0c64de3 100644 --- a/dbus/dbus-keyring.c +++ b/dbus/dbus-keyring.c @@ -80,7 +80,7 @@ * Maximum number of keys in the keyring before * we just ignore the rest */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #define MAX_KEYS_IN_FILE 10 #else #define MAX_KEYS_IN_FILE 256 @@ -697,10 +697,10 @@ _dbus_keyring_unref (DBusKeyring *keyring) /** * Creates a new keyring that lives in the ~/.dbus-keyrings directory - * of the given user credentials. If the credentials are #NULL or - * empty, uses those of the current process. + * of the user represented by @p credentials. If the @p credentials are + * #NULL or empty, uses those of the current process. * - * @param username username to get keyring for, or #NULL + * @param credentials a set of credentials representing a user or #NULL * @param context which keyring to get * @param error return location for errors * @returns the keyring or #NULL on error @@ -1023,7 +1023,7 @@ _dbus_keyring_get_hex_key (DBusKeyring *keyring, /** @} */ /* end of exposed API */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> @@ -1156,5 +1156,5 @@ _dbus_keyring_test (void) return FALSE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-list.c b/dbus/dbus-list.c index 7e11cc8d..c4c1856f 100644 --- a/dbus/dbus-list.c +++ b/dbus/dbus-list.c @@ -35,8 +35,8 @@ * Types and functions related to DBusList. */ +/* Protected by _DBUS_LOCK (list) */ static DBusMemPool *list_pool; -_DBUS_DEFINE_GLOBAL_LOCK (list); /** * @defgroup DBusListInternals Linked list implementation details @@ -56,7 +56,8 @@ alloc_link (void *data) { DBusList *link; - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + return FALSE; if (list_pool == NULL) { @@ -93,7 +94,10 @@ alloc_link (void *data) static void free_link (DBusList *link) { - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + _dbus_assert_not_reached ("we should have initialized global locks " + "before we allocated a linked-list link"); + if (_dbus_mem_pool_dealloc (list_pool, link)) { _dbus_mem_pool_free (list_pool); @@ -152,7 +156,14 @@ _dbus_list_get_stats (dbus_uint32_t *in_use_p, dbus_uint32_t *in_free_list_p, dbus_uint32_t *allocated_p) { - _DBUS_LOCK (list); + if (!_DBUS_LOCK (list)) + { + *in_use_p = 0; + *in_free_list_p = 0; + *allocated_p = 0; + return; + } + _dbus_mem_pool_get_stats (list_pool, in_use_p, in_free_list_p, allocated_p); _DBUS_UNLOCK (list); } @@ -777,7 +788,7 @@ _dbus_list_length_is_one (DBusList **list) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> diff --git a/dbus/dbus-mainloop.c b/dbus/dbus-mainloop.c index cef676a3..7ff9dc2c 100644 --- a/dbus/dbus-mainloop.c +++ b/dbus/dbus-mainloop.c @@ -34,27 +34,6 @@ #define MAINLOOP_SPEW 0 -#if MAINLOOP_SPEW -#ifdef DBUS_ENABLE_VERBOSE_MODE -static const char* -watch_flags_to_string (int flags) -{ - const char *watch_type; - - if ((flags & DBUS_WATCH_READABLE) && - (flags & DBUS_WATCH_WRITABLE)) - watch_type = "readwrite"; - else if (flags & DBUS_WATCH_READABLE) - watch_type = "read"; - else if (flags & DBUS_WATCH_WRITABLE) - watch_type = "write"; - else - watch_type = "not read or write"; - return watch_type; -} -#endif /* DBUS_ENABLE_VERBOSE_MODE */ -#endif /* MAINLOOP_SPEW */ - struct DBusLoop { int refcount; @@ -675,7 +654,7 @@ _dbus_loop_iterate (DBusLoop *loop, timeout = MIN (timeout, _dbus_get_oom_wait ()); #if MAINLOOP_SPEW - _dbus_verbose (" polling on %d descriptors timeout %ld\n", n_fds, timeout); + _dbus_verbose (" polling on %d descriptors timeout %ld\n", _DBUS_N_ELEMENTS (ready_fds), timeout); #endif n_ready = _dbus_socket_set_poll (loop->socket_set, ready_fds, @@ -922,7 +901,7 @@ _dbus_loop_quit (DBusLoop *loop) int _dbus_get_oom_wait (void) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* make tests go fast */ return 0; #else diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index 88b19f36..eafc2a9a 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -58,12 +58,10 @@ _DBUS_ASSERT_ALIGNMENT (dbus_bool_t, <=, 4); _DBUS_STATIC_ASSERT (sizeof (double) == 8); _DBUS_ASSERT_ALIGNMENT (double, <=, 8); -#ifdef DBUS_HAVE_INT64 _DBUS_STATIC_ASSERT (sizeof (dbus_int64_t) == 8); _DBUS_ASSERT_ALIGNMENT (dbus_int64_t, <=, 8); _DBUS_STATIC_ASSERT (sizeof (dbus_uint64_t) == 8); _DBUS_ASSERT_ALIGNMENT (dbus_uint64_t, <=, 8); -#endif _DBUS_STATIC_ASSERT (sizeof (DBusBasicValue) >= 8); /* The alignment of a DBusBasicValue might conceivably be > 8 because of the @@ -120,15 +118,10 @@ pack_8_octets (DBusBasicValue value, { _dbus_assert (_DBUS_ALIGN_ADDRESS (data, 8) == data); -#ifdef DBUS_HAVE_INT64 if ((byte_order) == DBUS_LITTLE_ENDIAN) *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_LE (value.u64); else *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_BE (value.u64); -#else - *(DBus8ByteStruct*)data = value.eight; - swap_8_octets ((DBusBasicValue*)data, byte_order); -#endif } /** @@ -146,65 +139,16 @@ _dbus_pack_uint32 (dbus_uint32_t value, pack_4_octets (value, byte_order, data); } -#ifndef DBUS_HAVE_INT64 -/* from ORBit */ -static void -swap_bytes (unsigned char *data, - unsigned int len) -{ - unsigned char *p1 = data; - unsigned char *p2 = data + len - 1; - - while (p1 < p2) - { - unsigned char tmp = *p1; - *p1 = *p2; - *p2 = tmp; - - --p2; - ++p1; - } -} -#endif /* !DBUS_HAVE_INT64 */ - static void swap_8_octets (DBusBasicValue *value, int byte_order) { if (byte_order != DBUS_COMPILER_BYTE_ORDER) { -#ifdef DBUS_HAVE_INT64 value->u64 = DBUS_UINT64_SWAP_LE_BE (value->u64); -#else - swap_bytes (&value->bytes, 8); -#endif } } -#if 0 -static DBusBasicValue -unpack_8_octets (int byte_order, - const unsigned char *data) -{ - DBusBasicValue r; - - _dbus_assert (_DBUS_ALIGN_ADDRESS (data, 8) == data); - _dbus_assert (sizeof (r) == 8); - -#ifdef DBUS_HAVE_INT64 - if (byte_order == DBUS_LITTLE_ENDIAN) - r.u64 = DBUS_UINT64_FROM_LE (*(dbus_uint64_t*)data); - else - r.u64 = DBUS_UINT64_FROM_BE (*(dbus_uint64_t*)data); -#else - r.eight = *(DBus8ByteStruct*)data; - swap_8_octets (&r, byte_order); -#endif - - return r; -} -#endif - #ifndef _dbus_unpack_uint16 /** * Unpacks a 16 bit unsigned integer from a data pointer @@ -601,15 +545,10 @@ _dbus_marshal_read_basic (const DBusString *str, { volatile dbus_uint64_t *vp = value; pos = _DBUS_ALIGN_VALUE (pos, 8); -#ifdef DBUS_HAVE_INT64 if (byte_order != DBUS_COMPILER_BYTE_ORDER) *vp = DBUS_UINT64_SWAP_LE_BE (*(dbus_uint64_t*)(str_data + pos)); else *vp = *(dbus_uint64_t*)(str_data + pos); -#else - *vp = *(DBus8ByteStruct*) (str_data + pos); - swap_8_octets (vp, byte_order); -#endif pos += 8; } break; @@ -965,11 +904,7 @@ _dbus_swap_array (unsigned char *data, { while (d != end) { -#ifdef DBUS_HAVE_INT64 *((dbus_uint64_t*)d) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)d)); -#else - swap_8_bytes ((DBusBasicValue*) d); -#endif d += 8; } } @@ -1501,7 +1436,7 @@ _dbus_first_type_in_signature_c_str (const char *str, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> @@ -1674,12 +1609,10 @@ _dbus_marshal_test (void) unsigned char array1[5] = { 3, 4, 0, 1, 9 }; dbus_int16_t array2[3] = { 124, 457, 780 }; dbus_int32_t array4[3] = { 123, 456, 789 }; -#ifdef DBUS_HAVE_INT64 dbus_int64_t array8[3] = { DBUS_INT64_CONSTANT (0x123ffffffff), DBUS_INT64_CONSTANT (0x456ffffffff), DBUS_INT64_CONSTANT (0x789ffffffff) }; dbus_int64_t *v_ARRAY_INT64; -#endif unsigned char *v_ARRAY_BYTE; dbus_int16_t *v_ARRAY_INT16; dbus_uint16_t *v_ARRAY_UINT16; @@ -1735,7 +1668,6 @@ _dbus_marshal_test (void) MARSHAL_TEST (UINT32, DBUS_BIG_ENDIAN, 0x12345678); MARSHAL_TEST (UINT32, DBUS_LITTLE_ENDIAN, 0x12345678); -#ifdef DBUS_HAVE_INT64 /* Marshal signed integers */ MARSHAL_TEST (INT64, DBUS_BIG_ENDIAN, DBUS_INT64_CONSTANT (-0x123456789abc7)); MARSHAL_TEST (INT64, DBUS_LITTLE_ENDIAN, DBUS_INT64_CONSTANT (-0x123456789abc7)); @@ -1743,7 +1675,6 @@ _dbus_marshal_test (void) /* Marshal unsigned integers */ MARSHAL_TEST (UINT64, DBUS_BIG_ENDIAN, DBUS_UINT64_CONSTANT (0x123456789abc7)); MARSHAL_TEST (UINT64, DBUS_LITTLE_ENDIAN, DBUS_UINT64_CONSTANT (0x123456789abc7)); -#endif /* DBUS_HAVE_INT64 */ /* Marshal byte */ MARSHAL_TEST (BYTE, DBUS_BIG_ENDIAN, 5); @@ -1785,10 +1716,8 @@ _dbus_marshal_test (void) MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_BIG_ENDIAN, array1); MARSHAL_TEST_FIXED_ARRAY (BYTE, DBUS_LITTLE_ENDIAN, array1); -#ifdef DBUS_HAVE_INT64 MARSHAL_TEST_FIXED_ARRAY (INT64, DBUS_BIG_ENDIAN, array8); MARSHAL_TEST_FIXED_ARRAY (INT64, DBUS_LITTLE_ENDIAN, array8); -#endif #if 0 @@ -1796,7 +1725,6 @@ _dbus_marshal_test (void) * FIXME restore the set/pack tests */ -#ifdef DBUS_HAVE_INT64 /* set/pack 64-bit integers */ _dbus_string_set_length (&str, 8); @@ -1867,7 +1795,6 @@ _dbus_marshal_test (void) _dbus_assert (DBUS_UINT64_CONSTANT (0x123456789abc7) == _dbus_unpack_uint64 (DBUS_BIG_ENDIAN, _dbus_string_get_const_data (&str))); -#endif /* DBUS_HAVE_INT64 */ /* set/pack 32-bit integers */ _dbus_string_set_length (&str, 4); @@ -1992,4 +1919,4 @@ _dbus_marshal_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-marshal-basic.h b/dbus/dbus-marshal-basic.h index 034fdaba..9df67cb8 100644 --- a/dbus/dbus-marshal-basic.h +++ b/dbus/dbus-marshal-basic.h @@ -57,8 +57,6 @@ #endif /* HAVE_BYTESWAP_H */ -#ifdef DBUS_HAVE_INT64 - #ifdef HAVE_BYTESWAP_H #define DBUS_UINT64_SWAP_LE_BE_CONSTANT(val) bswap_64(val) #else /* HAVE_BYTESWAP_H */ @@ -80,7 +78,6 @@ (dbus_uint64_t) DBUS_UINT64_CONSTANT (0x00ff000000000000)) >> 40) | \ (((dbus_uint64_t) (val) & \ (dbus_uint64_t) DBUS_UINT64_CONSTANT (0xff00000000000000)) >> 56))) -#endif /* DBUS_HAVE_INT64 */ #endif /* HAVE_BYTESWAP_H */ @@ -90,10 +87,8 @@ #define DBUS_UINT32_SWAP_LE_BE(val) (DBUS_UINT32_SWAP_LE_BE_CONSTANT (val)) #define DBUS_INT32_SWAP_LE_BE(val) ((dbus_int32_t)DBUS_UINT32_SWAP_LE_BE_CONSTANT (val)) -#ifdef DBUS_HAVE_INT64 -# define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) -# define DBUS_INT64_SWAP_LE_BE(val) ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) -#endif /* DBUS_HAVE_INT64 */ +#define DBUS_UINT64_SWAP_LE_BE(val) (DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) +#define DBUS_INT64_SWAP_LE_BE(val) ((dbus_int64_t)DBUS_UINT64_SWAP_LE_BE_CONSTANT (val)) #ifdef WORDS_BIGENDIAN @@ -105,12 +100,10 @@ # define DBUS_UINT32_TO_BE(val) ((dbus_uint32_t) (val)) # define DBUS_INT32_TO_LE(val) (DBUS_INT32_SWAP_LE_BE (val)) # define DBUS_UINT32_TO_LE(val) (DBUS_UINT32_SWAP_LE_BE (val)) -# ifdef DBUS_HAVE_INT64 -# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) (val)) -# define DBUS_UINT64_TO_BE(val) ((dbus_uint64_t) (val)) -# define DBUS_INT64_TO_LE(val) (DBUS_INT64_SWAP_LE_BE (val)) -# define DBUS_UINT64_TO_LE(val) (DBUS_UINT64_SWAP_LE_BE (val)) -# endif /* DBUS_HAVE_INT64 */ +# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) (val)) +# define DBUS_UINT64_TO_BE(val) ((dbus_uint64_t) (val)) +# define DBUS_INT64_TO_LE(val) (DBUS_INT64_SWAP_LE_BE (val)) +# define DBUS_UINT64_TO_LE(val) (DBUS_UINT64_SWAP_LE_BE (val)) #else /* WORDS_BIGENDIAN */ @@ -122,12 +115,10 @@ # define DBUS_UINT32_TO_LE(val) ((dbus_uint32_t) (val)) # define DBUS_INT32_TO_BE(val) ((dbus_int32_t) DBUS_UINT32_SWAP_LE_BE (val)) # define DBUS_UINT32_TO_BE(val) (DBUS_UINT32_SWAP_LE_BE (val)) -# ifdef DBUS_HAVE_INT64 -# define DBUS_INT64_TO_LE(val) ((dbus_int64_t) (val)) -# define DBUS_UINT64_TO_LE(val) ((dbus_uint64_t) (val)) -# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val)) -# define DBUS_UINT64_TO_BE(val) (DBUS_UINT64_SWAP_LE_BE (val)) -# endif /* DBUS_HAVE_INT64 */ +# define DBUS_INT64_TO_LE(val) ((dbus_int64_t) (val)) +# define DBUS_UINT64_TO_LE(val) ((dbus_uint64_t) (val)) +# define DBUS_INT64_TO_BE(val) ((dbus_int64_t) DBUS_UINT64_SWAP_LE_BE (val)) +# define DBUS_UINT64_TO_BE(val) (DBUS_UINT64_SWAP_LE_BE (val)) #endif /* The transformation is symmetric, so the FROM just maps to the TO. */ @@ -139,12 +130,10 @@ #define DBUS_UINT32_FROM_LE(val) (DBUS_UINT32_TO_LE (val)) #define DBUS_INT32_FROM_BE(val) (DBUS_INT32_TO_BE (val)) #define DBUS_UINT32_FROM_BE(val) (DBUS_UINT32_TO_BE (val)) -#ifdef DBUS_HAVE_INT64 -# define DBUS_INT64_FROM_LE(val) (DBUS_INT64_TO_LE (val)) -# define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val)) -# define DBUS_INT64_FROM_BE(val) (DBUS_INT64_TO_BE (val)) -# define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val)) -#endif /* DBUS_HAVE_INT64 */ +#define DBUS_INT64_FROM_LE(val) (DBUS_INT64_TO_LE (val)) +#define DBUS_UINT64_FROM_LE(val) (DBUS_UINT64_TO_LE (val)) +#define DBUS_INT64_FROM_BE(val) (DBUS_INT64_TO_BE (val)) +#define DBUS_UINT64_FROM_BE(val) (DBUS_UINT64_TO_BE (val)) #ifdef DBUS_DISABLE_ASSERT #define _dbus_unpack_uint16(byte_order, data) \ diff --git a/dbus/dbus-marshal-byteswap-util.c b/dbus/dbus-marshal-byteswap-util.c index edb74cad..57874859 100644 --- a/dbus/dbus-marshal-byteswap-util.c +++ b/dbus/dbus-marshal-byteswap-util.c @@ -23,7 +23,7 @@ #include <config.h> -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-marshal-byteswap.h" #include "dbus-test.h" #include <stdio.h> @@ -102,4 +102,4 @@ _dbus_marshal_byteswap_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-marshal-byteswap.c b/dbus/dbus-marshal-byteswap.c index 22d7e22b..e6711be6 100644 --- a/dbus/dbus-marshal-byteswap.c +++ b/dbus/dbus-marshal-byteswap.c @@ -73,11 +73,7 @@ byteswap_body_helper (DBusTypeReader *reader, case DBUS_TYPE_DOUBLE: { p = _DBUS_ALIGN_ADDRESS (p, 8); -#ifdef DBUS_HAVE_INT64 *((dbus_uint64_t*)p) = DBUS_UINT64_SWAP_LE_BE (*((dbus_uint64_t*)p)); -#else - _dbus_swap_array (p, 1, 8); -#endif p += 8; } break; diff --git a/dbus/dbus-marshal-header.c b/dbus/dbus-marshal-header.c index 88887a82..48151c62 100644 --- a/dbus/dbus-marshal-header.c +++ b/dbus/dbus-marshal-header.c @@ -276,6 +276,7 @@ _dbus_header_cache_known_nonexistent (DBusHeader *header, * Writes a struct of { byte, variant } with the given basic type. * * @param writer the writer (should be ready to write a struct) + * @param field the header field * @param type the type of the value * @param value the value as for _dbus_marshal_set_basic() * @returns #FALSE if no memory @@ -336,6 +337,7 @@ write_basic_field (DBusTypeWriter *writer, * Sets a struct of { byte, variant } with the given basic type. * * @param reader the reader (should be iterating over the array pointing at the field to set) + * @param field the header field * @param type the type of the value * @param value the value as for _dbus_marshal_set_basic() * @param realign_root where to realign from @@ -452,7 +454,6 @@ _dbus_header_reinit (DBusHeader *header) * to make the header valid, you have to call _dbus_header_create(). * * @param header header to initialize - * @param byte_order byte order of the header * @returns #FALSE if not enough memory */ dbus_bool_t @@ -514,6 +515,7 @@ _dbus_header_copy (const DBusHeader *header, * sense, and passing them in will trigger an assertion failure. * * @param header the header + * @param byte_order byte order of the header * @param message_type the message type * @param destination destination field or #NULL * @param path path field or #NULL diff --git a/dbus/dbus-marshal-recursive-util.c b/dbus/dbus-marshal-recursive-util.c index 95124140..4a42b47e 100644 --- a/dbus/dbus-marshal-recursive-util.c +++ b/dbus/dbus-marshal-recursive-util.c @@ -23,7 +23,7 @@ #include <config.h> -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-marshal-recursive.h" #include "dbus-marshal-basic.h" @@ -34,13 +34,7 @@ static void basic_value_zero (DBusBasicValue *value) { - -#ifdef DBUS_HAVE_INT64 value->u64 = 0; -#else - value->eight.first32 = 0; - value->eight.second32 = 0; -#endif } static dbus_bool_t @@ -56,12 +50,7 @@ basic_value_equal (int type, } else { -#ifdef DBUS_HAVE_INT64 return lhs->u64 == rhs->u64; -#else - return lhs->eight.first32 == rhs->eight.first32 && - lhs->eight.second32 == rhs->eight.second32; -#endif } } @@ -2337,7 +2326,6 @@ int32_read_multi (TestTypeNode *node, return TRUE; } -#ifdef DBUS_HAVE_INT64 static dbus_int64_t int64_from_seed (int seed) { @@ -2351,7 +2339,6 @@ int64_from_seed (int seed) return v; } -#endif static dbus_bool_t int64_write_value (TestTypeNode *node, @@ -2359,7 +2346,6 @@ int64_write_value (TestTypeNode *node, DBusTypeWriter *writer, int seed) { -#ifdef DBUS_HAVE_INT64 /* also used for uint64 */ dbus_int64_t v; @@ -2368,9 +2354,6 @@ int64_write_value (TestTypeNode *node, return _dbus_type_writer_write_basic (writer, node->klass->typecode, &v); -#else - return TRUE; -#endif } static dbus_bool_t @@ -2378,7 +2361,6 @@ int64_read_value (TestTypeNode *node, DBusTypeReader *reader, int seed) { -#ifdef DBUS_HAVE_INT64 /* also used for uint64 */ dbus_int64_t v; @@ -2390,9 +2372,6 @@ int64_read_value (TestTypeNode *node, _dbus_assert (v == int64_from_seed (seed)); return TRUE; -#else - return TRUE; -#endif } static dbus_bool_t @@ -2401,7 +2380,6 @@ int64_set_value (TestTypeNode *node, DBusTypeReader *realign_root, int seed) { -#ifdef DBUS_HAVE_INT64 /* also used for uint64 */ dbus_int64_t v; @@ -2410,9 +2388,6 @@ int64_set_value (TestTypeNode *node, return _dbus_type_reader_set_basic (reader, &v, realign_root); -#else - return TRUE; -#endif } #define MAX_SAMPLE_STRING_LEN 10 @@ -3574,4 +3549,4 @@ container_destroy (TestTypeNode *node) #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-marshal-validate-util.c b/dbus/dbus-marshal-validate-util.c index 81135bcf..d52cb6d8 100644 --- a/dbus/dbus-marshal-validate-util.c +++ b/dbus/dbus-marshal-validate-util.c @@ -22,7 +22,7 @@ */ #include <config.h> -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -585,4 +585,4 @@ _dbus_marshal_validate_test (void) #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-memory.c b/dbus/dbus-memory.c index 317e37ee..d59e8f8c 100644 --- a/dbus/dbus-memory.c +++ b/dbus/dbus-memory.c @@ -97,7 +97,7 @@ * @{ */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static dbus_bool_t debug_initialized = FALSE; static int fail_nth = -1; static size_t fail_size = 0; @@ -240,7 +240,7 @@ _dbus_get_fail_alloc_failures (void) return n_failures_per_failure; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Called when about to alloc some memory; if * it returns #TRUE, then the allocation should @@ -294,7 +294,7 @@ _dbus_decrement_fail_alloc_counter (void) return FALSE; } } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** * Get the number of outstanding malloc()'d blocks. @@ -460,7 +460,7 @@ set_guards (void *real_block, void* dbus_malloc (size_t bytes) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_initialize_malloc_debug (); if (_dbus_decrement_fail_alloc_counter ()) @@ -472,7 +472,7 @@ dbus_malloc (size_t bytes) if (bytes == 0) /* some system mallocs handle this, some don't */ return NULL; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS else if (fail_size != 0 && bytes > fail_size) return NULL; else if (guards) @@ -499,7 +499,7 @@ dbus_malloc (size_t bytes) void *mem; mem = malloc (bytes); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (mem) { _dbus_atomic_inc (&n_blocks_outstanding); @@ -530,7 +530,7 @@ dbus_malloc (size_t bytes) void* dbus_malloc0 (size_t bytes) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_initialize_malloc_debug (); if (_dbus_decrement_fail_alloc_counter ()) @@ -543,7 +543,7 @@ dbus_malloc0 (size_t bytes) if (bytes == 0) return NULL; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS else if (fail_size != 0 && bytes > fail_size) return NULL; else if (guards) @@ -571,7 +571,7 @@ dbus_malloc0 (size_t bytes) void *mem; mem = calloc (bytes, 1); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (mem) { _dbus_atomic_inc (&n_blocks_outstanding); @@ -601,7 +601,7 @@ void* dbus_realloc (void *memory, size_t bytes) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_initialize_malloc_debug (); if (_dbus_decrement_fail_alloc_counter ()) @@ -617,7 +617,7 @@ dbus_realloc (void *memory, dbus_free (memory); return NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS else if (fail_size != 0 && bytes > fail_size) return NULL; else if (guards) @@ -677,7 +677,7 @@ dbus_realloc (void *memory, void *mem; mem = realloc (memory, bytes); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (mem == NULL && malloc_cannot_fail) { _dbus_warn ("out of memory: malloc (%ld)\n", (long) bytes); @@ -700,7 +700,7 @@ dbus_realloc (void *memory, void dbus_free (void *memory) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (guards) { check_guards (memory, TRUE); @@ -724,7 +724,7 @@ dbus_free (void *memory) if (memory) /* we guarantee it's safe to free (NULL) */ { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifdef DBUS_DISABLE_ASSERT _dbus_atomic_dec (&n_blocks_outstanding); #else @@ -795,7 +795,7 @@ struct ShutdownClosure void *data; /**< Data for function */ }; -_DBUS_DEFINE_GLOBAL_LOCK (shutdown_funcs); +/* Protected by _DBUS_LOCK (shutdown_funcs) */ static ShutdownClosure *registered_globals = NULL; /** @@ -810,6 +810,20 @@ dbus_bool_t _dbus_register_shutdown_func (DBusShutdownFunction func, void *data) { + dbus_bool_t ok; + + if (!_DBUS_LOCK (shutdown_funcs)) + return FALSE; + + ok = _dbus_register_shutdown_func_unlocked (func, data); + _DBUS_UNLOCK (shutdown_funcs); + return ok; +} + +dbus_bool_t +_dbus_register_shutdown_func_unlocked (DBusShutdownFunction func, + void *data) +{ ShutdownClosure *c; c = dbus_new (ShutdownClosure, 1); @@ -820,13 +834,9 @@ _dbus_register_shutdown_func (DBusShutdownFunction func, c->func = func; c->data = data; - _DBUS_LOCK (shutdown_funcs); - c->next = registered_globals; registered_globals = c; - _DBUS_UNLOCK (shutdown_funcs); - return TRUE; } @@ -902,7 +912,7 @@ dbus_shutdown (void) /** @} */ /** End of public API docs block */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" /** diff --git a/dbus/dbus-mempool.c b/dbus/dbus-mempool.c index 0c3f117d..52466151 100644 --- a/dbus/dbus-mempool.c +++ b/dbus/dbus-mempool.c @@ -213,7 +213,7 @@ _dbus_mem_pool_free (DBusMemPool *pool) void* _dbus_mem_pool_alloc (DBusMemPool *pool) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (_dbus_disable_mem_pools ()) { DBusMemBlock *block; @@ -280,7 +280,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) /* Need a new block */ DBusMemBlock *block; int alloc_size; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS int saved_counter; #endif @@ -294,7 +294,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) alloc_size = sizeof (DBusMemBlock) - ELEMENT_PADDING + pool->block_size; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* We save/restore the counter, so that memory pools won't * cause a given function to have different number of * allocations on different invocations. i.e. when testing @@ -310,7 +310,7 @@ _dbus_mem_pool_alloc (DBusMemPool *pool) else block = dbus_malloc (alloc_size); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS _dbus_set_fail_alloc_counter (saved_counter); _dbus_assert (saved_counter == _dbus_get_fail_alloc_counter ()); #endif @@ -349,7 +349,7 @@ _dbus_mem_pool_dealloc (DBusMemPool *pool, { VALGRIND_MEMPOOL_FREE (pool, element); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (_dbus_disable_mem_pools ()) { DBusMemBlock *block; @@ -393,7 +393,7 @@ _dbus_mem_pool_dealloc (DBusMemPool *pool, freed = element; /* used for internal mempool administration */ - VALGRIND_MAKE_MEM_UNDEFINED (freed, sizeof (freed)); + VALGRIND_MAKE_MEM_UNDEFINED (freed, sizeof (*freed)); freed->next = pool->free_elements; pool->free_elements = freed; @@ -449,7 +449,7 @@ _dbus_mem_pool_get_stats (DBusMemPool *pool, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> #include <time.h> @@ -459,8 +459,10 @@ time_for_size (int size) { int i; int j; +#ifdef DBUS_ENABLE_VERBOSE_MODE clock_t start; clock_t end; +#endif #define FREE_ARRAY_SIZE 512 #define N_ITERATIONS FREE_ARRAY_SIZE * 512 void *to_free[FREE_ARRAY_SIZE]; @@ -470,8 +472,10 @@ time_for_size (int size) _dbus_verbose (" malloc\n"); +#ifdef DBUS_ENABLE_VERBOSE_MODE start = clock (); - +#endif + i = 0; j = 0; while (i < N_ITERATIONS) @@ -496,6 +500,7 @@ time_for_size (int size) ++i; } +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", @@ -506,6 +511,7 @@ time_for_size (int size) _dbus_verbose (" mempools\n"); start = clock (); +#endif pool = _dbus_mem_pool_new (size, FALSE); @@ -535,6 +541,7 @@ time_for_size (int size) _dbus_mem_pool_free (pool); +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", @@ -543,6 +550,7 @@ time_for_size (int size) _dbus_verbose (" zeroed malloc\n"); start = clock (); +#endif i = 0; j = 0; @@ -568,6 +576,7 @@ time_for_size (int size) ++i; } +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", @@ -576,6 +585,7 @@ time_for_size (int size) _dbus_verbose (" zeroed mempools\n"); start = clock (); +#endif pool = _dbus_mem_pool_new (size, TRUE); @@ -605,10 +615,12 @@ time_for_size (int size) _dbus_mem_pool_free (pool); +#ifdef DBUS_ENABLE_VERBOSE_MODE end = clock (); _dbus_verbose (" created/destroyed %d elements in %g seconds\n", N_ITERATIONS, (end - start) / (double) CLOCKS_PER_SEC); +#endif } /** @@ -632,4 +644,4 @@ _dbus_mem_pool_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-message-factory.c b/dbus/dbus-message-factory.c index efa4e029..b742e4c1 100644 --- a/dbus/dbus-message-factory.c +++ b/dbus/dbus-message-factory.c @@ -24,7 +24,7 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-message-factory.h" #include "dbus-message-private.h" #include "dbus-signature.h" @@ -1302,4 +1302,4 @@ _dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter, #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-message-factory.h b/dbus/dbus-message-factory.h index b0747504..fd7a4764 100644 --- a/dbus/dbus-message-factory.h +++ b/dbus/dbus-message-factory.h @@ -24,7 +24,7 @@ #ifndef DBUS_MESSAGE_FACTORY_H #define DBUS_MESSAGE_FACTORY_H -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include <dbus/dbus-string.h> #include <dbus/dbus-marshal-basic.h> @@ -56,6 +56,6 @@ dbus_bool_t _dbus_message_data_iter_get_and_next (DBusMessageDataIter *iter, DBUS_END_DECLS -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ #endif /* DBUS_MESSAGE_FACTORY_H */ diff --git a/dbus/dbus-message-internal.h b/dbus/dbus-message-internal.h index c1948732..5d6594e3 100644 --- a/dbus/dbus-message-internal.h +++ b/dbus/dbus-message-internal.h @@ -70,8 +70,7 @@ void _dbus_message_loader_unref (DBusMessageLoader void _dbus_message_loader_get_buffer (DBusMessageLoader *loader, DBusString **buffer); void _dbus_message_loader_return_buffer (DBusMessageLoader *loader, - DBusString *buffer, - int bytes_read); + DBusString *buffer); dbus_bool_t _dbus_message_loader_get_unix_fds (DBusMessageLoader *loader, int **fds, diff --git a/dbus/dbus-message-util.c b/dbus/dbus-message-util.c index f7859520..8f36dc0a 100644 --- a/dbus/dbus-message-util.c +++ b/dbus/dbus-message-util.c @@ -45,7 +45,7 @@ * @{ */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Reads arguments from a message iterator given a variable argument * list. Only arguments of basic type and arrays of fixed-length @@ -76,11 +76,11 @@ dbus_message_iter_get_args (DBusMessageIter *iter, return retval; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include "dbus-message-factory.h" #include <stdio.h> @@ -493,7 +493,7 @@ dbus_internal_do_not_use_try_message_data (const DBusString *data, _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_byte (buffer, _dbus_string_get_byte (data, i)); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } if (!check_loader_results (loader, expected_validity)) @@ -512,7 +512,7 @@ dbus_internal_do_not_use_try_message_data (const DBusString *data, _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_copy (data, 0, buffer, _dbus_string_get_length (buffer)); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } if (!check_loader_results (loader, expected_validity)) @@ -536,7 +536,7 @@ dbus_internal_do_not_use_try_message_data (const DBusString *data, if ((i+1) < len) _dbus_string_append_byte (buffer, _dbus_string_get_byte (data, i+1)); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } if (!check_loader_results (loader, expected_validity)) @@ -754,10 +754,8 @@ message_iter_test (DBusMessage *message) dbus_uint16_t v_UINT16; dbus_int32_t v_INT32; dbus_uint32_t v_UINT32; -#ifdef DBUS_HAVE_INT64 dbus_int64_t v_INT64; dbus_uint64_t v_UINT64; -#endif unsigned char v_BYTE; dbus_bool_t v_BOOLEAN; @@ -830,14 +828,12 @@ verify_test_message (DBusMessage *message) int our_uint32_array_len; dbus_int32_t *our_int32_array = (void*)0xdeadbeef; int our_int32_array_len; -#ifdef DBUS_HAVE_INT64 dbus_int64_t our_int64; dbus_uint64_t our_uint64; dbus_int64_t *our_uint64_array = (void*)0xdeadbeef; int our_uint64_array_len; const dbus_int64_t *our_int64_array = (void*)0xdeadbeef; int our_int64_array_len; -#endif const double *our_double_array = (void*)0xdeadbeef; int our_double_array_len; const unsigned char *our_byte_array = (void*)0xdeadbeef; @@ -854,10 +850,8 @@ verify_test_message (DBusMessage *message) DBUS_TYPE_UINT16, &our_uint16, DBUS_TYPE_INT32, &our_int, DBUS_TYPE_UINT32, &our_uint, -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_INT64, &our_int64, DBUS_TYPE_UINT64, &our_uint64, -#endif DBUS_TYPE_STRING, &our_str, DBUS_TYPE_DOUBLE, &our_double, DBUS_TYPE_BOOLEAN, &our_bool, @@ -867,12 +861,10 @@ verify_test_message (DBusMessage *message) &our_uint32_array, &our_uint32_array_len, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &our_int32_array, &our_int32_array_len, -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, &our_uint64_array, &our_uint64_array_len, DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, &our_int64_array, &our_int64_array_len, -#endif DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, &our_double_array, &our_double_array_len, DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, @@ -900,12 +892,10 @@ verify_test_message (DBusMessage *message) if (our_uint != 0x12300042) _dbus_assert_not_reached ("uints differ!"); -#ifdef DBUS_HAVE_INT64 if (our_int64 != DBUS_INT64_CONSTANT (-0x123456789abcd)) _dbus_assert_not_reached ("64-bit integers differ!"); if (our_uint64 != DBUS_UINT64_CONSTANT (0x123456789abcd)) _dbus_assert_not_reached ("64-bit unsigned integers differ!"); -#endif v_DOUBLE = 3.14159; if (! _DBUS_DOUBLES_BITWISE_EQUAL (our_double, v_DOUBLE)) @@ -937,7 +927,6 @@ verify_test_message (DBusMessage *message) our_int32_array[3] != -0x45678123) _dbus_assert_not_reached ("int array differs"); -#ifdef DBUS_HAVE_INT64 if (our_uint64_array_len != 4 || our_uint64_array[0] != 0x12345678 || our_uint64_array[1] != 0x23456781 || @@ -951,7 +940,6 @@ verify_test_message (DBusMessage *message) our_int64_array[2] != 0x34567812 || our_int64_array[3] != -0x45678123) _dbus_assert_not_reached ("int64 array differs"); -#endif /* DBUS_HAVE_INT64 */ if (our_double_array_len != 3) _dbus_assert_not_reached ("double array had wrong length"); @@ -1025,14 +1013,12 @@ _dbus_message_test (const char *test_data_dir) { 0x12345678, -0x23456781, 0x34567812, -0x45678123 }; const dbus_uint32_t *v_ARRAY_UINT32 = our_uint32_array; const dbus_int32_t *v_ARRAY_INT32 = our_int32_array; -#ifdef DBUS_HAVE_INT64 const dbus_uint64_t our_uint64_array[] = { 0x12345678, 0x23456781, 0x34567812, 0x45678123 }; const dbus_int64_t our_int64_array[] = { 0x12345678, -0x23456781, 0x34567812, -0x45678123 }; const dbus_uint64_t *v_ARRAY_UINT64 = our_uint64_array; const dbus_int64_t *v_ARRAY_INT64 = our_int64_array; -#endif const char *our_string_array[] = { "Foo", "bar", "", "woo woo woo woo" }; const char **v_ARRAY_STRING = our_string_array; const double our_double_array[] = { 0.1234, 9876.54321, -300.0 }; @@ -1049,10 +1035,8 @@ _dbus_message_test (const char *test_data_dir) dbus_uint16_t v_UINT16; dbus_int32_t v_INT32; dbus_uint32_t v_UINT32; -#ifdef DBUS_HAVE_INT64 dbus_int64_t v_INT64; dbus_uint64_t v_UINT64; -#endif unsigned char v_BYTE; unsigned char v2_BYTE; dbus_bool_t v_BOOLEAN; @@ -1201,10 +1185,8 @@ _dbus_message_test (const char *test_data_dir) v_UINT16 = 0x123; v_INT32 = -0x12345678; v_UINT32 = 0x12300042; -#ifdef DBUS_HAVE_INT64 v_INT64 = DBUS_INT64_CONSTANT (-0x123456789abcd); v_UINT64 = DBUS_UINT64_CONSTANT (0x123456789abcd); -#endif v_STRING = "Test string"; v_DOUBLE = 3.14159; v_BOOLEAN = TRUE; @@ -1219,10 +1201,8 @@ _dbus_message_test (const char *test_data_dir) DBUS_TYPE_UINT16, &v_UINT16, DBUS_TYPE_INT32, &v_INT32, DBUS_TYPE_UINT32, &v_UINT32, -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_INT64, &v_INT64, DBUS_TYPE_UINT64, &v_UINT64, -#endif DBUS_TYPE_STRING, &v_STRING, DBUS_TYPE_DOUBLE, &v_DOUBLE, DBUS_TYPE_BOOLEAN, &v_BOOLEAN, @@ -1232,12 +1212,10 @@ _dbus_message_test (const char *test_data_dir) _DBUS_N_ELEMENTS (our_uint32_array), DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, &v_ARRAY_INT32, _DBUS_N_ELEMENTS (our_int32_array), -#ifdef DBUS_HAVE_INT64 DBUS_TYPE_ARRAY, DBUS_TYPE_UINT64, &v_ARRAY_UINT64, _DBUS_N_ELEMENTS (our_uint64_array), DBUS_TYPE_ARRAY, DBUS_TYPE_INT64, &v_ARRAY_INT64, _DBUS_N_ELEMENTS (our_int64_array), -#endif DBUS_TYPE_ARRAY, DBUS_TYPE_DOUBLE, &v_ARRAY_DOUBLE, _DBUS_N_ELEMENTS (our_double_array), DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &v_ARRAY_BYTE, @@ -1254,10 +1232,8 @@ _dbus_message_test (const char *test_data_dir) sig[i++] = DBUS_TYPE_UINT16; sig[i++] = DBUS_TYPE_INT32; sig[i++] = DBUS_TYPE_UINT32; -#ifdef DBUS_HAVE_INT64 sig[i++] = DBUS_TYPE_INT64; sig[i++] = DBUS_TYPE_UINT64; -#endif sig[i++] = DBUS_TYPE_STRING; sig[i++] = DBUS_TYPE_DOUBLE; sig[i++] = DBUS_TYPE_BOOLEAN; @@ -1267,12 +1243,10 @@ _dbus_message_test (const char *test_data_dir) sig[i++] = DBUS_TYPE_UINT32; sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_INT32; -#ifdef DBUS_HAVE_INT64 sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_UINT64; sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_INT64; -#endif sig[i++] = DBUS_TYPE_ARRAY; sig[i++] = DBUS_TYPE_DOUBLE; sig[i++] = DBUS_TYPE_ARRAY; @@ -1353,7 +1327,7 @@ _dbus_message_test (const char *test_data_dir) _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_byte (buffer, data[i]); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } /* Write the body data one byte at a time */ @@ -1364,7 +1338,7 @@ _dbus_message_test (const char *test_data_dir) _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_byte (buffer, data[i]); - _dbus_message_loader_return_buffer (loader, buffer, 1); + _dbus_message_loader_return_buffer (loader, buffer); } #ifdef HAVE_UNIX_FD_PASSING @@ -1542,4 +1516,4 @@ _dbus_message_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c index 619bc695..9546da12 100644 --- a/dbus/dbus-message.c +++ b/dbus/dbus-message.c @@ -56,7 +56,7 @@ static void dbus_message_finalize (DBusMessage *message); * @{ */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static dbus_bool_t _dbus_enable_message_cache (void) { @@ -506,7 +506,7 @@ _dbus_message_set_signature (DBusMessage *message, /** Avoid caching too many messages */ #define MAX_MESSAGE_CACHE_SIZE 5 -_DBUS_DEFINE_GLOBAL_LOCK (message_cache); +/* Protected by _DBUS_LOCK (message_cache) */ static DBusMessage *message_cache[MAX_MESSAGE_CACHE_SIZE]; static int message_cache_count = 0; static dbus_bool_t message_cache_shutdown_registered = FALSE; @@ -516,7 +516,9 @@ dbus_message_cache_shutdown (void *data) { int i; - _DBUS_LOCK (message_cache); + if (!_DBUS_LOCK (message_cache)) + _dbus_assert_not_reached ("we would have initialized global locks " + "before registering a shutdown function"); i = 0; while (i < MAX_MESSAGE_CACHE_SIZE) @@ -548,7 +550,12 @@ dbus_message_get_cached (void) message = NULL; - _DBUS_LOCK (message_cache); + if (!_DBUS_LOCK (message_cache)) + { + /* we'd have initialized global locks before caching anything, + * so there can't be anything in the cache */ + return NULL; + } _dbus_assert (message_cache_count >= 0); @@ -660,7 +667,13 @@ dbus_message_cache_or_finalize (DBusMessage *message) was_cached = FALSE; - _DBUS_LOCK (message_cache); + if (!_DBUS_LOCK (message_cache)) + { + /* The only way to get a non-null message goes through + * dbus_message_get_cached() which takes the lock. */ + _dbus_assert_not_reached ("we would have initialized global locks " + "the first time we constructed a message"); + } if (!message_cache_shutdown_registered) { @@ -716,7 +729,7 @@ dbus_message_cache_or_finalize (DBusMessage *message) dbus_message_finalize (message); } -#ifndef DBUS_DISABLE_CHECKS +#if defined(DBUS_ENABLE_CHECKS) || defined(DBUS_ENABLE_ASSERT) static dbus_bool_t _dbus_message_iter_check (DBusMessageRealIter *iter) { @@ -764,7 +777,7 @@ _dbus_message_iter_check (DBusMessageRealIter *iter) return TRUE; } -#endif /* DBUS_DISABLE_CHECKS */ +#endif /* DBUS_ENABLE_CHECKS || DBUS_ENABLE_ASSERT */ /** * Implementation of the varargs arg-getting functions. @@ -787,7 +800,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, va_list var_args) { DBusMessageRealIter *real = (DBusMessageRealIter *)iter; - int spec_type, msg_type, i; + int spec_type, msg_type, i, j; dbus_bool_t retval; _dbus_assert (_dbus_message_iter_check (real)); @@ -923,30 +936,30 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, /* Now go through and dup each string */ _dbus_type_reader_recurse (&real->u.reader, &array); - i = 0; - while (i < n_elements) + j = 0; + while (j < n_elements) { const char *s; _dbus_type_reader_read_basic (&array, (void *) &s); - str_array[i] = _dbus_strdup (s); - if (str_array[i] == NULL) + str_array[j] = _dbus_strdup (s); + if (str_array[j] == NULL) { dbus_free_string_array (str_array); _DBUS_SET_OOM (error); goto out; } - ++i; + ++j; if (!_dbus_type_reader_next (&array)) - _dbus_assert (i == n_elements); + _dbus_assert (j == n_elements); } _dbus_assert (_dbus_type_reader_get_current_type (&array) == DBUS_TYPE_INVALID); - _dbus_assert (i == n_elements); - _dbus_assert (str_array[i] == NULL); + _dbus_assert (j == n_elements); + _dbus_assert (str_array[j] == NULL); *str_array_p = str_array; *n_elements_p = n_elements; @@ -973,7 +986,7 @@ _dbus_message_iter_get_args_valist (DBusMessageIter *iter, if (!_dbus_type_reader_next (&real->u.reader) && spec_type != DBUS_TYPE_INVALID) { dbus_set_error (error, DBUS_ERROR_INVALID_ARGS, - "Message has only %d arguments, but more were expected", i); + "Message has only %d arguments, but more were expected", i + 1); goto out; } @@ -1246,7 +1259,7 @@ dbus_message_new (int message_type) * * @param destination name that the message should be sent to or #NULL * @param path object path the message should be sent to - * @param interface interface to invoke method on, or #NULL + * @param iface interface to invoke method on, or #NULL * @param method method to invoke * * @returns a new DBusMessage, free with dbus_message_unref() @@ -1254,7 +1267,7 @@ dbus_message_new (int message_type) DBusMessage* dbus_message_new_method_call (const char *destination, const char *path, - const char *interface, + const char *iface, const char *method) { DBusMessage *message; @@ -1264,8 +1277,8 @@ dbus_message_new_method_call (const char *destination, _dbus_return_val_if_fail (destination == NULL || _dbus_check_is_valid_bus_name (destination), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_path (path), NULL); - _dbus_return_val_if_fail (interface == NULL || - _dbus_check_is_valid_interface (interface), NULL); + _dbus_return_val_if_fail (iface == NULL || + _dbus_check_is_valid_interface (iface), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_member (method), NULL); message = dbus_message_new_empty_header (); @@ -1275,7 +1288,7 @@ dbus_message_new_method_call (const char *destination, if (!_dbus_header_create (&message->header, DBUS_COMPILER_BYTE_ORDER, DBUS_MESSAGE_TYPE_METHOD_CALL, - destination, path, interface, method, NULL)) + destination, path, iface, method, NULL)) { dbus_message_unref (message); return NULL; @@ -1338,22 +1351,22 @@ dbus_message_new_method_return (DBusMessage *method_call) * specification defines the syntax of these fields). * * @param path the path to the object emitting the signal - * @param interface the interface the signal is emitted from + * @param iface the interface the signal is emitted from * @param name name of the signal * @returns a new DBusMessage, free with dbus_message_unref() */ DBusMessage* dbus_message_new_signal (const char *path, - const char *interface, + const char *iface, const char *name) { DBusMessage *message; _dbus_return_val_if_fail (path != NULL, NULL); - _dbus_return_val_if_fail (interface != NULL, NULL); + _dbus_return_val_if_fail (iface != NULL, NULL); _dbus_return_val_if_fail (name != NULL, NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_path (path), NULL); - _dbus_return_val_if_fail (_dbus_check_is_valid_interface (interface), NULL); + _dbus_return_val_if_fail (_dbus_check_is_valid_interface (iface), NULL); _dbus_return_val_if_fail (_dbus_check_is_valid_member (name), NULL); message = dbus_message_new_empty_header (); @@ -1363,7 +1376,7 @@ dbus_message_new_signal (const char *path, if (!_dbus_header_create (&message->header, DBUS_COMPILER_BYTE_ORDER, DBUS_MESSAGE_TYPE_SIGNAL, - NULL, path, interface, name, NULL)) + NULL, path, iface, name, NULL)) { dbus_message_unref (message); return NULL; @@ -3113,23 +3126,23 @@ dbus_message_get_path_decomposed (DBusMessage *message, * in the D-Bus specification. * * @param message the message - * @param interface the interface or #NULL to unset + * @param iface the interface or #NULL to unset * @returns #FALSE if not enough memory */ dbus_bool_t dbus_message_set_interface (DBusMessage *message, - const char *interface) + const char *iface) { _dbus_return_val_if_fail (message != NULL, FALSE); _dbus_return_val_if_fail (!message->locked, FALSE); - _dbus_return_val_if_fail (interface == NULL || - _dbus_check_is_valid_interface (interface), + _dbus_return_val_if_fail (iface == NULL || + _dbus_check_is_valid_interface (iface), FALSE); return set_or_delete_string_field (message, DBUS_HEADER_FIELD_INTERFACE, DBUS_TYPE_STRING, - interface); + iface); } /** @@ -3164,28 +3177,28 @@ dbus_message_get_interface (DBusMessage *message) * Checks if the message has an interface * * @param message the message - * @param interface the interface name + * @param iface the interface name * @returns #TRUE if the interface field in the header matches */ dbus_bool_t dbus_message_has_interface (DBusMessage *message, - const char *interface) + const char *iface) { const char *msg_interface; msg_interface = dbus_message_get_interface (message); if (msg_interface == NULL) { - if (interface == NULL) + if (iface == NULL) return TRUE; else return FALSE; } - if (interface == NULL) + if (iface == NULL) return FALSE; - if (strcmp (msg_interface, interface) == 0) + if (strcmp (msg_interface, iface) == 0) return TRUE; return FALSE; @@ -3477,13 +3490,13 @@ dbus_message_get_signature (DBusMessage *message) static dbus_bool_t _dbus_message_has_type_interface_member (DBusMessage *message, int type, - const char *interface, + const char *iface, const char *member) { const char *n; _dbus_assert (message != NULL); - _dbus_assert (interface != NULL); + _dbus_assert (iface != NULL); _dbus_assert (member != NULL); if (dbus_message_get_type (message) != type) @@ -3499,7 +3512,7 @@ _dbus_message_has_type_interface_member (DBusMessage *message, { n = dbus_message_get_interface (message); - if (n == NULL || strcmp (n, interface) == 0) + if (n == NULL || strcmp (n, iface) == 0) return TRUE; } @@ -3515,18 +3528,18 @@ _dbus_message_has_type_interface_member (DBusMessage *message, * protocol allows method callers to leave out the interface name. * * @param message the message - * @param interface the name to check (must not be #NULL) + * @param iface the name to check (must not be #NULL) * @param method the name to check (must not be #NULL) * * @returns #TRUE if the message is the specified method call */ dbus_bool_t dbus_message_is_method_call (DBusMessage *message, - const char *interface, + const char *iface, const char *method) { _dbus_return_val_if_fail (message != NULL, FALSE); - _dbus_return_val_if_fail (interface != NULL, FALSE); + _dbus_return_val_if_fail (iface != NULL, FALSE); _dbus_return_val_if_fail (method != NULL, FALSE); /* don't check that interface/method are valid since it would be * expensive, and not catch many common errors @@ -3534,7 +3547,7 @@ dbus_message_is_method_call (DBusMessage *message, return _dbus_message_has_type_interface_member (message, DBUS_MESSAGE_TYPE_METHOD_CALL, - interface, method); + iface, method); } /** @@ -3543,18 +3556,18 @@ dbus_message_is_method_call (DBusMessage *message, * has a different interface or member field, returns #FALSE. * * @param message the message - * @param interface the name to check (must not be #NULL) + * @param iface the name to check (must not be #NULL) * @param signal_name the name to check (must not be #NULL) * * @returns #TRUE if the message is the specified signal */ dbus_bool_t dbus_message_is_signal (DBusMessage *message, - const char *interface, + const char *iface, const char *signal_name) { _dbus_return_val_if_fail (message != NULL, FALSE); - _dbus_return_val_if_fail (interface != NULL, FALSE); + _dbus_return_val_if_fail (iface != NULL, FALSE); _dbus_return_val_if_fail (signal_name != NULL, FALSE); /* don't check that interface/name are valid since it would be * expensive, and not catch many common errors @@ -3562,7 +3575,7 @@ dbus_message_is_signal (DBusMessage *message, return _dbus_message_has_type_interface_member (message, DBUS_MESSAGE_TYPE_SIGNAL, - interface, signal_name); + iface, signal_name); } /** @@ -3899,12 +3912,10 @@ _dbus_message_loader_get_buffer (DBusMessageLoader *loader, * * @param loader the loader. * @param buffer the buffer. - * @param bytes_read number of bytes that were read into the buffer. */ void _dbus_message_loader_return_buffer (DBusMessageLoader *loader, - DBusString *buffer, - int bytes_read) + DBusString *buffer) { _dbus_assert (loader->buffer_outstanding); _dbus_assert (buffer == &loader->data); @@ -3968,7 +3979,7 @@ _dbus_message_loader_get_unix_fds(DBusMessageLoader *loader, * * @param loader the message loader. * @param fds the array fds were read into - * @param max_n_fds how many fds were read + * @param n_fds how many fds were read */ void @@ -4396,7 +4407,7 @@ _dbus_message_loader_get_max_message_size (DBusMessageLoader *loader) * Sets the maximum unix fds per message we allow. * * @param loader the loader - * @param size the max number of unix fds in a message + * @param n the max number of unix fds in a message */ void _dbus_message_loader_set_max_message_unix_fds (DBusMessageLoader *loader, @@ -4423,8 +4434,8 @@ _dbus_message_loader_get_max_message_unix_fds (DBusMessageLoader *loader) return loader->max_message_unix_fds; } -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (message_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (message_slots)); /** * Allocates an integer ID to be used for storing application-specific @@ -4444,7 +4455,6 @@ dbus_bool_t dbus_message_allocate_data_slot (dbus_int32_t *slot_p) { return _dbus_data_slot_allocator_alloc (&slot_allocator, - &_DBUS_LOCK_NAME (message_slots), slot_p); } @@ -4682,7 +4692,7 @@ dbus_message_demarshal (const char *str, _dbus_message_loader_get_buffer (loader, &buffer); _dbus_string_append_len (buffer, str, len); - _dbus_message_loader_return_buffer (loader, buffer, len); + _dbus_message_loader_return_buffer (loader, buffer); if (!_dbus_message_loader_queue_messages (loader)) goto fail_oom; @@ -4717,9 +4727,8 @@ dbus_message_demarshal (const char *str, * Generally, this function is only useful for encapsulating D-Bus messages in * a different protocol. * - * @param str data to be marshalled - * @param len the length of str - * @param error the location to save errors to + * @param buf data to be marshalled + * @param len the length of @p buf * @returns -1 if there was no valid data to be demarshalled, 0 if there wasn't enough data to determine how much should be demarshalled. Otherwise returns the number of bytes to be demarshalled * */ diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h index 5500492d..4fd44dab 100644 --- a/dbus/dbus-message.h +++ b/dbus/dbus-message.h @@ -71,13 +71,13 @@ DBusMessage* dbus_message_new (int message_type); DBUS_EXPORT DBusMessage* dbus_message_new_method_call (const char *bus_name, const char *path, - const char *interface, + const char *iface, const char *method); DBUS_EXPORT DBusMessage* dbus_message_new_method_return (DBusMessage *method_call); DBUS_EXPORT DBusMessage* dbus_message_new_signal (const char *path, - const char *interface, + const char *iface, const char *name); DBUS_EXPORT DBusMessage* dbus_message_new_error (DBusMessage *reply_to, @@ -108,12 +108,12 @@ dbus_bool_t dbus_message_has_path (DBusMessage *message, const char *object_path); DBUS_EXPORT dbus_bool_t dbus_message_set_interface (DBusMessage *message, - const char *interface); + const char *iface); DBUS_EXPORT const char* dbus_message_get_interface (DBusMessage *message); DBUS_EXPORT dbus_bool_t dbus_message_has_interface (DBusMessage *message, - const char *interface); + const char *iface); DBUS_EXPORT dbus_bool_t dbus_message_set_member (DBusMessage *message, const char *member); @@ -146,11 +146,11 @@ DBUS_EXPORT dbus_bool_t dbus_message_get_no_reply (DBusMessage *message); DBUS_EXPORT dbus_bool_t dbus_message_is_method_call (DBusMessage *message, - const char *interface, + const char *iface, const char *method); DBUS_EXPORT dbus_bool_t dbus_message_is_signal (DBusMessage *message, - const char *interface, + const char *iface, const char *signal_name); DBUS_EXPORT dbus_bool_t dbus_message_is_error (DBusMessage *message, diff --git a/dbus/dbus-misc.c b/dbus/dbus-misc.c index b1610133..6ca30f24 100644 --- a/dbus/dbus-misc.c +++ b/dbus/dbus-misc.c @@ -173,7 +173,7 @@ dbus_get_version (int *major_version_p, /** @} */ /* End of public API */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/dbus/dbus-misc.h b/dbus/dbus-misc.h index 3504bcaa..6e72d9ed 100644 --- a/dbus/dbus-misc.h +++ b/dbus/dbus-misc.h @@ -44,6 +44,10 @@ void dbus_get_version (int *major_version_p, int *minor_version_p, int *micro_version_p); +DBUS_EXPORT +dbus_bool_t dbus_setenv (const char *variable, + const char *value); + /** @} */ DBUS_END_DECLS diff --git a/dbus/dbus-nonce.c b/dbus/dbus-nonce.c index e74c2dd5..ef037ef9 100644 --- a/dbus/dbus-nonce.c +++ b/dbus/dbus-nonce.c @@ -240,6 +240,7 @@ do_noncefile_create (DBusNonceFile *noncefile, dbus_bool_t use_subdir) { DBusString randomStr; + const char *tmp; _DBUS_ASSERT_ERROR_IS_CLEAR (error); @@ -257,8 +258,11 @@ do_noncefile_create (DBusNonceFile *noncefile, goto on_error; } + tmp = _dbus_get_tmpdir (); + if (!_dbus_string_init (&noncefile->dir) - || !_dbus_string_append (&noncefile->dir, _dbus_get_tmpdir())) + || tmp == NULL + || !_dbus_string_append (&noncefile->dir, tmp)) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); goto on_error; diff --git a/dbus/dbus-object-tree.c b/dbus/dbus-object-tree.c index 172c9d95..d256018e 100644 --- a/dbus/dbus-object-tree.c +++ b/dbus/dbus-object-tree.c @@ -434,6 +434,185 @@ _dbus_object_tree_register (DBusObjectTree *tree, } /** + * Attempts to unregister the given subtree. If the subtree is registered, + * stores its unregister function and user data for later use and returns + * #TRUE. If subtree is not registered, simply returns #FALSE. Does not free + * subtree or remove it from the object tree. + * + * @param subtree the subtree to unregister + * @param unregister_function_out stores subtree's unregister_function + * @param user_data_out stores subtree's user_data + * @return #FALSE if the subtree was not registered, #TRUE on success + */ +static dbus_bool_t +unregister_subtree (DBusObjectSubtree *subtree, + DBusObjectPathUnregisterFunction *unregister_function_out, + void **user_data_out) +{ + _dbus_assert (subtree != NULL); + _dbus_assert (unregister_function_out != NULL); + _dbus_assert (user_data_out != NULL); + + /* Confirm subtree is registered */ + if (subtree->message_function != NULL) + { + subtree->message_function = NULL; + + *unregister_function_out = subtree->unregister_function; + *user_data_out = subtree->user_data; + + subtree->unregister_function = NULL; + subtree->user_data = NULL; + + return TRUE; + } + else + { + /* Assert that this unregistered subtree is either the root node or has + children, otherwise we have a dangling path which should never + happen */ + _dbus_assert (subtree->parent == NULL || subtree->n_subtrees > 0); + + /* The subtree is not registered */ + return FALSE; + } +} + +/** + * Attempts to remove a child subtree from its parent. If removal is + * successful, also frees the child. Returns #TRUE on success, #FALSE + * otherwise. A #FALSE return value tells unregister_and_free_path_recurse to + * stop attempting to remove ancestors, i.e., that no ancestors of the + * specified child are eligible for removal. + * + * @param parent parent from which to remove child + * @param child_index parent->subtrees index of child to remove + * @return #TRUE if removal and free succeed, #FALSE otherwise + */ +static dbus_bool_t +attempt_child_removal (DBusObjectSubtree *parent, + int child_index) +{ + /* Candidate for removal */ + DBusObjectSubtree* candidate; + + _dbus_assert (parent != NULL); + _dbus_assert (child_index >= 0 && child_index < parent->n_subtrees); + + candidate = parent->subtrees[child_index]; + _dbus_assert (candidate != NULL); + + if (candidate->n_subtrees == 0 && candidate->message_function == NULL) + { + /* The candidate node is childless and is not a registered + path, so... */ + + /* ... remove it from its parent... */ + /* Assumes a 0-byte memmove is OK */ + memmove (&parent->subtrees[child_index], + &parent->subtrees[child_index + 1], + (parent->n_subtrees - child_index - 1) + * sizeof (parent->subtrees[0])); + parent->n_subtrees -= 1; + + /* ... and free it */ + candidate->parent = NULL; + _dbus_object_subtree_unref (candidate); + + return TRUE; + } + return FALSE; +} + +/** + * Searches the object tree for a registered subtree node at the given path. + * If a registered node is found, it is removed from the tree and freed, and + * TRUE is returned. If a registered subtree node is not found at the given + * path, the tree is not modified and FALSE is returned. + * + * The found node's unregister_function and user_data are returned in the + * corresponding _out arguments. The caller should define these variables and + * pass their addresses as arguments. + * + * Likewise, the caller should define and set to TRUE a boolean variable, then + * pass its address as the continue_removal_attempts argument. + * + * Once a matching registered node is found, removed and freed, the recursive + * return path is traversed. Along the way, eligible ancestor nodes are + * removed and freed. An ancestor node is eligible for removal if and only if + * 1) it has no children, i.e., it has become childless and 2) it is not itself + * a registered handler. + * + * For example, suppose /A/B and /A/C are registered paths, and that these are + * the only paths in the tree. If B is removed and freed, C is still reachable + * through A, so A cannot be removed and freed. If C is subsequently removed + * and freed, then A becomes a childless node and it becomes eligible for + * removal, and will be removed and freed. + * + * Similarly, suppose /A is a registered path, and /A/B is also a registered + * path, and that these are the only paths in the tree. If B is removed and + * freed, then even though A has become childless, it can't be freed because it + * refers to a path that is still registered. + * + * @param subtree subtree from which to start the search, root for initial call + * @param path path to subtree (same as _dbus_object_tree_unregister_and_unlock) + * @param continue_removal_attempts pointer to a bool, #TRUE for initial call + * @param unregister_function_out returns the found node's unregister_function + * @param user_data_out returns the found node's user_data + * @returns #TRUE if a registered node was found at path, #FALSE otherwise + */ +static dbus_bool_t +unregister_and_free_path_recurse +(DBusObjectSubtree *subtree, + const char **path, + dbus_bool_t *continue_removal_attempts, + DBusObjectPathUnregisterFunction *unregister_function_out, + void **user_data_out) +{ + int i, j; + + _dbus_assert (continue_removal_attempts != NULL); + _dbus_assert (*continue_removal_attempts); + _dbus_assert (unregister_function_out != NULL); + _dbus_assert (user_data_out != NULL); + + if (path[0] == NULL) + return unregister_subtree (subtree, unregister_function_out, user_data_out); + + i = 0; + j = subtree->n_subtrees; + while (i < j) + { + int k, v; + + k = (i + j) / 2; + v = strcmp (path[0], subtree->subtrees[k]->name); + + if (v == 0) + { + dbus_bool_t freed; + freed = unregister_and_free_path_recurse (subtree->subtrees[k], + &path[1], + continue_removal_attempts, + unregister_function_out, + user_data_out); + if (freed && *continue_removal_attempts) + *continue_removal_attempts = attempt_child_removal (subtree, k); + return freed; + } + else if (v < 0) + { + j = k; + } + else + { + i = k + 1; + } + } + return FALSE; +} + +/** * Unregisters an object subtree that was registered with the * same path. * @@ -444,66 +623,42 @@ void _dbus_object_tree_unregister_and_unlock (DBusObjectTree *tree, const char **path) { - int i; - DBusObjectSubtree *subtree; + dbus_bool_t found_subtree; + dbus_bool_t continue_removal_attempts; DBusObjectPathUnregisterFunction unregister_function; void *user_data; DBusConnection *connection; + _dbus_assert (tree != NULL); _dbus_assert (path != NULL); + continue_removal_attempts = TRUE; unregister_function = NULL; user_data = NULL; - subtree = find_subtree (tree, path, &i); + found_subtree = unregister_and_free_path_recurse (tree->root, + path, + &continue_removal_attempts, + &unregister_function, + &user_data); #ifndef DBUS_DISABLE_CHECKS - if (subtree == NULL) + if (found_subtree == FALSE) { _dbus_warn ("Attempted to unregister path (path[0] = %s path[1] = %s) which isn't registered\n", path[0] ? path[0] : "null", - path[1] ? path[1] : "null"); + (path[0] && path[1]) ? path[1] : "null"); goto unlock; } #else - _dbus_assert (subtree != NULL); + _dbus_assert (found_subtree == TRUE); #endif - _dbus_assert (subtree->parent == NULL || - (i >= 0 && subtree->parent->subtrees[i] == subtree)); - - subtree->message_function = NULL; - - unregister_function = subtree->unregister_function; - user_data = subtree->user_data; - - subtree->unregister_function = NULL; - subtree->user_data = NULL; - - /* If we have no subtrees of our own, remove from - * our parent (FIXME could also be more aggressive - * and remove our parent if it becomes empty) - */ - if (subtree->parent && subtree->n_subtrees == 0) - { - /* assumes a 0-byte memmove is OK */ - memmove (&subtree->parent->subtrees[i], - &subtree->parent->subtrees[i+1], - (subtree->parent->n_subtrees - i - 1) * - sizeof (subtree->parent->subtrees[0])); - subtree->parent->n_subtrees -= 1; - - subtree->parent = NULL; - - _dbus_object_subtree_unref (subtree); - } - subtree = NULL; - unlock: connection = tree->connection; /* Unlock and call application code */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (connection) #endif { @@ -515,7 +670,7 @@ unlock: if (unregister_function) (* unregister_function) (connection, user_data); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (connection) #endif dbus_connection_unref (connection); @@ -638,7 +793,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -653,7 +808,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, if (!_dbus_string_init (&xml)) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -698,7 +853,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &v_STRING)) goto out; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -711,7 +866,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, result = DBUS_HANDLER_RESULT_HANDLED; out: -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -741,6 +896,7 @@ handle_default_introspect_and_unlock (DBusObjectTree *tree, * * @param tree the global object tree * @param message the message to dispatch + * @param found_object return location for the object * @returns whether message was handled successfully */ DBusHandlerResult @@ -762,7 +918,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, path = NULL; if (!dbus_message_get_path_decomposed (message, &path)) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -777,7 +933,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, if (path == NULL) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -846,7 +1002,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, _dbus_verbose (" (invoking a handler)\n"); #endif -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -863,7 +1019,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, message, user_data); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif _dbus_connection_lock (tree->connection); @@ -886,7 +1042,7 @@ _dbus_object_tree_dispatch_and_unlock (DBusObjectTree *tree, } else { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -1057,7 +1213,7 @@ _dbus_object_tree_list_registered_and_unlock (DBusObjectTree *tree, parent_path, child_entries); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (tree->connection) #endif { @@ -1214,7 +1370,7 @@ flatten_path (const char **path) } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -1507,6 +1663,17 @@ run_decompose_tests (void) return TRUE; } +static DBusObjectSubtree* +find_subtree_registered_or_unregistered (DBusObjectTree *tree, + const char **path) +{ +#if VERBOSE_FIND + _dbus_verbose ("Looking for exact subtree, registered or unregistered\n"); +#endif + + return find_subtree_recurse (tree->root, path, FALSE, NULL, NULL); +} + static dbus_bool_t object_tree_test_iteration (void *data) { @@ -1519,6 +1686,13 @@ object_tree_test_iteration (void *data) const char *path6[] = { "blah", "boof", NULL }; const char *path7[] = { "blah", "boof", "this", "is", "really", "long", NULL }; const char *path8[] = { "childless", NULL }; + const char *path9[] = { "blah", "a", NULL }; + const char *path10[] = { "blah", "b", NULL }; + const char *path11[] = { "blah", "c", NULL }; + const char *path12[] = { "blah", "a", "d", NULL }; + const char *path13[] = { "blah", "b", "d", NULL }; + const char *path14[] = { "blah", "c", "d", NULL }; + DBusObjectPathVTable test_vtable = { NULL, test_message_function, NULL }; DBusObjectTree *tree; TreeTestData tree_test_data[9]; int i; @@ -1889,6 +2063,200 @@ object_tree_test_iteration (void *data) ++i; } + /* Test removal of newly-childless unregistered nodes */ + if (!do_register (tree, path2, TRUE, 2, tree_test_data)) + goto out; + + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + /* Test that unregistered parents cannot be freed out from under their + children */ + if (!do_register (tree, path2, TRUE, 2, tree_test_data)) + goto out; + + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + +#if 0 + /* This triggers the "Attempted to unregister path ..." warning message */ + _dbus_object_tree_unregister_and_unlock (tree, path1); +#endif + _dbus_assert (find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + /* Test that registered parents cannot be freed out from under their + children, and that if they are unregistered before their children, they + are still freed when their children are unregistered */ + if (!do_register (tree, path1, TRUE, 1, tree_test_data)) + goto out; + if (!do_register (tree, path2, TRUE, 2, tree_test_data)) + goto out; + + _dbus_assert (find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree (tree, path2, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path1); + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (find_subtree (tree, path2, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree (tree, path1, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (!find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + /* Test with NULL unregister_function and user_data */ + if (!_dbus_object_tree_register (tree, TRUE, path2, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (_dbus_object_tree_get_user_data_unlocked (tree, path2) == NULL); + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_assert (!find_subtree (tree, path2, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + /* Test freeing a long path */ + if (!do_register (tree, path3, TRUE, 3, tree_test_data)) + goto out; + + _dbus_object_tree_unregister_and_unlock (tree, path3); + _dbus_assert (!find_subtree (tree, path3, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path3)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path0)); + + /* Test freeing multiple children from the same path */ + if (!do_register (tree, path3, TRUE, 3, tree_test_data)) + goto out; + if (!do_register (tree, path4, TRUE, 4, tree_test_data)) + goto out; + + _dbus_assert (find_subtree (tree, path3, NULL)); + _dbus_assert (find_subtree (tree, path4, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path3); + _dbus_assert (!find_subtree (tree, path3, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path3)); + _dbus_assert (find_subtree (tree, path4, NULL)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path4)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path1)); + + _dbus_object_tree_unregister_and_unlock (tree, path4); + _dbus_assert (!find_subtree (tree, path4, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path4)); + _dbus_assert (!find_subtree (tree, path3, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path3)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path2)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path1)); + + /* Test subtree removal */ + if (!_dbus_object_tree_register (tree, TRUE, path12, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path12, NULL)); + + if (!_dbus_object_tree_register (tree, TRUE, path13, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path13, NULL)); + + if (!_dbus_object_tree_register (tree, TRUE, path14, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path14, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path12); + + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path12)); + _dbus_assert (find_subtree (tree, path13, NULL)); + _dbus_assert (find_subtree (tree, path14, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path9)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + if (!_dbus_object_tree_register (tree, TRUE, path12, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path12, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path13); + + _dbus_assert (find_subtree (tree, path12, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path13)); + _dbus_assert (find_subtree (tree, path14, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path10)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + if (!_dbus_object_tree_register (tree, TRUE, path13, + &test_vtable, + NULL, + NULL)) + goto out; + + _dbus_assert (find_subtree (tree, path13, NULL)); + + _dbus_object_tree_unregister_and_unlock (tree, path14); + + _dbus_assert (find_subtree (tree, path12, NULL)); + _dbus_assert (find_subtree (tree, path13, NULL)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path14)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path11)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + _dbus_object_tree_unregister_and_unlock (tree, path12); + + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path12)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path9)); + _dbus_assert (find_subtree_registered_or_unregistered (tree, path5)); + + _dbus_object_tree_unregister_and_unlock (tree, path13); + + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path13)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path10)); + _dbus_assert (!find_subtree_registered_or_unregistered (tree, path5)); + +#if 0 + /* Test attempting to unregister non-existent paths. These trigger + "Attempted to unregister path ..." warning messages */ + _dbus_object_tree_unregister_and_unlock (tree, path0); + _dbus_object_tree_unregister_and_unlock (tree, path1); + _dbus_object_tree_unregister_and_unlock (tree, path2); + _dbus_object_tree_unregister_and_unlock (tree, path3); + _dbus_object_tree_unregister_and_unlock (tree, path4); +#endif + /* Register it all again, and test dispatch */ if (!do_register (tree, path0, TRUE, 0, tree_test_data)) @@ -1962,4 +2330,4 @@ _dbus_object_tree_test (void) #endif /* !DOXYGEN_SHOULD_SKIP_THIS */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-pending-call.c b/dbus/dbus-pending-call.c index 62c6c748..be534105 100644 --- a/dbus/dbus-pending-call.c +++ b/dbus/dbus-pending-call.c @@ -79,26 +79,19 @@ struct DBusPendingCall unsigned int timeout_added : 1; /**< Have added the timeout */ }; -#ifdef DBUS_ENABLE_VERBOSE_MODE static void _dbus_pending_call_trace_ref (DBusPendingCall *pending_call, int old_refcount, int new_refcount, const char *why) { +#ifdef DBUS_ENABLE_VERBOSE_MODE static int enabled = -1; _dbus_trace_ref ("DBusPendingCall", pending_call, old_refcount, new_refcount, why, "DBUS_PENDING_CALL_TRACE", &enabled); -} -#else -#define _dbus_pending_call_trace_ref(p, o, n, w) \ - do \ - {\ - (void) (o); \ - (void) (n); \ - } while (0) #endif +} static dbus_int32_t notify_user_data_slot = -1; @@ -489,8 +482,8 @@ _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending) return pending->completed; } -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (pending_call_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (pending_call_slots)); /** * Stores a pointer on a #DBusPendingCall, along @@ -768,7 +761,6 @@ dbus_pending_call_allocate_data_slot (dbus_int32_t *slot_p) _dbus_return_val_if_fail (slot_p != NULL, FALSE); return _dbus_data_slot_allocator_alloc (&slot_allocator, - &_DBUS_LOCK_NAME (pending_call_slots), slot_p); } diff --git a/dbus/dbus-server-debug-pipe.c b/dbus/dbus-server-debug-pipe.c index 419db5c5..8f5ff5fb 100644 --- a/dbus/dbus-server-debug-pipe.c +++ b/dbus/dbus-server-debug-pipe.c @@ -31,7 +31,7 @@ #include "dbus-string.h" #include "dbus-protocol.h" -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * @defgroup DBusServerDebugPipe DBusServerDebugPipe @@ -427,5 +427,5 @@ _dbus_transport_open_debug_pipe (DBusAddressEntry *entry, /** @} */ -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c index db4673c5..9832875e 100644 --- a/dbus/dbus-server-launchd.c +++ b/dbus/dbus-server-launchd.c @@ -40,6 +40,7 @@ #include <launch.h> #include <errno.h> +#include "dbus-misc.h" #include "dbus-server-socket.h" /* put other private launchd functions here */ @@ -176,7 +177,7 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error) else { display = launch_data_get_string(environment_param); - _dbus_setenv ("DISPLAY", display); + dbus_setenv ("DISPLAY", display); } } } diff --git a/dbus/dbus-server-socket.c b/dbus/dbus-server-socket.c index ae4b602e..060a919e 100644 --- a/dbus/dbus-server-socket.c +++ b/dbus/dbus-server-socket.c @@ -101,7 +101,7 @@ handle_new_client_fd_and_unlock (DBusServer *server, return TRUE; } - transport = _dbus_transport_new_for_socket (client_fd, &server->guid_hex, FALSE); + transport = _dbus_transport_new_for_socket (client_fd, &server->guid_hex, NULL); if (transport == NULL) { _dbus_close_socket (client_fd, NULL); @@ -478,7 +478,10 @@ _dbus_server_new_for_tcp_socket (const char *host, if (server == NULL) { dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL); - goto failed_4; + if (noncefile != NULL) + goto failed_4; + else + goto failed_2; } _dbus_string_free (&port_str); diff --git a/dbus/dbus-server.c b/dbus/dbus-server.c index b62c2b40..19d8590c 100644 --- a/dbus/dbus-server.c +++ b/dbus/dbus-server.c @@ -26,7 +26,7 @@ #include "dbus-server-unix.h" #include "dbus-server-socket.h" #include "dbus-string.h" -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-server-debug-pipe.h" #endif #include "dbus-address.h" @@ -529,7 +529,7 @@ static const struct { } listen_funcs[] = { { _dbus_server_listen_socket } , { _dbus_server_listen_platform_specific } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS , { _dbus_server_listen_debug_pipe } #endif }; @@ -699,13 +699,11 @@ dbus_server_ref (DBusServer *server) _dbus_return_val_if_fail (server != NULL, NULL); - /* can't get the refcount without a side-effect */ old_refcount = _dbus_atomic_inc (&server->refcount); #ifndef DBUS_DISABLE_CHECKS if (_DBUS_UNLIKELY (old_refcount <= 0)) { - /* undo side-effect first */ _dbus_atomic_dec (&server->refcount); _dbus_warn_check_failed (_dbus_return_if_fail_warning_format, _DBUS_FUNCTION_NAME, "old_refcount > 0", @@ -736,13 +734,18 @@ dbus_server_unref (DBusServer *server) _dbus_return_if_fail (server != NULL); - /* can't get the refcount without a side-effect */ old_refcount = _dbus_atomic_dec (&server->refcount); #ifndef DBUS_DISABLE_CHECKS if (_DBUS_UNLIKELY (old_refcount <= 0)) { - /* undo side-effect first */ + /* undo side-effect first + * please do not try to simplify the code here by using + * _dbus_atomic_get(), why we don't use it is + * because it issues another atomic operation even though + * DBUS_DISABLE_CHECKS defined. + * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=68303 + */ _dbus_atomic_inc (&server->refcount); _dbus_warn_check_failed (_dbus_return_if_fail_warning_format, _DBUS_FUNCTION_NAME, "old_refcount > 0", @@ -777,16 +780,7 @@ dbus_server_disconnect (DBusServer *server) { _dbus_return_if_fail (server != NULL); -#ifdef DBUS_DISABLE_CHECKS - _dbus_atomic_inc (&server->refcount); -#else - { - dbus_int32_t old_refcount = _dbus_atomic_inc (&server->refcount); - - _dbus_return_if_fail (old_refcount > 0); - } -#endif - + dbus_server_ref (server); SERVER_LOCK (server); _dbus_assert (server->vtable->disconnect != NULL); @@ -1071,9 +1065,8 @@ dbus_server_set_auth_mechanisms (DBusServer *server, return TRUE; } - -static DBusDataSlotAllocator slot_allocator; -_DBUS_DEFINE_GLOBAL_LOCK (server_slots); +static DBusDataSlotAllocator slot_allocator = + _DBUS_DATA_SLOT_ALLOCATOR_INIT (_DBUS_LOCK_NAME (server_slots)); /** * Allocates an integer ID to be used for storing application-specific @@ -1093,7 +1086,6 @@ dbus_bool_t dbus_server_allocate_data_slot (dbus_int32_t *slot_p) { return _dbus_data_slot_allocator_alloc (&slot_allocator, - (DBusRMutex **)&_DBUS_LOCK_NAME (server_slots), slot_p); } @@ -1190,7 +1182,7 @@ dbus_server_get_data (DBusServer *server, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <string.h> @@ -1246,4 +1238,4 @@ _dbus_server_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-sha.c b/dbus/dbus-sha.c index d1827522..febfba20 100644 --- a/dbus/dbus-sha.c +++ b/dbus/dbus-sha.c @@ -511,7 +511,7 @@ _dbus_sha_compute (const DBusString *data, /** @} */ /* end of exported functions */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> @@ -966,4 +966,4 @@ _dbus_sha_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-shell.c b/dbus/dbus-shell.c index 111d39df..2384961c 100644 --- a/dbus/dbus-shell.c +++ b/dbus/dbus-shell.c @@ -150,7 +150,7 @@ unquote_string_inplace (char* str, char** end) * through literally instead of being expanded). This function is * guaranteed to succeed if applied to the result of * _dbus_shell_quote(). If it fails, it returns %NULL. - * The @quoted_string need not actually contain quoted or + * The @p quoted_string need not actually contain quoted or * escaped text; _dbus_shell_unquote() simply goes through the string and * unquotes/unescapes anything that the shell would. Both single and * double quotes are handled, as are escapes including escaped @@ -163,7 +163,7 @@ unquote_string_inplace (char* str, char** end) * be escaped with backslash. Otherwise double quotes preserve things * literally. * - * @quoted_string: shell-quoted string + * @param quoted_string shell-quoted string **/ char* _dbus_shell_unquote (const char *quoted_string) @@ -544,10 +544,10 @@ tokenize_command_line (const char *command_line, DBusError *error) * does contain such expansions, they are passed through * literally. Free the returned vector with dbus_free_string_array(). * - * @command_line: command line to parse - * @argcp: return location for number of args - * @argvp: return location for array of args - * @error: error information + * @param command_line command line to parse + * @param argcp return location for number of args + * @param argvp return location for array of args + * @param error error information **/ dbus_bool_t _dbus_shell_parse_argv (const char *command_line, diff --git a/dbus/dbus-signature.c b/dbus/dbus-signature.c index c130de5b..8a4701c9 100644 --- a/dbus/dbus-signature.c +++ b/dbus/dbus-signature.c @@ -410,7 +410,7 @@ dbus_type_is_valid (int typecode) /** @} */ /* end of DBusSignature group */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * @ingroup DBusSignatureInternals diff --git a/dbus/dbus-socket-set-poll.c b/dbus/dbus-socket-set-poll.c index 65a1fd23..e322a3b4 100644 --- a/dbus/dbus-socket-set-poll.c +++ b/dbus/dbus-socket-set-poll.c @@ -44,7 +44,7 @@ typedef struct { #define MINIMUM_SIZE 8 /* If we're in the regression tests, force reallocation to happen sooner */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #define DEFAULT_SIZE_HINT 1 #else #define DEFAULT_SIZE_HINT MINIMUM_SIZE diff --git a/dbus/dbus-spawn-win.c b/dbus/dbus-spawn-win.c index 3dae4f38..cd8ca666 100644 --- a/dbus/dbus-spawn-win.c +++ b/dbus/dbus-spawn-win.c @@ -63,7 +63,7 @@ struct DBusBabysitter int refcount; HANDLE start_sync_event; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS HANDLE end_sync_event; #endif @@ -109,7 +109,7 @@ _dbus_babysitter_new (void) return NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS sitter->end_sync_event = CreateEvent (NULL, FALSE, FALSE, NULL); if (sitter->end_sync_event == NULL) { @@ -250,7 +250,7 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) sitter->start_sync_event = NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (sitter->end_sync_event != NULL) { CloseHandle (sitter->end_sync_event); @@ -628,7 +628,7 @@ babysitter (void *parameter) sitter->child_handle = NULL; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS SetEvent (sitter->end_sync_event); #endif @@ -753,7 +753,7 @@ _dbus_babysitter_set_result_function (DBusBabysitter *sitter, sitter->finished_data = user_data; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static char * get_test_exec (const char *exe, diff --git a/dbus/dbus-spawn.c b/dbus/dbus-spawn.c index 55a7e1e6..8965b587 100644 --- a/dbus/dbus-spawn.c +++ b/dbus/dbus-spawn.c @@ -308,15 +308,18 @@ _dbus_babysitter_unref (DBusBabysitter *sitter) if (ret == 0) kill (sitter->sitter_pid, SIGKILL); - again: if (ret == 0) - ret = waitpid (sitter->sitter_pid, &status, 0); + { + do + { + ret = waitpid (sitter->sitter_pid, &status, 0); + } + while (_DBUS_UNLIKELY (ret < 0 && errno == EINTR)); + } if (ret < 0) { - if (errno == EINTR) - goto again; - else if (errno == ECHILD) + if (errno == ECHILD) _dbus_warn ("Babysitter process not available to be reaped; should not happen\n"); else _dbus_warn ("Unexpected error %d in waitpid() for babysitter: %s\n", @@ -936,7 +939,7 @@ do_exec (int child_err_report_fd, DBusSpawnChildSetupFunc child_setup, void *user_data) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS int i, max_open; #endif @@ -947,7 +950,7 @@ do_exec (int child_err_report_fd, if (child_setup) (* child_setup) (user_data); -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS max_open = sysconf (_SC_OPEN_MAX); for (i = 3; i < max_open; i++) @@ -1325,7 +1328,7 @@ _dbus_babysitter_set_result_function (DBusBabysitter *sitter, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static char * get_test_exec (const char *exe, diff --git a/dbus/dbus-string-util.c b/dbus/dbus-string-util.c index 922580da..3babc053 100644 --- a/dbus/dbus-string-util.c +++ b/dbus/dbus-string-util.c @@ -115,7 +115,7 @@ _dbus_string_find_byte_backward (const DBusString *str, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-test.h" #include <stdio.h> @@ -935,4 +935,4 @@ _dbus_string_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c index e3766aad..c4e2e7fc 100644 --- a/dbus/dbus-string.c +++ b/dbus/dbus-string.c @@ -246,6 +246,14 @@ _dbus_string_free (DBusString *str) if (real->constant) return; + + /* so it's safe if @p str returned by a failed + * _dbus_string_init call + * Bug: https://bugs.freedesktop.org/show_bug.cgi?id=65959 + */ + if (real->str == NULL) + return; + dbus_free (real->str - real->align_offset); real->invalid = TRUE; @@ -277,9 +285,9 @@ compact (DBusRealString *real, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /* Not using this feature at the moment, - * so marked DBUS_BUILD_TESTS-only + * so marked DBUS_ENABLE_EMBEDDED_TESTS-only */ /** * Locks a string such that any attempts to change the string will @@ -303,7 +311,7 @@ _dbus_string_lock (DBusString *str) #define MAX_WASTE 48 compact (real, MAX_WASTE); } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ static dbus_bool_t reallocate_for_length (DBusRealString *real, @@ -327,14 +335,11 @@ reallocate_for_length (DBusRealString *real, * disable asserts to profile, you don't get this destroyer * of profiles. */ -#ifdef DBUS_DISABLE_ASSERT -#else -#ifdef DBUS_BUILD_TESTS +#if defined (DBUS_ENABLE_EMBEDDED_TESTS) && !defined (DBUS_DISABLE_ASSERT) new_allocated = 0; /* ensure a realloc every time so that we go * through all malloc failure codepaths */ -#endif /* DBUS_BUILD_TESTS */ -#endif /* !DBUS_DISABLE_ASSERT */ +#endif /* But be sure we always alloc at least space for the new length */ new_allocated = MAX (new_allocated, @@ -933,29 +938,9 @@ _dbus_string_append (DBusString *str, #define ASSIGN_4_OCTETS(p, octets) \ *((dbus_uint32_t*)(p)) = *((dbus_uint32_t*)(octets)); -#ifdef DBUS_HAVE_INT64 /** assign 8 bytes from one string to another */ #define ASSIGN_8_OCTETS(p, octets) \ *((dbus_uint64_t*)(p)) = *((dbus_uint64_t*)(octets)); -#else -/** assign 8 bytes from one string to another */ -#define ASSIGN_8_OCTETS(p, octets) \ -do { \ - unsigned char *b; \ - \ - b = p; \ - \ - *b++ = octets[0]; \ - *b++ = octets[1]; \ - *b++ = octets[2]; \ - *b++ = octets[3]; \ - *b++ = octets[4]; \ - *b++ = octets[5]; \ - *b++ = octets[6]; \ - *b++ = octets[7]; \ - _dbus_assert (b == p + 8); \ -} while (0) -#endif /* DBUS_HAVE_INT64 */ /** * Inserts 2 bytes aligned on a 2 byte boundary @@ -969,7 +954,7 @@ do { \ dbus_bool_t _dbus_string_insert_2_aligned (DBusString *str, int insert_at, - const unsigned char octets[4]) + const unsigned char octets[2]) { DBUS_STRING_PREAMBLE (str); @@ -1896,7 +1881,7 @@ _dbus_string_skip_white_reverse (const DBusString *str, * @todo owen correctly notes that this is a stupid function (it was * written purely for test code, * e.g. dbus-message-builder.c). Probably should be enforced as test - * code only with ifdef DBUS_BUILD_TESTS + * code only with ifdef DBUS_ENABLE_EMBEDDED_TESTS * * @param source the source string * @param dest the destination string (contents are replaced) @@ -1940,7 +1925,7 @@ _dbus_string_pop_line (DBusString *source, return TRUE; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Deletes up to and including the first blank space * in the string. @@ -1959,7 +1944,7 @@ _dbus_string_delete_first_word (DBusString *str) } #endif -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Deletes any leading blanks in the string * @@ -2220,7 +2205,7 @@ _dbus_string_starts_with_c_str (const DBusString *a, */ dbus_bool_t _dbus_string_append_byte_as_hex (DBusString *str, - int byte) + unsigned char byte) { const char hexdigits[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h index 4ef59db1..86fb8c39 100644 --- a/dbus/dbus-string.h +++ b/dbus/dbus-string.h @@ -259,7 +259,7 @@ void _dbus_string_delete_first_word (DBusString *str); void _dbus_string_delete_leading_blanks (DBusString *str); void _dbus_string_chop_white (DBusString *str); dbus_bool_t _dbus_string_append_byte_as_hex (DBusString *str, - int byte); + unsigned char byte); dbus_bool_t _dbus_string_hex_encode (const DBusString *source, int start, DBusString *dest, diff --git a/dbus/dbus-syntax.c b/dbus/dbus-syntax.c index 47922875..7ef659cb 100644 --- a/dbus/dbus-syntax.c +++ b/dbus/dbus-syntax.c @@ -93,7 +93,7 @@ dbus_validate_path (const char *path, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid interface name, which must not be #NULL + * @param name a potentially invalid interface name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ @@ -140,7 +140,7 @@ dbus_validate_interface (const char *name, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid member name, which must not be #NULL + * @param name a potentially invalid member name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ @@ -187,7 +187,7 @@ dbus_validate_member (const char *name, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid error name, which must not be #NULL + * @param name a potentially invalid error name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ @@ -234,7 +234,7 @@ dbus_validate_error_name (const char *name, * is also checked, since it assumes that the string ends at the first zero * byte according to normal C conventions. * - * @param path a potentially invalid bus name, which must not be #NULL + * @param name a potentially invalid bus name, which must not be #NULL * @param error error return * @returns #TRUE if name is valid */ diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 07b761b4..07080045 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -144,7 +144,7 @@ _dbus_open_socket (int *fd_p, cloexec_done = *fd_p >= 0; /* Check if kernel seems to be too old to know SOCK_CLOEXEC */ - if (*fd_p < 0 && errno == EINVAL) + if (*fd_p < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { *fd_p = socket (domain, type, protocol); @@ -741,7 +741,7 @@ _dbus_write_two (int fd, } #else /* HAVE_WRITEV */ { - int ret1; + int ret1, ret2; ret1 = _dbus_write (fd, buffer1, start1, len1); if (ret1 == len1 && buffer2 != NULL) @@ -892,16 +892,24 @@ _dbus_connect_exec (const char *path, { int fds[2]; pid_t pid; + int retval; + dbus_bool_t cloexec_done = 0; _DBUS_ASSERT_ERROR_IS_CLEAR (error); _dbus_verbose ("connecting to process %s\n", path); - if (socketpair (AF_UNIX, SOCK_STREAM #ifdef SOCK_CLOEXEC - |SOCK_CLOEXEC + retval = socketpair (AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds); + cloexec_done = (retval >= 0); + + if (retval < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif - , 0, fds) < 0) + { + retval = socketpair (AF_UNIX, SOCK_STREAM, 0, fds); + } + + if (retval < 0) { dbus_set_error (error, _dbus_error_from_errno (errno), @@ -910,8 +918,11 @@ _dbus_connect_exec (const char *path, return -1; } - _dbus_fd_set_close_on_exec (fds[0]); - _dbus_fd_set_close_on_exec (fds[1]); + if (!cloexec_done) + { + _dbus_fd_set_close_on_exec (fds[0]); + _dbus_fd_set_close_on_exec (fds[1]); + } pid = fork (); if (pid < 0) @@ -964,39 +975,6 @@ _dbus_connect_exec (const char *path, } /** - * Enables or disables the reception of credentials on the given socket during - * the next message transmission. This is only effective if the #LOCAL_CREDS - * system feature exists, in which case the other side of the connection does - * not have to do anything special to send the credentials. - * - * @param fd socket on which to change the #LOCAL_CREDS flag. - * @param on whether to enable or disable the #LOCAL_CREDS flag. - */ -static dbus_bool_t -_dbus_set_local_creds (int fd, dbus_bool_t on) -{ - dbus_bool_t retval = TRUE; - -#if defined(HAVE_CMSGCRED) - /* NOOP just to make sure only one codepath is used - * and to prefer CMSGCRED - */ -#elif defined(LOCAL_CREDS) - int val = on ? 1 : 0; - if (setsockopt (fd, 0, LOCAL_CREDS, &val, sizeof (val)) < 0) - { - _dbus_verbose ("Unable to set LOCAL_CREDS socket option on fd %d\n", fd); - retval = FALSE; - } - else - _dbus_verbose ("LOCAL_CREDS %s for further messages on fd %d\n", - on ? "enabled" : "disabled", fd); -#endif - - return retval; -} - -/** * Creates a socket and binds it to the given path, * then listens on the socket. The socket is * set to be nonblocking. @@ -1121,15 +1099,6 @@ _dbus_listen_unix_socket (const char *path, return -1; } - if (!_dbus_set_local_creds (listen_fd, TRUE)) - { - dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to enable LOCAL_CREDS on socket \"%s\": %s", - path, _dbus_strerror (errno)); - close (listen_fd); - return -1; - } - if (!_dbus_set_fd_nonblocking (listen_fd, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); @@ -1153,7 +1122,7 @@ _dbus_listen_unix_socket (const char *path, * * This will set FD_CLOEXEC for the sockets returned. * - * @oaram fds the file descriptors + * @param fds the file descriptors * @param error return location for errors * @returns the number of file descriptors */ @@ -1215,14 +1184,6 @@ _dbus_listen_systemd_sockets (int **fds, for (fd = SD_LISTEN_FDS_START; fd < SD_LISTEN_FDS_START + n; fd ++) { - if (!_dbus_set_local_creds (fd, TRUE)) - { - dbus_set_error (error, _dbus_error_from_errno (errno), - "Failed to enable LOCAL_CREDS on systemd socket: %s", - _dbus_strerror (errno)); - goto fail; - } - if (!_dbus_set_fd_nonblocking (fd, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); @@ -1681,12 +1642,6 @@ _dbus_read_credentials_socket (int client_fd, struct cmsghdr hdr; char cred[CMSG_SPACE (sizeof (struct cmsgcred))]; } cmsg; - -#elif defined(LOCAL_CREDS) - struct { - struct cmsghdr hdr; - struct sockcred cred; - } cmsg; #endif uid_read = DBUS_UID_UNSET; @@ -1704,12 +1659,6 @@ _dbus_read_credentials_socket (int client_fd, _dbus_credentials_clear (credentials); - /* Systems supporting LOCAL_CREDS are configured to have this feature - * enabled (if it does not conflict with HAVE_CMSGCRED) prior accepting - * the connection. Therefore, the received message must carry the - * credentials information without doing anything special. - */ - iov.iov_base = &buf; iov.iov_len = 1; @@ -1717,7 +1666,7 @@ _dbus_read_credentials_socket (int client_fd, msg.msg_iov = &iov; msg.msg_iovlen = 1; -#if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS) +#if defined(HAVE_CMSGCRED) _DBUS_ZERO(cmsg); msg.msg_control = (caddr_t) &cmsg; msg.msg_controllen = CMSG_SPACE (sizeof (struct cmsgcred)); @@ -1757,7 +1706,7 @@ _dbus_read_credentials_socket (int client_fd, return FALSE; } -#if defined(HAVE_CMSGCRED) || defined(LOCAL_CREDS) +#if defined(HAVE_CMSGCRED) if (cmsg.hdr.cmsg_len < CMSG_LEN (sizeof (struct cmsgcred)) || cmsg.hdr.cmsg_type != SCM_CREDS) { @@ -1771,6 +1720,14 @@ _dbus_read_credentials_socket (int client_fd, { #ifdef SO_PEERCRED + /* Supported by at least Linux and OpenBSD, with minor differences. + * + * This mechanism passes the process ID through and does not require + * the peer's cooperation, so we prefer it over all others. Notably, + * Linux also supports SCM_CREDENTIALS, which is similar to FreeBSD + * SCM_CREDS; it's implemented in GIO, but we don't use it in dbus at all, + * because this is much less fragile. + */ #ifdef __OpenBSD__ struct sockpeercred cr; #else @@ -1790,29 +1747,24 @@ _dbus_read_credentials_socket (int client_fd, cr_len, (int) sizeof (cr), _dbus_strerror (errno)); } #elif defined(HAVE_CMSGCRED) + /* We only check for HAVE_CMSGCRED, but we're really assuming that the + * presence of that struct implies SCM_CREDS. Supported by at least + * FreeBSD and DragonflyBSD. + * + * This mechanism requires the peer to help us (it has to send us a + * SCM_CREDS message) but it does pass the process ID through, + * which makes it better than getpeereid(). + */ struct cmsgcred *cred; cred = (struct cmsgcred *) CMSG_DATA (&cmsg.hdr); pid_read = cred->cmcred_pid; uid_read = cred->cmcred_euid; -#elif defined(LOCAL_CREDS) - pid_read = DBUS_PID_UNSET; - uid_read = cmsg.cred.sc_uid; - /* Since we have already got the credentials from this socket, we can - * disable its LOCAL_CREDS flag if it was ever set. */ - _dbus_set_local_creds (client_fd, FALSE); -#elif defined(HAVE_GETPEEREID) - uid_t euid; - gid_t egid; - if (getpeereid (client_fd, &euid, &egid) == 0) - { - uid_read = euid; - } - else - { - _dbus_verbose ("Failed to getpeereid() credentials: %s\n", _dbus_strerror (errno)); - } + #elif defined(HAVE_GETPEERUCRED) + /* Supported in at least Solaris >= 10. It should probably be higher + * up this list, because it carries the pid and we use this code path + * for audit data. */ ucred_t * ucred = NULL; if (getpeerucred (client_fd, &ucred) == 0) { @@ -1856,7 +1808,54 @@ _dbus_read_credentials_socket (int client_fd, } if (ucred != NULL) ucred_free (ucred); -#else /* !SO_PEERCRED && !HAVE_CMSGCRED && !HAVE_GETPEEREID && !HAVE_GETPEERUCRED */ + + /* ---------------------------------------------------------------- + * When adding new mechanisms, please add them above this point + * if they support passing the process ID through, or below if not. + * ---------------------------------------------------------------- */ + +#elif defined(HAVE_GETPEEREID) + /* getpeereid() originates from D.J. Bernstein and is fairly + * widely-supported. According to a web search, it might be present in + * any/all of: + * + * - AIX? + * - Blackberry? + * - Cygwin + * - FreeBSD 4.6+ (but we prefer SCM_CREDS: it carries the pid) + * - Mac OS X + * - Minix 3.1.8+ + * - MirBSD? + * - NetBSD 5.0+ (but LOCAL_PEEREID would be better: it carries the pid) + * - OpenBSD 3.0+ (but we prefer SO_PEERCRED: it carries the pid) + * - QNX? + */ + uid_t euid; + gid_t egid; + if (getpeereid (client_fd, &euid, &egid) == 0) + { + uid_read = euid; + } + else + { + _dbus_verbose ("Failed to getpeereid() credentials: %s\n", _dbus_strerror (errno)); + } +#else /* no supported mechanism */ + +#warning Socket credentials not supported on this Unix OS +#warning Please tell https://bugs.freedesktop.org/enter_bug.cgi?product=DBus + + /* Please add other operating systems known to support at least one of + * the mechanisms above to this list, keeping alphabetical order. + * Everything not in this list is best-effort. + */ +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__linux__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) +# error Credentials passing not working on this OS is a regression! +#endif + _dbus_verbose ("Socket credentials not supported on this OS\n"); #endif } @@ -1942,11 +1941,15 @@ _dbus_accept (int listen_fd) retry: #ifdef HAVE_ACCEPT4 - /* We assume that if accept4 is available SOCK_CLOEXEC is too */ + /* + * At compile-time, we assume that if accept4() is available in + * libc headers, SOCK_CLOEXEC is too. At runtime, it is still + * not necessarily true that either is supported by the running kernel. + */ client_fd = accept4 (listen_fd, &addr, &addrlen, SOCK_CLOEXEC); cloexec_done = client_fd >= 0; - if (client_fd < 0 && errno == ENOSYS) + if (client_fd < 0 && (errno == ENOSYS || errno == EINVAL)) #endif { client_fd = accept (listen_fd, &addr, &addrlen); @@ -2929,6 +2932,7 @@ _dbus_close (int fd, * (i.e. avoids stdin/stdout/stderr). Sets O_CLOEXEC. * * @param fd the file descriptor to duplicate + * @param error address of error location. * @returns duplicated file descriptor * */ int @@ -3069,7 +3073,7 @@ _dbus_full_duplex_pipe (int *fd1, retval = socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0, fds); cloexec_done = retval >= 0; - if (retval < 0 && errno == EINVAL) + if (retval < 0 && (errno == EINVAL || errno == EPROTOTYPE)) #endif { retval = socketpair(AF_UNIX, SOCK_STREAM, 0, fds); @@ -3196,13 +3200,17 @@ _dbus_printf_string_upper_bound (const char *format, * Gets the temporary files directory by inspecting the environment variables * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned * - * @returns location of temp directory + * @returns location of temp directory, or #NULL if no memory for locking */ const char* _dbus_get_tmpdir(void) { + /* Protected by _DBUS_LOCK_sysdeps */ static const char* tmpdir = NULL; + if (!_DBUS_LOCK (sysdeps)) + return NULL; + if (tmpdir == NULL) { /* TMPDIR is what glibc uses, then @@ -3225,6 +3233,8 @@ _dbus_get_tmpdir(void) tmpdir = "/tmp"; } + _DBUS_UNLOCK (sysdeps); + _dbus_assert(tmpdir != NULL); return tmpdir; @@ -3441,6 +3451,7 @@ _read_subprocess_line_argv (const char *progpath, * address. If a failure happens, returns #FALSE and * sets an error in @p error. * + * @param scope scope of autolaunch (Windows only) * @param address a DBusString where the address can be stored * @param error a DBusError to store the error in case of failure * @returns #TRUE on success, #FALSE if an error happened @@ -3455,7 +3466,7 @@ _dbus_get_autolaunch_address (const char *scope, * but that's done elsewhere, and if it worked, this function wouldn't * be called.) */ const char *display; - static char *argv[6]; + char *argv[6]; int i; DBusString uuid; dbus_bool_t retval; @@ -3495,7 +3506,12 @@ _dbus_get_autolaunch_address (const char *scope, } i = 0; - argv[i] = "dbus-launch"; +#ifdef DBUS_ENABLE_EMBEDDED_TESTS + if (_dbus_getenv ("DBUS_USE_TEST_BINARY") != NULL) + argv[i] = TEST_BUS_LAUNCH_BINARY; + else +#endif + argv[i] = DBUS_BINDIR "/dbus-launch"; ++i; argv[i] = "--autolaunch"; ++i; @@ -3510,7 +3526,7 @@ _dbus_get_autolaunch_address (const char *scope, _dbus_assert (i == _DBUS_N_ELEMENTS (argv)); - retval = _read_subprocess_line_argv (DBUS_BINDIR "/dbus-launch", + retval = _read_subprocess_line_argv (argv[0], TRUE, argv, address, error); @@ -3564,11 +3580,9 @@ _dbus_read_local_machine_uuid (DBusGUID *machine_id, return _dbus_read_uuid_file (&filename, machine_id, FALSE, error); } -#define DBUS_UNIX_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" -#define DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" - /** * quries launchd for a specific env var which holds the socket path. + * @param socket_path append the socket path to this DBusString * @param launchd_env_var the env var to look up * @param error a DBusError to store the error in case of failure * @return the value of the env var @@ -3717,167 +3731,6 @@ _dbus_lookup_session_address (dbus_bool_t *supported, } /** - * Returns the standard directories for a session bus to look for service - * activation files - * - * On UNIX this should be the standard xdg freedesktop.org data directories: - * - * XDG_DATA_HOME=${XDG_DATA_HOME-$HOME/.local/share} - * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} - * - * and - * - * DBUS_DATADIR - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_session_servicedirs (DBusList **dirs) -{ - const char *xdg_data_home; - const char *xdg_data_dirs; - DBusString servicedir_path; - - if (!_dbus_string_init (&servicedir_path)) - return FALSE; - - xdg_data_home = _dbus_getenv ("XDG_DATA_HOME"); - xdg_data_dirs = _dbus_getenv ("XDG_DATA_DIRS"); - - if (xdg_data_home != NULL) - { - if (!_dbus_string_append (&servicedir_path, xdg_data_home)) - goto oom; - } - else - { - const DBusString *homedir; - DBusString local_share; - - if (!_dbus_homedir_from_current_process (&homedir)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _dbus_string_get_const_data (homedir))) - goto oom; - - _dbus_string_init_const (&local_share, "/.local/share"); - if (!_dbus_concat_dir_and_file (&servicedir_path, &local_share)) - goto oom; - } - - if (!_dbus_string_append (&servicedir_path, ":")) - goto oom; - - if (xdg_data_dirs != NULL) - { - if (!_dbus_string_append (&servicedir_path, xdg_data_dirs)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, ":")) - goto oom; - } - else - { - if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:")) - goto oom; - } - - /* - * add configured datadir to defaults - * this may be the same as an xdg dir - * however the config parser should take - * care of duplicates - */ - if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) - goto oom; - - if (!_dbus_split_paths_and_append (&servicedir_path, - DBUS_UNIX_STANDARD_SESSION_SERVICEDIR, - dirs)) - goto oom; - - _dbus_string_free (&servicedir_path); - return TRUE; - - oom: - _dbus_string_free (&servicedir_path); - return FALSE; -} - - -/** - * Returns the standard directories for a system bus to look for service - * activation files - * - * On UNIX this should be the standard xdg freedesktop.org data directories: - * - * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} - * - * and - * - * DBUS_DATADIR - * - * On Windows there is no system bus and this function can return nothing. - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_system_servicedirs (DBusList **dirs) -{ - /* - * DBUS_DATADIR may be the same as one of the standard directories. However, - * the config parser should take care of the duplicates. - * - * Also, append /lib as counterpart of /usr/share on the root - * directory (the root directory does not know /share), in order to - * facilitate early boot system bus activation where /usr might not - * be available. - */ - static const char standard_search_path[] = - "/usr/local/share:" - "/usr/share:" - DBUS_DATADIR ":" - "/lib"; - DBusString servicedir_path; - - _dbus_string_init_const (&servicedir_path, standard_search_path); - - return _dbus_split_paths_and_append (&servicedir_path, - DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR, - dirs); -} - -/** - * Append the absolute path of the system.conf file - * (there is no system bus on Windows so this can just - * return FALSE and print a warning or something) - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_system_config_file (DBusString *str) -{ - return _dbus_string_append (str, DBUS_SYSTEM_CONFIG_FILE); -} - -/** - * Append the absolute path of the session.conf file. - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_session_config_file (DBusString *str) -{ - return _dbus_string_append (str, DBUS_SESSION_CONFIG_FILE); -} - -/** * Called when the bus daemon is signaled to reload its configuration; any * caches should be nuked. Of course any caches that need explicit reload * are probably broken, but c'est la vie. @@ -3923,7 +3776,7 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, if (!_dbus_homedir_from_uid (uid, &homedir)) goto failed; -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS { const char *override; @@ -3939,6 +3792,8 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, } else { + /* Not strictly thread-safe, but if we fail at thread-safety here, + * the worst that will happen is some extra warnings. */ static dbus_bool_t already_warned = FALSE; if (!already_warned) { @@ -4054,20 +3909,6 @@ _dbus_socket_can_pass_unix_fd(int fd) { #endif } - -/* - * replaces the term DBUS_PREFIX in configure_time_path by the - * current dbus installation directory. On unix this function is a noop - * - * @param configure_time_path - * @return real path - */ -const char * -_dbus_replace_install_prefix (const char *configure_time_path) -{ - return configure_time_path; -} - /** * Closes all file descriptors except the first three (i.e. stdin, * stdout, stderr). @@ -4161,6 +4002,8 @@ _dbus_check_setuid (void) uid_t ruid, euid, suid; /* Real, effective and saved user ID's */ gid_t rgid, egid, sgid; /* Real, effective and saved group ID's */ + /* We call into this function from _dbus_threads_init_platform_specific() + * to make sure these are initialized before we start threading. */ static dbus_bool_t check_setuid_initialised; static dbus_bool_t is_setuid; diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 6265e2b5..0d8a66c7 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -381,13 +381,13 @@ _dbus_change_to_daemon_user (const char *user, /** * Attempt to ensure that the current process can open - * at least @limit file descriptors. + * at least @p limit file descriptors. * - * If @limit is lower than the current, it will not be + * If @p limit is lower than the current, it will not be * lowered. No error is returned if the request can * not be satisfied. * - * @limit Number of file descriptors + * @param limit number of file descriptors */ void _dbus_request_file_descriptor_limit (unsigned int limit) @@ -449,8 +449,6 @@ _dbus_init_system_log (dbus_bool_t is_daemon) * * @param severity a severity value * @param msg a printf-style format string - * @param args arguments for the format string - * */ void _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) @@ -1159,6 +1157,7 @@ _dbus_command_for_pid (unsigned long pid, "Failed to read from \"%s\": %s", _dbus_string_get_const_data (&path), _dbus_strerror (errno)); + _dbus_close (fd, NULL); goto fail; } @@ -1180,3 +1179,180 @@ fail: _dbus_string_free (&path); return FALSE; } + +/* + * replaces the term DBUS_PREFIX in configure_time_path by the + * current dbus installation directory. On unix this function is a noop + * + * @param configure_time_path + * @return real path + */ +const char * +_dbus_replace_install_prefix (const char *configure_time_path) +{ + return configure_time_path; +} + +#define DBUS_UNIX_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" +#define DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" + +/** + * Returns the standard directories for a session bus to look for service + * activation files + * + * On UNIX this should be the standard xdg freedesktop.org data directories: + * + * XDG_DATA_HOME=${XDG_DATA_HOME-$HOME/.local/share} + * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} + * + * and + * + * DBUS_DATADIR + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_session_servicedirs (DBusList **dirs) +{ + const char *xdg_data_home; + const char *xdg_data_dirs; + DBusString servicedir_path; + + if (!_dbus_string_init (&servicedir_path)) + return FALSE; + + xdg_data_home = _dbus_getenv ("XDG_DATA_HOME"); + xdg_data_dirs = _dbus_getenv ("XDG_DATA_DIRS"); + + if (xdg_data_home != NULL) + { + if (!_dbus_string_append (&servicedir_path, xdg_data_home)) + goto oom; + } + else + { + const DBusString *homedir; + DBusString local_share; + + if (!_dbus_homedir_from_current_process (&homedir)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _dbus_string_get_const_data (homedir))) + goto oom; + + _dbus_string_init_const (&local_share, "/.local/share"); + if (!_dbus_concat_dir_and_file (&servicedir_path, &local_share)) + goto oom; + } + + if (!_dbus_string_append (&servicedir_path, ":")) + goto oom; + + if (xdg_data_dirs != NULL) + { + if (!_dbus_string_append (&servicedir_path, xdg_data_dirs)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, ":")) + goto oom; + } + else + { + if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:")) + goto oom; + } + + /* + * add configured datadir to defaults + * this may be the same as an xdg dir + * however the config parser should take + * care of duplicates + */ + if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) + goto oom; + + if (!_dbus_split_paths_and_append (&servicedir_path, + DBUS_UNIX_STANDARD_SESSION_SERVICEDIR, + dirs)) + goto oom; + + _dbus_string_free (&servicedir_path); + return TRUE; + + oom: + _dbus_string_free (&servicedir_path); + return FALSE; +} + + +/** + * Returns the standard directories for a system bus to look for service + * activation files + * + * On UNIX this should be the standard xdg freedesktop.org data directories: + * + * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} + * + * and + * + * DBUS_DATADIR + * + * On Windows there is no system bus and this function can return nothing. + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_system_servicedirs (DBusList **dirs) +{ + /* + * DBUS_DATADIR may be the same as one of the standard directories. However, + * the config parser should take care of the duplicates. + * + * Also, append /lib as counterpart of /usr/share on the root + * directory (the root directory does not know /share), in order to + * facilitate early boot system bus activation where /usr might not + * be available. + */ + static const char standard_search_path[] = + "/usr/local/share:" + "/usr/share:" + DBUS_DATADIR ":" + "/lib"; + DBusString servicedir_path; + + _dbus_string_init_const (&servicedir_path, standard_search_path); + + return _dbus_split_paths_and_append (&servicedir_path, + DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR, + dirs); +} + +/** + * Append the absolute path of the system.conf file + * (there is no system bus on Windows so this can just + * return FALSE and print a warning or something) + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_system_config_file (DBusString *str) +{ + return _dbus_string_append (str, DBUS_SYSTEM_CONFIG_FILE); +} + +/** + * Append the absolute path of the session.conf file. + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_session_config_file (DBusString *str) +{ + return _dbus_string_append (str, DBUS_SESSION_CONFIG_FILE); +} diff --git a/dbus/dbus-sysdeps-util-win.c b/dbus/dbus-sysdeps-util-win.c index abb10f70..4678b11e 100644 --- a/dbus/dbus-sysdeps-util-win.c +++ b/dbus/dbus-sysdeps-util-win.c @@ -54,7 +54,7 @@ * Does the chdir, fork, setsid, etc. to become a daemon process. * * @param pidfile #NULL, or pidfile to create - * @param print_pid_fd file descriptor to print daemon's pid to, or -1 for none + * @param print_pid_pipe file descriptor to print daemon's pid to, or -1 for none * @param error return location for errors * @param keep_umask #TRUE to keep the original umask * @returns #FALSE on failure @@ -65,7 +65,9 @@ _dbus_become_daemon (const DBusString *pidfile, DBusError *error, dbus_bool_t keep_umask) { - return TRUE; + dbus_set_error (error, DBUS_ERROR_NOT_SUPPORTED, + "Cannot daemonize on Windows"); + return FALSE; } /** @@ -272,8 +274,6 @@ _dbus_init_system_log (dbus_bool_t is_daemon) * * @param severity a severity value * @param msg a printf-style format string - * @param args arguments for the format string - * */ void _dbus_system_log (DBusSystemLogSeverity severity, const char *msg, ...) @@ -1530,3 +1530,207 @@ _dbus_command_for_pid (unsigned long pid, // FIXME return FALSE; } + +/* + * replaces the term DBUS_PREFIX in configure_time_path by the + * current dbus installation directory. On unix this function is a noop + * + * @param configure_time_path + * @return real path + */ +const char * +_dbus_replace_install_prefix (const char *configure_time_path) +{ +#ifndef DBUS_PREFIX + return configure_time_path; +#else + static char retval[1000]; + static char runtime_prefix[1000]; + int len = 1000; + int i; + + if (!configure_time_path) + return NULL; + + if ((!_dbus_get_install_root(runtime_prefix, len) || + strncmp (configure_time_path, DBUS_PREFIX "/", + strlen (DBUS_PREFIX) + 1))) { + strcat (retval, configure_time_path); + return retval; + } + + strcpy (retval, runtime_prefix); + strcat (retval, configure_time_path + strlen (DBUS_PREFIX) + 1); + + /* Somehow, in some situations, backslashes get collapsed in the string. + * Since windows C library accepts both forward and backslashes as + * path separators, convert all backslashes to forward slashes. + */ + + for(i = 0; retval[i] != '\0'; i++) { + if(retval[i] == '\\') + retval[i] = '/'; + } + return retval; +#endif +} + +/** + * return the relocated DATADIR + * + * @returns relocated DATADIR static string + */ + +static const char * +_dbus_windows_get_datadir (void) +{ + return _dbus_replace_install_prefix(DBUS_DATADIR); +} + +#undef DBUS_DATADIR +#define DBUS_DATADIR _dbus_windows_get_datadir () + + +#define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" +#define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" + +/** + * Returns the standard directories for a session bus to look for service + * activation files + * + * On Windows this should be data directories: + * + * %CommonProgramFiles%/dbus + * + * and + * + * relocated DBUS_DATADIR + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_session_servicedirs (DBusList **dirs) +{ + const char *common_progs; + DBusString servicedir_path; + + if (!_dbus_string_init (&servicedir_path)) + return FALSE; + +#ifdef DBUS_WINCE + { + /* On Windows CE, we adjust datadir dynamically to installation location. */ + const char *data_dir = _dbus_getenv ("DBUS_DATADIR"); + + if (data_dir != NULL) + { + if (!_dbus_string_append (&servicedir_path, data_dir)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) + goto oom; + } + } +#else +/* + the code for accessing services requires absolute base pathes + in case DBUS_DATADIR is relative make it absolute +*/ +#ifdef DBUS_WIN + { + DBusString p; + + _dbus_string_init_const (&p, DBUS_DATADIR); + + if (!_dbus_path_is_absolute (&p)) + { + char install_root[1000]; + if (_dbus_get_install_root (install_root, sizeof(install_root))) + if (!_dbus_string_append (&servicedir_path, install_root)) + goto oom; + } + } +#endif + if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) + goto oom; +#endif + + common_progs = _dbus_getenv ("CommonProgramFiles"); + + if (common_progs != NULL) + { + if (!_dbus_string_append (&servicedir_path, common_progs)) + goto oom; + + if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) + goto oom; + } + + if (!_dbus_split_paths_and_append (&servicedir_path, + DBUS_STANDARD_SESSION_SERVICEDIR, + dirs)) + goto oom; + + _dbus_string_free (&servicedir_path); + return TRUE; + + oom: + _dbus_string_free (&servicedir_path); + return FALSE; +} + +/** + * Returns the standard directories for a system bus to look for service + * activation files + * + * On UNIX this should be the standard xdg freedesktop.org data directories: + * + * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} + * + * and + * + * DBUS_DATADIR + * + * On Windows there is no system bus and this function can return nothing. + * + * @param dirs the directory list we are returning + * @returns #FALSE on OOM + */ + +dbus_bool_t +_dbus_get_standard_system_servicedirs (DBusList **dirs) +{ + *dirs = NULL; + return TRUE; +} + +/** + * Append the absolute path of the system.conf file + * (there is no system bus on Windows so this can just + * return FALSE and print a warning or something) + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_system_config_file (DBusString *str) +{ + return _dbus_get_config_file_name(str, "system.conf"); +} + +/** + * Append the absolute path of the session.conf file. + * + * @param str the string to append to + * @returns #FALSE if no memory + */ +dbus_bool_t +_dbus_append_session_config_file (DBusString *str) +{ + return _dbus_get_config_file_name(str, "session.conf"); +} diff --git a/dbus/dbus-sysdeps-util.c b/dbus/dbus-sysdeps-util.c index 4b3d16f2..6b361ef0 100644 --- a/dbus/dbus-sysdeps-util.c +++ b/dbus/dbus-sysdeps-util.c @@ -80,7 +80,7 @@ _dbus_get_environment (void) return environment; } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static void check_dirname (const char *filename, const char *dirname) @@ -196,4 +196,4 @@ _dbus_sysdeps_test (void) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 72ccb93d..1c974c50 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -77,16 +77,6 @@ extern BOOL WINAPI ConvertSidToStringSidA (PSID Sid, LPSTR *StringSid); #include <ws2tcpip.h> #endif -#ifdef HAVE_WSPIAPI_H -// needed for w2k compatibility (getaddrinfo/freeaddrinfo/getnameinfo) -#ifdef __GNUC__ -#define _inline -#include "wspiapi.h" -#else -#include <wspiapi.h> -#endif -#endif // HAVE_WSPIAPI_H - #ifndef O_BINARY #define O_BINARY 0 #endif @@ -104,6 +94,142 @@ _dbus_win_set_errno (int err) #endif } +static BOOL is_winxp_sp3_or_lower(); + +/* + * _MIB_TCPROW_EX and friends are not available in system headers + * and are mapped to attribute identical ...OWNER_PID typedefs. + */ +typedef MIB_TCPROW_OWNER_PID _MIB_TCPROW_EX; +typedef MIB_TCPTABLE_OWNER_PID MIB_TCPTABLE_EX; +typedef PMIB_TCPTABLE_OWNER_PID PMIB_TCPTABLE_EX; +typedef DWORD (WINAPI *ProcAllocateAndGetTcpExtTableFromStack)(PMIB_TCPTABLE_EX*,BOOL,HANDLE,DWORD,DWORD); +static ProcAllocateAndGetTcpExtTableFromStack lpfnAllocateAndGetTcpExTableFromStack = NULL; + +/** + * AllocateAndGetTcpExTableFromStack() is undocumented and not exported, + * but is the only way to do this in older XP versions. + * @return true if the procedures could be loaded + */ +static BOOL +load_ex_ip_helper_procedures(void) +{ + HMODULE hModule = LoadLibrary ("iphlpapi.dll"); + if (hModule == NULL) + { + _dbus_verbose ("could not load iphlpapi.dll\n"); + return FALSE; + } + + lpfnAllocateAndGetTcpExTableFromStack = (ProcAllocateAndGetTcpExtTableFromStack)GetProcAddress (hModule, "AllocateAndGetTcpExTableFromStack"); + if (lpfnAllocateAndGetTcpExTableFromStack == NULL) + { + _dbus_verbose ("could not find function AllocateAndGetTcpExTableFromStack in iphlpapi.dll\n"); + return FALSE; + } + return TRUE; +} + +/** + * get pid from localhost tcp connection using peer_port + * This function is available on WinXP >= SP3 + * @param peer_port peers tcp port + * @return process id or 0 if connection has not been found + */ +static dbus_pid_t +get_pid_from_extended_tcp_table(int peer_port) +{ + dbus_pid_t result; + DWORD errorCode, size, i; + MIB_TCPTABLE_OWNER_PID *tcp_table; + + if ((errorCode = + GetExtendedTcpTable (NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) == ERROR_INSUFFICIENT_BUFFER) + { + tcp_table = (MIB_TCPTABLE_OWNER_PID *) dbus_malloc (size); + if (tcp_table == NULL) + { + _dbus_verbose ("Error allocating memory\n"); + return 0; + } + } + else + { + _dbus_win_warn_win_error ("unexpected error returned from GetExtendedTcpTable", errorCode); + return 0; + } + + if ((errorCode = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) + { + _dbus_verbose ("Error fetching tcp table %d\n", (int)errorCode); + dbus_free (tcp_table); + return 0; + } + + result = 0; + for (i = 0; i < tcp_table->dwNumEntries; i++) + { + MIB_TCPROW_OWNER_PID *p = &tcp_table->table[i]; + int local_address = ntohl (p->dwLocalAddr); + int local_port = ntohs (p->dwLocalPort); + if (p->dwState == MIB_TCP_STATE_ESTAB + && local_address == INADDR_LOOPBACK && local_port == peer_port) + result = p->dwOwningPid; + } + + dbus_free (tcp_table); + _dbus_verbose ("got pid %lu\n", result); + return result; +} + +/** + * get pid from localhost tcp connection using peer_port + * This function is available on all WinXP versions, but + * not in wine (at least version <= 1.6.0) + * @param peer_port peers tcp port + * @return process id or 0 if connection has not been found + */ +static dbus_pid_t +get_pid_from_tcp_ex_table(int peer_port) +{ + dbus_pid_t result; + DWORD errorCode, i; + PMIB_TCPTABLE_EX tcp_table = NULL; + + if (!load_ex_ip_helper_procedures ()) + { + _dbus_verbose + ("Error not been able to load iphelper procedures\n"); + return 0; + } + + errorCode = lpfnAllocateAndGetTcpExTableFromStack (&tcp_table, TRUE, GetProcessHeap(), 0, 2); + + if (errorCode != NO_ERROR) + { + _dbus_verbose + ("Error not been able to call AllocateAndGetTcpExTableFromStack()\n"); + return 0; + } + + result = 0; + for (i = 0; i < tcp_table->dwNumEntries; i++) + { + _MIB_TCPROW_EX *p = &tcp_table->table[i]; + int local_port = ntohs (p->dwLocalPort); + int local_address = ntohl (p->dwLocalAddr); + if (local_address == INADDR_LOOPBACK && local_port == peer_port) + { + result = p->dwOwningPid; + break; + } + } + + HeapFree (GetProcessHeap(), 0, tcp_table); + _dbus_verbose ("got pid %lu\n", result); + return result; +} + /** * @brief return peer process id from tcp handle for localhost connections * @param handle tcp socket descriptor @@ -117,9 +243,6 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) int peer_port; dbus_pid_t result; - DWORD size; - MIB_TCPTABLE_OWNER_PID *tcp_table; - DWORD i; dbus_bool_t is_localhost = FALSE; getpeername (handle, (struct sockaddr *) &addr, &len); @@ -128,7 +251,7 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) { struct sockaddr_in *s = (struct sockaddr_in *) &addr; peer_port = ntohs (s->sin_port); - is_localhost = (htonl (s->sin_addr.s_addr) == INADDR_LOOPBACK); + is_localhost = (ntohl (s->sin_addr.s_addr) == INADDR_LOOPBACK); } else if (addr.ss_family == AF_INET6) { @@ -160,35 +283,12 @@ _dbus_get_peer_pid_from_tcp_handle (int handle) return 0; } - if ((result = - GetExtendedTcpTable (NULL, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) == ERROR_INSUFFICIENT_BUFFER) - { - tcp_table = (MIB_TCPTABLE_OWNER_PID *) dbus_malloc (size); - if (tcp_table == NULL) - { - _dbus_verbose ("Error allocating memory\n"); - return 0; - } - } + _dbus_verbose ("trying to get peers pid"); - if ((result = GetExtendedTcpTable (tcp_table, &size, TRUE, AF_INET, TCP_TABLE_OWNER_PID_ALL, 0)) != NO_ERROR) - { - _dbus_verbose ("Error fetching tcp table %d\n", result); - dbus_free (tcp_table); - return 0; - } - - result = 0; - for (i = 0; i < tcp_table->dwNumEntries; i++) - { - MIB_TCPROW_OWNER_PID *p = &tcp_table->table[i]; - int local_port = ntohs (p->dwLocalPort); - if (p->dwState == MIB_TCP_STATE_ESTAB && local_port == peer_port) - result = p->dwOwningPid; - } - - _dbus_verbose ("got pid %d\n", result); - dbus_free (tcp_table); + result = get_pid_from_extended_tcp_table (peer_port); + if (result > 0) + return result; + result = get_pid_from_tcp_ex_table (peer_port); return result; } @@ -412,7 +512,7 @@ _dbus_close_socket (int fd, * on exec. Should be called for all file * descriptors in D-Bus code. * - * @param fd the file descriptor + * @param handle the Windows HANDLE */ void _dbus_fd_set_close_on_exec (intptr_t handle) @@ -428,7 +528,7 @@ _dbus_fd_set_close_on_exec (intptr_t handle) /** * Sets a file descriptor to be nonblocking. * - * @param fd the file descriptor. + * @param handle the file descriptor. * @param error address of error location. * @returns #TRUE on success. */ @@ -562,21 +662,26 @@ _dbus_connect_named_pipe (const char *path, #endif - - -void +/** + * @returns #FALSE if no memory + */ +dbus_bool_t _dbus_win_startup_winsock (void) { /* Straight from MSDN, deuglified */ + /* Protected by _DBUS_LOCK_sysdeps */ static dbus_bool_t beenhere = FALSE; WORD wVersionRequested; WSADATA wsaData; int err; + if (!_DBUS_LOCK (sysdeps)) + return FALSE; + if (beenhere) - return; + goto out; wVersionRequested = MAKEWORD (2, 0); @@ -600,6 +705,10 @@ _dbus_win_startup_winsock (void) } beenhere = TRUE; + +out: + _DBUS_UNLOCK (sysdeps); + return TRUE; } @@ -832,6 +941,38 @@ _dbus_pid_for_log (void) } #ifndef DBUS_WINCE + +static BOOL is_winxp_sp3_or_lower() +{ + OSVERSIONINFOEX osvi; + DWORDLONG dwlConditionMask = 0; + int op=VER_LESS_EQUAL; + + // Initialize the OSVERSIONINFOEX structure. + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + osvi.dwMajorVersion = 5; + osvi.dwMinorVersion = 1; + osvi.wServicePackMajor = 3; + osvi.wServicePackMinor = 0; + + // Initialize the condition mask. + + VER_SET_CONDITION( dwlConditionMask, VER_MAJORVERSION, op ); + VER_SET_CONDITION( dwlConditionMask, VER_MINORVERSION, op ); + VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMAJOR, op ); + VER_SET_CONDITION( dwlConditionMask, VER_SERVICEPACKMINOR, op ); + + // Perform the test. + + return VerifyVersionInfo( + &osvi, + VER_MAJORVERSION | VER_MINORVERSION | + VER_SERVICEPACKMAJOR | VER_SERVICEPACKMINOR, + dwlConditionMask); +} + /** Gets our SID * @param sid points to sid buffer, need to be freed with LocalFree() * @param process_id the process id for which the sid should be returned @@ -845,7 +986,8 @@ _dbus_getsid(char **sid, dbus_pid_t process_id) DWORD n; PSID psid; int retval = FALSE; - HANDLE process_handle = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); + + HANDLE process_handle = OpenProcess(is_winxp_sp3_or_lower() ? PROCESS_QUERY_INFORMATION : PROCESS_QUERY_LIMITED_INFORMATION, FALSE, process_id); if (!OpenProcessToken (process_handle, TOKEN_QUERY, &process_token)) { @@ -879,7 +1021,7 @@ failed: if (process_token != INVALID_HANDLE_VALUE) CloseHandle (process_token); - _dbus_verbose("_dbus_getsid() returns %d\n",retval); + _dbus_verbose("_dbus_getsid() got '%s' and returns %d\n", *sid, retval); return retval; } #endif @@ -911,7 +1053,11 @@ _dbus_full_duplex_pipe (int *fd1, int len; u_long arg; - _dbus_win_startup_winsock (); + if (!_dbus_win_startup_winsock ()) + { + _DBUS_SET_OOM (error); + return FALSE; + } temp = socket (AF_INET, SOCK_STREAM, 0); if (temp == INVALID_SOCKET) @@ -1355,7 +1501,11 @@ _dbus_connect_tcp_socket_with_nonce (const char *host, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - _dbus_win_startup_winsock (); + if (!_dbus_win_startup_winsock ()) + { + _DBUS_SET_OOM (error); + return -1; + } _DBUS_ZERO (hints); @@ -1500,7 +1650,11 @@ _dbus_listen_tcp_socket (const char *host, *fds_p = NULL; _DBUS_ASSERT_ERROR_IS_CLEAR (error); - _dbus_win_startup_winsock (); + if (!_dbus_win_startup_winsock ()) + { + _DBUS_SET_OOM (error); + return -1; + } _DBUS_ZERO (hints); @@ -1766,7 +1920,7 @@ again: * The point of the byte is that on some systems we have to * use sendmsg()/recvmsg() to transmit credentials. * - * @param client_fd the client file descriptor + * @param handle the client file descriptor * @param credentials struct to fill with credentials of client * @param error location to store error code * @returns #TRUE on success @@ -2113,14 +2267,18 @@ _dbus_generate_random_bytes (DBusString *str, * Gets the temporary files directory by inspecting the environment variables * TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned * - * @returns location of temp directory + * @returns location of temp directory, or #NULL if no memory for locking */ const char* _dbus_get_tmpdir(void) { + /* Protected by _DBUS_LOCK_sysdeps */ static const char* tmpdir = NULL; static char buf[1000]; + if (!_DBUS_LOCK (sysdeps)) + return NULL; + if (tmpdir == NULL) { char *last_slash; @@ -2142,6 +2300,8 @@ _dbus_get_tmpdir(void) tmpdir = buf; } + _DBUS_UNLOCK (sysdeps); + _dbus_assert(tmpdir != NULL); return tmpdir; @@ -2177,51 +2337,7 @@ _dbus_delete_file (const DBusString *filename, return TRUE; } -/* - * replaces the term DBUS_PREFIX in configure_time_path by the - * current dbus installation directory. On unix this function is a noop - * - * @param configure_time_path - * @return real path - */ -const char * -_dbus_replace_install_prefix (const char *configure_time_path) -{ -#ifndef DBUS_PREFIX - return configure_time_path; -#else - static char retval[1000]; - static char runtime_prefix[1000]; - int len = 1000; - int i; - - if (!configure_time_path) - return NULL; - - if ((!_dbus_get_install_root(runtime_prefix, len) || - strncmp (configure_time_path, DBUS_PREFIX "/", - strlen (DBUS_PREFIX) + 1))) { - strcat (retval, configure_time_path); - return retval; - } - - strcpy (retval, runtime_prefix); - strcat (retval, configure_time_path + strlen (DBUS_PREFIX) + 1); - - /* Somehow, in some situations, backslashes get collapsed in the string. - * Since windows C library accepts both forward and backslashes as - * path separators, convert all backslashes to forward slashes. - */ - - for(i = 0; retval[i] != '\0'; i++) { - if(retval[i] == '\\') - retval[i] = '/'; - } - return retval; -#endif -} - -#if !defined (DBUS_DISABLE_ASSERTS) || defined(DBUS_BUILD_TESTS) +#if !defined (DBUS_DISABLE_ASSERT) || defined(DBUS_ENABLE_EMBEDDED_TESTS) #if defined(_MSC_VER) || defined(DBUS_WINCE) # ifdef BACKTRACES @@ -3060,140 +3176,6 @@ _dbus_make_file_world_readable(const DBusString *filename, } /** - * return the relocated DATADIR - * - * @returns relocated DATADIR static string - */ - -static const char * -_dbus_windows_get_datadir (void) -{ - return _dbus_replace_install_prefix(DBUS_DATADIR); -} - -#undef DBUS_DATADIR -#define DBUS_DATADIR _dbus_windows_get_datadir () - - -#define DBUS_STANDARD_SESSION_SERVICEDIR "/dbus-1/services" -#define DBUS_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services" - -/** - * Returns the standard directories for a session bus to look for service - * activation files - * - * On Windows this should be data directories: - * - * %CommonProgramFiles%/dbus - * - * and - * - * relocated DBUS_DATADIR - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_session_servicedirs (DBusList **dirs) -{ - const char *common_progs; - DBusString servicedir_path; - - if (!_dbus_string_init (&servicedir_path)) - return FALSE; - -#ifdef DBUS_WINCE - { - /* On Windows CE, we adjust datadir dynamically to installation location. */ - const char *data_dir = _dbus_getenv ("DBUS_DATADIR"); - - if (data_dir != NULL) - { - if (!_dbus_string_append (&servicedir_path, data_dir)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) - goto oom; - } - } -#else -/* - the code for accessing services requires absolute base pathes - in case DBUS_DATADIR is relative make it absolute -*/ -#ifdef DBUS_WIN - { - DBusString p; - - _dbus_string_init_const (&p, DBUS_DATADIR); - - if (!_dbus_path_is_absolute (&p)) - { - char install_root[1000]; - if (_dbus_get_install_root (install_root, sizeof(install_root))) - if (!_dbus_string_append (&servicedir_path, install_root)) - goto oom; - } - } -#endif - if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) - goto oom; -#endif - - common_progs = _dbus_getenv ("CommonProgramFiles"); - - if (common_progs != NULL) - { - if (!_dbus_string_append (&servicedir_path, common_progs)) - goto oom; - - if (!_dbus_string_append (&servicedir_path, _DBUS_PATH_SEPARATOR)) - goto oom; - } - - if (!_dbus_split_paths_and_append (&servicedir_path, - DBUS_STANDARD_SESSION_SERVICEDIR, - dirs)) - goto oom; - - _dbus_string_free (&servicedir_path); - return TRUE; - - oom: - _dbus_string_free (&servicedir_path); - return FALSE; -} - -/** - * Returns the standard directories for a system bus to look for service - * activation files - * - * On UNIX this should be the standard xdg freedesktop.org data directories: - * - * XDG_DATA_DIRS=${XDG_DATA_DIRS-/usr/local/share:/usr/share} - * - * and - * - * DBUS_DATADIR - * - * On Windows there is no system bus and this function can return nothing. - * - * @param dirs the directory list we are returning - * @returns #FALSE on OOM - */ - -dbus_bool_t -_dbus_get_standard_system_servicedirs (DBusList **dirs) -{ - *dirs = NULL; - return TRUE; -} - -/** * Atomically increments an integer * * @param atomic pointer to the integer to increment @@ -3275,7 +3257,7 @@ _dbus_get_is_errno_eagain_or_ewouldblock (void) /** * return the absolute path of the dbus installation * - * @param s buffer for installation path + * @param prefix buffer for installation path * @param len length of buffer * @returns #FALSE on failure */ @@ -3380,32 +3362,6 @@ _dbus_get_config_file_name(DBusString *config_file, char *s) return TRUE; } -/** - * Append the absolute path of the system.conf file - * (there is no system bus on Windows so this can just - * return FALSE and print a warning or something) - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_system_config_file (DBusString *str) -{ - return _dbus_get_config_file_name(str, "system.conf"); -} - -/** - * Append the absolute path of the session.conf file. - * - * @param str the string to append to - * @returns #FALSE if no memory - */ -dbus_bool_t -_dbus_append_session_config_file (DBusString *str) -{ - return _dbus_get_config_file_name(str, "session.conf"); -} - /* See comment in dbus-sysdeps-unix.c */ dbus_bool_t _dbus_lookup_session_address (dbus_bool_t *supported, @@ -3457,7 +3413,7 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, _dbus_string_append(&homedir,homepath); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS { const char *override; @@ -3473,6 +3429,8 @@ _dbus_append_keyring_directory_for_credentials (DBusString *directory, } else { + /* Not strictly thread-safe, but if we fail at thread-safety here, + * the worst that will happen is some extra warnings. */ static dbus_bool_t already_warned = FALSE; if (!already_warned) { @@ -3697,7 +3655,7 @@ _dbus_win_set_error_from_win_error (DBusError *error, void _dbus_win_warn_win_error (const char *message, - int code) + unsigned long code) { DBusError error; diff --git a/dbus/dbus-sysdeps-win.h b/dbus/dbus-sysdeps-win.h index 5e7f1e46..90d14de0 100644 --- a/dbus/dbus-sysdeps-win.h +++ b/dbus/dbus-sysdeps-win.h @@ -42,9 +42,9 @@ extern void *_dbus_win_get_dll_hmodule (void); void _dbus_win_set_errno (int err); const char* _dbus_win_error_from_last_error (void); -void _dbus_win_startup_winsock (void); +dbus_bool_t _dbus_win_startup_winsock (void); void _dbus_win_warn_win_error (const char *message, - int code); + unsigned long code); char * _dbus_win_error_string (int error_number); void _dbus_win_free_error_string (char *string); diff --git a/dbus/dbus-sysdeps-wince-glue.c b/dbus/dbus-sysdeps-wince-glue.c index 74b1371f..e276f046 100644 --- a/dbus/dbus-sysdeps-wince-glue.c +++ b/dbus/dbus-sysdeps-wince-glue.c @@ -491,7 +491,7 @@ SearchPathA (LPCSTR lpPath, LPCSTR lpFileName, LPCSTR lpExtension, /** Gets our SID - * @param points to sid buffer, need to be freed with LocalFree() + * @param sid points to sid buffer, need to be freed with LocalFree() * @returns process sid */ dbus_bool_t diff --git a/dbus/dbus-sysdeps.c b/dbus/dbus-sysdeps.c index 4e14ac38..de3a18cb 100644 --- a/dbus/dbus-sysdeps.c +++ b/dbus/dbus-sysdeps.c @@ -29,6 +29,7 @@ #include "dbus-protocol.h" #include "dbus-string.h" #include "dbus-list.h" +#include "dbus-misc.h" /* NOTE: If you include any unix/windows-specific headers here, you are probably doing something * wrong and should be putting some code in dbus-sysdeps-unix.c or dbus-sysdeps-win.c. @@ -46,8 +47,6 @@ #include <errno.h> #endif -_DBUS_DEFINE_GLOBAL_LOCK (system_users); - #ifdef DBUS_WIN #include <stdlib.h> #elif (defined __APPLE__) @@ -94,6 +93,8 @@ _dbus_abort (void) } /** + * @ingroup DBusMisc + * * Wrapper for setenv(). If the value is #NULL, unsets * the environment variable. * @@ -102,13 +103,16 @@ _dbus_abort (void) * we can not rely on internal implementation details of * the underlying libc library. * + * This function is not thread-safe, because altering the environment + * in Unix is not thread-safe in general. + * * @param varname name of environment variable - * @param value value of environment variable - * @returns #TRUE on success. + * @param value value of environment variable, or #NULL to unset + * @returns #TRUE on success, #FALSE if not enough memory. */ dbus_bool_t -_dbus_setenv (const char *varname, - const char *value) +dbus_setenv (const char *varname, + const char *value) { _dbus_assert (varname != NULL); diff --git a/dbus/dbus-sysdeps.h b/dbus/dbus-sysdeps.h index 1053303a..e586946f 100644 --- a/dbus/dbus-sysdeps.h +++ b/dbus/dbus-sysdeps.h @@ -89,8 +89,6 @@ void _dbus_abort (void) _DBUS_GNUC_NORETURN; dbus_bool_t _dbus_check_setuid (void); const char* _dbus_getenv (const char *varname); -dbus_bool_t _dbus_setenv (const char *varname, - const char *value); dbus_bool_t _dbus_clearenv (void); char ** _dbus_get_environment (void); diff --git a/dbus/dbus-test.c b/dbus/dbus-test.c index 224a6c8c..b707ee22 100644 --- a/dbus/dbus-test.c +++ b/dbus/dbus-test.c @@ -28,7 +28,7 @@ #include <stdio.h> #include <stdlib.h> -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS static void die (const char *failure) { @@ -84,7 +84,7 @@ run_data_test (const char *test_name, } } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** * An exported symbol to be run in order to execute @@ -94,11 +94,12 @@ run_data_test (const char *test_name, * (with --enable-tests=no) * * @param test_data_dir the directory with test data (test/data normally) + * @param specific_test run specific test or #NULL to run all tests */ void dbus_internal_do_not_use_run_tests (const char *test_data_dir, const char *specific_test) { -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS if (!_dbus_threads_init_debug ()) die ("debug threads init"); diff --git a/dbus/dbus-threads.c b/dbus/dbus-threads.c index 43676bc1..12d40493 100644 --- a/dbus/dbus-threads.c +++ b/dbus/dbus-threads.c @@ -27,18 +27,6 @@ #include "dbus-list.h" static int thread_init_generation = 0; - -static DBusList *uninitialized_rmutex_list = NULL; -static DBusList *uninitialized_cmutex_list = NULL; -static DBusList *uninitialized_condvar_list = NULL; - -/** This is used for the no-op default mutex pointer, just to be distinct from #NULL */ -#define _DBUS_DUMMY_MUTEX ((DBusMutex*)0xABCDEF) -#define _DBUS_DUMMY_RMUTEX ((DBusRMutex *) _DBUS_DUMMY_MUTEX) -#define _DBUS_DUMMY_CMUTEX ((DBusCMutex *) _DBUS_DUMMY_MUTEX) - -/** This is used for the no-op default mutex pointer, just to be distinct from #NULL */ -#define _DBUS_DUMMY_CONDVAR ((DBusCondVar*)0xABCDEF2) /** * @defgroup DBusThreadsInternals Thread functions @@ -59,11 +47,6 @@ static DBusList *uninitialized_condvar_list = NULL; * If possible, the mutex returned by this function is recursive, to * avoid deadlocks. However, that cannot be relied on. * - * The extra level of indirection given by allocating a pointer - * to point to the mutex location allows the threading - * module to swap out dummy mutexes for a real mutex so libraries - * can initialize threads even after the D-Bus API has been used. - * * @param location_p the location of the new mutex, can return #NULL on OOM */ void @@ -71,17 +54,13 @@ _dbus_rmutex_new_at_location (DBusRMutex **location_p) { _dbus_assert (location_p != NULL); - if (thread_init_generation == _dbus_current_generation) + if (!dbus_threads_init_default ()) { - *location_p = _dbus_platform_rmutex_new (); + *location_p = NULL; + return; } - else - { - *location_p = _DBUS_DUMMY_RMUTEX; - if (!_dbus_list_append (&uninitialized_rmutex_list, location_p)) - *location_p = NULL; - } + *location_p = _dbus_platform_rmutex_new (); } /** @@ -92,11 +71,6 @@ _dbus_rmutex_new_at_location (DBusRMutex **location_p) * * The returned mutex is suitable for use with condition variables. * - * The extra level of indirection given by allocating a pointer - * to point to the mutex location allows the threading - * module to swap out dummy mutexes for a real mutex so libraries - * can initialize threads even after the D-Bus API has been used. - * * @param location_p the location of the new mutex, can return #NULL on OOM */ void @@ -104,22 +78,17 @@ _dbus_cmutex_new_at_location (DBusCMutex **location_p) { _dbus_assert (location_p != NULL); - if (thread_init_generation == _dbus_current_generation) + if (!dbus_threads_init_default ()) { - *location_p = _dbus_platform_cmutex_new (); + *location_p = NULL; + return; } - else - { - *location_p = _DBUS_DUMMY_CMUTEX; - if (!_dbus_list_append (&uninitialized_cmutex_list, location_p)) - *location_p = NULL; - } + *location_p = _dbus_platform_cmutex_new (); } /** - * Frees a DBusRMutex or removes it from the uninitialized mutex list; - * does nothing if passed a #NULL pointer. + * Frees a DBusRMutex; does nothing if passed a #NULL pointer. */ void _dbus_rmutex_free_at_location (DBusRMutex **location_p) @@ -127,23 +96,12 @@ _dbus_rmutex_free_at_location (DBusRMutex **location_p) if (location_p == NULL) return; - if (thread_init_generation == _dbus_current_generation) - { - if (*location_p != NULL) - _dbus_platform_rmutex_free (*location_p); - } - else - { - _dbus_assert (*location_p == NULL || *location_p == _DBUS_DUMMY_RMUTEX); - - _dbus_list_remove (&uninitialized_rmutex_list, location_p); - } + if (*location_p != NULL) + _dbus_platform_rmutex_free (*location_p); } /** - * Frees a DBusCMutex and removes it from the - * uninitialized mutex list; - * does nothing if passed a #NULL pointer. + * Frees a DBusCMutex; does nothing if passed a #NULL pointer. */ void _dbus_cmutex_free_at_location (DBusCMutex **location_p) @@ -151,17 +109,8 @@ _dbus_cmutex_free_at_location (DBusCMutex **location_p) if (location_p == NULL) return; - if (thread_init_generation == _dbus_current_generation) - { - if (*location_p != NULL) - _dbus_platform_cmutex_free (*location_p); - } - else - { - _dbus_assert (*location_p == NULL || *location_p == _DBUS_DUMMY_CMUTEX); - - _dbus_list_remove (&uninitialized_cmutex_list, location_p); - } + if (*location_p != NULL) + _dbus_platform_cmutex_free (*location_p); } /** @@ -172,8 +121,10 @@ _dbus_cmutex_free_at_location (DBusCMutex **location_p) void _dbus_rmutex_lock (DBusRMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_rmutex_lock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_rmutex_lock (mutex); } /** @@ -184,8 +135,10 @@ _dbus_rmutex_lock (DBusRMutex *mutex) void _dbus_cmutex_lock (DBusCMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_cmutex_lock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_cmutex_lock (mutex); } /** @@ -196,8 +149,10 @@ _dbus_cmutex_lock (DBusCMutex *mutex) void _dbus_rmutex_unlock (DBusRMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_rmutex_unlock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_rmutex_unlock (mutex); } /** @@ -208,8 +163,10 @@ _dbus_rmutex_unlock (DBusRMutex *mutex) void _dbus_cmutex_unlock (DBusCMutex *mutex) { - if (mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_cmutex_unlock (mutex); + if (mutex == NULL) + return; + + _dbus_platform_cmutex_unlock (mutex); } /** @@ -223,19 +180,17 @@ _dbus_cmutex_unlock (DBusCMutex *mutex) DBusCondVar * _dbus_condvar_new (void) { - if (thread_init_generation == _dbus_current_generation) - return _dbus_platform_condvar_new (); - else - return _DBUS_DUMMY_CONDVAR; + if (!dbus_threads_init_default ()) + return NULL; + + return _dbus_platform_condvar_new (); } /** * This does the same thing as _dbus_condvar_new. It however * gives another level of indirection by allocating a pointer - * to point to the condvar location. This allows the threading - * module to swap out dummy condvars for a real condvar so libraries - * can initialize threads even after the D-Bus API has been used. + * to point to the condvar location; this used to be useful. * * @returns the location of a new condvar or #NULL on OOM */ @@ -245,17 +200,7 @@ _dbus_condvar_new_at_location (DBusCondVar **location_p) { _dbus_assert (location_p != NULL); - if (thread_init_generation == _dbus_current_generation) - { - *location_p = _dbus_condvar_new(); - } - else - { - *location_p = _DBUS_DUMMY_CONDVAR; - - if (!_dbus_list_append (&uninitialized_condvar_list, location_p)) - *location_p = NULL; - } + *location_p = _dbus_condvar_new(); } @@ -266,14 +211,14 @@ _dbus_condvar_new_at_location (DBusCondVar **location_p) void _dbus_condvar_free (DBusCondVar *cond) { - if (cond && thread_init_generation == _dbus_current_generation) - _dbus_platform_condvar_free (cond); + if (cond == NULL) + return; + + _dbus_platform_condvar_free (cond); } /** - * Frees a conditional variable and removes it from the - * uninitialized_condvar_list; - * does nothing if passed a #NULL pointer. + * Frees a condition variable; does nothing if passed a #NULL pointer. */ void _dbus_condvar_free_at_location (DBusCondVar **location_p) @@ -281,17 +226,8 @@ _dbus_condvar_free_at_location (DBusCondVar **location_p) if (location_p == NULL) return; - if (thread_init_generation == _dbus_current_generation) - { - if (*location_p != NULL) - _dbus_platform_condvar_free (*location_p); - } - else - { - _dbus_assert (*location_p == NULL || *location_p == _DBUS_DUMMY_CONDVAR); - - _dbus_list_remove (&uninitialized_condvar_list, location_p); - } + if (*location_p != NULL) + _dbus_platform_condvar_free (*location_p); } /** @@ -304,8 +240,10 @@ void _dbus_condvar_wait (DBusCondVar *cond, DBusCMutex *mutex) { - if (cond && mutex && thread_init_generation == _dbus_current_generation) - _dbus_platform_condvar_wait (cond, mutex); + if (cond == NULL || mutex == NULL) + return; + + _dbus_platform_condvar_wait (cond, mutex); } /** @@ -324,11 +262,11 @@ _dbus_condvar_wait_timeout (DBusCondVar *cond, DBusCMutex *mutex, int timeout_milliseconds) { - if (cond && mutex && thread_init_generation == _dbus_current_generation) - return _dbus_platform_condvar_wait_timeout (cond, mutex, - timeout_milliseconds); - else + if (cond == NULL || mutex == NULL) return TRUE; + + return _dbus_platform_condvar_wait_timeout (cond, mutex, + timeout_milliseconds); } /** @@ -339,209 +277,83 @@ _dbus_condvar_wait_timeout (DBusCondVar *cond, void _dbus_condvar_wake_one (DBusCondVar *cond) { - if (cond && thread_init_generation == _dbus_current_generation) - _dbus_platform_condvar_wake_one (cond); + if (cond == NULL) + return; + + _dbus_platform_condvar_wake_one (cond); } +static DBusRMutex *global_locks[_DBUS_N_GLOBAL_LOCKS] = { NULL }; + static void -shutdown_global_locks (void *data) +shutdown_global_locks (void *nil) { - DBusRMutex ***locks = data; int i; - i = 0; - while (i < _DBUS_N_GLOBAL_LOCKS) + for (i = 0; i < _DBUS_N_GLOBAL_LOCKS; i++) { - if (*(locks[i]) != NULL) - _dbus_platform_rmutex_free (*(locks[i])); - - *(locks[i]) = NULL; - ++i; + _dbus_assert (global_locks[i] != NULL); + _dbus_platform_rmutex_free (global_locks[i]); + global_locks[i] = NULL; } - - dbus_free (locks); -} - -static void -shutdown_uninitialized_locks (void *data) -{ - _dbus_list_clear (&uninitialized_rmutex_list); - _dbus_list_clear (&uninitialized_cmutex_list); - _dbus_list_clear (&uninitialized_condvar_list); } static dbus_bool_t -init_uninitialized_locks (void) +init_global_locks (void) { - DBusList *link; - - _dbus_assert (thread_init_generation != _dbus_current_generation); - - link = uninitialized_rmutex_list; - while (link != NULL) - { - DBusRMutex **mp; - - mp = link->data; - _dbus_assert (*mp == _DBUS_DUMMY_RMUTEX); - - *mp = _dbus_platform_rmutex_new (); - if (*mp == NULL) - goto fail_mutex; - - link = _dbus_list_get_next_link (&uninitialized_rmutex_list, link); - } - - link = uninitialized_cmutex_list; - while (link != NULL) - { - DBusCMutex **mp; - - mp = link->data; - _dbus_assert (*mp == _DBUS_DUMMY_CMUTEX); - - *mp = _dbus_platform_cmutex_new (); - if (*mp == NULL) - goto fail_mutex; - - link = _dbus_list_get_next_link (&uninitialized_cmutex_list, link); - } + int i; + dbus_bool_t ok; - link = uninitialized_condvar_list; - while (link != NULL) + for (i = 0; i < _DBUS_N_GLOBAL_LOCKS; i++) { - DBusCondVar **cp; - - cp = (DBusCondVar **)link->data; - _dbus_assert (*cp == _DBUS_DUMMY_CONDVAR); + _dbus_assert (global_locks[i] == NULL); - *cp = _dbus_platform_condvar_new (); - if (*cp == NULL) - goto fail_condvar; + global_locks[i] = _dbus_platform_rmutex_new (); - link = _dbus_list_get_next_link (&uninitialized_condvar_list, link); + if (global_locks[i] == NULL) + goto failed; } - _dbus_list_clear (&uninitialized_rmutex_list); - _dbus_list_clear (&uninitialized_cmutex_list); - _dbus_list_clear (&uninitialized_condvar_list); + _dbus_platform_rmutex_lock (global_locks[_DBUS_LOCK_shutdown_funcs]); + ok = _dbus_register_shutdown_func_unlocked (shutdown_global_locks, NULL); + _dbus_platform_rmutex_unlock (global_locks[_DBUS_LOCK_shutdown_funcs]); - if (!_dbus_register_shutdown_func (shutdown_uninitialized_locks, - NULL)) - goto fail_condvar; + if (!ok) + goto failed; return TRUE; - fail_condvar: - link = uninitialized_condvar_list; - while (link != NULL) - { - DBusCondVar **cp; - - cp = link->data; - - if (*cp != _DBUS_DUMMY_CONDVAR && *cp != NULL) - _dbus_platform_condvar_free (*cp); - - *cp = _DBUS_DUMMY_CONDVAR; - - link = _dbus_list_get_next_link (&uninitialized_condvar_list, link); - } - - fail_mutex: - link = uninitialized_rmutex_list; - while (link != NULL) - { - DBusRMutex **mp; - - mp = link->data; - - if (*mp != _DBUS_DUMMY_RMUTEX && *mp != NULL) - _dbus_platform_rmutex_free (*mp); - - *mp = _DBUS_DUMMY_RMUTEX; - - link = _dbus_list_get_next_link (&uninitialized_rmutex_list, link); - } - - link = uninitialized_cmutex_list; - while (link != NULL) + failed: + for (i = i - 1; i >= 0; i--) { - DBusCMutex **mp; - - mp = link->data; - - if (*mp != _DBUS_DUMMY_CMUTEX && *mp != NULL) - _dbus_platform_cmutex_free (*mp); - - *mp = _DBUS_DUMMY_CMUTEX; - - link = _dbus_list_get_next_link (&uninitialized_cmutex_list, link); + _dbus_platform_rmutex_free (global_locks[i]); + global_locks[i] = NULL; } return FALSE; } -static dbus_bool_t -init_locks (void) +dbus_bool_t +_dbus_lock (DBusGlobalLock lock) { - int i; - DBusRMutex ***dynamic_global_locks; - DBusRMutex **global_locks[] = { -#define LOCK_ADDR(name) (& _dbus_lock_##name) - LOCK_ADDR (list), - LOCK_ADDR (connection_slots), - LOCK_ADDR (pending_call_slots), - LOCK_ADDR (server_slots), - LOCK_ADDR (message_slots), - LOCK_ADDR (bus), - LOCK_ADDR (bus_datas), - LOCK_ADDR (shutdown_funcs), - LOCK_ADDR (system_users), - LOCK_ADDR (message_cache), - LOCK_ADDR (shared_connections), - LOCK_ADDR (machine_uuid) -#undef LOCK_ADDR - }; - - _DBUS_STATIC_ASSERT (_DBUS_N_ELEMENTS (global_locks) == _DBUS_N_GLOBAL_LOCKS); - - i = 0; - - dynamic_global_locks = dbus_new (DBusRMutex**, _DBUS_N_GLOBAL_LOCKS); - if (dynamic_global_locks == NULL) - goto failed; - - while (i < _DBUS_N_ELEMENTS (global_locks)) - { - *global_locks[i] = _dbus_platform_rmutex_new (); - - if (*global_locks[i] == NULL) - goto failed; - - dynamic_global_locks[i] = global_locks[i]; + _dbus_assert (lock >= 0); + _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); - ++i; - } - - if (!_dbus_register_shutdown_func (shutdown_global_locks, - dynamic_global_locks)) - goto failed; + if (thread_init_generation != _dbus_current_generation && + !dbus_threads_init_default ()) + return FALSE; - if (!init_uninitialized_locks ()) - goto failed; - + _dbus_platform_rmutex_lock (global_locks[lock]); return TRUE; +} - failed: - dbus_free (dynamic_global_locks); - - for (i = i - 1; i >= 0; i--) - { - _dbus_platform_rmutex_free (*global_locks[i]); - *global_locks[i] = NULL; - } - return FALSE; +void +_dbus_unlock (DBusGlobalLock lock) +{ + _dbus_assert (lock >= 0); + _dbus_assert (lock < _DBUS_N_GLOBAL_LOCKS); + + _dbus_platform_rmutex_unlock (global_locks[lock]); } /** @} */ /* end of internals */ @@ -587,7 +399,7 @@ dbus_threads_init (const DBusThreadFunctions *functions) } if (!_dbus_threads_init_platform_specific() || - !init_locks ()) + !init_global_locks ()) { _dbus_threads_unlock_platform_specific (); return FALSE; @@ -631,7 +443,7 @@ dbus_threads_init_default (void) /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS dbus_bool_t _dbus_threads_init_debug (void) @@ -639,4 +451,4 @@ _dbus_threads_init_debug (void) return dbus_threads_init (NULL); } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-transport-protected.h b/dbus/dbus-transport-protected.h index 44b9d785..396f0ffd 100644 --- a/dbus/dbus-transport-protected.h +++ b/dbus/dbus-transport-protected.h @@ -111,7 +111,7 @@ struct DBusTransport DBusFreeFunction free_windows_user_data; /**< Function to free windows_user_data */ unsigned int disconnected : 1; /**< #TRUE if we are disconnected. */ - unsigned int authenticated : 1; /**< Cache of auth state; use _dbus_transport_get_is_authenticated() to query value */ + unsigned int authenticated : 1; /**< Cache of auth state; use _dbus_transport_peek_is_authenticated() to query value */ unsigned int send_credentials_pending : 1; /**< #TRUE if we need to send credentials */ unsigned int receive_credentials_pending : 1; /**< #TRUE if we need to receive credentials */ unsigned int is_server : 1; /**< #TRUE if on the server side */ diff --git a/dbus/dbus-transport-socket.c b/dbus/dbus-transport-socket.c index 544d00a9..44c7af7d 100644 --- a/dbus/dbus-transport-socket.c +++ b/dbus/dbus-transport-socket.c @@ -135,7 +135,7 @@ check_write_watch (DBusTransport *transport) _dbus_transport_ref (transport); - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) needed = _dbus_connection_has_messages_to_send_unlocked (transport->connection); else { @@ -190,7 +190,7 @@ check_read_watch (DBusTransport *transport) _dbus_transport_ref (transport); - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) need_read_watch = (_dbus_counter_get_size_value (transport->live_messages) < transport->max_live_messages_size) && (_dbus_counter_get_unix_fd_value (transport->live_messages) < transport->max_live_messages_unix_fds); @@ -404,7 +404,7 @@ do_authentication (DBusTransport *transport, oom = FALSE; - orig_auth_state = _dbus_transport_get_is_authenticated (transport); + orig_auth_state = _dbus_transport_try_to_authenticate (transport); /* This is essential to avoid the check_write_watch() at the end, * we don't want to add a write watch in do_iteration before @@ -419,7 +419,7 @@ do_authentication (DBusTransport *transport, _dbus_transport_ref (transport); - while (!_dbus_transport_get_is_authenticated (transport) && + while (!_dbus_transport_try_to_authenticate (transport) && _dbus_transport_get_is_connected (transport)) { if (!exchange_credentials (transport, do_reading, do_writing)) @@ -477,7 +477,7 @@ do_authentication (DBusTransport *transport, out: if (auth_completed) - *auth_completed = (orig_auth_state != _dbus_transport_get_is_authenticated (transport)); + *auth_completed = (orig_auth_state != _dbus_transport_try_to_authenticate (transport)); check_read_watch (transport); check_write_watch (transport); @@ -498,7 +498,7 @@ do_writing (DBusTransport *transport) dbus_bool_t oom; /* No messages without authentication! */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) { _dbus_verbose ("Not authenticated, not writing anything\n"); return TRUE; @@ -703,7 +703,7 @@ do_reading (DBusTransport *transport) _dbus_verbose ("fd = %d\n",socket_transport->fd); /* No messages without authentication! */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) return TRUE; oom = FALSE; @@ -748,29 +748,23 @@ do_reading (DBusTransport *transport) if (bytes_read > 0) { - int orig_len; - _dbus_message_loader_get_buffer (transport->loader, &buffer); - orig_len = _dbus_string_get_length (buffer); - if (!_dbus_auth_decode_data (transport->auth, &socket_transport->encoded_incoming, buffer)) { _dbus_verbose ("Out of memory decoding incoming data\n"); _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - orig_len); + buffer); oom = TRUE; goto out; } _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - orig_len); + buffer); _dbus_string_set_length (&socket_transport->encoded_incoming, 0); _dbus_string_compact (&socket_transport->encoded_incoming, 2048); @@ -789,7 +783,7 @@ do_reading (DBusTransport *transport) if (!_dbus_message_loader_get_unix_fds(transport->loader, &fds, &n_fds)) { _dbus_verbose ("Out of memory reading file descriptors\n"); - _dbus_message_loader_return_buffer (transport->loader, buffer, 0); + _dbus_message_loader_return_buffer (transport->loader, buffer); oom = TRUE; goto out; } @@ -812,8 +806,7 @@ do_reading (DBusTransport *transport) } _dbus_message_loader_return_buffer (transport->loader, - buffer, - bytes_read < 0 ? 0 : bytes_read); + buffer); } if (bytes_read < 0) @@ -1055,7 +1048,7 @@ socket_do_iteration (DBusTransport *transport, poll_fd.fd = socket_transport->fd; poll_fd.events = 0; - if (_dbus_transport_get_is_authenticated (transport)) + if (_dbus_transport_try_to_authenticate (transport)) { /* This is kind of a hack; if we have stuff to write, then try * to avoid the poll. This is probably about a 5% speedup on an @@ -1299,7 +1292,7 @@ _dbus_transport_new_for_socket (int fd, * @param host the host to connect to * @param port the port to connect to * @param family the address family to connect to - * @param path to nonce file + * @param noncefile path to nonce file * @param error location to store reason for failure. * @returns a new transport, or #NULL on failure. */ diff --git a/dbus/dbus-transport-unix.c b/dbus/dbus-transport-unix.c index 6ba5c0b5..9a9fea50 100644 --- a/dbus/dbus-transport-unix.c +++ b/dbus/dbus-transport-unix.c @@ -412,7 +412,7 @@ _dbus_transport_open_platform_specific (DBusAddressEntry *entry, /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS dbus_bool_t _dbus_transport_unix_test (void) diff --git a/dbus/dbus-transport.c b/dbus/dbus-transport.c index c483d764..ecc31827 100644 --- a/dbus/dbus-transport.c +++ b/dbus/dbus-transport.c @@ -32,7 +32,7 @@ #include "dbus-credentials.h" #include "dbus-mainloop.h" #include "dbus-message.h" -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include "dbus-server-debug-pipe.h" #endif @@ -242,6 +242,7 @@ _dbus_transport_finalize_base (DBusTransport *transport) * opened DBusTransport object. If it isn't, returns #NULL * and sets @p error. * + * @param address the address to be checked. * @param error address where an error can be returned. * @returns a new transport, or #NULL on failure. */ @@ -272,6 +273,7 @@ check_address (const char *address, DBusError *error) * Creates a new transport for the "autostart" method. * This creates a client-side of a transport. * + * @param scope scope of autolaunch (Windows only) * @param error address where an error can be returned. * @returns a new transport, or #NULL on failure. */ @@ -348,7 +350,7 @@ static const struct { { _dbus_transport_open_socket }, { _dbus_transport_open_platform_specific }, { _dbus_transport_open_autolaunch } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS , { _dbus_transport_open_debug_pipe } #endif }; @@ -684,10 +686,33 @@ auth_via_default_rules (DBusTransport *transport) return allow; } +/** + * Returns #TRUE if we have been authenticated. It will return #TRUE even if + * the transport is now disconnected, but was ever authenticated before + * disconnecting. + * + * This replaces the older _dbus_transport_get_is_authenticated() which + * had side-effects. + * + * @param transport the transport + * @returns whether we're authenticated + */ +dbus_bool_t +_dbus_transport_peek_is_authenticated (DBusTransport *transport) +{ + return transport->authenticated; +} /** - * Returns #TRUE if we have been authenticated. Will return #TRUE - * even if the transport is disconnected. + * Returns #TRUE if we have been authenticated. It will return #TRUE even if + * the transport is now disconnected, but was ever authenticated before + * disconnecting. + * + * If we have not finished authenticating, but we have enough buffered input + * to finish the job, then this function will do so before it returns. + * + * This used to be called _dbus_transport_get_is_authenticated(), but that + * name seems inappropriate for a function with side-effects. * * @todo we drop connection->mutex when calling the unix_user_function, * and windows_user_function, which may not be safe really. @@ -696,7 +721,7 @@ auth_via_default_rules (DBusTransport *transport) * @returns whether we're authenticated */ dbus_bool_t -_dbus_transport_get_is_authenticated (DBusTransport *transport) +_dbus_transport_try_to_authenticate (DBusTransport *transport) { if (transport->authenticated) return TRUE; @@ -1020,9 +1045,7 @@ recover_unused_bytes (DBusTransport *transport) orig_len); _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - - orig_len); + buffer); _dbus_auth_delete_unused_bytes (transport->auth); @@ -1052,9 +1075,7 @@ recover_unused_bytes (DBusTransport *transport) orig_len); _dbus_message_loader_return_buffer (transport->loader, - buffer, - _dbus_string_get_length (buffer) - - orig_len); + buffer); if (succeeded) _dbus_auth_delete_unused_bytes (transport->auth); @@ -1083,12 +1104,12 @@ _dbus_transport_get_dispatch_status (DBusTransport *transport) _dbus_counter_get_unix_fd_value (transport->live_messages) >= transport->max_live_messages_unix_fds) return DBUS_DISPATCH_COMPLETE; /* complete for now */ - if (!_dbus_transport_get_is_authenticated (transport)) + if (!_dbus_transport_try_to_authenticate (transport)) { if (_dbus_auth_do_work (transport->auth) == DBUS_AUTH_STATE_WAITING_FOR_MEMORY) return DBUS_DISPATCH_NEED_MEMORY; - else if (!_dbus_transport_get_is_authenticated (transport)) + else if (!_dbus_transport_try_to_authenticate (transport)) return DBUS_DISPATCH_COMPLETE; } diff --git a/dbus/dbus-transport.h b/dbus/dbus-transport.h index 4b821517..80fa24ef 100644 --- a/dbus/dbus-transport.h +++ b/dbus/dbus-transport.h @@ -38,7 +38,8 @@ DBusTransport* _dbus_transport_ref (DBusTransport void _dbus_transport_unref (DBusTransport *transport); void _dbus_transport_disconnect (DBusTransport *transport); dbus_bool_t _dbus_transport_get_is_connected (DBusTransport *transport); -dbus_bool_t _dbus_transport_get_is_authenticated (DBusTransport *transport); +dbus_bool_t _dbus_transport_peek_is_authenticated (DBusTransport *transport); +dbus_bool_t _dbus_transport_try_to_authenticate (DBusTransport *transport); dbus_bool_t _dbus_transport_get_is_anonymous (DBusTransport *transport); dbus_bool_t _dbus_transport_can_pass_unix_fd (DBusTransport *transport); diff --git a/dbus/dbus-types.h b/dbus/dbus-types.h index 57fc586a..021a55af 100644 --- a/dbus/dbus-types.h +++ b/dbus/dbus-types.h @@ -79,43 +79,23 @@ typedef dbus_uint32_t dbus_bool_t; /** * @typedef dbus_uint64_t * - * A 64-bit unsigned integer on all platforms that support it. - * If supported, #DBUS_HAVE_INT64 will be defined. - * - * C99 requires a 64-bit type and most likely all interesting - * compilers support one. GLib for example flat-out requires - * a 64-bit type. - * - * You probably want to just assume #DBUS_HAVE_INT64 is always defined. + * A 64-bit unsigned integer. */ /** * @typedef dbus_int64_t * - * A 64-bit signed integer on all platforms that support it. - * If supported, #DBUS_HAVE_INT64 will be defined. - * - * C99 requires a 64-bit type and most likely all interesting - * compilers support one. GLib for example flat-out requires - * a 64-bit type. - * - * You probably want to just assume #DBUS_HAVE_INT64 is always defined. + * A 64-bit signed integer. */ /** * @def DBUS_HAVE_INT64 * - * Defined if 64-bit integers are available. Will be defined - * on any platform you care about, unless you care about - * some truly ancient UNIX, or some bizarre embedded platform. + * Always defined. * - * C99 requires a 64-bit type and most likely all interesting - * compilers support one. GLib for example flat-out requires - * a 64-bit type. - * - * You should feel comfortable ignoring this macro and just using - * int64 unconditionally. - * + * In older libdbus versions, this would be undefined if there was no + * 64-bit integer type on that platform. libdbus no longer supports + * such platforms. */ /** @@ -136,7 +116,7 @@ typedef dbus_uint32_t dbus_bool_t; /** * An 8-byte struct you could use to access int64 without having - * int64 support + * int64 support. Use #dbus_int64_t or #dbus_uint64_t instead. */ typedef struct { @@ -162,10 +142,8 @@ typedef union dbus_int32_t i32; /**< as int32 */ dbus_uint32_t u32; /**< as int32 */ dbus_bool_t bool_val; /**< as boolean */ -#ifdef DBUS_HAVE_INT64 dbus_int64_t i64; /**< as int64 */ dbus_uint64_t u64; /**< as int64 */ -#endif DBus8ByteStruct eight; /**< as 8-byte struct */ double dbl; /**< as double */ unsigned char byt; /**< as byte */ diff --git a/dbus/dbus-userdb-util.c b/dbus/dbus-userdb-util.c index 5af00922..888a23e9 100644 --- a/dbus/dbus-userdb-util.c +++ b/dbus/dbus-userdb-util.c @@ -104,7 +104,11 @@ _dbus_is_console_user (dbus_uid_t uid, #endif /* HAVE_CONSOLE_OWNER_FILE */ - _dbus_user_database_lock_system (); + if (!_dbus_user_database_lock_system ()) + { + _DBUS_SET_OOM (error); + return FALSE; + } db = _dbus_user_database_get_system (); if (db == NULL) @@ -158,7 +162,10 @@ _dbus_get_group_id (const DBusString *groupname, { DBusUserDatabase *db; const DBusGroupInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -195,7 +202,10 @@ _dbus_get_user_id_and_primary_group (const DBusString *username, { DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -251,7 +261,6 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db, gid = n; } -#ifdef DBUS_ENABLE_USERDB_CACHE if (gid != DBUS_GID_UNSET) info = _dbus_hash_table_lookup_uintptr (db->groups, gid); else @@ -264,9 +273,6 @@ _dbus_user_database_lookup_group (DBusUserDatabase *db, return info; } else -#else - if (1) -#endif { if (gid != DBUS_GID_UNSET) _dbus_verbose ("No cache for GID "DBUS_GID_FORMAT"\n", @@ -388,7 +394,9 @@ _dbus_groups_from_uid (dbus_uid_t uid, *group_ids = NULL; *n_group_ids = 0; - _dbus_user_database_lock_system (); + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -425,7 +433,7 @@ _dbus_groups_from_uid (dbus_uid_t uid, } /** @} */ -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS #include <stdio.h> /** @@ -478,4 +486,4 @@ _dbus_userdb_test (const char *test_data_dir) return TRUE; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ diff --git a/dbus/dbus-userdb.c b/dbus/dbus-userdb.c index 4e8b39aa..52f927a3 100644 --- a/dbus/dbus-userdb.c +++ b/dbus/dbus-userdb.c @@ -144,7 +144,6 @@ _dbus_user_database_lookup (DBusUserDatabase *db, uid = n; } -#ifdef DBUS_ENABLE_USERDB_CACHE if (uid != DBUS_UID_UNSET) info = _dbus_hash_table_lookup_uintptr (db->users, uid); else @@ -157,9 +156,6 @@ _dbus_user_database_lookup (DBusUserDatabase *db, return info; } else -#else - if (1) -#endif { if (uid != DBUS_UID_UNSET) _dbus_verbose ("No cache for UID "DBUS_UID_FORMAT"\n", @@ -306,11 +302,18 @@ init_system_db (void) /** * Locks global system user database. */ -void +dbus_bool_t _dbus_user_database_lock_system (void) { - _DBUS_LOCK (system_users); - database_locked = TRUE; + if (_DBUS_LOCK (system_users)) + { + database_locked = TRUE; + return TRUE; + } + else + { + return FALSE; + } } /** @@ -345,8 +348,12 @@ _dbus_user_database_get_system (void) void _dbus_user_database_flush_system (void) { - _dbus_user_database_lock_system (); - + if (!_dbus_user_database_lock_system ()) + { + /* nothing to flush */ + return; + } + if (system_db != NULL) _dbus_user_database_flush (system_db); @@ -363,7 +370,9 @@ _dbus_user_database_flush_system (void) dbus_bool_t _dbus_username_from_current_process (const DBusString **username) { - _dbus_user_database_lock_system (); + if (!_dbus_user_database_lock_system ()) + return FALSE; + if (!init_system_db ()) { _dbus_user_database_unlock_system (); @@ -385,7 +394,9 @@ _dbus_username_from_current_process (const DBusString **username) dbus_bool_t _dbus_homedir_from_current_process (const DBusString **homedir) { - _dbus_user_database_lock_system (); + if (!_dbus_user_database_lock_system ()) + return FALSE; + if (!init_system_db ()) { _dbus_user_database_unlock_system (); @@ -410,7 +421,10 @@ _dbus_homedir_from_username (const DBusString *username, { DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -449,7 +463,10 @@ _dbus_homedir_from_uid (dbus_uid_t uid, { DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -496,7 +513,9 @@ _dbus_credentials_add_from_user (DBusCredentials *credentials, DBusUserDatabase *db; const DBusUserInfo *info; - _dbus_user_database_lock_system (); + /* FIXME: this can't distinguish ENOMEM from other errors */ + if (!_dbus_user_database_lock_system ()) + return FALSE; db = _dbus_user_database_get_system (); if (db == NULL) @@ -579,7 +598,7 @@ _dbus_user_database_flush (DBusUserDatabase *db) _dbus_hash_table_remove_all(db->groups); } -#ifdef DBUS_BUILD_TESTS +#ifdef DBUS_ENABLE_EMBEDDED_TESTS /** * Increments refcount of user database. * @param db the database @@ -594,7 +613,7 @@ _dbus_user_database_ref (DBusUserDatabase *db) return db; } -#endif /* DBUS_BUILD_TESTS */ +#endif /* DBUS_ENABLE_EMBEDDED_TESTS */ /** * Decrements refcount of user database. diff --git a/dbus/dbus-userdb.h b/dbus/dbus-userdb.h index cb49d9e7..d6b72d8c 100644 --- a/dbus/dbus-userdb.h +++ b/dbus/dbus-userdb.h @@ -86,7 +86,7 @@ void _dbus_group_info_free_allocated (DBusGroupInfo *info); #endif /* DBUS_USERDB_INCLUDES_PRIVATE */ DBusUserDatabase* _dbus_user_database_get_system (void); -void _dbus_user_database_lock_system (void); +dbus_bool_t _dbus_user_database_lock_system (void) _DBUS_GNUC_WARN_UNUSED_RESULT; void _dbus_user_database_unlock_system (void); void _dbus_user_database_flush_system (void); diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c index b9f4ac23..b82c57d4 100644 --- a/dbus/dbus-watch.c +++ b/dbus/dbus-watch.c @@ -259,6 +259,25 @@ _dbus_watch_list_free (DBusWatchList *watch_list) dbus_free (watch_list); } +#ifdef DBUS_ENABLE_VERBOSE_MODE +static const char* +watch_flags_to_string (int flags) +{ + const char *watch_type; + + if ((flags & DBUS_WATCH_READABLE) && + (flags & DBUS_WATCH_WRITABLE)) + watch_type = "readwrite"; + else if (flags & DBUS_WATCH_READABLE) + watch_type = "read"; + else if (flags & DBUS_WATCH_WRITABLE) + watch_type = "write"; + else + watch_type = "not read or write"; + return watch_type; +} +#endif /* DBUS_ENABLE_VERBOSE_MODE */ + /** * Sets the watch functions. This function is the "backend" * for dbus_connection_set_watch_functions() and @@ -292,27 +311,9 @@ _dbus_watch_list_set_functions (DBusWatchList *watch_list, DBusList *next = _dbus_list_get_next_link (&watch_list->watches, link); -#ifdef DBUS_ENABLE_VERBOSE_MODE - { - const char *watch_type; - int flags; - - flags = dbus_watch_get_flags (link->data); - if ((flags & DBUS_WATCH_READABLE) && - (flags & DBUS_WATCH_WRITABLE)) - watch_type = "readwrite"; - else if (flags & DBUS_WATCH_READABLE) - watch_type = "read"; - else if (flags & DBUS_WATCH_WRITABLE) - watch_type = "write"; - else - watch_type = "not read or write"; - - _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", - watch_type, - dbus_watch_get_socket (link->data)); - } -#endif /* DBUS_ENABLE_VERBOSE_MODE */ + _dbus_verbose ("Adding a %s watch on fd %d using newly-set add watch function\n", + watch_flags_to_string (dbus_watch_get_flags (link->data)), + dbus_watch_get_socket (link->data)); if (!(* add_function) (link->data, data)) { diff --git a/doc/Makefile.am b/doc/Makefile.am index aa5c7e1f..b9a4c106 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,34 +1,22 @@ apidir = @htmldir@/api -MAN_XML_FILES = \ - dbus-cleanup-sockets.1.xml \ - dbus-daemon.1.xml \ - dbus-launch.1.xml \ - dbus-monitor.1.xml \ - dbus-run-session.1.xml \ - dbus-send.1.xml \ - dbus-uuidgen.1.xml \ - $(NULL) - -if DBUS_XML_DOCS_ENABLED -man1_MANS = \ +man_pages = \ dbus-cleanup-sockets.1 \ dbus-daemon.1 \ dbus-launch.1 \ dbus-monitor.1 \ dbus-run-session.1 \ dbus-send.1 \ - dbus-uuidgen.1 + dbus-uuidgen.1 \ + $(NULL) + +MAN_XML_FILES = $(patsubst %.1,%.1.xml,$(man_pages)) + +if DBUS_XML_DOCS_ENABLED +man1_MANS = $(man_pages) endif -MAN_HTML_FILES = \ - dbus-cleanup-sockets.1.html \ - dbus-daemon.1.html \ - dbus-launch.1.html \ - dbus-monitor.1.html \ - dbus-run-session.1.html \ - dbus-send.1.html \ - dbus-uuidgen.1.html +MAN_HTML_FILES = $(patsubst %.1,%.1.html,$(man_pages)) DTDS = \ busconfig.dtd \ diff --git a/doc/Makefile.in b/doc/Makefile.in index a0c16c40..3aa7b524 100644 --- a/doc/Makefile.in +++ b/doc/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. @@ -186,7 +186,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@ @@ -289,7 +288,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@ @@ -366,34 +364,19 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ apidir = @htmldir@/api -MAN_XML_FILES = \ - dbus-cleanup-sockets.1.xml \ - dbus-daemon.1.xml \ - dbus-launch.1.xml \ - dbus-monitor.1.xml \ - dbus-run-session.1.xml \ - dbus-send.1.xml \ - dbus-uuidgen.1.xml \ +man_pages = \ + dbus-cleanup-sockets.1 \ + dbus-daemon.1 \ + dbus-launch.1 \ + dbus-monitor.1 \ + dbus-run-session.1 \ + dbus-send.1 \ + dbus-uuidgen.1 \ $(NULL) -@DBUS_XML_DOCS_ENABLED_TRUE@man1_MANS = \ -@DBUS_XML_DOCS_ENABLED_TRUE@ dbus-cleanup-sockets.1 \ -@DBUS_XML_DOCS_ENABLED_TRUE@ dbus-daemon.1 \ -@DBUS_XML_DOCS_ENABLED_TRUE@ dbus-launch.1 \ -@DBUS_XML_DOCS_ENABLED_TRUE@ dbus-monitor.1 \ -@DBUS_XML_DOCS_ENABLED_TRUE@ dbus-run-session.1 \ -@DBUS_XML_DOCS_ENABLED_TRUE@ dbus-send.1 \ -@DBUS_XML_DOCS_ENABLED_TRUE@ dbus-uuidgen.1 - -MAN_HTML_FILES = \ - dbus-cleanup-sockets.1.html \ - dbus-daemon.1.html \ - dbus-launch.1.html \ - dbus-monitor.1.html \ - dbus-run-session.1.html \ - dbus-send.1.html \ - dbus-uuidgen.1.html - +MAN_XML_FILES = $(patsubst %.1,%.1.xml,$(man_pages)) +@DBUS_XML_DOCS_ENABLED_TRUE@man1_MANS = $(man_pages) +MAN_HTML_FILES = $(patsubst %.1,%.1.html,$(man_pages)) DTDS = \ busconfig.dtd \ introspect.dtd diff --git a/doc/dbus-daemon.1.xml.in b/doc/dbus-daemon.1.xml.in index aea25144..c08cf2b2 100644 --- a/doc/dbus-daemon.1.xml.in +++ b/doc/dbus-daemon.1.xml.in @@ -89,10 +89,16 @@ with SIGHUP.</para> <para>Force the message bus to fork and become a daemon, even if the configuration file does not specify that it should. In most contexts the configuration file already gets this -right, though. -<option>--nofork</option> -Force the message bus not to fork and become a daemon, even if -the configuration file specifies that it should.</para> +right, though. This option is not supported on Windows.</para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>--nofork</option></term> + <listitem> + <para>Force the message bus not to fork and become a daemon, even if + the configuration file specifies that it should. On Windows, + the dbus-daemon never forks, so this option is allowed but does + nothing.</para> </listitem> </varlistentry> <varlistentry> @@ -391,7 +397,7 @@ which mechanisms are listed is not meaningful.</para> </itemizedlist> <para>Adds a directory to scan for .service files. Directories are -scanned starting with the last to appear in the config file +scanned starting with the first to appear in the config file (the first .service file found that provides a particular service will be used).</para> diff --git a/doc/dbus-launch.1.xml.in b/doc/dbus-launch.1.xml.in index 727495b7..31dd6eac 100644 --- a/doc/dbus-launch.1.xml.in +++ b/doc/dbus-launch.1.xml.in @@ -20,10 +20,14 @@ <!-- body begins here --> <refsynopsisdiv id='synopsis'> <cmdsynopsis> - <command>dbus-launch</command> <arg choice='opt'>--version </arg> + <command>dbus-launch</command> + <arg choice='opt'>--version </arg> + <arg choice='opt'>--help </arg> <arg choice='opt'>--sh-syntax </arg> <arg choice='opt'>--csh-syntax </arg> <arg choice='opt'>--auto-syntax </arg> + <arg choice='opt'>--binary-syntax </arg> + <arg choice='opt'>--close-stderr </arg> <arg choice='opt'>--exit-with-session </arg> <arg choice='opt'>--autolaunch=<replaceable>MACHINEID</replaceable></arg> <arg choice='opt'>--config-file=<replaceable>FILENAME</replaceable></arg> @@ -175,8 +179,12 @@ no real reason to use it outside of the libdbus implementation anyhow.</para> <listitem> <para>Choose --csh-syntax or --sh-syntax based on the SHELL environment variable.</para> -<para><option>--binary-syntax</option> -Write to stdout a nul-terminated bus address, then the bus PID as a + </listitem> + </varlistentry> + <varlistentry> + <term><option>--binary-syntax</option></term> + <listitem> +<para>Write to stdout a nul-terminated bus address, then the bus PID as a binary integer of size sizeof(pid_t), then the bus X window ID as a binary integer of size sizeof(long). Integers are in the machine's byte order, not network byte order or any other canonical byte order.</para> @@ -244,6 +252,13 @@ use it manually. It may change in the future.</para> </listitem> </varlistentry> + <varlistentry> + <term><option>--help</option></term> + <listitem> +<para>Print the help info of dbus-launch</para> + + </listitem> + </varlistentry> </variablelist> </refsect1> diff --git a/doc/dbus-run-session.1.xml.in b/doc/dbus-run-session.1.xml.in index 693c5e4e..5181a8b1 100644 --- a/doc/dbus-run-session.1.xml.in +++ b/doc/dbus-run-session.1.xml.in @@ -130,6 +130,13 @@ contain a <emphasis remap='I'>PROGRAM</emphasis> in the environment variable <emphasis remap='B'>DBUS_SESSION_BUS_ADDRESS</emphasis>.</para> + +<para>The variables + <emphasis remap='B'>DBUS_SESSION_BUS_PID</emphasis>, + <emphasis remap='B'>DBUS_SESSION_BUS_WINDOWID</emphasis>, + <emphasis remap='B'>DBUS_STARTER_BUS_TYPE</emphasis> and + <emphasis remap='B'>DBUS_STARTER_ADDRESS</emphasis> + are removed from the environment, if present.</para> </refsect1> <refsect1 id='bugs'><title>BUGS</title> diff --git a/doc/dbus-specification.xml b/doc/dbus-specification.xml index ec8afde8..bc374b9b 100644 --- a/doc/dbus-specification.xml +++ b/doc/dbus-specification.xml @@ -6,8 +6,8 @@ <article id="index"> <articleinfo> <title>D-Bus Specification</title> - <releaseinfo>Version 0.21</releaseinfo> - <date>2013-04-25</date> + <releaseinfo>Version 0.22</releaseinfo> + <date>2013-10-09</date> <authorgroup> <author> <firstname>Havoc</firstname> @@ -72,6 +72,15 @@ </authorgroup> <revhistory> <revision> + <revnumber>0.22</revnumber> + <date>2013-10-09</date> + <authorinitials></authorinitials> + <revremark>add GetConnectionCredentials, document + GetAtdAuditSessionData, document GetConnectionSELinuxSecurityContext, + document and correct .service file syntax and naming + </revremark> + </revision> + <revision> <revnumber>0.21</revnumber> <date>2013-04-25</date> <authorinitials>smcv</authorinitials> @@ -169,23 +178,18 @@ <sect1 id="introduction"> <title>Introduction</title> <para> - D-Bus is a system for low-latency, low-overhead, easy to use + D-Bus is a system for low-overhead, easy to use interprocess communication (IPC). In more detail: <itemizedlist> <listitem> <para> - D-Bus is <emphasis>low-latency</emphasis> because it is designed - to avoid round trips and allow asynchronous operation, much like - the X protocol. - </para> - </listitem> - <listitem> - <para> D-Bus is <emphasis>low-overhead</emphasis> because it uses a binary protocol, and does not have to convert to and from a text format such as XML. Because D-Bus is intended for potentially high-resolution same-machine IPC, not primarily for Internet IPC, - this is an interesting optimization. + this is an interesting optimization. D-Bus is also designed to + avoid round trips and allow asynchronous operation, much like + the X protocol. </para> </listitem> <listitem> @@ -3655,8 +3659,8 @@ <programlisting> <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> - <node name="/org/freedesktop/sample_object"> - <interface name="org.freedesktop.SampleInterface"> + <node name="/com/example/sample_object"> + <interface name="com.example.SampleInterface"> <method name="Frobate"> <arg name="foo" type="i" direction="in"/> <arg name="bar" type="s" direction="out"/> @@ -3816,7 +3820,7 @@ unique-for-the-lifetime-of-the-bus name automatically assigned. Applications may request additional names for a connection. Additional names are usually "well-known names" such as - "org.freedesktop.TextEditor". When a name is bound to a connection, + "com.example.TextEditor". When a name is bound to a connection, that connection is said to <firstterm>own</firstterm> the name. </para> <para> @@ -3838,7 +3842,7 @@ <para> This feature causes the right thing to happen if you start two text - editors for example; the first one may request "org.freedesktop.TextEditor", + editors for example; the first one may request "com.example.TextEditor", and the second will be queued as a possible owner of that name. When the first exits, the second will take over. </para> @@ -4410,8 +4414,7 @@ </para> <para> The following table describes the keys that can be used to create - a match rule: - The following table summarizes the D-Bus types. + a match rule. <informaltable> <tgroup cols="3"> <thead> @@ -4613,9 +4616,9 @@ <para> With D-Bus, starting a service is normally done by name. That is, applications ask the message bus to start some program that will own a - well-known name, such as <literal>org.freedesktop.TextEditor</literal>. - This implies a contract documented along with the name - <literal>org.freedesktop.TextEditor</literal> for which objects + well-known name, such as <literal>com.example.TextEditor</literal>. + This implies a contract documented along with the name + <literal>com.example.TextEditor</literal> for which object the owner of that name will provide, and what interfaces those objects will have. </para> @@ -4639,6 +4642,19 @@ </para> <para> + On the well-known system bus, the name of a service description file + must be its well-known name plus <literal>.service</literal>, + for instance + <literal>com.example.ConfigurationDatabase.service</literal>. + </para> + + <para> + On the well-known session bus, services should follow the same + service description file naming convention as on the system bus, + but for backwards compatibility they are not required to do so. + </para> + + <para> [FIXME the file format should be much better specified than "similar to .desktop entries" esp. since desktop entries are already badly-specified. ;-)] @@ -4649,23 +4665,55 @@ <listitem><para>Comment format</para></listitem> </itemizedlist> + Service description files must contain a + <literal>D-BUS Service</literal> group with at least the keys + <literal>Name</literal> (the well-known name of the service) + and <literal>Exec</literal> (the command to be executed). + <figure> <title>Example service description file</title> <programlisting> # Sample service description file [D-BUS Service] - Names=org.freedesktop.ConfigurationDatabase;org.gnome.GConf; - Exec=/usr/libexec/gconfd-2 + Name=com.example.ConfigurationDatabase + Exec=/usr/bin/sample-configd </programlisting> </figure> </para> + + <para> + Additionally, service description files for the well-known system + bus on Unix must contain a <literal>User</literal> key, whose value + is the name of a user account (e.g. <literal>root</literal>). + The system service will be run as that user. + </para> + <para> When an application asks to start a service by name, the bus daemon tries to find a service that will own that name. It then tries to spawn the executable associated with it. If this fails, it will report an - error. [FIXME what happens if two .service files offer the same service; - what kind of error is reported, should we have a way for the client to - choose one?] + error. + </para> + + <para> + On the well-known system bus, it is not possible for two .service files + in the same directory to offer the same service, because they are + constrained to have names that match the service name. + </para> + + <para> + On the well-known session bus, if two .service files in the same + directory offer the same service name, the result is undefined. + Distributors should avoid this situation, for instance by naming + session services' .service files according to their service name. + </para> + + <para> + If two .service files in different directories offer the same + service name, the one in the higher-priority directory is used: + for instance, on the system bus, .service files in + /usr/local/share/dbus-1/system-services take precedence over those + in /usr/share/dbus-1/system-services. </para> <para> The executable launched will have the environment variable @@ -5574,6 +5622,225 @@ </para> </sect3> + <sect3 id="bus-messages-get-connection-credentials"> + <title><literal>org.freedesktop.DBus.GetConnectionCredentials</literal></title> + <para> + As a method: + <programlisting> + DICT<STRING,VARIANT> GetConnectionCredentials (in STRING bus_name) + </programlisting> + Message arguments: + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Argument</entry> + <entry>Type</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>0</entry> + <entry>STRING</entry> + <entry>Unique or well-known bus name of the connection to + query, such as <literal>:12.34</literal> or + <literal>com.example.tea</literal></entry> + </row> + </tbody> + </tgroup> + </informaltable> + Reply arguments: + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Argument</entry> + <entry>Type</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>0</entry> + <entry>DICT<STRING,VARIANT></entry> + <entry>Credentials</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + + <para> + Returns as many credentials as possible for the process connected to + the server. If unable to determine certain credentials (for instance, + because the process is not on the same machine as the bus daemon, + or because this version of the bus daemon does not support a + particular security framework), or if the values of those credentials + cannot be represented as documented here, then those credentials + are omitted. + </para> + + <para> + Keys in the returned dictionary not containing "." are defined + by this specification. Bus daemon implementors supporting + credentials frameworks not mentioned in this document should either + contribute patches to this specification, or use keys containing + "." and starting with a reversed domain name. + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Key</entry> + <entry>Value type</entry> + <entry>Value</entry> + </row> + </thead> + <tbody> + <row> + <entry>UnixUserID</entry> + <entry>UINT32</entry> + <entry>The numeric Unix user ID, as defined by POSIX</entry> + </row> + <row> + <entry>ProcessID</entry> + <entry>UINT32</entry> + <entry>The numeric process ID, on platforms that have + this concept. On Unix, this is the process ID defined by + POSIX.</entry> + </row> + </tbody> + </tgroup> + </informaltable> + </para> + + <para> + This method was added in D-Bus 1.7 to reduce the round-trips + required to list a process's credentials. In older versions, calling + this method will fail: applications should recover by using the + separate methods such as + <xref linkend="bus-messages-get-connection-unix-user"/> + instead. + </para> + </sect3> + + <sect3 id="bus-messages-get-adt-audit-session-data"> + <title><literal>org.freedesktop.DBus.GetAdtAuditSessionData</literal></title> + <para> + As a method: + <programlisting> + ARRAY of BYTE GetAdtAuditSessionData (in STRING bus_name) + </programlisting> + Message arguments: + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Argument</entry> + <entry>Type</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>0</entry> + <entry>STRING</entry> + <entry>Unique or well-known bus name of the connection to + query, such as <literal>:12.34</literal> or + <literal>com.example.tea</literal></entry> + </row> + </tbody> + </tgroup> + </informaltable> + Reply arguments: + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Argument</entry> + <entry>Type</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>0</entry> + <entry>ARRAY of BYTE</entry> + <entry>auditing data as returned by + adt_export_session_data()</entry> + </row> + </tbody> + </tgroup> + </informaltable> + Returns auditing data used by Solaris ADT, in an unspecified + binary format. If you know what this means, please contribute + documentation via the D-Bus bug tracking system. + This method is on the core DBus interface for historical reasons; + the same information should be made available via + <xref linkend="bus-messages-get-connection-credentials"/> + in future. + </para> + </sect3> + + <sect3 id="bus-messages-get-connection-selinux-security-context"> + <title><literal>org.freedesktop.DBus.GetConnectionSELinuxSecurityContext</literal></title> + <para> + As a method: + <programlisting> + ARRAY of BYTE GetConnectionSELinuxSecurityContext (in STRING bus_name) + </programlisting> + Message arguments: + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Argument</entry> + <entry>Type</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>0</entry> + <entry>STRING</entry> + <entry>Unique or well-known bus name of the connection to + query, such as <literal>:12.34</literal> or + <literal>com.example.tea</literal></entry> + </row> + </tbody> + </tgroup> + </informaltable> + Reply arguments: + <informaltable> + <tgroup cols="3"> + <thead> + <row> + <entry>Argument</entry> + <entry>Type</entry> + <entry>Description</entry> + </row> + </thead> + <tbody> + <row> + <entry>0</entry> + <entry>ARRAY of BYTE</entry> + <entry>some sort of string of bytes, not necessarily UTF-8, + not including '\0'</entry> + </row> + </tbody> + </tgroup> + </informaltable> + Returns the security context used by SELinux, in an unspecified + format. If you know what this means, please contribute + documentation via the D-Bus bug tracking system. + This method is on the core DBus interface for historical reasons; + the same information should be made available via + <xref linkend="bus-messages-get-connection-credentials"/> + in future. + </para> + </sect3> + + <sect3 id="bus-messages-add-match"> <title><literal>org.freedesktop.DBus.AddMatch</literal></title> <para> @@ -5816,9 +6083,9 @@ A service is an executable that can be launched by the bus daemon. Services normally guarantee some particular features, for example they may guarantee that they will request a specific name such as - "org.freedesktop.Screensaver", have a singleton object - "/org/freedesktop/Application", and that object will implement the - interface "org.freedesktop.ScreensaverControl". + "com.example.Screensaver", have a singleton object + "/com/example/Application", and that object will implement the + interface "com.example.Screensaver.Control". </para> </glossdef> </glossentry> @@ -70,7 +70,7 @@ # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) -# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.2 +# $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1.3 # automake: $automake_version # autoconf: $autoconf_version # @@ -80,7 +80,7 @@ PROGRAM=libtool PACKAGE=libtool -VERSION="2.4.2 Debian-2.4.2-1.2" +VERSION="2.4.2 Debian-2.4.2-1.3" TIMESTAMP="" package_revision=1.3337 diff --git a/test/Makefile.am b/test/Makefile.am index 6f0e6e10..eddcd644 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -19,21 +19,45 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ static_cppflags = \ $(AM_CPPFLAGS) \ -DDBUS_STATIC_BUILD \ + -DDBUS_COMPILATION \ + -DDBUS_TEST_USE_INTERNAL \ $(NULL) -libdbus_testutils_la_CPPFLAGS = \ - $(static_cppflags) +noinst_LTLIBRARIES = libdbus-testutils-internal.la + +# You can link either libdbus-testutils, dbus-glib and libdbus-1, +# or libdbus-testutils-internal and libdbus-internal - never both in the +# same binary. +if DBUS_WITH_DBUS_GLIB +noinst_LTLIBRARIES += libdbus-testutils.la libdbus_testutils_la_SOURCES = \ test-utils.c \ test-utils.h \ $(NULL) libdbus_testutils_la_LIBADD = \ - $(top_builddir)/dbus/libdbus-internal.la \ + $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) \ + $(DBUS_GLIB_LIBS) \ $(NULL) +testutils_shared_if_possible_cppflags = $(AM_CPPFLAGS) +testutils_shared_if_possible_libs = libdbus-testutils.la +else +testutils_shared_if_possible_cppflags = $(static_cppflags) +testutils_shared_if_possible_libs = libdbus-testutils-internal.la +endif -noinst_LTLIBRARIES = libdbus-testutils.la +libdbus_testutils_internal_la_CPPFLAGS = \ + $(static_cppflags) \ + $(NULL) +libdbus_testutils_internal_la_SOURCES = \ + test-utils.c \ + test-utils.h \ + $(NULL) +libdbus_testutils_internal_la_LIBADD = \ + $(top_builddir)/dbus/libdbus-internal.la \ + $(NULL) -if DBUS_BUILD_TESTS +if DBUS_ENABLE_EMBEDDED_TESTS ## break-loader removed for now ## these binaries are used in tests but are not themselves tests TEST_BINARIES = \ @@ -59,25 +83,25 @@ if DBUS_UNIX TESTS += ../bus/bus-test-launch-helper$(EXEEXT) endif -else !DBUS_BUILD_TESTS +else !DBUS_ENABLE_EMBEDDED_TESTS TEST_BINARIES= TESTS= -endif !DBUS_BUILD_TESTS +endif !DBUS_ENABLE_EMBEDDED_TESTS noinst_PROGRAMS= $(TEST_BINARIES) test_service_CPPFLAGS = $(static_cppflags) -test_service_LDADD = libdbus-testutils.la +test_service_LDADD = libdbus-testutils-internal.la test_names_CPPFLAGS = $(static_cppflags) -test_names_LDADD = libdbus-testutils.la +test_names_LDADD = libdbus-testutils-internal.la ## break_loader_CPPFLAGS = $(static_cppflags) ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_shell_service_CPPFLAGS = $(static_cppflags) -test_shell_service_LDADD = libdbus-testutils.la +test_shell_service_LDADD = libdbus-testutils-internal.la shell_test_CPPFLAGS = $(static_cppflags) -shell_test_LDADD = libdbus-testutils.la +shell_test_LDADD = libdbus-testutils-internal.la spawn_test_CPPFLAGS = $(static_cppflags) spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la @@ -87,11 +111,11 @@ test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_refs_SOURCES = internals/refs.c test_refs_CPPFLAGS = $(static_cppflags) -test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) +test_refs_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS) test_syslog_SOURCES = internals/syslog.c test_syslog_CPPFLAGS = $(static_cppflags) -test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) +test_syslog_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS) EXTRA_DIST = dbus-test-runner @@ -103,6 +127,8 @@ installable_tests = \ shell-test \ test-printf \ $(NULL) +installable_manual_tests = \ + $(NULL) if DBUS_WITH_GLIB installable_tests += \ @@ -116,6 +142,9 @@ installable_tests += \ test-syntax \ test-syslog \ $(NULL) +installable_manual_tests += \ + manual-authz \ + $(NULL) endif DBUS_WITH_GLIB installcheck_tests = @@ -132,50 +161,68 @@ TESTS_ENVIRONMENT = \ DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \ $(NULL) +manual_authz_SOURCES = manual-authz.c +manual_authz_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +manual_authz_LDADD = \ + $(testutils_shared_if_possible_libs) \ + $(GLIB_LIBS) \ + $(NULL) + test_corrupt_SOURCES = corrupt.c -test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_corrupt_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_corrupt_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_loopback_SOURCES = loopback.c -test_loopback_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_loopback_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_loopback_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_relay_SOURCES = relay.c -test_relay_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_relay_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_relay_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_dbus_daemon_SOURCES = dbus-daemon.c -test_dbus_daemon_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_dbus_daemon_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_dbus_daemon_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c -test_dbus_daemon_eavesdrop_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS) -test_dbus_daemon_eavesdrop_LDFLAGS = @R_DYNAMIC_LDFLAG@ -test_dbus_daemon_eavesdrop_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_dbus_daemon_eavesdrop_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_dbus_daemon_eavesdrop_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_marshal_SOURCES = marshal.c -test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_marshal_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_syntax_SOURCES = syntax.c -test_syntax_LDADD = $(top_builddir)/dbus/libdbus-1.la \ - $(GLIB_LIBS) +test_syntax_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) \ + $(NULL) if DBUS_ENABLE_MODULAR_TESTS TESTS += $(installable_tests) installcheck_tests += $(installable_tests) if DBUS_ENABLE_INSTALLED_TESTS - testexec_PROGRAMS += $(installable_tests) + testexec_PROGRAMS += $(installable_tests) $(installable_manual_tests) else !DBUS_ENABLE_INSTALLED_TESTS - noinst_PROGRAMS += $(installable_tests) + noinst_PROGRAMS += $(installable_tests) $(installable_manual_tests) endif !DBUS_ENABLE_INSTALLED_TESTS endif DBUS_ENABLE_MODULAR_TESTS @@ -323,10 +370,6 @@ imported_data = \ noinst_DATA = $(imported_data) CLEANFILES = $(noinst_DATA) -data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf - $(AM_V_at)$(MKDIR_P) data/valid-config-files - $(AM_V_GEN)cp $< $@ - -data/valid-config-files/system.conf: $(top_builddir)/bus/system.conf +$(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf $(AM_V_at)$(MKDIR_P) data/valid-config-files $(AM_V_GEN)cp $< $@ diff --git a/test/Makefile.in b/test/Makefile.in index 0eddf831..90556603 100644 --- a/test/Makefile.in +++ b/test/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. @@ -80,15 +80,21 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@DBUS_BUILD_TESTS_FALSE@TESTS = $(am__EXEEXT_6) -@DBUS_BUILD_TESTS_TRUE@TESTS = ../bus/bus-test$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ ../bus/bus-test-system$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ ../dbus/dbus-test$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ $(am__append_1) $(am__EXEEXT_6) -@DBUS_BUILD_TESTS_TRUE@@DBUS_UNIX_TRUE@am__append_1 = ../bus/bus-test-launch-helper$(EXEEXT) -noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_4) -testexec_PROGRAMS = $(am__EXEEXT_5) -@DBUS_WITH_GLIB_TRUE@am__append_2 = \ + +# You can link either libdbus-testutils, dbus-glib and libdbus-1, +# or libdbus-testutils-internal and libdbus-internal - never both in the +# same binary. +@DBUS_WITH_DBUS_GLIB_TRUE@am__append_1 = libdbus-testutils.la +@DBUS_ENABLE_EMBEDDED_TESTS_FALSE@TESTS = $(am__EXEEXT_8) +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@TESTS = ../bus/bus-test$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ ../bus/bus-test-system$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ ../dbus/dbus-test$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ $(am__append_2) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ $(am__EXEEXT_8) +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@@DBUS_UNIX_TRUE@am__append_2 = ../bus/bus-test-launch-helper$(EXEEXT) +noinst_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_6) +testexec_PROGRAMS = $(am__EXEEXT_7) +@DBUS_WITH_GLIB_TRUE@am__append_3 = \ @DBUS_WITH_GLIB_TRUE@ test-corrupt \ @DBUS_WITH_GLIB_TRUE@ test-dbus-daemon \ @DBUS_WITH_GLIB_TRUE@ test-dbus-daemon-eavesdrop \ @@ -100,10 +106,14 @@ testexec_PROGRAMS = $(am__EXEEXT_5) @DBUS_WITH_GLIB_TRUE@ test-syslog \ @DBUS_WITH_GLIB_TRUE@ $(NULL) -@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_3 = $(installable_tests) -@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_4 = $(installable_tests) -@DBUS_ENABLE_INSTALLED_TESTS_TRUE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_5 = $(installable_tests) -@DBUS_ENABLE_INSTALLED_TESTS_FALSE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_6 = $(installable_tests) +@DBUS_WITH_GLIB_TRUE@am__append_4 = \ +@DBUS_WITH_GLIB_TRUE@ manual-authz \ +@DBUS_WITH_GLIB_TRUE@ $(NULL) + +@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_5 = $(installable_tests) +@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_6 = $(installable_tests) +@DBUS_ENABLE_INSTALLED_TESTS_TRUE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_7 = $(installable_tests) $(installable_manual_tests) +@DBUS_ENABLE_INSTALLED_TESTS_FALSE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__append_8 = $(installable_tests) $(installable_manual_tests) subdir = test DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(top_srcdir)/test-driver @@ -122,20 +132,33 @@ CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) -libdbus_testutils_la_DEPENDENCIES = \ +libdbus_testutils_internal_la_DEPENDENCIES = \ $(top_builddir)/dbus/libdbus-internal.la -am_libdbus_testutils_la_OBJECTS = libdbus_testutils_la-test-utils.lo -libdbus_testutils_la_OBJECTS = $(am_libdbus_testutils_la_OBJECTS) +am_libdbus_testutils_internal_la_OBJECTS = \ + libdbus_testutils_internal_la-test-utils.lo +libdbus_testutils_internal_la_OBJECTS = \ + $(am_libdbus_testutils_internal_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = -@DBUS_BUILD_TESTS_TRUE@am__EXEEXT_1 = spawn-test$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-exit$(EXEEXT) test-names$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-segfault$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-service$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-shell-service$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-sleep-forever$(EXEEXT) +am__DEPENDENCIES_1 = +@DBUS_WITH_DBUS_GLIB_TRUE@libdbus_testutils_la_DEPENDENCIES = \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(top_builddir)/dbus/libdbus-1.la \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(am__DEPENDENCIES_1) \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(am__DEPENDENCIES_1) +am__libdbus_testutils_la_SOURCES_DIST = test-utils.c test-utils.h +@DBUS_WITH_DBUS_GLIB_TRUE@am_libdbus_testutils_la_OBJECTS = \ +@DBUS_WITH_DBUS_GLIB_TRUE@ test-utils.lo +libdbus_testutils_la_OBJECTS = $(am_libdbus_testutils_la_OBJECTS) +@DBUS_WITH_DBUS_GLIB_TRUE@am_libdbus_testutils_la_rpath = +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@am__EXEEXT_1 = spawn-test$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-exit$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-names$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-segfault$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-service$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-shell-service$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-sleep-forever$(EXEEXT) @DBUS_WITH_GLIB_TRUE@am__EXEEXT_2 = test-corrupt$(EXEEXT) \ @DBUS_WITH_GLIB_TRUE@ test-dbus-daemon$(EXEEXT) \ @DBUS_WITH_GLIB_TRUE@ test-dbus-daemon-eavesdrop$(EXEEXT) \ @@ -145,70 +168,73 @@ am__v_lt_1 = @DBUS_WITH_GLIB_TRUE@ test-syslog$(EXEEXT) am__EXEEXT_3 = shell-test$(EXEEXT) test-printf$(EXEEXT) \ $(am__EXEEXT_2) -@DBUS_ENABLE_INSTALLED_TESTS_FALSE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_4 = $(am__EXEEXT_3) -@DBUS_ENABLE_INSTALLED_TESTS_TRUE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_5 = $(am__EXEEXT_3) +@DBUS_WITH_GLIB_TRUE@am__EXEEXT_4 = manual-authz$(EXEEXT) +am__EXEEXT_5 = $(am__EXEEXT_4) +@DBUS_ENABLE_INSTALLED_TESTS_FALSE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_6 = $(am__EXEEXT_3) \ +@DBUS_ENABLE_INSTALLED_TESTS_FALSE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@ $(am__EXEEXT_5) +@DBUS_ENABLE_INSTALLED_TESTS_TRUE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_7 = $(am__EXEEXT_3) \ +@DBUS_ENABLE_INSTALLED_TESTS_TRUE@@DBUS_ENABLE_MODULAR_TESTS_TRUE@ $(am__EXEEXT_5) am__installdirs = "$(DESTDIR)$(testexecdir)" PROGRAMS = $(noinst_PROGRAMS) $(testexec_PROGRAMS) +am_manual_authz_OBJECTS = manual_authz-manual-authz.$(OBJEXT) +manual_authz_OBJECTS = $(am_manual_authz_OBJECTS) +manual_authz_DEPENDENCIES = $(testutils_shared_if_possible_libs) \ + $(am__DEPENDENCIES_1) shell_test_SOURCES = shell-test.c shell_test_OBJECTS = shell_test-shell-test.$(OBJEXT) -shell_test_DEPENDENCIES = libdbus-testutils.la +shell_test_DEPENDENCIES = libdbus-testutils-internal.la spawn_test_SOURCES = spawn-test.c spawn_test_OBJECTS = spawn_test-spawn-test.$(OBJEXT) spawn_test_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la -am_test_corrupt_OBJECTS = corrupt.$(OBJEXT) +am_test_corrupt_OBJECTS = test_corrupt-corrupt.$(OBJEXT) test_corrupt_OBJECTS = $(am_test_corrupt_OBJECTS) -am__DEPENDENCIES_1 = -test_corrupt_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -am_test_dbus_daemon_OBJECTS = dbus-daemon.$(OBJEXT) +test_corrupt_DEPENDENCIES = $(testutils_shared_if_possible_libs) \ + $(am__DEPENDENCIES_1) +am_test_dbus_daemon_OBJECTS = test_dbus_daemon-dbus-daemon.$(OBJEXT) test_dbus_daemon_OBJECTS = $(am_test_dbus_daemon_OBJECTS) -test_dbus_daemon_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_dbus_daemon_DEPENDENCIES = $(testutils_shared_if_possible_libs) \ + $(am__DEPENDENCIES_1) am_test_dbus_daemon_eavesdrop_OBJECTS = \ test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.$(OBJEXT) test_dbus_daemon_eavesdrop_OBJECTS = \ $(am_test_dbus_daemon_eavesdrop_OBJECTS) test_dbus_daemon_eavesdrop_DEPENDENCIES = \ - $(top_builddir)/dbus/libdbus-1.la $(am__DEPENDENCIES_1) \ - $(am__DEPENDENCIES_1) -test_dbus_daemon_eavesdrop_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ - $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ - $(AM_CFLAGS) $(CFLAGS) $(test_dbus_daemon_eavesdrop_LDFLAGS) \ - $(LDFLAGS) -o $@ + $(testutils_shared_if_possible_libs) $(am__DEPENDENCIES_1) test_exit_SOURCES = test-exit.c test_exit_OBJECTS = test-exit.$(OBJEXT) test_exit_LDADD = $(LDADD) -am_test_loopback_OBJECTS = loopback.$(OBJEXT) +am_test_loopback_OBJECTS = test_loopback-loopback.$(OBJEXT) test_loopback_OBJECTS = $(am_test_loopback_OBJECTS) -test_loopback_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_loopback_DEPENDENCIES = $(testutils_shared_if_possible_libs) \ + $(am__DEPENDENCIES_1) am_test_marshal_OBJECTS = marshal.$(OBJEXT) test_marshal_OBJECTS = $(am_test_marshal_OBJECTS) test_marshal_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) + $(am__DEPENDENCIES_1) test_names_SOURCES = test-names.c test_names_OBJECTS = test_names-test-names.$(OBJEXT) -test_names_DEPENDENCIES = libdbus-testutils.la +test_names_DEPENDENCIES = libdbus-testutils-internal.la am_test_printf_OBJECTS = test_printf-printf.$(OBJEXT) test_printf_OBJECTS = $(am_test_printf_OBJECTS) test_printf_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la am_test_refs_OBJECTS = test_refs-refs.$(OBJEXT) test_refs_OBJECTS = $(am_test_refs_OBJECTS) -test_refs_DEPENDENCIES = libdbus-testutils.la $(am__DEPENDENCIES_1) -am_test_relay_OBJECTS = relay.$(OBJEXT) +test_refs_DEPENDENCIES = libdbus-testutils-internal.la \ + $(am__DEPENDENCIES_1) +am_test_relay_OBJECTS = test_relay-relay.$(OBJEXT) test_relay_OBJECTS = $(am_test_relay_OBJECTS) -test_relay_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ - $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +test_relay_DEPENDENCIES = $(testutils_shared_if_possible_libs) \ + $(am__DEPENDENCIES_1) test_segfault_SOURCES = test-segfault.c test_segfault_OBJECTS = test-segfault.$(OBJEXT) test_segfault_LDADD = $(LDADD) test_service_SOURCES = test-service.c test_service_OBJECTS = test_service-test-service.$(OBJEXT) -test_service_DEPENDENCIES = libdbus-testutils.la +test_service_DEPENDENCIES = libdbus-testutils-internal.la test_shell_service_SOURCES = test-shell-service.c test_shell_service_OBJECTS = \ test_shell_service-test-shell-service.$(OBJEXT) -test_shell_service_DEPENDENCIES = libdbus-testutils.la +test_shell_service_DEPENDENCIES = libdbus-testutils-internal.la test_sleep_forever_SOURCES = test-sleep-forever.c test_sleep_forever_OBJECTS = test-sleep-forever.$(OBJEXT) test_sleep_forever_LDADD = $(LDADD) @@ -218,7 +244,8 @@ test_syntax_DEPENDENCIES = $(top_builddir)/dbus/libdbus-1.la \ $(am__DEPENDENCIES_1) am_test_syslog_OBJECTS = test_syslog-syslog.$(OBJEXT) test_syslog_OBJECTS = $(am_test_syslog_OBJECTS) -test_syslog_DEPENDENCIES = libdbus-testutils.la $(am__DEPENDENCIES_1) +test_syslog_DEPENDENCIES = libdbus-testutils-internal.la \ + $(am__DEPENDENCIES_1) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -253,17 +280,20 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = -SOURCES = $(libdbus_testutils_la_SOURCES) shell-test.c spawn-test.c \ - $(test_corrupt_SOURCES) $(test_dbus_daemon_SOURCES) \ +SOURCES = $(libdbus_testutils_internal_la_SOURCES) \ + $(libdbus_testutils_la_SOURCES) $(manual_authz_SOURCES) \ + shell-test.c spawn-test.c $(test_corrupt_SOURCES) \ + $(test_dbus_daemon_SOURCES) \ $(test_dbus_daemon_eavesdrop_SOURCES) test-exit.c \ $(test_loopback_SOURCES) $(test_marshal_SOURCES) test-names.c \ $(test_printf_SOURCES) $(test_refs_SOURCES) \ $(test_relay_SOURCES) test-segfault.c test-service.c \ test-shell-service.c test-sleep-forever.c \ $(test_syntax_SOURCES) $(test_syslog_SOURCES) -DIST_SOURCES = $(libdbus_testutils_la_SOURCES) shell-test.c \ - spawn-test.c $(test_corrupt_SOURCES) \ - $(test_dbus_daemon_SOURCES) \ +DIST_SOURCES = $(libdbus_testutils_internal_la_SOURCES) \ + $(am__libdbus_testutils_la_SOURCES_DIST) \ + $(manual_authz_SOURCES) shell-test.c spawn-test.c \ + $(test_corrupt_SOURCES) $(test_dbus_daemon_SOURCES) \ $(test_dbus_daemon_eavesdrop_SOURCES) test-exit.c \ $(test_loopback_SOURCES) $(test_marshal_SOURCES) test-names.c \ $(test_printf_SOURCES) $(test_refs_SOURCES) \ @@ -494,7 +524,7 @@ am__set_TESTS_bases = \ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \ bases=`echo $$bases` RECHECK_LOGS = $(TEST_LOGS) -@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_6 = $(am__EXEEXT_3) +@DBUS_ENABLE_MODULAR_TESTS_TRUE@am__EXEEXT_8 = $(am__EXEEXT_3) TEST_SUITE_LOG = test-suite.log TEST_EXTENSIONS = @EXEEXT@ .test LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver @@ -569,7 +599,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@ @@ -672,7 +701,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@ @@ -767,40 +795,58 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ static_cppflags = \ $(AM_CPPFLAGS) \ -DDBUS_STATIC_BUILD \ + -DDBUS_COMPILATION \ + -DDBUS_TEST_USE_INTERNAL \ $(NULL) -libdbus_testutils_la_CPPFLAGS = \ - $(static_cppflags) +noinst_LTLIBRARIES = libdbus-testutils-internal.la $(am__append_1) +@DBUS_WITH_DBUS_GLIB_TRUE@libdbus_testutils_la_SOURCES = \ +@DBUS_WITH_DBUS_GLIB_TRUE@ test-utils.c \ +@DBUS_WITH_DBUS_GLIB_TRUE@ test-utils.h \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(NULL) + +@DBUS_WITH_DBUS_GLIB_TRUE@libdbus_testutils_la_LIBADD = \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(top_builddir)/dbus/libdbus-1.la \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(GLIB_LIBS) \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(DBUS_GLIB_LIBS) \ +@DBUS_WITH_DBUS_GLIB_TRUE@ $(NULL) + +@DBUS_WITH_DBUS_GLIB_FALSE@testutils_shared_if_possible_cppflags = $(static_cppflags) +@DBUS_WITH_DBUS_GLIB_TRUE@testutils_shared_if_possible_cppflags = $(AM_CPPFLAGS) +@DBUS_WITH_DBUS_GLIB_FALSE@testutils_shared_if_possible_libs = libdbus-testutils-internal.la +@DBUS_WITH_DBUS_GLIB_TRUE@testutils_shared_if_possible_libs = libdbus-testutils.la +libdbus_testutils_internal_la_CPPFLAGS = \ + $(static_cppflags) \ + $(NULL) -libdbus_testutils_la_SOURCES = \ +libdbus_testutils_internal_la_SOURCES = \ test-utils.c \ test-utils.h \ $(NULL) -libdbus_testutils_la_LIBADD = \ +libdbus_testutils_internal_la_LIBADD = \ $(top_builddir)/dbus/libdbus-internal.la \ $(NULL) -noinst_LTLIBRARIES = libdbus-testutils.la -@DBUS_BUILD_TESTS_FALSE@TEST_BINARIES = -@DBUS_BUILD_TESTS_TRUE@TEST_BINARIES = \ -@DBUS_BUILD_TESTS_TRUE@ spawn-test \ -@DBUS_BUILD_TESTS_TRUE@ test-exit \ -@DBUS_BUILD_TESTS_TRUE@ test-names \ -@DBUS_BUILD_TESTS_TRUE@ test-segfault \ -@DBUS_BUILD_TESTS_TRUE@ test-service \ -@DBUS_BUILD_TESTS_TRUE@ test-shell-service \ -@DBUS_BUILD_TESTS_TRUE@ test-sleep-forever \ -@DBUS_BUILD_TESTS_TRUE@ $(NULL) +@DBUS_ENABLE_EMBEDDED_TESTS_FALSE@TEST_BINARIES = +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@TEST_BINARIES = \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ spawn-test \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-exit \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-names \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-segfault \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-service \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-shell-service \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-sleep-forever \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ $(NULL) test_service_CPPFLAGS = $(static_cppflags) -test_service_LDADD = libdbus-testutils.la +test_service_LDADD = libdbus-testutils-internal.la test_names_CPPFLAGS = $(static_cppflags) -test_names_LDADD = libdbus-testutils.la +test_names_LDADD = libdbus-testutils-internal.la test_shell_service_CPPFLAGS = $(static_cppflags) -test_shell_service_LDADD = libdbus-testutils.la +test_shell_service_LDADD = libdbus-testutils-internal.la shell_test_CPPFLAGS = $(static_cppflags) -shell_test_LDADD = libdbus-testutils.la +shell_test_LDADD = libdbus-testutils-internal.la spawn_test_CPPFLAGS = $(static_cppflags) spawn_test_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_printf_SOURCES = internals/printf.c @@ -808,14 +854,15 @@ test_printf_CPPFLAGS = $(static_cppflags) test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_refs_SOURCES = internals/refs.c test_refs_CPPFLAGS = $(static_cppflags) -test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) +test_refs_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS) test_syslog_SOURCES = internals/syslog.c test_syslog_CPPFLAGS = $(static_cppflags) -test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) +test_syslog_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS) EXTRA_DIST = dbus-test-runner $(in_data) $(static_data) testexecdir = $(libdir)/dbus-1.0/test -installable_tests = shell-test test-printf $(NULL) $(am__append_2) -installcheck_tests = $(am__append_4) +installable_tests = shell-test test-printf $(NULL) $(am__append_3) +installable_manual_tests = $(NULL) $(am__append_4) +installcheck_tests = $(am__append_6) installcheck_environment = \ DBUS_TEST_DAEMON=$(DESTDIR)$(DBUS_DAEMONDIR)/dbus-daemon$(EXEEXT) \ DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \ @@ -829,41 +876,59 @@ TESTS_ENVIRONMENT = \ DBUS_TEST_HOMEDIR=@abs_top_builddir@/dbus \ $(NULL) +manual_authz_SOURCES = manual-authz.c +manual_authz_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +manual_authz_LDADD = \ + $(testutils_shared_if_possible_libs) \ + $(GLIB_LIBS) \ + $(NULL) + test_corrupt_SOURCES = corrupt.c -test_corrupt_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_corrupt_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_corrupt_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_loopback_SOURCES = loopback.c -test_loopback_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_loopback_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_loopback_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_relay_SOURCES = relay.c -test_relay_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_relay_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_relay_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_dbus_daemon_SOURCES = dbus-daemon.c -test_dbus_daemon_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_dbus_daemon_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_dbus_daemon_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c -test_dbus_daemon_eavesdrop_CPPFLAGS = $(GLIB_CFLAGS) $(DBUS_GLIB_CFLAGS) -test_dbus_daemon_eavesdrop_LDFLAGS = @R_DYNAMIC_LDFLAG@ -test_dbus_daemon_eavesdrop_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_dbus_daemon_eavesdrop_CPPFLAGS = $(testutils_shared_if_possible_cppflags) +test_dbus_daemon_eavesdrop_LDADD = \ + $(testutils_shared_if_possible_libs) \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_marshal_SOURCES = marshal.c -test_marshal_LDADD = $(top_builddir)/dbus/libdbus-1.la \ +test_marshal_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) + $(NULL) test_syntax_SOURCES = syntax.c -test_syntax_LDADD = $(top_builddir)/dbus/libdbus-1.la \ - $(GLIB_LIBS) +test_syntax_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ + $(GLIB_LIBS) \ + $(NULL) in_data = \ data/valid-config-files-system/debug-allow-all-fail.conf.in \ @@ -1012,8 +1077,11 @@ clean-noinstLTLIBRARIES: rm -f $${locs}; \ } +libdbus-testutils-internal.la: $(libdbus_testutils_internal_la_OBJECTS) $(libdbus_testutils_internal_la_DEPENDENCIES) $(EXTRA_libdbus_testutils_internal_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libdbus_testutils_internal_la_OBJECTS) $(libdbus_testutils_internal_la_LIBADD) $(LIBS) + libdbus-testutils.la: $(libdbus_testutils_la_OBJECTS) $(libdbus_testutils_la_DEPENDENCIES) $(EXTRA_libdbus_testutils_la_DEPENDENCIES) - $(AM_V_CCLD)$(LINK) $(libdbus_testutils_la_OBJECTS) $(libdbus_testutils_la_LIBADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(am_libdbus_testutils_la_rpath) $(libdbus_testutils_la_OBJECTS) $(libdbus_testutils_la_LIBADD) $(LIBS) clean-noinstPROGRAMS: @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \ @@ -1073,6 +1141,10 @@ clean-testexecPROGRAMS: echo " rm -f" $$list; \ rm -f $$list +manual-authz$(EXEEXT): $(manual_authz_OBJECTS) $(manual_authz_DEPENDENCIES) $(EXTRA_manual_authz_DEPENDENCIES) + @rm -f manual-authz$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(manual_authz_OBJECTS) $(manual_authz_LDADD) $(LIBS) + shell-test$(EXEEXT): $(shell_test_OBJECTS) $(shell_test_DEPENDENCIES) $(EXTRA_shell_test_DEPENDENCIES) @rm -f shell-test$(EXEEXT) $(AM_V_CCLD)$(LINK) $(shell_test_OBJECTS) $(shell_test_LDADD) $(LIBS) @@ -1091,7 +1163,7 @@ test-dbus-daemon$(EXEEXT): $(test_dbus_daemon_OBJECTS) $(test_dbus_daemon_DEPEND test-dbus-daemon-eavesdrop$(EXEEXT): $(test_dbus_daemon_eavesdrop_OBJECTS) $(test_dbus_daemon_eavesdrop_DEPENDENCIES) $(EXTRA_test_dbus_daemon_eavesdrop_DEPENDENCIES) @rm -f test-dbus-daemon-eavesdrop$(EXEEXT) - $(AM_V_CCLD)$(test_dbus_daemon_eavesdrop_LINK) $(test_dbus_daemon_eavesdrop_OBJECTS) $(test_dbus_daemon_eavesdrop_LDADD) $(LIBS) + $(AM_V_CCLD)$(LINK) $(test_dbus_daemon_eavesdrop_OBJECTS) $(test_dbus_daemon_eavesdrop_LDADD) $(LIBS) test-exit$(EXEEXT): $(test_exit_OBJECTS) $(test_exit_DEPENDENCIES) $(EXTRA_test_exit_DEPENDENCIES) @rm -f test-exit$(EXEEXT) @@ -1151,22 +1223,24 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/corrupt.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-daemon.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_testutils_la-test-utils.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loopback.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdbus_testutils_internal_la-test-utils.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manual_authz-manual-authz.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/marshal.Po@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relay.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell_test-shell-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/spawn_test-spawn-test.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syntax.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-exit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-segfault.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-sleep-forever.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-utils.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_corrupt-corrupt.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dbus_daemon-dbus-daemon.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_loopback-loopback.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_names-test-names.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_printf-printf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_refs-refs.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_relay-relay.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_service-test-service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_shell_service-test-shell-service.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_syslog-syslog.Po@am__quote@ @@ -1176,14 +1250,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 $@ $< @@ -1192,12 +1266,26 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< -libdbus_testutils_la-test-utils.lo: test-utils.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_testutils_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_testutils_la-test-utils.lo -MD -MP -MF $(DEPDIR)/libdbus_testutils_la-test-utils.Tpo -c -o libdbus_testutils_la-test-utils.lo `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_testutils_la-test-utils.Tpo $(DEPDIR)/libdbus_testutils_la-test-utils.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-utils.c' object='libdbus_testutils_la-test-utils.lo' libtool=yes @AMDEPBACKSLASH@ +libdbus_testutils_internal_la-test-utils.lo: test-utils.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_testutils_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libdbus_testutils_internal_la-test-utils.lo -MD -MP -MF $(DEPDIR)/libdbus_testutils_internal_la-test-utils.Tpo -c -o libdbus_testutils_internal_la-test-utils.lo `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdbus_testutils_internal_la-test-utils.Tpo $(DEPDIR)/libdbus_testutils_internal_la-test-utils.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test-utils.c' object='libdbus_testutils_internal_la-test-utils.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_testutils_internal_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_testutils_internal_la-test-utils.lo `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c + +manual_authz-manual-authz.o: manual-authz.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(manual_authz_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT manual_authz-manual-authz.o -MD -MP -MF $(DEPDIR)/manual_authz-manual-authz.Tpo -c -o manual_authz-manual-authz.o `test -f 'manual-authz.c' || echo '$(srcdir)/'`manual-authz.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/manual_authz-manual-authz.Tpo $(DEPDIR)/manual_authz-manual-authz.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='manual-authz.c' object='manual_authz-manual-authz.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdbus_testutils_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libdbus_testutils_la-test-utils.lo `test -f 'test-utils.c' || echo '$(srcdir)/'`test-utils.c +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(manual_authz_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o manual_authz-manual-authz.o `test -f 'manual-authz.c' || echo '$(srcdir)/'`manual-authz.c + +manual_authz-manual-authz.obj: manual-authz.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(manual_authz_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT manual_authz-manual-authz.obj -MD -MP -MF $(DEPDIR)/manual_authz-manual-authz.Tpo -c -o manual_authz-manual-authz.obj `if test -f 'manual-authz.c'; then $(CYGPATH_W) 'manual-authz.c'; else $(CYGPATH_W) '$(srcdir)/manual-authz.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/manual_authz-manual-authz.Tpo $(DEPDIR)/manual_authz-manual-authz.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='manual-authz.c' object='manual_authz-manual-authz.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(manual_authz_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o manual_authz-manual-authz.obj `if test -f 'manual-authz.c'; then $(CYGPATH_W) 'manual-authz.c'; else $(CYGPATH_W) '$(srcdir)/manual-authz.c'; fi` shell_test-shell-test.o: shell-test.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(shell_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT shell_test-shell-test.o -MD -MP -MF $(DEPDIR)/shell_test-shell-test.Tpo -c -o shell_test-shell-test.o `test -f 'shell-test.c' || echo '$(srcdir)/'`shell-test.c @@ -1227,6 +1315,34 @@ spawn_test-spawn-test.obj: spawn-test.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(spawn_test_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o spawn_test-spawn-test.obj `if test -f 'spawn-test.c'; then $(CYGPATH_W) 'spawn-test.c'; else $(CYGPATH_W) '$(srcdir)/spawn-test.c'; fi` +test_corrupt-corrupt.o: corrupt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_corrupt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_corrupt-corrupt.o -MD -MP -MF $(DEPDIR)/test_corrupt-corrupt.Tpo -c -o test_corrupt-corrupt.o `test -f 'corrupt.c' || echo '$(srcdir)/'`corrupt.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_corrupt-corrupt.Tpo $(DEPDIR)/test_corrupt-corrupt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='corrupt.c' object='test_corrupt-corrupt.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_corrupt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_corrupt-corrupt.o `test -f 'corrupt.c' || echo '$(srcdir)/'`corrupt.c + +test_corrupt-corrupt.obj: corrupt.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_corrupt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_corrupt-corrupt.obj -MD -MP -MF $(DEPDIR)/test_corrupt-corrupt.Tpo -c -o test_corrupt-corrupt.obj `if test -f 'corrupt.c'; then $(CYGPATH_W) 'corrupt.c'; else $(CYGPATH_W) '$(srcdir)/corrupt.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_corrupt-corrupt.Tpo $(DEPDIR)/test_corrupt-corrupt.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='corrupt.c' object='test_corrupt-corrupt.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_corrupt_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_corrupt-corrupt.obj `if test -f 'corrupt.c'; then $(CYGPATH_W) 'corrupt.c'; else $(CYGPATH_W) '$(srcdir)/corrupt.c'; fi` + +test_dbus_daemon-dbus-daemon.o: dbus-daemon.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dbus_daemon_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dbus_daemon-dbus-daemon.o -MD -MP -MF $(DEPDIR)/test_dbus_daemon-dbus-daemon.Tpo -c -o test_dbus_daemon-dbus-daemon.o `test -f 'dbus-daemon.c' || echo '$(srcdir)/'`dbus-daemon.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_dbus_daemon-dbus-daemon.Tpo $(DEPDIR)/test_dbus_daemon-dbus-daemon.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus-daemon.c' object='test_dbus_daemon-dbus-daemon.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dbus_daemon_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_dbus_daemon-dbus-daemon.o `test -f 'dbus-daemon.c' || echo '$(srcdir)/'`dbus-daemon.c + +test_dbus_daemon-dbus-daemon.obj: dbus-daemon.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dbus_daemon_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dbus_daemon-dbus-daemon.obj -MD -MP -MF $(DEPDIR)/test_dbus_daemon-dbus-daemon.Tpo -c -o test_dbus_daemon-dbus-daemon.obj `if test -f 'dbus-daemon.c'; then $(CYGPATH_W) 'dbus-daemon.c'; else $(CYGPATH_W) '$(srcdir)/dbus-daemon.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_dbus_daemon-dbus-daemon.Tpo $(DEPDIR)/test_dbus_daemon-dbus-daemon.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='dbus-daemon.c' object='test_dbus_daemon-dbus-daemon.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dbus_daemon_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_dbus_daemon-dbus-daemon.obj `if test -f 'dbus-daemon.c'; then $(CYGPATH_W) 'dbus-daemon.c'; else $(CYGPATH_W) '$(srcdir)/dbus-daemon.c'; fi` + test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.o: dbus-daemon-eavesdrop.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dbus_daemon_eavesdrop_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.o -MD -MP -MF $(DEPDIR)/test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.Tpo -c -o test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.o `test -f 'dbus-daemon-eavesdrop.c' || echo '$(srcdir)/'`dbus-daemon-eavesdrop.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.Tpo $(DEPDIR)/test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.Po @@ -1241,6 +1357,20 @@ test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.obj: dbus-daemon-eavesdrop.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_dbus_daemon_eavesdrop_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_dbus_daemon_eavesdrop-dbus-daemon-eavesdrop.obj `if test -f 'dbus-daemon-eavesdrop.c'; then $(CYGPATH_W) 'dbus-daemon-eavesdrop.c'; else $(CYGPATH_W) '$(srcdir)/dbus-daemon-eavesdrop.c'; fi` +test_loopback-loopback.o: loopback.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_loopback_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_loopback-loopback.o -MD -MP -MF $(DEPDIR)/test_loopback-loopback.Tpo -c -o test_loopback-loopback.o `test -f 'loopback.c' || echo '$(srcdir)/'`loopback.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_loopback-loopback.Tpo $(DEPDIR)/test_loopback-loopback.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loopback.c' object='test_loopback-loopback.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_loopback_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_loopback-loopback.o `test -f 'loopback.c' || echo '$(srcdir)/'`loopback.c + +test_loopback-loopback.obj: loopback.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_loopback_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_loopback-loopback.obj -MD -MP -MF $(DEPDIR)/test_loopback-loopback.Tpo -c -o test_loopback-loopback.obj `if test -f 'loopback.c'; then $(CYGPATH_W) 'loopback.c'; else $(CYGPATH_W) '$(srcdir)/loopback.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_loopback-loopback.Tpo $(DEPDIR)/test_loopback-loopback.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='loopback.c' object='test_loopback-loopback.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_loopback_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_loopback-loopback.obj `if test -f 'loopback.c'; then $(CYGPATH_W) 'loopback.c'; else $(CYGPATH_W) '$(srcdir)/loopback.c'; fi` + test_names-test-names.o: test-names.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_names_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_names-test-names.o -MD -MP -MF $(DEPDIR)/test_names-test-names.Tpo -c -o test_names-test-names.o `test -f 'test-names.c' || echo '$(srcdir)/'`test-names.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_names-test-names.Tpo $(DEPDIR)/test_names-test-names.Po @@ -1283,6 +1413,20 @@ test_refs-refs.obj: internals/refs.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_refs_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_refs-refs.obj `if test -f 'internals/refs.c'; then $(CYGPATH_W) 'internals/refs.c'; else $(CYGPATH_W) '$(srcdir)/internals/refs.c'; fi` +test_relay-relay.o: relay.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_relay_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_relay-relay.o -MD -MP -MF $(DEPDIR)/test_relay-relay.Tpo -c -o test_relay-relay.o `test -f 'relay.c' || echo '$(srcdir)/'`relay.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_relay-relay.Tpo $(DEPDIR)/test_relay-relay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='relay.c' object='test_relay-relay.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_relay_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_relay-relay.o `test -f 'relay.c' || echo '$(srcdir)/'`relay.c + +test_relay-relay.obj: relay.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_relay_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_relay-relay.obj -MD -MP -MF $(DEPDIR)/test_relay-relay.Tpo -c -o test_relay-relay.obj `if test -f 'relay.c'; then $(CYGPATH_W) 'relay.c'; else $(CYGPATH_W) '$(srcdir)/relay.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_relay-relay.Tpo $(DEPDIR)/test_relay-relay.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='relay.c' object='test_relay-relay.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_relay_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o test_relay-relay.obj `if test -f 'relay.c'; then $(CYGPATH_W) 'relay.c'; else $(CYGPATH_W) '$(srcdir)/relay.c'; fi` + test_service-test-service.o: test-service.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(test_service_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT test_service-test-service.o -MD -MP -MF $(DEPDIR)/test_service-test-service.Tpo -c -o test_service-test-service.o `test -f 'test-service.c' || echo '$(srcdir)/'`test-service.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_service-test-service.Tpo $(DEPDIR)/test_service-test-service.Po @@ -1913,11 +2057,7 @@ clean-local: rm -f $(static_data); \ fi -data/valid-config-files/session.conf: $(top_builddir)/bus/session.conf - $(AM_V_at)$(MKDIR_P) data/valid-config-files - $(AM_V_GEN)cp $< $@ - -data/valid-config-files/system.conf: $(top_builddir)/bus/system.conf +$(imported_data): data/valid-config-files/%.conf: $(top_builddir)/bus/%.conf $(AM_V_at)$(MKDIR_P) data/valid-config-files $(AM_V_GEN)cp $< $@ diff --git a/test/corrupt.c b/test/corrupt.c index 02495901..1a7d4460 100644 --- a/test/corrupt.c +++ b/test/corrupt.c @@ -30,10 +30,12 @@ #include <gio/gio.h> #include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> + +#include "test-utils.h" typedef struct { DBusError e; + TestMainContext *ctx; DBusServer *server; DBusConnection *server_conn; @@ -72,13 +74,14 @@ new_conn_cb (DBusServer *server, g_assert (f->server_conn == NULL); f->server_conn = dbus_connection_ref (server_conn); - dbus_connection_setup_with_g_main (server_conn, NULL); + test_connection_setup (f->ctx, server_conn); } static void setup (Fixture *f, gconstpointer addr) { + f->ctx = test_main_context_get (); dbus_error_init (&f->e); g_queue_init (&f->client_messages); @@ -88,7 +91,7 @@ setup (Fixture *f, dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->server, NULL); + test_server_setup (f->ctx, f->server); } static void @@ -103,12 +106,12 @@ test_connect (Fixture *f, dbus_server_get_address (f->server), &f->e); assert_no_error (&f->e); g_assert (f->client_conn != NULL); - dbus_connection_setup_with_g_main (f->client_conn, NULL); + test_connection_setup (f->ctx, f->client_conn); while (f->server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } have_mem = dbus_connection_add_filter (f->client_conn, @@ -137,7 +140,7 @@ test_message (Fixture *f, while (g_queue_is_empty (&f->client_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->client_messages), ==, 1); @@ -229,7 +232,7 @@ test_corrupt (Fixture *f, while (g_queue_is_empty (&f->client_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } incoming = g_queue_pop_head (&f->client_messages); @@ -246,6 +249,16 @@ test_corrupt (Fixture *f, "/org/freedesktop/DBus/Local"); dbus_message_unref (incoming); + + /* Free the DBusConnection before the GSocket, because GSocket is + * going to close our fd. GSocket tolerates closing an already-closed + * fd, whereas DBusLoop + DBusSocketSetEpoll doesn't. On Unix + * we could use dup() but that isn't portable to Windows :-( + */ + dbus_connection_close (f->server_conn); + dbus_connection_unref (f->server_conn); + f->server_conn = NULL; + g_object_unref (socket); } @@ -308,7 +321,7 @@ test_byte_order (Fixture *f, while (g_queue_is_empty (&f->client_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } message = g_queue_pop_head (&f->client_messages); @@ -325,6 +338,12 @@ test_byte_order (Fixture *f, "/org/freedesktop/DBus/Local"); dbus_message_unref (message); + + /* Free the DBusConnection before the GSocket, as above. */ + dbus_connection_close (f->server_conn); + dbus_connection_unref (f->server_conn); + f->server_conn = NULL; + g_object_unref (socket); } @@ -352,6 +371,8 @@ teardown (Fixture *f, dbus_server_unref (f->server); f->server = NULL; } + + test_main_context_unref (f->ctx); } int diff --git a/test/dbus-daemon-eavesdrop.c b/test/dbus-daemon-eavesdrop.c index 0bd923d2..2c45f54e 100644 --- a/test/dbus-daemon-eavesdrop.c +++ b/test/dbus-daemon-eavesdrop.c @@ -30,7 +30,6 @@ #include <glib.h> #include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> #include <string.h> @@ -42,6 +41,8 @@ # include <unistd.h> #endif +#include "test-utils.h" + #define SENDER_NAME "test.eavesdrop.sender" #define SENDER_PATH "/test/eavesdrop/sender" #define SENDER_IFACE SENDER_NAME @@ -71,6 +72,7 @@ typedef enum { } SignalDst; typedef struct { + TestMainContext *ctx; DBusError e; GError *ge; @@ -160,7 +162,8 @@ spawn_dbus_daemon (gchar *binary, } static DBusConnection * -connect_to_bus (const gchar *address) +connect_to_bus (Fixture *f, + const gchar *address) { DBusConnection *conn; DBusError error = DBUS_ERROR_INIT; @@ -175,7 +178,7 @@ connect_to_bus (const gchar *address) g_assert (ok); g_assert (dbus_bus_get_unique_name (conn) != NULL); - dbus_connection_setup_with_g_main (conn, NULL); + test_connection_setup (f->ctx, conn); return conn; } @@ -380,6 +383,8 @@ setup (Fixture *f, gchar *config; gchar *address; + f->ctx = test_main_context_get (); + f->ge = NULL; dbus_error_init (&f->e); @@ -409,12 +414,12 @@ setup (Fixture *f, g_free (dbus_daemon); g_free (config); - f->sender = connect_to_bus (address); + f->sender = connect_to_bus (f, address); dbus_bus_request_name (f->sender, SENDER_NAME, DBUS_NAME_FLAG_DO_NOT_QUEUE, &(f->e)); - f->receiver = connect_to_bus (address); - f->eavesdropper = connect_to_bus (address); - f->politelistener = connect_to_bus (address); + f->receiver = connect_to_bus (f, address); + f->eavesdropper = connect_to_bus (f, address); + f->politelistener = connect_to_bus (f, address); add_receiver_filter (f); add_politelistener_filter (f); add_eavesdropper_filter (f); @@ -432,7 +437,7 @@ test_eavesdrop_broadcast (Fixture *f, while (!f->receiver_got_stopper || !f->politelistener_got_stopper || !f->eavesdropper_got_stopper) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); /* all the three connection can receive a broadcast */ g_assert_cmpint (f->receiver_dst, ==, BROADCAST); @@ -452,7 +457,7 @@ test_eavesdrop_unicast_to_sender (Fixture *f, while (!f->receiver_got_stopper || !f->politelistener_got_stopper || !f->eavesdropper_got_stopper) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); /* not directed to it and not broadcasted, they cannot receive it */ g_assert_cmpint (f->receiver_dst, ==, NONE_YET); @@ -472,7 +477,7 @@ test_eavesdrop_unicast_to_receiver (Fixture *f, while (!f->receiver_got_stopper || !f->politelistener_got_stopper || !f->eavesdropper_got_stopper) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); /* direct to him */ g_assert_cmpint (f->receiver_dst, ==, TO_ME); @@ -534,6 +539,8 @@ teardown (Fixture *f, #endif g_spawn_close_pid (f->daemon_pid); + + test_main_context_unref (f->ctx); } int diff --git a/test/dbus-daemon.c b/test/dbus-daemon.c index cc871530..22ea23e3 100644 --- a/test/dbus-daemon.c +++ b/test/dbus-daemon.c @@ -29,7 +29,6 @@ #include <glib.h> #include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> #include <string.h> @@ -39,11 +38,16 @@ #else # include <signal.h> # include <unistd.h> +# include <sys/types.h> #endif +#include "test-utils.h" + typedef struct { gboolean skip; + TestMainContext *ctx; + DBusError e; GError *ge; @@ -126,7 +130,8 @@ spawn_dbus_daemon (gchar *binary, } static DBusConnection * -connect_to_bus (const gchar *address) +connect_to_bus (Fixture *f, + const gchar *address) { DBusConnection *conn; DBusError error = DBUS_ERROR_INIT; @@ -141,7 +146,7 @@ connect_to_bus (const gchar *address) g_assert (ok); g_assert (dbus_bus_get_unique_name (conn) != NULL); - dbus_connection_setup_with_g_main (conn, NULL); + test_connection_setup (f->ctx, conn); return conn; } @@ -183,6 +188,7 @@ setup (Fixture *f, gchar *arg; gchar *address; + f->ctx = test_main_context_get (); f->ge = NULL; dbus_error_init (&f->e); @@ -226,8 +232,8 @@ setup (Fixture *f, g_free (dbus_daemon); g_free (arg); - f->left_conn = connect_to_bus (address); - f->right_conn = connect_to_bus (address); + f->left_conn = connect_to_bus (f, address); + f->right_conn = connect_to_bus (f, address); g_free (address); } @@ -301,7 +307,7 @@ test_echo (Fixture *f, } while (received < count) - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); elapsed = g_test_timer_elapsed (); @@ -310,6 +316,131 @@ test_echo (Fixture *f, } static void +pending_call_store_reply (DBusPendingCall *pc, + void *data) +{ + DBusMessage **message_p = data; + + *message_p = dbus_pending_call_steal_reply (pc); + g_assert (*message_p != NULL); +} + +static void +test_creds (Fixture *f, + gconstpointer context) +{ + const char *unique = dbus_bus_get_unique_name (f->left_conn); + DBusMessage *m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, + DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetConnectionCredentials"); + DBusPendingCall *pc; + DBusMessageIter args_iter; + DBusMessageIter arr_iter; + DBusMessageIter pair_iter; + DBusMessageIter var_iter; + enum { + SEEN_UNIX_USER = 1, + SEEN_PID = 2, + SEEN_WINDOWS_SID = 4 + } seen = 0; + + if (m == NULL) + g_error ("OOM"); + + if (!dbus_message_append_args (m, + DBUS_TYPE_STRING, &unique, + DBUS_TYPE_INVALID)) + g_error ("OOM"); + + if (!dbus_connection_send_with_reply (f->left_conn, m, &pc, + DBUS_TIMEOUT_USE_DEFAULT) || + pc == NULL) + g_error ("OOM"); + + dbus_message_unref (m); + m = NULL; + + if (dbus_pending_call_get_completed (pc)) + pending_call_store_reply (pc, &m); + else if (!dbus_pending_call_set_notify (pc, pending_call_store_reply, + &m, NULL)) + g_error ("OOM"); + + while (m == NULL) + test_main_context_iterate (f->ctx, TRUE); + + g_assert_cmpstr (dbus_message_get_signature (m), ==, "a{sv}"); + + dbus_message_iter_init (m, &args_iter); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&args_iter), ==, + DBUS_TYPE_ARRAY); + g_assert_cmpuint (dbus_message_iter_get_element_type (&args_iter), ==, + DBUS_TYPE_DICT_ENTRY); + dbus_message_iter_recurse (&args_iter, &arr_iter); + + while (dbus_message_iter_get_arg_type (&arr_iter) != DBUS_TYPE_INVALID) + { + const char *name; + + dbus_message_iter_recurse (&arr_iter, &pair_iter); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&pair_iter), ==, + DBUS_TYPE_STRING); + dbus_message_iter_get_basic (&pair_iter, &name); + dbus_message_iter_next (&pair_iter); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&pair_iter), ==, + DBUS_TYPE_VARIANT); + dbus_message_iter_recurse (&pair_iter, &var_iter); + + if (g_strcmp0 (name, "UnixUserID") == 0) + { +#ifdef G_OS_UNIX + guint32 u32; + + g_assert (!(seen & SEEN_UNIX_USER)); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==, + DBUS_TYPE_UINT32); + dbus_message_iter_get_basic (&var_iter, &u32); + g_message ("%s of this process is %u", name, u32); + g_assert_cmpuint (u32, ==, geteuid ()); + seen |= SEEN_UNIX_USER; +#else + g_assert_not_reached (); +#endif + } + else if (g_strcmp0 (name, "ProcessID") == 0) + { + guint32 u32; + + g_assert (!(seen & SEEN_PID)); + g_assert_cmpuint (dbus_message_iter_get_arg_type (&var_iter), ==, + DBUS_TYPE_UINT32); + dbus_message_iter_get_basic (&var_iter, &u32); + g_message ("%s of this process is %u", name, u32); +#ifdef G_OS_UNIX + g_assert_cmpuint (u32, ==, getpid ()); +#elif defined(G_OS_WIN32) + g_assert_cmpuint (u32, ==, GetCurrentProcessId ()); +#else + g_assert_not_reached (); +#endif + seen |= SEEN_PID; + } + + dbus_message_iter_next (&arr_iter); + } + +#ifdef G_OS_UNIX + g_assert (seen & SEEN_UNIX_USER); + g_assert (seen & SEEN_PID); +#endif + +#ifdef G_OS_WIN32 + /* FIXME: when implemented: + g_assert (seen & SEEN_WINDOWS_SID); + */ +#endif +} + +static void teardown (Fixture *f, gconstpointer context G_GNUC_UNUSED) { @@ -347,6 +478,8 @@ teardown (Fixture *f, g_spawn_close_pid (f->daemon_pid); f->daemon_pid = 0; } + + test_main_context_unref (f->ctx); } static Config limited_config = { @@ -363,6 +496,7 @@ main (int argc, g_test_add ("/echo/session", Fixture, NULL, setup, test_echo, teardown); g_test_add ("/echo/limited", Fixture, &limited_config, setup, test_echo, teardown); + g_test_add ("/creds", Fixture, NULL, setup, test_creds, teardown); return g_test_run (); } diff --git a/test/internals/printf.c b/test/internals/printf.c index 2d2fff8d..db151518 100644 --- a/test/internals/printf.c +++ b/test/internals/printf.c @@ -26,7 +26,6 @@ #include <config.h> -#define DBUS_COMPILATION /* this test uses libdbus-internal */ #include <dbus/dbus.h> #include <dbus/dbus-internals.h> #include <dbus/dbus-string.h> diff --git a/test/internals/refs.c b/test/internals/refs.c index db43a4da..202dc043 100644 --- a/test/internals/refs.c +++ b/test/internals/refs.c @@ -29,7 +29,6 @@ #include <glib.h> #include <glib-object.h> -#define DBUS_COMPILATION /* this test uses libdbus-internal */ #include <dbus/dbus.h> #include <dbus/dbus-connection-internal.h> #include <dbus/dbus-mainloop.h> diff --git a/test/internals/syslog.c b/test/internals/syslog.c index 658281cb..2811b757 100644 --- a/test/internals/syslog.c +++ b/test/internals/syslog.c @@ -30,7 +30,6 @@ #include <glib.h> -#define DBUS_COMPILATION /* this test uses libdbus-internal */ #include <dbus/dbus.h> #include <dbus/dbus-sysdeps.h> diff --git a/test/loopback.c b/test/loopback.c index d0d69c82..7526d8d2 100644 --- a/test/loopback.c +++ b/test/loopback.c @@ -1,7 +1,7 @@ /* Simple sanity-check for loopback through TCP and Unix sockets. * * Author: Simon McVittie <simon.mcvittie@collabora.co.uk> - * Copyright © 2010-2011 Nokia Corporation + * Copyright © 2010-2012 Nokia Corporation * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation files @@ -29,9 +29,13 @@ #include <glib.h> #include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> + +#include <string.h> + +#include "test-utils.h" typedef struct { + TestMainContext *ctx; DBusError e; DBusServer *server; @@ -72,7 +76,7 @@ new_conn_cb (DBusServer *server, g_assert (f->server_conn == NULL); f->server_conn = dbus_connection_ref (server_conn); - dbus_connection_setup_with_g_main (server_conn, NULL); + test_connection_setup (f->ctx, server_conn); have_mem = dbus_connection_add_filter (server_conn, server_message_cb, f, NULL); @@ -83,6 +87,7 @@ static void setup (Fixture *f, gconstpointer addr) { + f->ctx = test_main_context_get (); dbus_error_init (&f->e); g_queue_init (&f->server_messages); @@ -92,7 +97,7 @@ setup (Fixture *f, dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->server, NULL); + test_server_setup (f->ctx, f->server); } static void @@ -105,13 +110,73 @@ test_connect (Fixture *f, dbus_server_get_address (f->server), &f->e); assert_no_error (&f->e); g_assert (f->client_conn != NULL); - dbus_connection_setup_with_g_main (f->client_conn, NULL); + test_connection_setup (f->ctx, f->client_conn); while (f->server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); + } +} + +static void +test_bad_guid (Fixture *f, + gconstpointer addr G_GNUC_UNUSED) +{ + DBusMessage *incoming; + gchar *address = g_strdup (dbus_server_get_address (f->server)); + gchar *guid; + + g_test_bug ("39720"); + + g_assert (f->server_conn == NULL); + + g_assert (strstr (address, "guid=") != NULL); + guid = strstr (address, "guid="); + g_assert_cmpuint (strlen (guid), >=, 5 + 32); + + /* Change the first char of the guid to something different */ + if (guid[5] == '0') + guid[5] = 'f'; + else + guid[5] = '0'; + + f->client_conn = dbus_connection_open_private (address, &f->e); + assert_no_error (&f->e); + g_assert (f->client_conn != NULL); + test_connection_setup (f->ctx, f->client_conn); + + while (f->server_conn == NULL) + { + g_print ("."); + test_main_context_iterate (f->ctx, TRUE); + } + + /* We get disconnected */ + + while (g_queue_is_empty (&f->server_messages)) + { + g_print ("."); + test_main_context_iterate (f->ctx, TRUE); } + + g_assert_cmpuint (g_queue_get_length (&f->server_messages), ==, 1); + + incoming = g_queue_pop_head (&f->server_messages); + + g_assert (!dbus_message_contains_unix_fds (incoming)); + g_assert_cmpstr (dbus_message_get_destination (incoming), ==, NULL); + g_assert_cmpstr (dbus_message_get_error_name (incoming), ==, NULL); + g_assert_cmpstr (dbus_message_get_interface (incoming), ==, + DBUS_INTERFACE_LOCAL); + g_assert_cmpstr (dbus_message_get_member (incoming), ==, "Disconnected"); + g_assert_cmpstr (dbus_message_get_sender (incoming), ==, NULL); + g_assert_cmpstr (dbus_message_get_signature (incoming), ==, ""); + g_assert_cmpstr (dbus_message_get_path (incoming), ==, DBUS_PATH_LOCAL); + + dbus_message_unref (incoming); + + g_free (address); } static void @@ -135,7 +200,7 @@ test_message (Fixture *f, while (g_queue_is_empty (&f->server_messages)) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->server_messages), ==, 1); @@ -182,6 +247,8 @@ teardown (Fixture *f, dbus_server_unref (f->server); f->server = NULL; } + + test_main_context_unref (f->ctx); } int @@ -189,6 +256,7 @@ main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); + g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id="); g_test_add ("/connect/tcp", Fixture, "tcp:host=127.0.0.1", setup, test_connect, teardown); @@ -207,5 +275,8 @@ main (int argc, test_message, teardown); #endif + g_test_add ("/message/bad-guid", Fixture, "tcp:host=127.0.0.1", setup, + test_bad_guid, teardown); + return g_test_run (); } diff --git a/test/manual-authz.c b/test/manual-authz.c new file mode 100644 index 00000000..f9e3688e --- /dev/null +++ b/test/manual-authz.c @@ -0,0 +1,409 @@ +/* Simple sanity-check for authentication and authorization. + * + * Copyright © 2010-2011 Nokia Corporation + * Copyright © 2012 Collabora Ltd. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include <config.h> + +#include <glib.h> + +#include <dbus/dbus.h> + +#ifdef G_OS_UNIX +#include <unistd.h> +#include <sys/types.h> +#endif + +#include "test-utils.h" + +typedef struct { + DBusError e; + TestMainContext *ctx; + + DBusServer *normal_server; + DBusServer *anon_allowed_server; + DBusServer *anon_only_server; + DBusServer *anon_mech_only_server; + DBusServer *anon_disallowed_server; + DBusServer *permissive_server; + DBusServer *unhappy_server; + DBusServer *same_uid_server; + DBusServer *same_uid_or_anon_server; +} Fixture; + +static void oom (void) G_GNUC_NORETURN; +static void +oom (void) +{ + g_error ("out of memory"); +} + +static void +assert_no_error (const DBusError *e) +{ + if (G_UNLIKELY (dbus_error_is_set (e))) + g_error ("expected success but got error: %s: %s", e->name, e->message); +} + +static DBusHandlerResult +server_message_cb (DBusConnection *conn, + DBusMessage *message, + void *data) +{ + if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected")) + { + dbus_connection_unref (conn); + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_CALL) + { + DBusMessage *reply = dbus_message_new_method_return (message); + const char *hello = "Hello, world!"; + unsigned long uid; + char *sid; + + if (dbus_connection_get_unix_user (conn, &uid)) + { + g_message ("message from uid %lu", uid); + } + else if (dbus_connection_get_windows_user (conn, &sid)) + { + if (sid == NULL) + oom (); + + g_message ("message from sid \"%s\"", sid); + dbus_free (sid); + } + else if (dbus_connection_get_is_anonymous (conn)) + { + g_message ("message from Anonymous"); + } + else + { + g_message ("message from ... someone?"); + } + + if (reply == NULL) + oom (); + + if (!dbus_message_append_args (reply, + DBUS_TYPE_STRING, &hello, + DBUS_TYPE_INVALID)) + oom (); + + if (!dbus_connection_send (conn, reply, NULL)) + oom (); + + dbus_message_unref (reply); + + return DBUS_HANDLER_RESULT_HANDLED; + } + + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static dbus_bool_t +permissive_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_message ("accepting Unix user %lu", uid); + return TRUE; +} + +static dbus_bool_t +permissive_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_message ("accepting Windows user \"%s\"", sid); + return TRUE; +} + +static dbus_bool_t +broken_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_error ("libdbus called the Unix user function for an ANONYMOUS-only " + "connection"); + return FALSE; +} + +static dbus_bool_t +broken_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_error ("libdbus called the Windows user function for an ANONYMOUS-only " + "connection"); + return FALSE; +} + +static dbus_bool_t +unhappy_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_message ("rejecting Unix user %lu", uid); + return FALSE; +} + +static dbus_bool_t +unhappy_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_message ("rejecting Windows user \"%s\"", sid); + return FALSE; +} + +static dbus_bool_t +same_uid_unix_func (DBusConnection *conn, + unsigned long uid, + void *data) +{ + g_message ("checking whether Unix user %lu owns this process", uid); + /* I'd use _dbus_unix_user_is_process_owner(), but it's private... */ +#ifdef G_OS_UNIX + return (geteuid () == uid); +#else + return FALSE; +#endif +} + +static dbus_bool_t +same_uid_win_func (DBusConnection *conn, + const char *sid, + void *data) +{ + g_message ("checking whether Windows user \"%s\" owns this process", sid); + g_message ("Stub implementation consistent with dbus-sysdeps-util-win: " + "assume they do"); + return TRUE; +} + +static void +new_conn_cb (DBusServer *server, + DBusConnection *conn, + void *data) +{ + Fixture *f = data; + + dbus_connection_ref (conn); + test_connection_setup (f->ctx, conn); + + if (!dbus_connection_add_filter (conn, server_message_cb, f, NULL)) + oom (); + + if (server == f->normal_server) + { + } + else if (server == f->anon_allowed_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + } + else if (server == f->anon_only_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + + dbus_connection_set_unix_user_function (conn, unhappy_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, unhappy_win_func, + f, NULL); + } + else if (server == f->anon_mech_only_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + + /* should never get called */ + dbus_connection_set_unix_user_function (conn, broken_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, broken_win_func, + f, NULL); + } + else if (server == f->anon_disallowed_server) + { + dbus_connection_set_allow_anonymous (conn, FALSE); + + /* should never get called */ + dbus_connection_set_unix_user_function (conn, broken_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, broken_win_func, + f, NULL); + } + else if (server == f->permissive_server) + { + dbus_connection_set_unix_user_function (conn, permissive_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, permissive_win_func, + f, NULL); + } + else if (server == f->unhappy_server) + { + dbus_connection_set_unix_user_function (conn, unhappy_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, unhappy_win_func, + f, NULL); + } + else if (server == f->same_uid_server) + { + dbus_connection_set_unix_user_function (conn, same_uid_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, same_uid_win_func, + f, NULL); + } + else if (server == f->same_uid_or_anon_server) + { + dbus_connection_set_allow_anonymous (conn, TRUE); + + dbus_connection_set_unix_user_function (conn, same_uid_unix_func, + f, NULL); + dbus_connection_set_windows_user_function (conn, same_uid_win_func, + f, NULL); + } + else + { + g_assert_not_reached (); + } +} + +static void +setup (Fixture *f, + const gchar *listen_addr) +{ + const char *only_anon[] = { "ANONYMOUS", NULL }; + char *connect_addr; + + f->normal_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->normal_server != NULL); + dbus_server_set_new_connection_function (f->normal_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->normal_server); + connect_addr = dbus_server_get_address (f->normal_server); + g_message ("Normal server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_allowed_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_allowed_server != NULL); + dbus_server_set_new_connection_function (f->anon_allowed_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->anon_allowed_server); + connect_addr = dbus_server_get_address (f->anon_allowed_server); + g_message ("Anonymous-allowed server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_only_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_only_server != NULL); + dbus_server_set_new_connection_function (f->anon_only_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->anon_only_server); + connect_addr = dbus_server_get_address (f->anon_only_server); + g_message ("Anonymous-only server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_mech_only_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_mech_only_server != NULL); + dbus_server_set_auth_mechanisms (f->anon_mech_only_server, only_anon); + dbus_server_set_new_connection_function (f->anon_mech_only_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->anon_mech_only_server); + connect_addr = dbus_server_get_address (f->anon_mech_only_server); + g_message ("Anon mech only server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->anon_disallowed_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->anon_disallowed_server != NULL); + dbus_server_set_auth_mechanisms (f->anon_disallowed_server, only_anon); + dbus_server_set_new_connection_function (f->anon_disallowed_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->anon_disallowed_server); + connect_addr = dbus_server_get_address (f->anon_disallowed_server); + g_message ("Anonymous-disallowed server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->permissive_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->permissive_server != NULL); + dbus_server_set_new_connection_function (f->permissive_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->permissive_server); + connect_addr = dbus_server_get_address (f->permissive_server); + g_message ("Permissive server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->unhappy_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->unhappy_server != NULL); + dbus_server_set_new_connection_function (f->unhappy_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->unhappy_server); + connect_addr = dbus_server_get_address (f->unhappy_server); + g_message ("Unhappy server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->same_uid_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->same_uid_server != NULL); + dbus_server_set_new_connection_function (f->same_uid_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->same_uid_server); + connect_addr = dbus_server_get_address (f->same_uid_server); + g_message ("Same-UID server:\n%s", connect_addr); + dbus_free (connect_addr); + + f->same_uid_or_anon_server = dbus_server_listen (listen_addr, &f->e); + assert_no_error (&f->e); + g_assert (f->same_uid_or_anon_server != NULL); + dbus_server_set_new_connection_function (f->same_uid_or_anon_server, + new_conn_cb, f, NULL); + test_server_setup (f->ctx, f->same_uid_or_anon_server); + connect_addr = dbus_server_get_address (f->same_uid_or_anon_server); + g_message ("Same-UID-or-anon server:\n%s", connect_addr); + dbus_free (connect_addr); +} + +int +main (int argc, + char **argv) +{ + Fixture f = { DBUS_ERROR_INIT, test_main_context_get () }; + + if (argc >= 2) + setup (&f, argv[1]); + else + setup (&f, "tcp:host=127.0.0.1"); + + for (;;) + test_main_context_iterate (f.ctx, TRUE); + + /* never returns */ +} diff --git a/test/marshal.c b/test/marshal.c index e9ac7e30..d74e7671 100644 --- a/test/marshal.c +++ b/test/marshal.c @@ -27,9 +27,9 @@ #include <config.h> #include <glib.h> +#include <string.h> #include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> typedef struct { DBusError e; @@ -244,14 +244,30 @@ int main (int argc, char **argv) { + int ret; + char *aligned_le_blob; + char *aligned_be_blob; + g_test_init (&argc, &argv, NULL); - g_test_add ("/demarshal/le", Fixture, le_blob, setup, test_endian, teardown); - g_test_add ("/demarshal/be", Fixture, be_blob, setup, test_endian, teardown); - g_test_add ("/demarshal/needed/le", Fixture, le_blob, setup, test_needed, + /* We have to pass in a buffer that's at least "default aligned", + * i.e. on GNU systems to 8 or 16. The linker may have only given + * us byte-alignment for the char[] static variables. + */ + aligned_le_blob = g_malloc (sizeof (le_blob)); + memcpy (aligned_le_blob, le_blob, sizeof (le_blob)); + aligned_be_blob = g_malloc (sizeof (be_blob)); + memcpy (aligned_be_blob, be_blob, sizeof (be_blob)); + + g_test_add ("/demarshal/le", Fixture, aligned_le_blob, setup, test_endian, teardown); + g_test_add ("/demarshal/be", Fixture, aligned_be_blob, setup, test_endian, teardown); + g_test_add ("/demarshal/needed/le", Fixture, aligned_le_blob, setup, test_needed, teardown); - g_test_add ("/demarshal/needed/be", Fixture, be_blob, setup, test_needed, + g_test_add ("/demarshal/needed/be", Fixture, aligned_be_blob, setup, test_needed, teardown); - return g_test_run (); + ret = g_test_run (); + g_free (aligned_le_blob); + g_free (aligned_be_blob); + return ret; } diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 6aaf1783..da41e58b 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -3,6 +3,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -DDBUS_COMPILATION \ -DDBUS_STATIC_BUILD \ + -DDBUS_TEST_USE_INTERNAL \ $(NULL) # if assertions are enabled, improve backtraces @@ -11,8 +12,14 @@ AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ ## note that TESTS has special meaning (stuff to use in make check) ## so if adding tests not to be run in make check, don't add them to ## TESTS -if DBUS_BUILD_TESTS -TESTS_ENVIRONMENT=DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ PYTHON=@PYTHON@ +if DBUS_ENABLE_EMBEDDED_TESTS +TESTS_ENVIRONMENT = \ + DBUS_TOP_BUILDDIR=@abs_top_builddir@ \ + DBUS_TOP_SRCDIR=@abs_top_srcdir@ \ + PYTHON=@PYTHON@ \ + DBUS_TEST_DATA=@abs_top_builddir@/test/data \ + DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \ + $(NULL) TESTS=run-test.sh run-test-systemserver.sh else TESTS= @@ -20,7 +27,7 @@ endif EXTRA_DIST=run-test.sh run-test-systemserver.sh test-wait-for-echo.py test-activation-forking.py -if DBUS_BUILD_TESTS +if DBUS_ENABLE_EMBEDDED_TESTS ## we use noinst_PROGRAMS not check_PROGRAMS for TESTS so that we ## build even when not doing "make check" @@ -31,9 +38,9 @@ test_pending_call_timeout_LDADD=$(top_builddir)/dbus/libdbus-internal.la test_threads_init_LDADD=$(top_builddir)/dbus/libdbus-internal.la test_ids_LDADD=$(top_builddir)/dbus/libdbus-internal.la -test_shutdown_LDADD=../libdbus-testutils.la -test_privserver_LDADD=../libdbus-testutils.la -test_privserver_client_LDADD=../libdbus-testutils.la -test_autolaunch_LDADD=../libdbus-testutils.la +test_shutdown_LDADD=../libdbus-testutils-internal.la +test_privserver_LDADD=../libdbus-testutils-internal.la +test_privserver_client_LDADD=../libdbus-testutils-internal.la +test_autolaunch_LDADD=../libdbus-testutils-internal.la endif diff --git a/test/name-test/Makefile.in b/test/name-test/Makefile.in index 93463cd1..bfe2706c 100644 --- a/test/name-test/Makefile.in +++ b/test/name-test/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. @@ -78,16 +78,16 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -@DBUS_BUILD_TESTS_TRUE@TESTS = run-test.sh run-test-systemserver.sh -@DBUS_BUILD_TESTS_TRUE@noinst_PROGRAMS = \ -@DBUS_BUILD_TESTS_TRUE@ test-pending-call-dispatch$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-pending-call-timeout$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-threads-init$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-ids$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-shutdown$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-privserver$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-privserver-client$(EXEEXT) \ -@DBUS_BUILD_TESTS_TRUE@ test-autolaunch$(EXEEXT) +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@TESTS = run-test.sh \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ run-test-systemserver.sh +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@noinst_PROGRAMS = test-pending-call-dispatch$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-pending-call-timeout$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-threads-init$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-ids$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-shutdown$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-privserver$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-privserver-client$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ test-autolaunch$(EXEEXT) subdir = test/name-test DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp $(top_srcdir)/test-driver @@ -108,38 +108,34 @@ CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) test_autolaunch_SOURCES = test-autolaunch.c test_autolaunch_OBJECTS = test-autolaunch.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_autolaunch_DEPENDENCIES = \ -@DBUS_BUILD_TESTS_TRUE@ ../libdbus-testutils.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_autolaunch_DEPENDENCIES = ../libdbus-testutils-internal.la AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent am__v_lt_1 = test_ids_SOURCES = test-ids.c test_ids_OBJECTS = test-ids.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_ids_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_ids_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la test_pending_call_dispatch_SOURCES = test-pending-call-dispatch.c test_pending_call_dispatch_OBJECTS = \ test-pending-call-dispatch.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_pending_call_dispatch_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_pending_call_dispatch_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la test_pending_call_timeout_SOURCES = test-pending-call-timeout.c test_pending_call_timeout_OBJECTS = \ test-pending-call-timeout.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_pending_call_timeout_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_pending_call_timeout_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la test_privserver_SOURCES = test-privserver.c test_privserver_OBJECTS = test-privserver.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_privserver_DEPENDENCIES = \ -@DBUS_BUILD_TESTS_TRUE@ ../libdbus-testutils.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_privserver_DEPENDENCIES = ../libdbus-testutils-internal.la test_privserver_client_SOURCES = test-privserver-client.c test_privserver_client_OBJECTS = test-privserver-client.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_privserver_client_DEPENDENCIES = \ -@DBUS_BUILD_TESTS_TRUE@ ../libdbus-testutils.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_privserver_client_DEPENDENCIES = ../libdbus-testutils-internal.la test_shutdown_SOURCES = test-shutdown.c test_shutdown_OBJECTS = test-shutdown.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_shutdown_DEPENDENCIES = \ -@DBUS_BUILD_TESTS_TRUE@ ../libdbus-testutils.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_shutdown_DEPENDENCIES = ../libdbus-testutils-internal.la test_threads_init_SOURCES = test-threads-init.c test_threads_init_OBJECTS = test-threads-init.$(OBJEXT) -@DBUS_BUILD_TESTS_TRUE@test_threads_init_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_threads_init_DEPENDENCIES = $(top_builddir)/dbus/libdbus-internal.la AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -438,7 +434,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@ @@ -541,7 +536,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@ @@ -623,21 +617,29 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -DDBUS_COMPILATION \ -DDBUS_STATIC_BUILD \ + -DDBUS_TEST_USE_INTERNAL \ $(NULL) # if assertions are enabled, improve backtraces AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ -@DBUS_BUILD_TESTS_TRUE@TESTS_ENVIRONMENT = DBUS_TOP_BUILDDIR=@abs_top_builddir@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ PYTHON=@PYTHON@ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@TESTS_ENVIRONMENT = \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ DBUS_TOP_BUILDDIR=@abs_top_builddir@ \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ DBUS_TOP_SRCDIR=@abs_top_srcdir@ \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ PYTHON=@PYTHON@ \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ DBUS_TEST_DATA=@abs_top_builddir@/test/data \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ DBUS_TEST_DAEMON=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \ +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@ $(NULL) + EXTRA_DIST = run-test.sh run-test-systemserver.sh test-wait-for-echo.py test-activation-forking.py -@DBUS_BUILD_TESTS_TRUE@test_pending_call_dispatch_LDADD = $(top_builddir)/dbus/libdbus-internal.la -@DBUS_BUILD_TESTS_TRUE@test_pending_call_timeout_LDADD = $(top_builddir)/dbus/libdbus-internal.la -@DBUS_BUILD_TESTS_TRUE@test_threads_init_LDADD = $(top_builddir)/dbus/libdbus-internal.la -@DBUS_BUILD_TESTS_TRUE@test_ids_LDADD = $(top_builddir)/dbus/libdbus-internal.la -@DBUS_BUILD_TESTS_TRUE@test_shutdown_LDADD = ../libdbus-testutils.la -@DBUS_BUILD_TESTS_TRUE@test_privserver_LDADD = ../libdbus-testutils.la -@DBUS_BUILD_TESTS_TRUE@test_privserver_client_LDADD = ../libdbus-testutils.la -@DBUS_BUILD_TESTS_TRUE@test_autolaunch_LDADD = ../libdbus-testutils.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_pending_call_dispatch_LDADD = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_pending_call_timeout_LDADD = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_threads_init_LDADD = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_ids_LDADD = $(top_builddir)/dbus/libdbus-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_shutdown_LDADD = ../libdbus-testutils-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_privserver_LDADD = ../libdbus-testutils-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_privserver_client_LDADD = ../libdbus-testutils-internal.la +@DBUS_ENABLE_EMBEDDED_TESTS_TRUE@test_autolaunch_LDADD = ../libdbus-testutils-internal.la all: all-am .SUFFIXES: @@ -734,14 +736,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/test/name-test/test-autolaunch.c b/test/name-test/test-autolaunch.c index adbeb185..8b5206a6 100644 --- a/test/name-test/test-autolaunch.c +++ b/test/name-test/test-autolaunch.c @@ -16,21 +16,23 @@ main (int argc, char *argv[]) DBusConnection *conn = NULL; DBusError error; - _dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", NULL); + dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", NULL); dbus_error_init (&error); conn = dbus_bus_get (DBUS_BUS_SESSION, &error); #ifdef DBUS_ENABLE_X11_AUTOLAUNCH - if (dbus_error_is_set (&error)) + /* If X11 autolaunch was enabled, we expect dbus-launch to have worked. */ + if (_dbus_getenv ("DISPLAY") != NULL && dbus_error_is_set (&error)) { fprintf (stderr, "*** Failed to autolaunch session bus: %s\n", error.message); dbus_error_free (&error); return 1; } -#else +#endif + /* We don't necessarily expect it to *work* without X (although it might - * for instance on Mac OS it might have used launchd). Just check that the * results are consistent. */ @@ -40,7 +42,6 @@ main (int argc, char *argv[]) fprintf (stderr, "*** Autolaunched session bus, but an error was set!\n"); return 1; } -#endif if (!dbus_error_is_set (&error) && conn == NULL) { diff --git a/test/name-test/test-threads-init.c b/test/name-test/test-threads-init.c index 5e22852a..580ffe14 100644 --- a/test/name-test/test-threads-init.c +++ b/test/name-test/test-threads-init.c @@ -149,11 +149,15 @@ main (int argc, char *argv[]) &dispatch_cond1, &io_path_cond1); - check_mutex_lock (mutex1, mutex2, FALSE); - check_mutex_lock (dispatch_mutex1, dispatch_mutex2, FALSE); - check_mutex_lock (io_path_mutex1, io_path_mutex2, FALSE); - check_condvar_lock (dispatch_cond1, dispatch_cond2, FALSE); - check_condvar_lock (io_path_cond1, io_path_cond2, FALSE); + /* Since 1.7 it is no longer the case that mutex1 != mutex2, because + * initializing global locks automatically initializes locks + * in general. However, it is true that the mutex is not the dummy + * implementation, which is what we really wanted to check here. */ + _dbus_assert (mutex1 != (DBusMutex *) 0xABCDEF); + _dbus_assert (dispatch_mutex1 != (DBusMutex *) 0xABCDEF); + _dbus_assert (dispatch_cond1 != (DBusCondVar *) 0xABCDEF2); + _dbus_assert (io_path_mutex1 != (DBusMutex *) 0xABCDEF); + _dbus_assert (io_path_cond1 != (DBusCondVar *) 0xABCDEF2); _run_iteration (conn); _dbus_connection_test_get_locks (conn, &mutex2, diff --git a/test/relay.c b/test/relay.c index f4129d0a..ecfe4c82 100644 --- a/test/relay.c +++ b/test/relay.c @@ -29,7 +29,8 @@ #include <glib.h> #include <dbus/dbus.h> -#include <dbus/dbus-glib-lowlevel.h> + +#include "test-utils.h" /* This is basically a miniature dbus-daemon. We relay messages from the client * on the left to the client on the right. @@ -43,6 +44,7 @@ */ typedef struct { + TestMainContext *ctx; DBusError e; DBusServer *server; @@ -113,13 +115,14 @@ new_conn_cb (DBusServer *server, f->right_server_conn = dbus_connection_ref (server_conn); } - dbus_connection_setup_with_g_main (server_conn, NULL); + test_connection_setup (f->ctx, server_conn); } static void setup (Fixture *f, gconstpointer data G_GNUC_UNUSED) { + f->ctx = test_main_context_get (); dbus_error_init (&f->e); g_queue_init (&f->messages); @@ -129,7 +132,7 @@ setup (Fixture *f, dbus_server_set_new_connection_function (f->server, new_conn_cb, f, NULL); - dbus_server_setup_with_g_main (f->server, NULL); + test_server_setup (f->ctx, f->server); } static void @@ -148,25 +151,25 @@ test_connect (Fixture *f, f->left_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->left_client_conn != NULL); - dbus_connection_setup_with_g_main (f->left_client_conn, NULL); + test_connection_setup (f->ctx, f->left_client_conn); while (f->left_server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } f->right_client_conn = dbus_connection_open_private (address, &f->e); assert_no_error (&f->e); g_assert (f->right_client_conn != NULL); - dbus_connection_setup_with_g_main (f->right_client_conn, NULL); + test_connection_setup (f->ctx, f->right_client_conn); dbus_free (address); while (f->right_server_conn == NULL) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } have_mem = dbus_connection_add_filter (f->right_client_conn, @@ -208,7 +211,7 @@ test_relay (Fixture *f, while (g_queue_get_length (&f->messages) < 2) { g_print ("."); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } g_assert_cmpuint (g_queue_get_length (&f->messages), ==, 2); @@ -237,7 +240,7 @@ test_limit (Fixture *f, /* This was an attempt to reproduce fd.o #34393. It didn't work. */ g_test_bug ("34393"); dbus_connection_set_max_received_size (f->left_server_conn, 1); - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); for (i = 0; i < MANY; i++) { @@ -253,7 +256,7 @@ test_limit (Fixture *f, { while (g_queue_is_empty (&f->messages)) { - g_main_context_iteration (NULL, TRUE); + test_main_context_iterate (f->ctx, TRUE); } while ((incoming = g_queue_pop_head (&f->messages)) != NULL) @@ -302,6 +305,8 @@ teardown (Fixture *f, dbus_server_unref (f->server); f->server = NULL; } + + test_main_context_unref (f->ctx); } int diff --git a/test/shell-test.c b/test/shell-test.c index b479a9c6..d1dc5b5b 100644 --- a/test/shell-test.c +++ b/test/shell-test.c @@ -1,7 +1,7 @@ #include <config.h> #include <stdio.h> #include <stdlib.h> -#define DBUS_COMPILATION + #include <dbus/dbus-internals.h> #include <dbus/dbus-list.h> #include <dbus/dbus-memory.h> diff --git a/test/spawn-test.c b/test/spawn-test.c index f1a55051..e6513fa6 100644 --- a/test/spawn-test.c +++ b/test/spawn-test.c @@ -1,10 +1,8 @@ #include <config.h> #include <dbus/dbus.h> -#define DBUS_COMPILATION /* cheat and use dbus-sysdeps */ #include <dbus/dbus-sysdeps.h> #include <dbus/dbus-spawn.h> -#undef DBUS_COMPILATION #include <stdio.h> static void diff --git a/test/test-utils.c b/test/test-utils.c index c3c3ed34..9a4f3584 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -1,6 +1,13 @@ #include <config.h> #include "test-utils.h" +#ifndef DBUS_TEST_USE_INTERNAL +# include <dbus/dbus.h> +# include <dbus/dbus-glib-lowlevel.h> +#endif + +#ifdef DBUS_TEST_USE_INTERNAL + typedef struct { DBusLoop *loop; @@ -97,10 +104,14 @@ cdata_new (DBusLoop *loop, return cd; } +#endif /* DBUS_TEST_USE_INTERNAL */ + dbus_bool_t -test_connection_setup (DBusLoop *loop, +test_connection_setup (TestMainContext *ctx, DBusConnection *connection) { +#ifdef DBUS_TEST_USE_INTERNAL + DBusLoop *loop = ctx; CData *cd; cd = NULL; @@ -148,10 +159,23 @@ test_connection_setup (DBusLoop *loop, dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL); return FALSE; +#else /* !DBUS_TEST_USE_INTERNAL */ + + dbus_connection_setup_with_g_main (connection, ctx); + return TRUE; + +#endif /* !DBUS_TEST_USE_INTERNAL */ +} + +static void +die (const char *message) +{ + fprintf (stderr, "*** %s", message); + exit (1); } void -test_connection_shutdown (DBusLoop *loop, +test_connection_shutdown (TestMainContext *ctx, DBusConnection *connection) { if (!dbus_connection_set_watch_functions (connection, @@ -159,18 +183,20 @@ test_connection_shutdown (DBusLoop *loop, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting watch functions to NULL failed"); + die ("setting watch functions to NULL failed"); if (!dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting timeout functions to NULL failed"); + die ("setting timeout functions to NULL failed"); dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); } +#ifdef DBUS_TEST_USE_INTERNAL + typedef struct { DBusLoop *loop; @@ -252,10 +278,14 @@ remove_server_timeout (DBusTimeout *timeout, _dbus_loop_remove_timeout (context->loop, timeout); } +#endif /* DBUS_TEST_USE_INTERNAL */ + dbus_bool_t -test_server_setup (DBusLoop *loop, +test_server_setup (TestMainContext *ctx, DBusServer *server) { +#ifdef DBUS_TEST_USE_INTERNAL + DBusLoop *loop = ctx; ServerData *sd; sd = serverdata_new (loop, server); @@ -293,10 +323,17 @@ test_server_setup (DBusLoop *loop, test_server_shutdown (loop, server); return FALSE; + +#else /* !DBUS_TEST_USE_INTERNAL */ + + dbus_server_setup_with_g_main (server, ctx); + return TRUE; + +#endif /* !DBUS_TEST_USE_INTERNAL */ } void -test_server_shutdown (DBusLoop *loop, +test_server_shutdown (TestMainContext *ctx, DBusServer *server) { dbus_server_disconnect (server); @@ -305,11 +342,51 @@ test_server_shutdown (DBusLoop *loop, NULL, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting watch functions to NULL failed"); + die ("setting watch functions to NULL failed"); if (!dbus_server_set_timeout_functions (server, NULL, NULL, NULL, NULL, NULL)) - _dbus_assert_not_reached ("setting timeout functions to NULL failed"); + die ("setting timeout functions to NULL failed"); +} + +TestMainContext * +test_main_context_get (void) +{ +#ifdef DBUS_TEST_USE_INTERNAL + return _dbus_loop_new (); +#else + /* I suspect dbus-glib relies the default main context in some places */ + return g_main_context_ref (g_main_context_default ()); +#endif +} + +TestMainContext * +test_main_context_ref (TestMainContext *ctx) +{ +#ifdef DBUS_TEST_USE_INTERNAL + return _dbus_loop_ref (ctx); +#else + return g_main_context_ref (ctx); +#endif +} + +void test_main_context_unref (TestMainContext *ctx) +{ +#ifdef DBUS_TEST_USE_INTERNAL + _dbus_loop_unref (ctx); +#else + g_main_context_unref (ctx); +#endif +} + +void test_main_context_iterate (TestMainContext *ctx, + dbus_bool_t may_block) +{ +#ifdef DBUS_TEST_USE_INTERNAL + _dbus_loop_iterate (ctx, may_block); +#else + g_main_context_iteration (ctx, may_block); +#endif } diff --git a/test/test-utils.h b/test/test-utils.h index 3e1e55e6..0d3f3690 100644 --- a/test/test-utils.h +++ b/test/test-utils.h @@ -1,25 +1,38 @@ #ifndef TEST_UTILS_H #define TEST_UTILS_H -#ifndef DBUS_COMPILATION -#define DBUS_COMPILATION /* Cheat and use private stuff */ -#endif -#include <dbus/dbus.h> + #include <stdio.h> #include <stdlib.h> -#include <dbus/dbus-mainloop.h> -#include <dbus/dbus-internals.h> -#undef DBUS_COMPILATION -dbus_bool_t test_connection_setup (DBusLoop *loop, +#include <dbus/dbus.h> + +#ifdef DBUS_TEST_USE_INTERNAL + +# include <dbus/dbus-mainloop.h> +# include <dbus/dbus-internals.h> + typedef DBusLoop TestMainContext; + +#else /* !DBUS_TEST_USE_INTERNAL */ + +# include <glib.h> + typedef GMainContext TestMainContext; + +#endif /* !DBUS_TEST_USE_INTERNAL */ + +TestMainContext *test_main_context_get (void); +TestMainContext *test_main_context_ref (TestMainContext *ctx); +void test_main_context_unref (TestMainContext *ctx); +void test_main_context_iterate (TestMainContext *ctx, + dbus_bool_t may_block); + +dbus_bool_t test_connection_setup (TestMainContext *ctx, DBusConnection *connection); -void test_connection_shutdown (DBusLoop *loop, +void test_connection_shutdown (TestMainContext *ctx, DBusConnection *connection); -void test_connection_dispatch_all_messages (DBusConnection *connection); -dbus_bool_t test_connection_dispatch_one_message (DBusConnection *connection); -dbus_bool_t test_server_setup (DBusLoop *loop, +dbus_bool_t test_server_setup (TestMainContext *ctx, DBusServer *server); -void test_server_shutdown (DBusLoop *loop, +void test_server_shutdown (TestMainContext *ctx, DBusServer *server); #endif diff --git a/tools/Makefile.am b/tools/Makefile.am index 464a8050..73d95fcf 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -47,6 +47,10 @@ dbus_launch_SOURCES= \ dbus_run_session_SOURCES = \ dbus-run-session.c + +dbus_run_session_LDADD = \ + $(top_builddir)/dbus/libdbus-1.la \ + $(NULL) endif dbus_cleanup_sockets_SOURCES= \ diff --git a/tools/Makefile.in b/tools/Makefile.in index a166a49c..2c220696 100644 --- a/tools/Makefile.in +++ b/tools/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. @@ -132,7 +132,8 @@ am__dbus_run_session_SOURCES_DIST = dbus-run-session.c @DBUS_WIN_FALSE@am_dbus_run_session_OBJECTS = \ @DBUS_WIN_FALSE@ dbus-run-session.$(OBJEXT) dbus_run_session_OBJECTS = $(am_dbus_run_session_OBJECTS) -dbus_run_session_LDADD = $(LDADD) +@DBUS_WIN_FALSE@dbus_run_session_DEPENDENCIES = \ +@DBUS_WIN_FALSE@ $(top_builddir)/dbus/libdbus-1.la am_dbus_send_OBJECTS = dbus-print-message.$(OBJEXT) \ dbus-send.$(OBJEXT) dbus_send_OBJECTS = $(am_dbus_send_OBJECTS) @@ -234,7 +235,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@ @@ -337,7 +337,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@ @@ -447,6 +446,10 @@ dbus_monitor_SOURCES = \ @DBUS_WIN_FALSE@dbus_run_session_SOURCES = \ @DBUS_WIN_FALSE@ dbus-run-session.c +@DBUS_WIN_FALSE@dbus_run_session_LDADD = \ +@DBUS_WIN_FALSE@ $(top_builddir)/dbus/libdbus-1.la \ +@DBUS_WIN_FALSE@ $(NULL) + dbus_cleanup_sockets_SOURCES = \ dbus-cleanup-sockets.c @@ -603,14 +606,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/tools/dbus-launch-win.c b/tools/dbus-launch-win.c index 215fac3f..d899010a 100644 --- a/tools/dbus-launch-win.c +++ b/tools/dbus-launch-win.c @@ -159,8 +159,8 @@ main (int argc, char **argv) if (result == 0) { if (verbose) - fprintf (stderr, "Could not start " DBUS_DAEMON_NAME ". error=%d\n", - GetLastError ()); + fprintf (stderr, "Could not start " DBUS_DAEMON_NAME ". error=%u\n", + (unsigned)GetLastError ()); return 4; } diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index b2ffe41d..7ecee63e 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -105,6 +105,7 @@ save_machine_uuid (const char *uuid_arg) machine_uuid = xstrdup (uuid_arg); } +#ifdef DBUS_BUILD_X11 #define UUID_MAXLEN 40 /* Read the machine uuid from file if needed. Returns TRUE if machine_uuid is * set after this function */ @@ -131,7 +132,7 @@ read_machine_uuid_if_needed (void) goto out; /* rstrip the read uuid */ - while (len > 31 && isspace(uuid[len - 1])) + while (len > 31 && isspace((int) uuid[len - 1])) len--; if (len != 32) @@ -146,12 +147,13 @@ out: fclose(f); return ret; } - +#endif /* DBUS_BUILD_X11 */ void verbose (const char *format, ...) { +#ifdef DBUS_ENABLE_VERBOSE_MODE va_list args; static int verbose = TRUE; static int verbose_initted = FALSE; @@ -176,12 +178,16 @@ verbose (const char *format, va_start (args, format); vfprintf (stderr, format, args); va_end (args); +#endif /* DBUS_ENABLE_VERBOSE_MODE */ } static void usage (int ecode) { - fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax] [--csh-syntax] [--auto-syntax] [--exit-with-session]\n"); + fprintf (stderr, "dbus-launch [--version] [--help] [--sh-syntax]" + " [--csh-syntax] [--auto-syntax] [--binary-syntax] [--close-stderr]" + " [--exit-with-session] [--autolaunch=MACHINEID]" + " [--config-file=FILENAME] [PROGRAM] [ARGS...]\n"); exit (ecode); } @@ -216,6 +222,26 @@ xstrdup (const char *str) return copy; } +static char * +concat2 (const char *a, + const char *b) +{ + size_t la, lb; + char *ret; + + la = strlen (a); + lb = strlen (b); + + ret = malloc (la + lb + 1); + + if (ret == NULL) + return NULL; + + memcpy (ret, a, la); + memcpy (ret + la, b, lb + 1); + return ret; +} + typedef enum { READ_STATUS_OK, /**< Read succeeded */ @@ -445,9 +471,7 @@ signal_handler (int sig) { switch (sig) { -#ifdef SIGHUP case SIGHUP: -#endif case SIGINT: case SIGTERM: got_sighup = TRUE; @@ -755,31 +779,35 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, if (envvar == NULL || args == NULL) goto oom; - args[0] = xstrdup (runprog); + args[0] = xstrdup (runprog); if (!args[0]) goto oom; - for (i = 1; i <= (argc-remaining_args); i++) - { - size_t len = strlen (argv[remaining_args+i-1])+1; - args[i] = malloc (len); - if (!args[i]) - goto oom; - strncpy (args[i], argv[remaining_args+i-1], len); - } - args[i] = NULL; + for (i = 1; i <= (argc-remaining_args); i++) + { + size_t len = strlen (argv[remaining_args+i-1])+1; + args[i] = malloc (len); + if (!args[i]) + { + while (i > 1) + free (args[--i]); + goto oom; + } + strncpy (args[i], argv[remaining_args+i-1], len); + } + args[i] = NULL; - strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); - strcat (envvar, bus_address); - putenv (envvar); + strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); + strcat (envvar, bus_address); + putenv (envvar); - execvp (runprog, args); - fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno)); - exit (1); + execvp (runprog, args); + fprintf (stderr, "Couldn't exec %s: %s\n", runprog, strerror (errno)); + exit (1); } else { print_variables (bus_address, bus_pid, bus_wid, c_shell_syntax, - bourne_shell_syntax, binary_syntax); + bourne_shell_syntax, binary_syntax); } verbose ("dbus-launch exiting\n"); @@ -1100,24 +1128,41 @@ main (int argc, char **argv) verbose ("Calling exec()\n"); -#ifdef DBUS_BUILD_TESTS - /* exec from testdir */ - if (getenv("DBUS_USE_TEST_BINARY") != NULL) - { - execl (TEST_BUS_BINARY, - TEST_BUS_BINARY, - "--fork", - "--print-pid", write_pid_fd_as_string, - "--print-address", write_address_fd_as_string, - config_file ? "--config-file" : "--session", - config_file, /* has to be last in this varargs list */ - NULL); - - fprintf (stderr, - "Failed to execute test message bus daemon %s: %s. Will try again with the system path.\n", - TEST_BUS_BINARY, strerror (errno)); - } - #endif /* DBUS_BUILD_TESTS */ +#ifdef DBUS_ENABLE_EMBEDDED_TESTS + { + const char *test_daemon; + /* exec from testdir */ + if (getenv ("DBUS_USE_TEST_BINARY") != NULL && + (test_daemon = getenv ("DBUS_TEST_DAEMON")) != NULL) + { + if (config_file == NULL && getenv ("DBUS_TEST_DATA") != NULL) + { + config_file = concat2 (getenv ("DBUS_TEST_DATA"), + "/valid-config-files/session.conf"); + + if (config_file == NULL) + { + fprintf (stderr, "Out of memory\n"); + exit (1); + } + } + + execl (test_daemon, + test_daemon, + "--fork", + "--print-pid", write_pid_fd_as_string, + "--print-address", write_address_fd_as_string, + config_file ? "--config-file" : "--session", + config_file, /* has to be last in this varargs list */ + NULL); + + fprintf (stderr, + "Failed to execute test message bus daemon %s: %s.\n", + test_daemon, strerror (errno)); + exit (1); + } + } + #endif /* DBUS_ENABLE_EMBEDDED_TESTS */ execl (DBUS_DAEMONDIR"/dbus-daemon", DBUS_DAEMONDIR"/dbus-daemon", diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index a4b54782..ff8390d7 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -106,6 +106,9 @@ monitor_filter_func (DBusConnection *connection, #ifdef __APPLE__ #define PROFILE_TIMED_FORMAT "%s\t%lu\t%d" +#elif defined(__NetBSD__) +#include <inttypes.h> +#define PROFILE_TIMED_FORMAT "%s\t%" PRId64 "\t%d" #else #define PROFILE_TIMED_FORMAT "%s\t%lu\t%lu" #endif @@ -310,7 +313,7 @@ main (int argc, char *argv[]) filters = (char **) realloc (filters, numFilters * sizeof (char *)); if (filters == NULL) oom ("adding a new filter slot"); - filters[j] = (char *) malloc (filter_len * sizeof (char *)); + filters[j] = (char *) malloc (filter_len); if (filters[j] == NULL) oom ("adding a new filter"); snprintf (filters[j], filter_len, "%s,%s", EAVESDROPPING_RULE, arg); @@ -364,41 +367,45 @@ main (int argc, char *argv[]) if (numFilters) { + size_t offset = 0; for (i = 0; i < j; i++) { - dbus_bus_add_match (connection, filters[i], &error); - if (dbus_error_is_set (&error)) + dbus_bus_add_match (connection, filters[i] + offset, &error); + if (dbus_error_is_set (&error) && i == 0 && offset == 0) + { + /* We might be talking to a pre-1.5.6 dbus-daemon + * which wouldn't understand eavesdrop=true. + * If this works, carry on with offset > 0 + * on the remaining iterations. */ + offset = strlen (EAVESDROPPING_RULE) + 1; + dbus_error_free (&error); + dbus_bus_add_match (connection, filters[i] + offset, &error); + } + + if (dbus_error_is_set (&error)) { fprintf (stderr, "Failed to setup match \"%s\": %s\n", filters[i], error.message); dbus_error_free (&error); exit (1); } - free(filters[i]); + free(filters[i]); } } else { dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='signal'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='method_call'", - &error); + EAVESDROPPING_RULE, + &error); if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='method_return'", - &error); - if (dbus_error_is_set (&error)) - goto lose; - dbus_bus_add_match (connection, - EAVESDROPPING_RULE ",type='error'", - &error); - if (dbus_error_is_set (&error)) - goto lose; + { + dbus_error_free (&error); + dbus_bus_add_match (connection, + "", + &error); + if (dbus_error_is_set (&error)) + goto lose; + } } if (!dbus_connection_add_filter (connection, filter_func, NULL, NULL)) { diff --git a/tools/dbus-run-session.c b/tools/dbus-run-session.c index 4f0b32b5..105ab3b4 100644 --- a/tools/dbus-run-session.c +++ b/tools/dbus-run-session.c @@ -34,6 +34,9 @@ #include <sys/types.h> #include <sys/wait.h> +#include <signal.h> + +#include "dbus/dbus.h" #define MAX_ADDR_LEN 512 #define PIPE_READ_END 0 @@ -99,22 +102,6 @@ oom (void) exit (1); } -static void * -xmalloc (size_t bytes) -{ - void *ret; - - if (bytes == 0) - bytes = 1; - - ret = malloc (bytes); - - if (ret == NULL) - oom (); - - return ret; -} - typedef enum { READ_STATUS_OK, /**< Read succeeded */ @@ -227,7 +214,6 @@ main (int argc, char **argv) int requires_arg = 0; pid_t bus_pid; pid_t app_pid; - char *envvar; while (i < argc) { @@ -396,11 +382,12 @@ main (int argc, char **argv) close (bus_address_pipe[PIPE_READ_END]); - envvar = xmalloc (strlen ("DBUS_SESSION_BUS_ADDRESS=") + - strlen (bus_address) + 1); - strcpy (envvar, "DBUS_SESSION_BUS_ADDRESS="); - strcat (envvar, bus_address); - putenv (envvar); + if (!dbus_setenv ("DBUS_SESSION_BUS_ADDRESS", bus_address) || + !dbus_setenv ("DBUS_SESSION_BUS_PID", NULL) || + !dbus_setenv ("DBUS_SESSION_BUS_WINDOWID", NULL) || + !dbus_setenv ("DBUS_STARTER_ADDRESS", NULL) || + !dbus_setenv ("DBUS_STARTER_BUS_TYPE", NULL)) + oom (); app_pid = fork (); diff --git a/tools/dbus-send.c b/tools/dbus-send.c index ca5dd5c6..d3ff2589 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -51,7 +51,7 @@ static const char *appname; static void usage (int ecode) { - fprintf (stderr, "Usage: %s [--help] [--system | --session | --address=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]\n", appname); + fprintf (stderr, "Usage: %s [--help] [--system | --session | --bus=ADDRESS | --peer=ADDRESS] [--dest=NAME] [--type=TYPE] [--print-reply[=literal]] [--reply-timeout=MSEC] <destination object path> <message name> [contents ...]\n", appname); exit (ecode); } @@ -241,6 +241,7 @@ main (int argc, char *argv[]) int message_type = DBUS_MESSAGE_TYPE_SIGNAL; const char *type_str = NULL; const char *address = NULL; + int is_bus = FALSE; int session_or_system = FALSE; appname = argv[0]; @@ -266,14 +267,28 @@ main (int argc, char *argv[]) type = DBUS_BUS_SESSION; session_or_system = TRUE; } - else if (strstr (arg, "--address=") == arg) + else if ((strstr (arg, "--bus=") == arg) || (strstr (arg, "--peer=") == arg) || (strstr (arg, "--address=") == arg)) { - if (*(strchr (arg, '=') + 1) == '\0') + if (arg[2] == 'b') /* bus */ { - fprintf (stderr, "\"--address=\" requires an ADDRESS\n"); - usage (1); + is_bus = TRUE; + } + else if (arg[2] == 'p') /* peer */ + { + is_bus = FALSE; + } + else /* address; keeping backwards compatibility */ + { + is_bus = FALSE; } + address = strchr (arg, '=') + 1; + + if (address[0] == '\0') + { + fprintf (stderr, "\"--peer=\" and \"--bus=\" require an ADDRESS\n"); + usage (1); + } } else if (strncmp (arg, "--print-reply", 13) == 0) { @@ -330,7 +345,7 @@ main (int argc, char *argv[]) if (session_or_system && (address != NULL)) { - fprintf (stderr, "\"--address\" may not be used with \"--system\" or \"--session\"\n"); + fprintf (stderr, "\"--peer\" and \"--bus\" may not be used with \"--system\" or \"--session\"\n"); usage (1); } @@ -348,7 +363,7 @@ main (int argc, char *argv[]) dbus_error_init (&error); - if (!dbus_validate_bus_name (dest, &error)) + if (dest && !dbus_validate_bus_name (dest, &error)) { fprintf (stderr, "invalid value (%s) of \"--dest\"\n", dest); usage (1); @@ -372,6 +387,16 @@ main (int argc, char *argv[]) dbus_error_free (&error); exit (1); } + else if ((address != NULL) && is_bus) + { + if (!dbus_bus_register (connection, &error)) + { + fprintf (stderr, "Failed to register on connection to \"%s\" message bus: %s\n", + address, error.message); + dbus_error_free (&error); + exit (1); + } + } if (message_type == DBUS_MESSAGE_TYPE_METHOD_CALL) { diff --git a/tools/run-with-tmp-session-bus.sh b/tools/run-with-tmp-session-bus.sh index 3245652e..94ae8fc8 100755 --- a/tools/run-with-tmp-session-bus.sh +++ b/tools/run-with-tmp-session-bus.sh @@ -4,9 +4,12 @@ SCRIPTNAME="$0" WRAPPED_SCRIPT="$1" shift +CONFIG_FILE=./tmp-session-bus.$$.conf + die () { echo "$SCRIPTNAME: $*" >&2 + rm -f "$CONFIG_FILE" exit 1 } @@ -14,7 +17,6 @@ if test -z "$DBUS_TOP_BUILDDIR" ; then die "Must set DBUS_TOP_BUILDDIR" fi -CONFIG_FILE=./run-with-tmp-session-bus.conf SERVICE_DIR="$DBUS_TOP_BUILDDIR/test/data/valid-service-files" ESCAPED_SERVICE_DIR=`echo $SERVICE_DIR | sed -e 's/\//\\\\\\//g'` echo "escaped service dir is: $ESCAPED_SERVICE_DIR" >&2 @@ -48,8 +50,13 @@ unset DBUS_SESSION_BUS_PID DBUS_USE_TEST_BINARY=1 export DBUS_USE_TEST_BINARY -exec $DBUS_TOP_BUILDDIR/tools/dbus-run-session \ +$DBUS_TOP_BUILDDIR/tools/dbus-run-session \ --config-file="$CONFIG_FILE" \ --dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \ -- \ "$WRAPPED_SCRIPT" "$@" +error=$? + +# clean up +rm -f "$CONFIG_FILE" +exit $error |