Skip to content

Commit f942b02

Browse files
authored
Sandbox: Mount a temporary directory on /dev/shm (#1484)
1 parent 02ee587 commit f942b02

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cms/grading/Sandbox.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def __init__(
217217
# TODO: move all other common properties here.
218218
self.box_id: int = 0
219219
self.fsize: int | None = None
220-
self.dirs: list[tuple[str, str, str | None]] = []
220+
self.dirs: list[tuple[str | None, str, str | None]] = []
221221
self.preserve_env: bool = False
222222
self.inherit_env: list[str] = []
223223
self.set_env: dict[str, str] = {}
@@ -966,6 +966,10 @@ def __init__(self, file_cacher, name=None, temp_dir=None):
966966
self.add_mapped_directory(
967967
self._home, dest=self._home_dest, options="rw")
968968

969+
# Create temporary directory on /dev/shm to prevent communication
970+
# between sandboxes.
971+
self.dirs.append((None, "/dev/shm", "tmp"))
972+
969973
# Set common environment variables.
970974
# Specifically needed by Python, that searches the home for
971975
# packages.
@@ -1132,7 +1136,9 @@ def build_box_options(self) -> list[str]:
11321136
if self.chdir is not None:
11331137
res += ["--chdir=%s" % self.chdir]
11341138
for src, dest, options in self.dirs:
1135-
s = dest + "=" + src
1139+
s = dest
1140+
if src is not None:
1141+
s += "=" + src
11361142
if options is not None:
11371143
s += ":" + options
11381144
res += ["--dir=%s" % s]

0 commit comments

Comments
 (0)