core: only refuse Type=dbus service enqueuing if dbus has stop job
authorMike Yuan <me@yhndnzj.com>
Wed, 10 May 2023 05:54:15 +0000 (13:54 +0800)
committerMike Yuan <me@yhndnzj.com>
Fri, 12 May 2023 08:21:44 +0000 (16:21 +0800)
commitbee6e755bb8e53a7a436e221b015ce0232ed87c0
treef5dd35457e56d0c6641cdefe340171db6f9e22b6
parent153d5dfd871da3980b956ba65da20d7d022f2b03
core: only refuse Type=dbus service enqueuing if dbus has stop job

Follow-up for #27579

In #27579 we refused all StartUnit requests for Type=dbus units
if dbus is not running, which means if dbus is manually stopped,
user can't use systemctl to start Type=dbus units again, which
is incorrect.

The only culprit that leads to the cancellation of the whole
transaction mentioned in #26799 is job type conflict on dbus.
So let's relax the restriction and only refuse job enqueuing
if dbus has a stop job.

To summarize, the case we want to avoid is:

1. dbus has a stop job installed
2. StartUnit/ActivationRequest is received
3. Type=dbus service gets started, which has Requires=dbus.socket
4. dbus is pulled in again, resulting in job type conflict

What we can support is:

1. dbus is already stopped
2. StartUnit is received (possibly through systemctl, i.e. on private bus)
3. Type=dbus service gets started, which will wait for dbus to start
4. dbus is started again, thus the job for Type=dbus service

Replaces #27590
Fixes #27588
src/core/dbus-unit.c