From a50966416e382bd02f77d897d58dcd9c1b09e66d Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 19 Nov 2021 15:48:01 +0100 Subject: [PATCH] nspawn: use FOREACH_STRING() more --- src/nspawn/nspawn.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index e23d042b577..e5ae382d5f5 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -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)) { -- 2.47.3