diff options
-rw-r--r-- | snekbox/memfs.py | 11 | ||||
-rw-r--r-- | snekbox/nsjail.py | 7 |
2 files changed, 3 insertions, 15 deletions
diff --git a/snekbox/memfs.py b/snekbox/memfs.py index 2372d43..bc8313d 100644 --- a/snekbox/memfs.py +++ b/snekbox/memfs.py @@ -5,7 +5,6 @@ import logging import os import subprocess from collections.abc import Generator -from contextlib import contextmanager from pathlib import Path from threading import BoundedSemaphore from types import TracebackType @@ -20,14 +19,12 @@ PID = os.getpid() NAMESPACE_DIR = Path("/memfs") NAMESPACE_DIR.mkdir(exist_ok=True) -NAMESPACE_DIR.chmod(0o711) # Execute only access for other users def mount_tmpfs(name: str, size: int | str) -> Path: """Create and mount a tmpfs directory.""" tmp = NAMESPACE_DIR / name tmp.mkdir() - tmp.chmod(0o711) # Mount the tmpfs subprocess.check_call( [ @@ -112,14 +109,6 @@ class MemFS: folder.chmod(chmod) return folder - @contextmanager - def allow_write(self) -> None: - """Temporarily allow writes to the root tempdir.""" - backup = self.path.stat().st_mode - self.path.chmod(0o777) - yield - self.path.chmod(backup) - def attachments( self, max_count: int, max_size: int | None = None ) -> Generator[FileAttachment, None, None]: diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py index 6866377..556aab2 100644 --- a/snekbox/nsjail.py +++ b/snekbox/nsjail.py @@ -215,10 +215,9 @@ class NsJail: case (True, _) | (None, False): args.append("main.py") # Write the code to a file - with fs.allow_write(): - code_path = fs.home / "main.py" - code_path.write_text(code) - log.info(f"Created code file at [{code_path!r}].") + code_path = fs.home / "main.py" + code_path.write_text(code) + log.info(f"Created code file at [{code_path!r}].") case _: args.append(code) |