summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-10 15:47:12 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-29 16:17:56 +0200
commit0d11db59825a9deee0b56fdede0602ef1c37c5c5 (patch)
treed636ede0f1088d56f454066e153c3628e0bd8cee /src
parentshared/install: propagate errors about invalid aliases and such too (diff)
downloadsystemd-0d11db59825a9deee0b56fdede0602ef1c37c5c5.tar.xz
systemd-0d11db59825a9deee0b56fdede0602ef1c37c5c5.zip
shared/install: return failure when enablement fails, but process as much as possible
So far we'd issue a warning (before this series, just in the logs on the server side, and before this commit, on stderr on the caller's side), but return success. It seems that successfull return was introduced by mistake in aa0f357fd833feecbea6c3e9be80b643e433bced (my fault :( ), which was supposed to be a refactoring without a functional change. I think it's better to fail, because if enablement fails, the user will most likely want to diagnose the issue. Note that we still do partial enablement, as far as that is possible. So if e.g. we have [Install] Alias=foo.service foobar, we'll create the symlink 'foo.service', but not 'foobar', since that's not a valid unit name. We'll print info about the action taken, and about 'foobar' being invalid, and return failure.
Diffstat (limited to 'src')
-rw-r--r--src/shared/install.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index 332c146710..554c530cc4 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1794,20 +1794,22 @@ static int install_info_symlink_alias(
q = install_name_printf(scope, info, *s, info->root, &dst);
if (q < 0) {
unit_file_changes_add(changes, n_changes, q, *s, NULL);
- return q;
+ r = r < 0 ? r : q;
+ continue;
}
q = unit_file_verify_alias(info, dst, &dst_updated, changes, n_changes);
- if (q < 0)
+ if (q < 0) {
+ r = r < 0 ? r : q;
continue;
+ }
alias_path = path_make_absolute(dst_updated ?: dst, config_path);
if (!alias_path)
return -ENOMEM;
q = create_symlink(lp, info->path, alias_path, force, changes, n_changes);
- if (r == 0)
- r = q;
+ r = r < 0 ? r : q;
}
return r;