summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-10-01 10:53:56 +0200
committerLennart Poettering <lennart@poettering.net>2020-10-01 11:02:11 +0200
commit14eb3285ab5b22064b34255fda17599656f05308 (patch)
tree73c7d7c14d4fc97d04848b3c5351573cac6d8bd8
parent74e125207283c029b373f9a9b8c0ed32921dc97b (diff)
downloadsystemd-14eb3285ab5b22064b34255fda17599656f05308.tar.gz
execute: use empty_to_root() a bit more
-rw-r--r--coccinelle/empty-to-root.cocci5
-rw-r--r--src/core/execute.c10
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),