jail: consider PATH for argv in OCI container
authorDaniel Golle <daniel@makrotopia.org>
Mon, 13 Jul 2020 02:00:22 +0000 (03:00 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 13 Jul 2020 11:14:49 +0000 (12:14 +0100)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
jail/jail.c

index aa9285c88dc896743a11583fc0dd20a71c59ef56..5018fcc09fce13e6c22c3d161b3be0ef4e545def 100644 (file)
@@ -714,7 +714,11 @@ static int exec_jail(void *pipes_ptr)
                exit(EXIT_FAILURE);
 
        INFO("exec-ing %s\n", *opts.jail_argv);
-       execve(*opts.jail_argv, opts.jail_argv, envp);
+       if (opts.envp) /* respect PATH if potentially set in ENV */
+               execvpe(*opts.jail_argv, opts.jail_argv, envp);
+       else
+               execve(*opts.jail_argv, opts.jail_argv, envp);
+
        /* we get there only if execve fails */
        ERROR("failed to execve %s: %m\n", *opts.jail_argv);
        exit(EXIT_FAILURE);