]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nspawn: use FOREACH_STRING() more
authorLennart Poettering <lennart@poettering.net>
Fri, 19 Nov 2021 14:48:01 +0000 (15:48 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sat, 20 Nov 2021 17:54:53 +0000 (17:54 +0000)
src/nspawn/nspawn.c

index e23d042b577152802650ab7cb7ae40fb3829e524..e5ae382d5f59369d98ebc978be44c4611c1d6816 100644 (file)
@@ -3513,6 +3513,7 @@ static int inner_child(
         (void) fdset_close_others(fds);
 
         if (arg_start_mode == START_BOOT) {
+                const char *init;
                 char **a;
                 size_t m;
 
@@ -3523,14 +3524,13 @@ static int inner_child(
                 memcpy_safe(a + 1, arg_parameters, m * sizeof(char*));
                 a[1 + m] = NULL;
 
-                a[0] = (char*) "/usr/lib/systemd/systemd";
-                execve(a[0], a, env_use);
-
-                a[0] = (char*) "/lib/systemd/systemd";
-                execve(a[0], a, env_use);
-
-                a[0] = (char*) "/sbin/init";
-                execve(a[0], a, env_use);
+                FOREACH_STRING(init,
+                               "/usr/lib/systemd/systemd",
+                               "/lib/systemd/systemd",
+                               "/sbin/init") {
+                        a[0] = (char*) init;
+                        execve(a[0], a, env_use);
+                }
 
                 exec_target = "/usr/lib/systemd/systemd, /lib/systemd/systemd, /sbin/init";
         } else if (!strv_isempty(arg_parameters)) {