mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2025-12-25 10:30:10 +01:00
Use separate bus configuration files for executing test cases with a temporary session bus
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
This commit is contained in:
parent
93b7bb392b
commit
6d4639a333
6 changed files with 90 additions and 42 deletions
|
|
@ -458,6 +458,8 @@ in_data = \
|
||||||
data/valid-config-files/multi-user.conf.in \
|
data/valid-config-files/multi-user.conf.in \
|
||||||
data/valid-config-files/pending-fd-timeout.conf.in \
|
data/valid-config-files/pending-fd-timeout.conf.in \
|
||||||
data/valid-config-files/systemd-activation.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.TestSuiteNoExec.service.in \
|
||||||
data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \
|
data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoService.service.in \
|
||||||
data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \
|
data/invalid-service-files-system/org.freedesktop.DBus.TestSuiteNoUser.service.in \
|
||||||
|
|
@ -476,7 +478,6 @@ in_data = \
|
||||||
EXTRA_DIST += $(in_data)
|
EXTRA_DIST += $(in_data)
|
||||||
|
|
||||||
static_data = \
|
static_data = \
|
||||||
name-test/tmp-session-like-system.conf \
|
|
||||||
data/auth/anonymous-client-successful.auth-script \
|
data/auth/anonymous-client-successful.auth-script \
|
||||||
data/auth/anonymous-server-successful.auth-script \
|
data/auth/anonymous-server-successful.auth-script \
|
||||||
data/auth/cancel.auth-script \
|
data/auth/cancel.auth-script \
|
||||||
|
|
@ -579,6 +580,8 @@ uninstalled-config-local:
|
||||||
for F in $(in_data); do \
|
for F in $(in_data); do \
|
||||||
$(MKDIR_P) "$${F%/*}"; \
|
$(MKDIR_P) "$${F%/*}"; \
|
||||||
sed \
|
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_DATA[@],@abs_builddir@/data,' \
|
||||||
-e 's,[@]DBUS_TEST_EXEC[@],@abs_builddir@,' \
|
-e 's,[@]DBUS_TEST_EXEC[@],@abs_builddir@,' \
|
||||||
-e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
|
-e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
|
||||||
|
|
@ -594,6 +597,8 @@ if DBUS_ENABLE_INSTALLED_TESTS
|
||||||
for F in $(in_data); do \
|
for F in $(in_data); do \
|
||||||
$(MKDIR_P) "installable/$${F%/*}"; \
|
$(MKDIR_P) "installable/$${F%/*}"; \
|
||||||
sed \
|
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_DATA[@],$(testexecdir)/data,' \
|
||||||
-e 's,[@]DBUS_TEST_EXEC[@],$(testexecdir),' \
|
-e 's,[@]DBUS_TEST_EXEC[@],$(testexecdir),' \
|
||||||
-e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
|
-e 's,[@]DBUS_USER[@],$(DBUS_USER),' \
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<!-- This configuration file controls the per-user-login-session message bus.
|
<!-- 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. -->
|
file directly. -->
|
||||||
|
|
||||||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
<listen>unix:tmpdir=/tmp</listen>
|
<listen>unix:tmpdir=/tmp</listen>
|
||||||
|
|
||||||
<standard_session_servicedirs />
|
<servicedir>@DBUS_TEST_DATA@/valid-service-files</servicedir>
|
||||||
|
|
||||||
<!-- intended to match system bus -->
|
<!-- intended to match system bus -->
|
||||||
<policy context="default">
|
<policy context="default">
|
||||||
|
|
@ -63,21 +63,21 @@
|
||||||
send_member="EmitFoo"/>
|
send_member="EmitFoo"/>
|
||||||
</policy>
|
</policy>
|
||||||
|
|
||||||
<!-- For the session bus, override the default relatively-low limits
|
<!-- For the session bus, override the default relatively-low limits
|
||||||
with essentially infinite limits, since the bus is just running
|
with essentially infinite limits, since the bus is just running
|
||||||
as the user anyway, using up bus resources is not something we need
|
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
|
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,
|
"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
|
having the bus enforce a limit is nicer than a huge memory leak. But the
|
||||||
intent is that these limits should never be hit. -->
|
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 -->
|
<!-- 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_bytes">1000000000</limit>
|
||||||
<limit name="max_outgoing_bytes">1000000000</limit>
|
<limit name="max_outgoing_bytes">1000000000</limit>
|
||||||
<limit name="max_message_size">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="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_incomplete_connections">10000</limit>
|
||||||
<limit name="max_connections_per_user">100000</limit>
|
<limit name="max_connections_per_user">100000</limit>
|
||||||
<limit name="max_pending_service_starts">10000</limit>
|
<limit name="max_pending_service_starts">10000</limit>
|
||||||
67
test/data/valid-config-files/tmp-session.conf.in
Normal file
67
test/data/valid-config-files/tmp-session.conf.in
Normal file
|
|
@ -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>
|
||||||
|
|
@ -19,7 +19,7 @@ SH_LOG_DRIVER = $(LOG_DRIVER)
|
||||||
|
|
||||||
LOG_COMPILER = \
|
LOG_COMPILER = \
|
||||||
@abs_top_builddir@/tools/dbus-run-session$(EXEEXT) \
|
@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) \
|
--dbus-daemon=@abs_top_builddir@/bus/dbus-daemon$(EXEEXT) \
|
||||||
-- \
|
-- \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
@ -46,15 +46,6 @@ AM_TESTS_ENVIRONMENT = \
|
||||||
unset DBUS_SESSION_BUS_PID; \
|
unset DBUS_SESSION_BUS_PID; \
|
||||||
$(NULL)
|
$(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 += \
|
TESTS += \
|
||||||
run-test.sh \
|
run-test.sh \
|
||||||
run-test-systemserver.sh \
|
run-test-systemserver.sh \
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ MODE=$1
|
||||||
DBUS_TEST_NAME_RUN_TEST_SCRIPT=1
|
DBUS_TEST_NAME_RUN_TEST_SCRIPT=1
|
||||||
export DBUS_TEST_NAME_RUN_TEST_SCRIPT
|
export DBUS_TEST_NAME_RUN_TEST_SCRIPT
|
||||||
|
|
||||||
SOURCE_CONFIG_FILE=$DBUS_TOP_SRCDIR/test/name-test/tmp-session-like-system.conf
|
DBUS_TEST_CONFIG_FILE=$DBUS_TOP_BUILDDIR/test/data/valid-config-files-system/tmp-session-like-system.conf
|
||||||
export SOURCE_CONFIG_FILE
|
export DBUS_TEST_CONFIG_FILE
|
||||||
# Rerun ourselves with tmp session bus if we're not already
|
# Rerun ourselves with tmp session bus if we're not already
|
||||||
if test -z "$DBUS_TEST_NAME_IN_SYS_RUN_TEST"; then
|
if test -z "$DBUS_TEST_NAME_IN_SYS_RUN_TEST"; then
|
||||||
DBUS_TEST_NAME_IN_SYS_RUN_TEST=1
|
DBUS_TEST_NAME_IN_SYS_RUN_TEST=1
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,13 @@ SCRIPTNAME="$0"
|
||||||
WRAPPED_SCRIPT="$1"
|
WRAPPED_SCRIPT="$1"
|
||||||
shift
|
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 ()
|
die ()
|
||||||
{
|
{
|
||||||
echo "$SCRIPTNAME: $*" >&2
|
echo "$SCRIPTNAME: $*" >&2
|
||||||
rm -f "$CONFIG_FILE"
|
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -17,21 +18,6 @@ if test -z "$DBUS_TOP_BUILDDIR" ; then
|
||||||
die "Must set DBUS_TOP_BUILDDIR"
|
die "Must set DBUS_TOP_BUILDDIR"
|
||||||
fi
|
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
|
if ! test -e "$DBUS_TOP_BUILDDIR"/bus/dbus-daemon ; then
|
||||||
die "$DBUS_TOP_BUILDDIR/bus/dbus-daemon does not exist"
|
die "$DBUS_TOP_BUILDDIR/bus/dbus-daemon does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
@ -46,12 +32,11 @@ unset DBUS_SESSION_BUS_ADDRESS
|
||||||
unset DBUS_SESSION_BUS_PID
|
unset DBUS_SESSION_BUS_PID
|
||||||
|
|
||||||
$DBUS_TOP_BUILDDIR/tools/dbus-run-session \
|
$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" \
|
--dbus-daemon="$DBUS_TOP_BUILDDIR/bus/dbus-daemon" \
|
||||||
-- \
|
-- \
|
||||||
"$WRAPPED_SCRIPT" "$@"
|
"$WRAPPED_SCRIPT" "$@"
|
||||||
error=$?
|
error=$?
|
||||||
|
|
||||||
# clean up
|
# clean up
|
||||||
rm -f "$CONFIG_FILE"
|
|
||||||
exit $error
|
exit $error
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue