diff options
author | 2021-01-10 17:05:32 -0800 | |
---|---|---|
committer | 2021-01-10 17:05:32 -0800 | |
commit | 69aad44154d9695276a45c1c076d34a35067521c (patch) | |
tree | 9548e4e7757e78287003e4c04759ef16d3800ea2 | |
parent | Add comments to justify why cgroup limits are set manually (diff) |
Support overriding nsjail config values with additional arguments
-rw-r--r-- | snekbox/nsjail.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py index 3d88336..c329434 100644 --- a/snekbox/nsjail.py +++ b/snekbox/nsjail.py @@ -165,13 +165,19 @@ class NsJail: return "".join(output) - def python3(self, code: str) -> CompletedProcess: - """Execute Python 3 code in an isolated environment and return the completed process.""" + def python3(self, code: str, *args) -> CompletedProcess: + """ + Execute Python 3 code in an isolated environment and return the completed process. + + Additional arguments passed will be used to override the values in the NsJail config. + These arguments are only options for NsJail; they do not affect Python's arguments. + """ with NamedTemporaryFile() as nsj_log: args = ( self.nsjail_binary, "--config", NSJAIL_CFG, "--log", nsj_log.name, + *args, "--", self.config.exec_bin.path, *self.config.exec_bin.arg, "-c", code ) |