]> git.ipfire.org Git - thirdparty/systemd.git/commit
run: fix generated unit name clash after soft-reboot
authorLuca Boccassi <bluca@debian.org>
Wed, 27 Mar 2024 21:14:15 +0000 (21:14 +0000)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 28 Mar 2024 02:19:46 +0000 (11:19 +0900)
commited358516937780b524a2cfa833427da3df1bc87f
tree0da580c12f77f32ae511c89201083eeda51c36bb
parent2a4fb037cb3f44d0b13ccf860661d0e14c852f0e
run: fix generated unit name clash after soft-reboot

When sd-run connects to D-Bus rather than the private socket, it will
generate the transient unit name using the bus ID assigned by the D-Bus
broker/daemon. The issue is that this ID is only unique per D-Bus run,
if the broker/daemon restarts it starts again from 1, and it's a simple
incremental counter for each client.
So if a transient unit run-u6.service starts and fails, and it is not
collected (default on failure), and the system soft-reboots, any new
transient unit might conflict as the counter will restart:

Failed to start transient service unit: Unit run-u6.service was already loaded or has a fragment file.

Get the soft-reboot counter, and if it's greater than zero, append it
to the autogenerated unit name to avoid clashes.
src/run/run.c
test/units/testsuite-82.sh