diff --git a/src/core/namespace.c b/src/core/namespace.c index aa80570885..b97eabd51b 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -3333,6 +3333,23 @@ int temporary_filesystem_add( return 0; } +char* namespace_cleanup_tmpdir(char *p) { + if (!p) + return NULL; + + if (!streq(p, RUN_SYSTEMD_EMPTY)) { + _cleanup_free_ char *child = path_join(p, "tmp"); + if (!child) + log_oom_debug(); + else + (void) rmdir(child); + + (void) rmdir(p); + } + + return mfree(p); +} + static int make_tmp_prefix(const char *prefix) { _cleanup_free_ char *t = NULL; _cleanup_close_ int fd = -EBADF; @@ -3444,13 +3461,6 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, ch return 0; } -char* namespace_cleanup_tmpdir(char *p) { - PROTECT_ERRNO; - if (!streq_ptr(p, RUN_SYSTEMD_EMPTY)) - (void) rmdir(p); - return mfree(p); -} - int setup_tmp_dirs(const char *id, char **tmp_dir, char **var_tmp_dir) { _cleanup_(namespace_cleanup_tmpdirp) char *a = NULL; _cleanup_(rmdir_and_freep) char *a_tmp = NULL;