]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Use separate bus configuration files for executing test cases with a temporary sessio...
authorRalf Habacker <ralf.habacker@freenet.de>
Mon, 31 Oct 2011 14:53:25 +0000 (15:53 +0100)
committerRalf Habacker <ralf.habacker@freenet.de>
Thu, 18 Oct 2018 18:06:43 +0000 (20:06 +0200)
Instead of the previous adaptation of the existing template
for the session bus, a separate template is now used, which
can be more easily adapted to the requirements of the test
applications.

Bug: https://gitlab.freedesktop.org/dbus/dbus/issues/57

test/Makefile.am
test/data/valid-config-files-system/tmp-session-like-system.conf.in [moved from test/name-test/tmp-session-like-system.conf with 93% similarity]
test/data/valid-config-files/tmp-session.conf.in [new file with mode: 0644]
test/name-test/Makefile.am
test/name-test/run-test-systemserver.sh
tools/run-with-tmp-session-bus.sh

index f373585c5e843d94fe8386dc60553c92237f648d..7e2e202f6e727e2ee0f5ac9e6fd06280de3a09b7 100644 (file)
@@ -458,6 +458,8 @@ in_data = \
        data/valid-config-files/multi-user.conf.in \
        data/valid-config-files/pending-fd-timeout.conf.in \
        data/valid-config-files/systemd-activation.conf.in \
+       data/valid-config-files/tmp-session.conf.in \
+       data/valid-config-files-system/tmp-session-like-system.conf.in \
        data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoExec.service.in \
        data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \
        data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \
@@ -476,7 +478,6 @@ in_data = \
 EXTRA_DIST += $(in_data)
 
 static_data = \
-       name-test/tmp-session-like-system.conf \
        data/auth/anonymous-client-successful.auth-script \
        data/auth/anonymous-server-successful.auth-script \
        data/auth/cancel.auth-script \
@@ -579,6 +580,8 @@ uninstalled-config-local:
        for F in $(in_data); do \
                $(MKDIR_P) "$${F%/*}"; \
                sed \
+                       -e 's,[@]DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL[@],$(DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL),' \
+                       -e 's,[@]DBUS_SESSION_BUS_LISTEN_ADDRESS[@],$(DBUS_SESSION_BUS_LISTEN_ADDRESS),' \
                        -e 's,[@]DBUS_TEST_DATA[@],@abs_builddir@/data,' \
                        -e 's,[@]DBUS_TEST_EXEC[@],@abs_builddir@,' \
                        -e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
@@ -594,6 +597,8 @@ if DBUS_ENABLE_INSTALLED_TESTS
        for F in $(in_data); do \
                $(MKDIR_P) "installable/$${F%/*}"; \
                sed \
+                       -e 's,[@]DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL[@],$(DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL),' \
+                       -e 's,[@]DBUS_SESSION_BUS_LISTEN_ADDRESS[@],$(DBUS_SESSION_BUS_LISTEN_ADDRESS),' \
                        -e 's,[@]DBUS_TEST_DATA[@],$(testexecdir)/data,' \
                        -e 's,[@]DBUS_TEST_EXEC[@],$(testexecdir),' \
                        -e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
similarity index 93%
rename from test/name-test/tmp-session-like-system.conf
rename to test/data/valid-config-files-system/tmp-session-like-system.conf.in
index b3d9caeafd80dc144f743680c901136f3f9ac6c2..9665a22a08ecd8d84ed8134fa1cba88bf359eb86 100644 (file)
@@ -1,5 +1,5 @@
 <!-- This configuration file controls the per-user-login-session message bus.
-     Add a session-local.conf and edit that rather than changing this 
+     Add a session-local.conf and edit that rather than changing this
      file directly. -->
 
 <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
@@ -14,7 +14,7 @@
 
   <listen>unix:tmpdir=/tmp</listen>
 
-  <standard_session_servicedirs />
+  <servicedir>@DBUS_TEST_DATA@/valid-service-files</servicedir>
 
   <!-- intended to match system bus -->
   <policy context="default">
             send_member="EmitFoo"/>
   </policy>
 
-  <!-- For the session bus, override the default relatively-low limits 
-       with essentially infinite limits, since the bus is just running 
-       as the user anyway, using up bus resources is not something we need 
-       to worry about. In some cases, we do set the limits lower than 
-       "all available memory" if exceeding the limit is almost certainly a bug, 
-       having the bus enforce a limit is nicer than a huge memory leak. But the 
+  <!-- For the session bus, override the default relatively-low limits
+       with essentially infinite limits, since the bus is just running
+       as the user anyway, using up bus resources is not something we need
+       to worry about. In some cases, we do set the limits lower than
+       "all available memory" if exceeding the limit is almost certainly a bug,
+       having the bus enforce a limit is nicer than a huge memory leak. But the
        intent is that these limits should never be hit. -->
 
   <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max -->
   <limit name="max_incoming_bytes">1000000000</limit>
   <limit name="max_outgoing_bytes">1000000000</limit>
   <limit name="max_message_size">1000000000</limit>
-  <limit name="service_start_timeout">120000</limit>  
+  <limit name="service_start_timeout">120000</limit>
   <limit name="auth_timeout">240000</limit>
-  <limit name="max_completed_connections">100000</limit>  
+  <limit name="max_completed_connections">100000</limit>
   <limit name="max_incomplete_connections">10000</limit>
   <limit name="max_connections_per_user">100000</limit>
   <limit name="max_pending_service_starts">10000</limit>
diff --git a/test/data/valid-config-files/tmp-session.conf.in b/test/data/valid-config-files/tmp-session.conf.in
new file mode 100644 (file)
index 0000000..502619d
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+  <!-- Our well-known bus type, don't change this -->
+  <type>session</type>
+
+  <!-- If we fork, keep the user's original umask to avoid affecting
+       the behavior of child processes. -->
+  <keep_umask/>
+
+  <listen>@DBUS_SESSION_BUS_LISTEN_ADDRESS@</listen>
+
+  <!-- On Unix systems, the most secure authentication mechanism is
+  EXTERNAL, which uses credential-passing over Unix sockets.
+
+  This authentication mechanism is not available on Windows,
+  is not suitable for use with the tcp: or nonce-tcp: transports,
+  and will not work on obscure flavours of Unix that do not have
+  a supported credentials-passing mechanism. On those platforms/transports,
+  comment out the <auth> element to allow fallback to DBUS_COOKIE_SHA1. -->
+  @DBUS_SESSION_CONF_MAYBE_AUTH_EXTERNAL@
+
+  <servicedir>@DBUS_TEST_DATA@/valid-service-files</servicedir>
+
+  <policy context="default">
+    <!-- Allow everything to be sent -->
+    <allow send_destination="*" eavesdrop="true"/>
+    <!-- Allow everything to be received -->
+    <allow eavesdrop="true"/>
+    <!-- Allow anyone to own anything -->
+    <allow own="*"/>
+  </policy>
+
+  <!-- For the session bus, override the default relatively-low limits
+       with essentially infinite limits, since the bus is just running
+       as the user anyway, using up bus resources is not something we need
+       to worry about. In some cases, we do set the limits lower than
+       "all available memory" if exceeding the limit is almost certainly a bug,
+       having the bus enforce a limit is nicer than a huge memory leak. But the
+       intent is that these limits should never be hit. -->
+
+  <!-- the memory limits are 1G instead of say 4G because they can't exceed 32-bit signed int max -->
+  <limit name="max_incoming_bytes">1000000000</limit>
+  <limit name="max_incoming_unix_fds">250000000</limit>
+  <limit name="max_outgoing_bytes">1000000000</limit>
+  <limit name="max_outgoing_unix_fds">250000000</limit>
+  <limit name="max_message_size">1000000000</limit>
+  <!-- We do not override max_message_unix_fds here since the in-kernel
+       limit is also relatively low -->
+  <limit name="service_start_timeout">120000</limit>
+  <limit name="auth_timeout">240000</limit>
+  <limit name="pending_fd_timeout">150000</limit>
+  <limit name="max_completed_connections">100000</limit>
+  <limit name="max_incomplete_connections">10000</limit>
+  <limit name="max_connections_per_user">100000</limit>
+  <limit name="max_pending_service_starts">10000</limit>
+  <limit name="max_names_per_connection">50000</limit>
+  <limit name="max_match_rules_per_connection">50000</limit>
+  <limit name="max_replies_per_connection">50000</limit>
+  <limit name="max_containers">10000</limit>
+  <limit name="max_containers_per_user">10000</limit>
+  <limit name="max_container_metadata_bytes">1000000000</limit>
+  <!-- This is relatively low so that app-containers (which we do not fully
+       trust) do not cause DoS. -->
+  <limit name="max_connections_per_container">16</limit>
+
+</busconfig>
index dd7f82a8828512a69e88c4080be67c837a0d4d31..8269feff36fd87d69c2f0e6d56d734f808f686eb 100644 (file)
@@ -19,7 +19,7 @@ SH_LOG_DRIVER = $(LOG_DRIVER)
 
 LOG_COMPILER = \
        @abs_top_builddir@/tools/dbus-run-session$(EXEEXT) \
-       --config-file=@abs_builddir@/uninstalled-session.conf \
+        --config-file=@abs_top_builddir@/test/data/valid-config-files/tmp-session.conf \
        --dbus-daemon=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
        -- \
        $(NULL)
@@ -46,15 +46,6 @@ AM_TESTS_ENVIRONMENT = \
         unset DBUS_SESSION_BUS_PID; \
         $(NULL)
 
-uninstalled-session.conf: $(top_builddir)/bus/session.conf Makefile
-       $(SED) -e 's|<standard_session_servicedirs.*$$|<servicedir>@abs_top_builddir@/test/data/valid-service-files</servicedir>|g' \
-               -e 's|<include.*$$||g' \
-               < $< > $@
-
-check_DATA = \
-       uninstalled-session.conf \
-       $(NULL)
-
 TESTS += \
        run-test.sh \
        run-test-systemserver.sh \
index 9926cad6c5100943a2a56191bfed19653bebaa3a..b4a04984488a6ead7cff69165cdeffc75ddfbed2 100755 (executable)
@@ -7,8 +7,8 @@ MODE=$1
 DBUS_TEST_NAME_RUN_TEST_SCRIPT=1
 export DBUS_TEST_NAME_RUN_TEST_SCRIPT
 
-SOURCE_CONFIG_FILE=$DBUS_TOP_SRCDIR/test/name-test/tmp-session-like-system.conf
-export SOURCE_CONFIG_FILE
+DBUS_TEST_CONFIG_FILE=$DBUS_TOP_BUILDDIR/test/data/valid-config-files-system/tmp-session-like-system.conf
+export DBUS_TEST_CONFIG_FILE
 # Rerun ourselves with tmp session bus if we're not already
 if test -z "$DBUS_TEST_NAME_IN_SYS_RUN_TEST"; then
   DBUS_TEST_NAME_IN_SYS_RUN_TEST=1
index 688f9e483050945f32c1ab6245ac0b14277f5100..28379bfaab0acce7db0376470bffaf0af30dba68 100755 (executable)
@@ -4,12 +4,13 @@ SCRIPTNAME="$0"
 WRAPPED_SCRIPT="$1"
 shift
 
-CONFIG_FILE=./tmp-session-bus.$$.conf
+if test -z "$DBUS_TEST_CONFIG_FILE"; then
+    DBUS_TEST_CONFIG_FILE="$DBUS_TOP_BUILDDIR/test/data/valid-config-files/tmp-session.conf"
+fi
 
 die ()
 {
     echo "$SCRIPTNAME: $*" >&2
-    rm -f "$CONFIG_FILE"
     exit 1
 }
 
@@ -17,21 +18,6 @@ if test -z "$DBUS_TOP_BUILDDIR" ; then
     die "Must set DBUS_TOP_BUILDDIR"
 fi
 
-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
-
-if test -z "$SOURCE_CONFIG_FILE"; then
-    SOURCE_CONFIG_FILE="$DBUS_TOP_BUILDDIR/bus/session.conf";
-fi
-## create a configuration file based on the standard session.conf
-cat $SOURCE_CONFIG_FILE |  \
-    sed -e 's/<standard_session_servicedirs.*$/<servicedir>'$ESCAPED_SERVICE_DIR'<\/servicedir>/g' |  \
-    sed -e 's/<include.*$//g'                \
-  > $CONFIG_FILE
-
-echo "Created configuration file $CONFIG_FILE" >&2
-
 if ! test -e "$DBUS_TOP_BUILDDIR"/bus/dbus-daemon ; then
     die "$DBUS_TOP_BUILDDIR/bus/dbus-daemon does not exist"
 fi
@@ -46,12 +32,11 @@ unset DBUS_SESSION_BUS_ADDRESS
 unset DBUS_SESSION_BUS_PID
 
 $DBUS_TOP_BUILDDIR/tools/dbus-run-session \
-    --config-file="$CONFIG_FILE" \
+    --config-file="$DBUS_TEST_CONFIG_FILE" \
     --dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \
     -- \
     "$WRAPPED_SCRIPT" "$@"
 error=$?
 
 # clean up
-rm -f "$CONFIG_FILE"
 exit $error