Skip to content
Snippets Groups Projects
Commit 85c9dd5c authored by Colin Walters's avatar Colin Walters
Browse files

libcontainer: Always set PATH when running in new root

For rpm-ostree's use we always run in a new root, so we don't want to
inherit the host system's PATH.  For example, NixOS uses PATH for its
software namespacing, but one could be using rpm-ostree to build
CentOS commits.
parent 47ddbfa5
No related branches found
No related tags found
No related merge requests found
...@@ -274,6 +274,14 @@ glnx_libcontainer_run_chroot_private (const char *dest, ...@@ -274,6 +274,14 @@ glnx_libcontainer_run_chroot_private (const char *dest,
if (chdir ("/") != 0) if (chdir ("/") != 0)
_perror_fatal ("chdir: "); _perror_fatal ("chdir: ");
/* Environment variables like PATH in the end are distribution
* specific. The most correct thing would be to run through PAM,
* but that's a huge level of pain. We'd like to drive towards a
* standard /usr/bin (i.e. unified sbin too), but for now this is
* pretty compatible.
*/
setenv ("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", 1);
if (binary[0] == '/') if (binary[0] == '/')
{ {
if (execv (binary, argv) != 0) if (execv (binary, argv) != 0)
...@@ -281,9 +289,6 @@ glnx_libcontainer_run_chroot_private (const char *dest, ...@@ -281,9 +289,6 @@ glnx_libcontainer_run_chroot_private (const char *dest,
} }
else else
{ {
/* Set PATH to something sane. */
setenv ("PATH", "/usr/sbin:/usr/bin", 1);
if (execvp (binary, argv) != 0) if (execvp (binary, argv) != 0)
_perror_fatal ("execvp: "); _perror_fatal ("execvp: ");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment