From b6b180b77b78103cd94ad7e0d6f8b4951c4988a3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 13 Oct 2018 13:11:32 +0200 Subject: [PATCH] nspawn: use container $PATH (not host $PATH) when searching for PID 1 binaries to execute Fixes: #10377 --- src/nspawn/nspawn.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index fb360a6f4f1..7ece7f4cdee 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -2795,7 +2795,18 @@ static int inner_child( exec_target = "/usr/lib/systemd/systemd, /lib/systemd/systemd, /sbin/init"; } else if (!strv_isempty(arg_parameters)) { + const char *dollar_path; + exec_target = arg_parameters[0]; + + /* Use the user supplied search $PATH if there is one, or DEFAULT_PATH_COMPAT if not to search the + * binary. */ + dollar_path = strv_env_get(env_use, "PATH"); + if (dollar_path) { + if (putenv((char*) dollar_path) != 0) + return log_error_errno(errno, "Failed to update $PATH: %m"); + } + execvpe(arg_parameters[0], arg_parameters, env_use); } else { if (!arg_chdir) -- 2.47.3