From 14eb3285ab5b22064b34255fda17599656f05308 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 1 Oct 2020 10:53:56 +0200 Subject: [PATCH] execute: use empty_to_root() a bit more --- coccinelle/empty-to-root.cocci | 5 +++++ src/core/execute.c | 10 ++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/coccinelle/empty-to-root.cocci b/coccinelle/empty-to-root.cocci index 45627c9801..3720497bef 100644 --- a/coccinelle/empty-to-root.cocci +++ b/coccinelle/empty-to-root.cocci @@ -9,3 +9,8 @@ expression s; @@ - (empty_or_root(s) ? "/" : s) + empty_to_root(s) +@@ +expression s; +@@ +- (s ? s : "/") ++ empty_to_root(s) diff --git a/src/core/execute.c b/src/core/execute.c index b866747719..5264b8f091 100644 --- a/src/core/execute.c +++ b/src/core/execute.c @@ -3245,10 +3245,8 @@ static int apply_working_directory( wd = home; - } else if (context->working_directory) - wd = context->working_directory; - else - wd = "/"; + } else + wd = empty_to_root(context->working_directory); if (params->flags & EXEC_APPLY_CHROOT) d = wd; @@ -5171,8 +5169,8 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) { "%sProtectProc: %s\n" "%sProcSubset: %s\n", prefix, c->umask, - prefix, c->working_directory ? c->working_directory : "/", - prefix, c->root_directory ? c->root_directory : "/", + prefix, empty_to_root(c->working_directory), + prefix, empty_to_root(c->root_directory), prefix, yes_no(c->non_blocking), prefix, yes_no(c->private_tmp), prefix, yes_no(c->private_devices),