From: Ronny Chevalier Date: Wed, 2 Mar 2016 21:06:47 +0000 (+0100) Subject: systemctl: rm empty dropin dirs after cancelled edit X-Git-Tag: v230~291^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5f18271ec100b3035bb65c17d08f04f0d94022d6;p=thirdparty%2Fsystemd.git systemctl: rm empty dropin dirs after cancelled edit Fixes #2734 --- diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 11e26ce7373..c741baf58a2 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; }