This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch valentindavid/chroot_fixes in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit a64f976d4e465ff211e70ab116244e4eebd3ac0d Author: Valentin David <[email protected]> AuthorDate: Thu Jul 11 20:35:11 2019 +0200 Catch unhandled exception when shell is not executable on chroot sandbox --- src/buildstream/sandbox/_sandboxchroot.py | 2 ++ .../sandbox-bwrap/non-executable-shell-success.bst | 9 +++++++++ tests/integration/sandbox-chroot.py | 23 ++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/buildstream/sandbox/_sandboxchroot.py b/src/buildstream/sandbox/_sandboxchroot.py index 7266a00..95e247e 100644 --- a/src/buildstream/sandbox/_sandboxchroot.py +++ b/src/buildstream/sandbox/_sandboxchroot.py @@ -194,6 +194,8 @@ class SandboxChroot(Sandbox): .format(rootfs, cwd)) from e else: raise SandboxError('Could not run command {}: {}'.format(command, e)) from e + except PermissionError as e: + raise SandboxError('Permission error to run command {}: {}'.format(command, e)) from e return code diff --git a/tests/integration/project/elements/sandbox-bwrap/non-executable-shell-success.bst b/tests/integration/project/elements/sandbox-bwrap/non-executable-shell-success.bst new file mode 100644 index 0000000..e22e989 --- /dev/null +++ b/tests/integration/project/elements/sandbox-bwrap/non-executable-shell-success.bst @@ -0,0 +1,9 @@ +kind: manual + +depends: + - sandbox-bwrap/break-shell.bst + +config: + build-commands: + - | + exit 0 diff --git a/tests/integration/sandbox-chroot.py b/tests/integration/sandbox-chroot.py new file mode 100644 index 0000000..7596cbe --- /dev/null +++ b/tests/integration/sandbox-chroot.py @@ -0,0 +1,23 @@ +import os +import pytest + +from buildstream.testing._utils.site import HAVE_SANBOX + + +pytestmark = pytest.mark.integration + + +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "project" +) + + [email protected](HAVE_SANBOX, reason='Chroot equivalent test') [email protected](DATA_DIR) +def test_sandbox_chroot_permission_denied(cli, datafiles): + project = str(datafiles) + element_name = 'sandbox-bwrap/non-executable-shell-success.bst' + + result = cli.run(project=project, args=['build', element_name]) + result.assert_task_error(error_domain=ErrorDomain.SANDBOX)
