summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-03-03 11:34:09 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-03-03 11:34:09 -0500
commit7e6be9c2ecb860ab54401420591e26664dcdbfe8 (patch)
tree693de556d1b38080ca7c1ccf24ceab73fbc9dbb6
parent77f911c56bcfe2eccf15d9fa77bdd306a0359879 (diff)
parent5f18271ec100b3035bb65c17d08f04f0d94022d6 (diff)
Merge pull request #2787 from ronnychevalier/rc/systemctl_edit_rm_empty_dropin_dirs
systemctl: rm empty dropin dirs after cancelled edit
-rw-r--r--src/systemctl/systemctl.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 11e26ce737..c741baf58a 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -6162,9 +6162,19 @@ static int edit(int argc, char *argv[], void *userdata) {
r = daemon_reload(argc, argv, userdata);
end:
- STRV_FOREACH_PAIR(original, tmp, paths)
+ STRV_FOREACH_PAIR(original, tmp, paths) {
(void) unlink(*tmp);
+ /* Removing empty dropin dirs */
+ if (!arg_full) {
+ _cleanup_free_ char *dir = dirname_malloc(*original);
+ /* no need to check if the dir is empty, rmdir
+ * does nothing if it is not the case.
+ */
+ (void) rmdir(dir);
+ }
+ }
+
return r;
}