From: Lennart Poettering Date: Sat, 13 Oct 2018 11:11:32 +0000 (+0200) Subject: nspawn: use container $PATH (not host $PATH) when searching for PID 1 binaries to... X-Git-Tag: v240~512^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b6b180b77b78103cd94ad7e0d6f8b4951c4988a3;p=thirdparty%2Fsystemd.git nspawn: use container $PATH (not host $PATH) when searching for PID 1 binaries to execute Fixes: #10377 --- 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)