summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/execute.c24
-rw-r--r--src/core/namespace.c16
2 files changed, 21 insertions, 19 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index 18e25fa6e6..bc876a3292 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -40,6 +40,7 @@
#include <sys/poll.h>
#include <linux/seccomp-bpf.h>
#include <glob.h>
+#include <libgen.h>
#ifdef HAVE_PAM
#include <security/pam_appl.h>
@@ -1551,19 +1552,22 @@ void exec_context_init(ExecContext *c) {
}
void exec_context_tmp_dirs_done(ExecContext *c) {
- assert(c);
+ char* dirs[] = {c->tmp_dir ? c->tmp_dir : c->var_tmp_dir,
+ c->tmp_dir ? c->var_tmp_dir : NULL,
+ NULL};
+ char **dirp;
- if (c->tmp_dir) {
- rm_rf_dangerous(c->tmp_dir, false, true, false);
- free(c->tmp_dir);
- c->tmp_dir = NULL;
- }
+ for(dirp = dirs; *dirp; dirp++) {
+ char *dir;
+ rm_rf_dangerous(*dirp, false, true, false);
- if (c->var_tmp_dir) {
- rm_rf_dangerous(c->var_tmp_dir, false, true, false);
- free(c->var_tmp_dir);
- c->var_tmp_dir = NULL;
+ dir = dirname(*dirp);
+ rmdir(dir);
+
+ free(*dirp);
}
+
+ c->tmp_dir = c->var_tmp_dir = NULL;
}
void exec_context_done(ExecContext *c, bool reloading_or_reexecuting) {
diff --git a/src/core/namespace.c b/src/core/namespace.c
index ceeed2e1ae..972380abc0 100644
--- a/src/core/namespace.c
+++ b/src/core/namespace.c
@@ -183,22 +183,20 @@ int setup_tmpdirs(char **tmp_dir,
assert(tmp_dir);
assert(var_tmp_dir);
- r = create_tmp_dir(tmp_dir_template, 0000, true, tmp_dir);
+ r = create_tmp_dir(tmp_dir_template, tmp_dir);
if (r < 0)
- goto fail2;
+ return r;
- r = create_tmp_dir(var_tmp_dir_template, 0000, true, var_tmp_dir);
- if (r < 0)
- goto fail1;
-
- return 0;
+ r = create_tmp_dir(var_tmp_dir_template, var_tmp_dir);
+ if (r == 0)
+ return 0;
-fail1:
+ /* failure */
rmdir(*tmp_dir);
+ rmdir(tmp_dir_template);
free(*tmp_dir);
*tmp_dir = NULL;
-fail2:
return r;
}