summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-06-17 00:33:39 +0200
committerLennart Poettering <lennart@poettering.net>2014-06-17 02:43:43 +0200
commit559367add5e22bf32d14fa1496512c68488f48b0 (patch)
tree510007589122587a95d1f17b5d309f98c49d7ee7
parentd54c4993699f4fa5feece43715aac3564c4dada6 (diff)
install: make sure "systemctl disable foobar@.service" actually removes all instances
-rw-r--r--src/shared/install.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index 1e7863acbf..54fbfe8a9e 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -266,8 +266,22 @@ static int remove_marked_symlinks_fd(
if (unit_name_is_instance(de->d_name) &&
instance_whitelist &&
- !strv_contains(instance_whitelist, de->d_name))
- continue;
+ !strv_contains(instance_whitelist, de->d_name)) {
+
+ _cleanup_free_ char *w;
+
+ /* OK, the file is not listed directly
+ * in the whitelist, so let's check if
+ * the template of it might be
+ * listed. */
+
+ w = unit_name_template(de->d_name);
+ if (!w)
+ return -ENOMEM;
+
+ if (!strv_contains(instance_whitelist, w))
+ continue;
+ }
p = path_make_absolute(de->d_name, path);
if (!p)
@@ -290,18 +304,14 @@ static int remove_marked_symlinks_fd(
if (!found)
continue;
-
if (unlink(p) < 0 && errno != ENOENT) {
-
if (r == 0)
r = -errno;
continue;
}
- rmdir_parents(p, config_path);
-
path_kill_slashes(p);
-
+ rmdir_parents(p, config_path);
add_file_change(changes, n_changes, UNIT_FILE_UNLINK, p, NULL);
if (!set_get(remove_symlinks_to, p)) {