element.py: Add BST_ALLOW_SHELL to improve errors
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 @@ *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 @@ 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 @@ # 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 @@ # 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 @@ # 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 @@ # 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