You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by gi...@apache.org on 2020/12/29 13:07:18 UTC

[buildstream] branch becky/shell_launch_errors created (now 7a118e0)

This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a change to branch becky/shell_launch_errors
in repository https://gitbox.apache.org/repos/asf/buildstream.git.


      at 7a118e0  element.py: Add BST_ALLOW_SHELL to improve errors

This branch includes the following new commits:

     new 7a118e0  element.py: Add BST_ALLOW_SHELL to improve errors

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[buildstream] 01/01: element.py: Add BST_ALLOW_SHELL to improve errors

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-bot pushed a commit to branch becky/shell_launch_errors
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 7a118e054353d93856d7f82a974b13dd74f374c4
Author: Rebecca Grayson <be...@hotmail.co.uk>
AuthorDate: Mon Jul 8 12:19:29 2019 +0100

    element.py: Add BST_ALLOW_SHELL to improve errors
---
 src/buildstream/element.py                   | 5 +++++
 src/buildstream/plugins/elements/filter.py   | 2 ++
 src/buildstream/plugins/elements/import.py   | 2 ++
 src/buildstream/plugins/elements/junction.py | 1 +
 src/buildstream/plugins/elements/stack.py    | 1 +
 5 files changed, 11 insertions(+)

diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index fa4f63b..16f1fdf 100644
--- a/src/buildstream/element.py
+++ b/src/buildstream/element.py
@@ -185,6 +185,8 @@ class Element(Plugin):
     *Since: 1.4*
     """
 
+    BST_ALLOW_SHELL = True
+
     def __init__(self, context, project, meta, plugin_conf):
 
         self.__cache_key_dict = None            # Dict for cache key calculation
@@ -1957,6 +1959,9 @@ class Element(Plugin):
     def _shell(self, scope=None, directory=None, *, mounts=None, isolate=False, prompt=None, command=None,
                usebuildtree=False):
 
+        if scope == Scope.BUILD and self.BST_ALLOW_SHELL == False:    
+            raise ElementError("{} does not allow build shell access".format(self))
+        
         with self._prepare_sandbox(scope, directory, shell=True, usebuildtree=usebuildtree) as sandbox:
             environment = self.get_environment()
             environment = copy.copy(environment)
diff --git a/src/buildstream/plugins/elements/filter.py b/src/buildstream/plugins/elements/filter.py
index 45847e6..7f786a4 100644
--- a/src/buildstream/plugins/elements/filter.py
+++ b/src/buildstream/plugins/elements/filter.py
@@ -166,6 +166,8 @@ class FilterElement(Element):
     # Filter elements do not run any commands
     BST_RUN_COMMANDS = False
 
+    BST_ALLOW_SHELL = False
+
     def configure(self, node):
         self.node_validate(node, [
             'include', 'exclude', 'include-orphans'
diff --git a/src/buildstream/plugins/elements/import.py b/src/buildstream/plugins/elements/import.py
index 61e353d..3885fa3 100644
--- a/src/buildstream/plugins/elements/import.py
+++ b/src/buildstream/plugins/elements/import.py
@@ -44,6 +44,8 @@ class ImportElement(Element):
     # Import elements do not run any commands
     BST_RUN_COMMANDS = False
 
+    BST_ALLOW_SHELL = False
+
     def configure(self, node):
         self.node_validate(node, [
             'source', 'target'
diff --git a/src/buildstream/plugins/elements/junction.py b/src/buildstream/plugins/elements/junction.py
index 4222de3..d3f8cf5 100644
--- a/src/buildstream/plugins/elements/junction.py
+++ b/src/buildstream/plugins/elements/junction.py
@@ -173,6 +173,7 @@ class JunctionElement(Element):
     # Junctions are not allowed any dependencies
     BST_FORBID_BDEPENDS = True
     BST_FORBID_RDEPENDS = True
+    BST_ALLOW_SHELL = False
 
     def configure(self, node):
         self.path = self.node_get_member(node, str, 'path', default='')
diff --git a/src/buildstream/plugins/elements/stack.py b/src/buildstream/plugins/elements/stack.py
index 97517ca..e4eba2c 100644
--- a/src/buildstream/plugins/elements/stack.py
+++ b/src/buildstream/plugins/elements/stack.py
@@ -32,6 +32,7 @@ class StackElement(Element):
 
     # This plugin has been modified to avoid the use of Sandbox.get_directory
     BST_VIRTUAL_DIRECTORY = True
+    BST_ALLOW_SHELL = False
 
     def configure(self, node):
         pass