summaryrefslogtreecommitdiffstats
path: root/src/nspawn
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-13 13:11:32 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-18 16:40:12 +0200
commitb6b180b77b78103cd94ad7e0d6f8b4951c4988a3 (patch)
tree402032c2e1a3b54f1822818c73ed86adc7775f24 /src/nspawn
parentmkosi: use Fedora 29 (diff)
downloadsystemd-b6b180b77b78103cd94ad7e0d6f8b4951c4988a3.tar.xz
systemd-b6b180b77b78103cd94ad7e0d6f8b4951c4988a3.zip
nspawn: use container $PATH (not host $PATH) when searching for PID 1 binaries to execute
Fixes: #10377
Diffstat (limited to 'src/nspawn')
-rw-r--r--src/nspawn/nspawn.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index fb360a6f4f..7ece7f4cde 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)