summaryrefslogtreecommitdiff
path: root/sandboxlib/linux_user_chroot.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-08 14:27:13 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-06-08 14:29:34 +0100
commitc6fe37a7d60e17d936d8a0f424190bb96fc882bc (patch)
tree6bb84cbb51e193858ae01b893846b1671fab7f8e /sandboxlib/linux_user_chroot.py
parent79504a2446c7617fb20b855117b5aa77e07603c8 (diff)
downloadsandboxlib-c6fe37a7d60e17d936d8a0f424190bb96fc882bc.tar.gz
Change how we search for 'linux-user-chroot'
First, the user should get better errors now if it is not found: sandboxlib.ProgramNotFound: Did not find 'linux-user-chroot' in PATH. Searched '/sbin:/bin:/usr/sbin:/usr/bin' Second, we explicitly search for the program on each call to run_sandbox() using the same search code used in sandbox_module_for_platform(). This shouldn't change anything, but I think it's better practice to search for the program ourselves than to assume exec('linux-user-chroot') will do the right thing.
Diffstat (limited to 'sandboxlib/linux_user_chroot.py')
-rw-r--r--sandboxlib/linux_user_chroot.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/sandboxlib/linux_user_chroot.py b/sandboxlib/linux_user_chroot.py
index a5f84e0..3397a1a 100644
--- a/sandboxlib/linux_user_chroot.py
+++ b/sandboxlib/linux_user_chroot.py
@@ -281,6 +281,11 @@ def create_mount_points_if_missing(filesystem_root, mount_info_list):
os.makedirs(path)
+def linux_user_chroot_program():
+ # Raises sandboxlib.ProgramNotFound if not found.
+ return sandboxlib.utils.find_program('linux-user-chroot')
+
+
def run_sandbox(command, cwd=None, env=None,
filesystem_root='/', filesystem_writable_paths='all',
mounts='undefined', extra_mounts=None,
@@ -289,7 +294,7 @@ def run_sandbox(command, cwd=None, env=None,
if type(command) == str:
command = [command]
- linux_user_chroot_command = ['linux-user-chroot']
+ linux_user_chroot_command = [linux_user_chroot_program()]
extra_mounts = sandboxlib.validate_extra_mounts(extra_mounts)