Merge pull request #19921 from yuwata/service-verify-bus-type

core/service: fix assertion when Type=dbus but BusName= is not specified
This commit is contained in:
Luca Boccassi 2021-06-15 12:21:53 +01:00 committed by GitHub
commit e4948b0f0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View file

@ -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);

View file

@ -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 <<EOF
#!/usr/bin/env bash