From f1bfb88cea3730c921d7a1d466621c13cdb611ac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 17 Jun 2014 00:33:39 +0200 Subject: [PATCH] install: make sure "systemctl disable foobar@.service" actually removes all instances (cherry picked from commit 559367add5e22bf32d14fa1496512c68488f48b0) Conflicts: src/shared/install.c (cherry picked from commit b83e096610a05b7bb3b096cebd634ef3717c4b2c) --- src/shared/install.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/shared/install.c b/src/shared/install.c index 00a6a77..e772c45 100644 --- a/src/shared/install.c +++ b/src/shared/install.c @@ -267,8 +267,21 @@ 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) @@ -297,10 +310,10 @@ static int remove_marked_symlinks_fd( 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)) {