]> git.ipfire.org Git - thirdparty/systemd.git/commit
shared/install: rework error propagation again 40504/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 29 Jan 2026 07:12:52 +0000 (08:12 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 29 Jan 2026 07:49:44 +0000 (08:49 +0100)
commit64eb78135c49b7d84bfa183cae0dc3a56789b20c
tree3bb11b3a2ced82e62a27ae2932f0a83165d40867
parentc67d64add6f5bad6f65c7b61b2dc0f138d5370bd
shared/install: rework error propagation again

The immediate impulse for this change is the fedora scriptlet which called:
  /usr/lib/systemd/systemd-update-helper install-system-units cryptsetup-pre.target cryptsetup.target getty@.service ... system-systemd\x2dcryptsetup.slice system-systemd\x2dveritysetup.slice ...
which called
  systemctl preset cryptsetup-pre.target cryptsetup.target getty@.service ... system-systemd\x2dcryptsetup.slice system-systemd\x2dveritysetup.slice ...
which threw an error that system-systemdx2dcryptsetup.slice does not exist
and did nothing at all. (The backslash is consumed by the shell.)
The obvious fix here is to figure out more levels of escaping… But we should
do something more robust in such cases.

If we fail in processing of a single unit, let preset all continue processing
units, report the failure through 'changes'. At the end, return failure. In
general, for operations which operate on a list of units specified by the user,
fail the whole operation if any of the individual operations failed. The only
operation where we don't do this is 'preset-all'.

$ SYSTEMD_LOG_LEVEL=debug build/systemctl --root=/ preset asdf1.servie asdf2.path; echo $?
Cannot find unit asdf1.servie.service.
Cannot find unit asdf2.path.
Failed to preset unit: Unit asdf1.servie.service does not exist
Failed to preset unit: Unit asdf2.path does not exist
1

While at it, fix double logging in the manager: dump_unit_changes() already
logs about errors, so the manager should only log on success.
src/core/manager.c
src/shared/install.c
src/shared/install.h
src/systemctl/systemctl-add-dependency.c
src/systemctl/systemctl-enable.c
src/systemctl/systemctl-preset-all.c
src/systemctl/systemctl-set-default.c