summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sandboxlib/chroot.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/sandboxlib/chroot.py b/sandboxlib/chroot.py
index 6adaa06..c0f662b 100644
--- a/sandboxlib/chroot.py
+++ b/sandboxlib/chroot.py
@@ -167,6 +167,9 @@ def run_command_in_chroot(pipe, stdout, stderr, extra_mounts, chroot_path,
except OSError as e:
raise RuntimeError("Unable to chroot: %s" % e)
+ # This is important in case 'cwd' is a relative path.
+ os.chdir('/')
+
if cwd is not None:
try:
os.chdir(cwd)