Skip to content

Commit

Permalink
executors: make compiler fs whitelists a superset of their runtimes'
Browse files Browse the repository at this point in the history
This makes sense because compilers are often written in the same language that
they implement, so need similar whitelists.

This change enables Java 22 to compile.
  • Loading branch information
Xyene committed Jun 2, 2024
1 parent 5302a4c commit 95a432b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 1 addition & 4 deletions dmoj/executors/RKT.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
class Executor(CompiledExecutor):
ext = 'rkt'
fs = [RecursiveDir('/etc/racket'), ExactFile('/etc/passwd'), ExactDir('/')]
compiler_read_fs = [
RecursiveDir('/etc/racket'),
RecursiveDir('~/.local/share/racket'),
]
compiler_read_fs = [RecursiveDir('~/.local/share/racket')]

command = 'racket'

Expand Down
10 changes: 9 additions & 1 deletion dmoj/executors/compiled_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,16 @@ def get_compile_env(self) -> Optional[Dict[str, str]]:
def get_compile_popen_kwargs(self) -> Dict[str, Any]:
return {}

def get_compiler_read_fs(self) -> List[FilesystemAccessRule]:
return self.get_fs() + self.compiler_read_fs

def get_compiler_write_fs(self) -> List[FilesystemAccessRule]:
return self.get_write_fs() + self.compiler_write_fs

def get_compiler_security(self):
sec = CompilerIsolateTracer(tmpdir=self._dir, read_fs=self.compiler_read_fs, write_fs=self.compiler_write_fs)
sec = CompilerIsolateTracer(
tmpdir=self._dir, read_fs=self.get_compiler_read_fs(), write_fs=self.get_compiler_write_fs()
)
return self._add_syscalls(sec, self.compiler_syscalls)

def create_compile_process(self, args: List[str]) -> TracedPopen:
Expand Down
1 change: 0 additions & 1 deletion dmoj/executors/mono_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class MonoExecutor(CompiledExecutor):
data_grace = 65536
cptbox_popen_class = MonoTracedPopen
fs = [RecursiveDir('/etc/mono')]
compiler_read_fs = fs
# Mono sometimes forks during its crashdump procedure, but continues even if
# the call to fork fails.
syscalls = [
Expand Down

0 comments on commit 95a432b

Please sign in to comment.