summaryrefslogtreecommitdiffstats
path: root/src/nspawn
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-10-19 01:48:37 +0200
committerGitHub <noreply@github.com>2018-10-19 01:48:37 +0200
commitb0b8c9a5a45da32f261b91d0a777661339290cf4 (patch)
tree28fbf54ea07f065666e6641cc5fa4a758139898f /src/nspawn
parentMerge pull request #10450 from poettering/foreach-line-excorcism (diff)
parenttest: check for putenv() failures, the call might theortically fail (diff)
downloadsystemd-b0b8c9a5a45da32f261b91d0a777661339290cf4.tar.xz
systemd-b0b8c9a5a45da32f261b91d0a777661339290cf4.zip
Merge pull request #10389 from poettering/nspawn-path-fix
nspawn $PATH execvpe() fix
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 88138d7d9d..d6a7d5b9ad 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)