From 4daea6433eec715f4193b6019832227e3e46567c Mon Sep 17 00:00:00 2001 From: "Gerd v. Egidy" Date: Sat, 21 May 2022 21:41:39 +0200 Subject: [PATCH] Add workaround for systemd not re-evaluating dependencies while running a transaction As described in #279, systemd does not re-evaluate the dependencies of changed units and targets when daemon-reload is executed. It just continues it's transaction as it was configured when starting the transaction. So a late-loaded SRM can't autostart a service. To work around this, add an extra call to "systemctl --no-block start multi-user.target" after the daemon-reload. This will create a new transaction after the current one and allow new services to be added to multi-user.target in a late-loaded SRM. This means of course that this workaround only works for multi-user.target, not other services or targets. --- airootfs/etc/systemd/scripts/sysrescue-initialize.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/airootfs/etc/systemd/scripts/sysrescue-initialize.py b/airootfs/etc/systemd/scripts/sysrescue-initialize.py index 0a07c41..47123ba 100755 --- a/airootfs/etc/systemd/scripts/sysrescue-initialize.py +++ b/airootfs/etc/systemd/scripts/sysrescue-initialize.py @@ -171,9 +171,13 @@ if 'sysconfig' in config and 'ca-trust' in config['sysconfig'] and config['sysco if (late_load_srm != None) and (late_load_srm != ""): print(f"====> Late-loading SystemRescueModule (SRM) ...") - p = subprocess.run(["/usr/share/sysrescue/bin/load-srm", late_load_srm], text=True) + subprocess.run(["/usr/share/sysrescue/bin/load-srm", late_load_srm]) # the SRM could contain changes to systemd units -> let them take effect - p = subprocess.run(["/usr/bin/systemctl", "daemon-reload"], text=True) + subprocess.run(["/usr/bin/systemctl", "daemon-reload"]) + # trigger start of multi-user.target: the SRM could have added something to it's "Wants" + # systemd doesn't re-evaluate the dependencies on daemon-reload while running a transaction + # so we have to do this manually. Note: only affects multi-user.target, nothing else + subprocess.run(["/usr/bin/systemctl", "--no-block", "start", "multi-user.target"]) # ============================================================================== # End of the script