diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index e23d042b57..e5ae382d5f 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)) {