summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-11 14:27:46 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-03-29 16:17:56 +0200
commit20d68b3aec62110351bdc695fd1a55adcf3a6ee5 (patch)
treeb2fe2f02a82fb5fb9dca36b44b48224f120a9b6a /src
parentman: fix invalid description of template handling in WantedBy= (diff)
downloadsystemd-20d68b3aec62110351bdc695fd1a55adcf3a6ee5.tar.xz
systemd-20d68b3aec62110351bdc695fd1a55adcf3a6ee5.zip
install: when linking a file, create the link first or abort
We'd create aliases and other symlinks first, and only then try to create the main link. Since that can fail, let's do things in opposite order, and abort immediately if we can't link the file itself.
Diffstat (limited to 'src')
-rw-r--r--src/shared/install.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index bc15b0e9d2..5dbc267eb8 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1980,6 +1980,13 @@ static int install_info_apply(
bool force = file_flags & UNIT_FILE_FORCE;
+ r = install_info_symlink_link(info, lp, config_path, force, changes, n_changes);
+ /* Do not count links to the unit file towards the "carries_install_info" count */
+ if (r < 0)
+ /* If linking of the file failed, do not try to create other symlinks,
+ * because they might would pointing to a non-existent or wrong unit. */
+ return r;
+
r = install_info_symlink_alias(scope, info, lp, config_path, force, changes, n_changes);
q = install_info_symlink_wants(scope, file_flags, info, lp, config_path, info->wanted_by, ".wants/", changes, n_changes);
@@ -1990,11 +1997,6 @@ static int install_info_apply(
if (r == 0)
r = q;
- q = install_info_symlink_link(info, lp, config_path, force, changes, n_changes);
- /* Do not count links to the unit file towards the "carries_install_info" count */
- if (r == 0 && q < 0)
- r = q;
-
return r;
}