diff options
author | Valentin David <valentin.david@codethink.co.uk> | 2018-07-25 10:13:14 +0200 |
---|---|---|
committer | Valentin David <valentin.david@gmail.com> | 2018-08-10 12:18:55 +0000 |
commit | 5dcecbad2acace52e79bce1b8682bdadda6ba8a6 (patch) | |
tree | 0b212d760431c7dfbf6afd6738d4594873ebf36f /buildstream | |
parent | 04cee9a96df64c5e74d62db2bfbf28d7f248ae60 (diff) | |
download | buildstream-5dcecbad2acace52e79bce1b8682bdadda6ba8a6.tar.gz |
Set environment in bwrap command line instead of its environment
Fixes #498
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/sandbox/_sandboxbwrap.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/buildstream/sandbox/_sandboxbwrap.py b/buildstream/sandbox/_sandboxbwrap.py index 010e4791d..3ef3d4cb9 100644 --- a/buildstream/sandbox/_sandboxbwrap.py +++ b/buildstream/sandbox/_sandboxbwrap.py @@ -89,6 +89,11 @@ class SandboxBwrap(Sandbox): # Grab the full path of the bwrap binary bwrap_command = [utils.get_host_tool('bwrap')] + for k, v in env.items(): + bwrap_command += ['--setenv', k, v] + for k in os.environ.keys() - env.keys(): + bwrap_command += ['--unsetenv', k] + # Create a new pid namespace, this also ensures that any subprocesses # are cleaned up when the bwrap process exits. bwrap_command += ['--unshare-pid'] @@ -194,7 +199,7 @@ class SandboxBwrap(Sandbox): stdin = stack.enter_context(open(os.devnull, "r")) # Run bubblewrap ! - exit_code = self.run_bwrap(bwrap_command, stdin, stdout, stderr, env, + exit_code = self.run_bwrap(bwrap_command, stdin, stdout, stderr, (flags & SandboxFlags.INTERACTIVE)) # Cleanup things which bwrap might have left behind, while @@ -245,7 +250,7 @@ class SandboxBwrap(Sandbox): return exit_code - def run_bwrap(self, argv, stdin, stdout, stderr, env, interactive): + def run_bwrap(self, argv, stdin, stdout, stderr, interactive): # Wrapper around subprocess.Popen() with common settings. # # This function blocks until the subprocess has terminated. @@ -321,7 +326,6 @@ class SandboxBwrap(Sandbox): # The default is to share file descriptors from the parent process # to the subprocess, which is rarely good for sandboxing. close_fds=True, - env=env, stdin=stdin, stdout=stdout, stderr=stderr, |