summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Grayson <becky.grayson1@hotmail.co.uk>2019-07-08 12:19:29 +0100
committerRebecca Grayson <becky.grayson1@hotmail.co.uk>2019-07-08 12:19:29 +0100
commit7a118e054353d93856d7f82a974b13dd74f374c4 (patch)
treee63a3efd95be625ab2dfefec3a588d24771d3978
parent93816bea18d93495744263deaabc1d73a68029ac (diff)
downloadbuildstream-becky/shell_launch_errors.tar.gz
element.py: Add BST_ALLOW_SHELL to improve errorsbecky/shell_launch_errors
-rw-r--r--src/buildstream/element.py5
-rw-r--r--src/buildstream/plugins/elements/filter.py2
-rw-r--r--src/buildstream/plugins/elements/import.py2
-rw-r--r--src/buildstream/plugins/elements/junction.py1
-rw-r--r--src/buildstream/plugins/elements/stack.py1
5 files changed, 11 insertions, 0 deletions
diff --git a/src/buildstream/element.py b/src/buildstream/element.py
index fa4f63bff..16f1fdfbf 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 45847e685..7f786a497 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 61e353dbc..3885fa314 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 4222de360..d3f8cf5ff 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 97517ca48..e4eba2c86 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