]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
execute: use empty_to_root() a bit more 17219/head
authorLennart Poettering <lennart@poettering.net>
Thu, 1 Oct 2020 08:53:56 +0000 (10:53 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Oct 2020 09:02:11 +0000 (11:02 +0200)
coccinelle/empty-to-root.cocci
src/core/execute.c

index 45627c98019bbee737a980761385f3674af25de9..3720497bef9f60b526c16f76be2f403a3b029c8d 100644 (file)
@@ -9,3 +9,8 @@ expression s;
 @@
 - (empty_or_root(s) ? "/" : s)
 + empty_to_root(s)
+@@
+expression s;
+@@
+- (s ? s : "/")
++ empty_to_root(s)
index b86674771986a1350783d52c7a8f42284595ed71..5264b8f0919fd219a2eaf45d5a8b7f48b8acb6d5 100644 (file)
@@ -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),