Merge pull request #2787 from ronnychevalier/rc/systemctl_edit_rm_empty_dropin_dirs

systemctl: rm empty dropin dirs after cancelled edit
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2016-03-03 11:34:09 -05:00
+11 -1
View File
@@ -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;
}