summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2020-02-20 17:57:26 +0100
committerJürg Billeter <j@bitron.ch>2020-02-27 12:18:07 +0100
commitcef76e3e38c51fc67e137199f7cd959b7ceaf52e (patch)
tree9efb7611efb6a40749aa60c8552ba0e6a22727df /src
parentaead8c86831485abccdb92be058e778187e4aac3 (diff)
downloadbuildstream-cef76e3e38c51fc67e137199f7cd959b7ceaf52e.tar.gz
_sandboxreapi.py: Set unixUID and unixGID platform properties
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/sandbox/_sandboxbuildboxrun.py7
-rw-r--r--src/buildstream/sandbox/_sandboxreapi.py19
2 files changed, 20 insertions, 6 deletions
diff --git a/src/buildstream/sandbox/_sandboxbuildboxrun.py b/src/buildstream/sandbox/_sandboxbuildboxrun.py
index 93ee330b1..df2c4394d 100644
--- a/src/buildstream/sandbox/_sandboxbuildboxrun.py
+++ b/src/buildstream/sandbox/_sandboxbuildboxrun.py
@@ -56,10 +56,6 @@ class SandboxBuildBoxRun(SandboxREAPI):
@classmethod
def check_sandbox_config(cls, platform, config):
- # Report error for elements requiring non-0 UID/GID
- if config.build_uid != 0 or config.build_gid != 0:
- return False
-
# Check host os and architecture match
if config.build_os != platform.get_host_os():
raise SandboxError("Configured and host OS don't match.")
@@ -176,5 +172,8 @@ class SandboxBuildBoxRun(SandboxREAPI):
if returncode != 0:
raise SandboxError("buildbox-run failed with returncode {}".format(returncode))
+ def _supported_platform_properties(self):
+ return {"unixUID", "unixGID"}
+
def _warn(self, msg):
self._get_context().messenger.message(Message(MessageType.WARN, msg))
diff --git a/src/buildstream/sandbox/_sandboxreapi.py b/src/buildstream/sandbox/_sandboxreapi.py
index 718dbefdc..774058d6a 100644
--- a/src/buildstream/sandbox/_sandboxreapi.py
+++ b/src/buildstream/sandbox/_sandboxreapi.py
@@ -78,7 +78,7 @@ class SandboxREAPI(Sandbox):
# Generate Action proto
input_root_digest = vdir._get_digest()
- command_proto = self._create_command(command, cwd, env, read_write_directories)
+ command_proto = self._create_command(command, cwd, env, read_write_directories, flags)
command_digest = cascache.add_object(buffer=command_proto.SerializeToString())
action = remote_execution_pb2.Action(command_digest=command_digest, input_root_digest=input_root_digest)
if self._output_node_properties:
@@ -95,7 +95,7 @@ class SandboxREAPI(Sandbox):
# the remote execution system has worked correctly but the command failed.
return action_result.exit_code
- def _create_command(self, command, working_directory, environment, read_write_directories):
+ def _create_command(self, command, working_directory, environment, read_write_directories, flags):
# Creates a command proto
environment_variables = [
remote_execution_pb2.Command.EnvironmentVariable(name=k, value=v) for (k, v) in environment.items()
@@ -105,10 +105,22 @@ class SandboxREAPI(Sandbox):
output_directories = [os.path.relpath(dir, start=working_directory) for dir in read_write_directories]
config = self._get_config()
+ supported_properties = self._supported_platform_properties()
platform = remote_execution_pb2.Platform()
platform.properties.add(name="OSFamily", value=config.build_os)
platform.properties.add(name="ISA", value=config.build_arch)
+ if flags & SandboxFlags.INHERIT_UID:
+ uid = os.geteuid()
+ gid = os.getegid()
+ else:
+ uid = config.build_uid
+ gid = config.build_gid
+ if "unixUID" in supported_properties:
+ platform.properties.add(name="unixUID", value=str(uid))
+ if "unixGID" in supported_properties:
+ platform.properties.add(name="unixGID", value=str(gid))
+
return remote_execution_pb2.Command(
arguments=command,
working_directory=working_directory[1:],
@@ -158,6 +170,9 @@ class SandboxREAPI(Sandbox):
def _execute_action(self, action, flags):
raise ImplError("Sandbox of type '{}' does not implement _execute_action()".format(type(self).__name__))
+ def _supported_platform_properties(self):
+ return set()
+
# _SandboxREAPIBatch()
#