From 0f97b7c338bb7440572c454558efb8fee395896a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 15 Jun 2021 03:04:06 +0900 Subject: [PATCH 1/2] core/service: fix assertion when Type=dbus but BusName= is not specified Fixes #19920. --- src/core/service.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/service.c b/src/core/service.c index 792ec99a00..af5a2decf1 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -668,7 +668,8 @@ static int service_setup_bus_name(Service *s) { assert(s); - if (s->type != SERVICE_DBUS) + /* If s->bus_name is not set, then the unit will be refused by service_verify() later. */ + if (s->type != SERVICE_DBUS || !s->bus_name) return 0; r = unit_add_dependency_by_name(UNIT(s), UNIT_REQUIRES, SPECIAL_DBUS_SOCKET, true, UNIT_DEPENDENCY_FILE); From 2429808b297e6a711a245b93b8bc7df516c9d5bd Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 15 Jun 2021 03:05:48 +0900 Subject: [PATCH 2/2] test: add a test case for #19920 --- test/units/testsuite-42.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/units/testsuite-42.sh b/test/units/testsuite-42.sh index e47fab46e6..4e6be7e06e 100755 --- a/test/units/testsuite-42.sh +++ b/test/units/testsuite-42.sh @@ -65,6 +65,10 @@ test -f /run/dbus1 systemd-run --unit=dbus2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus2' true test -f /run/dbus2 +# https://github.com/systemd/systemd/issues/19920 +systemd-run --unit=dbus3.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p ExecStopPost='/bin/touch /run/dbus3' true \ + && { echo 'unexpected success'; exit 1; } + cat >/tmp/notify1.sh <