diff options
-rw-r--r-- | snekbox/memfs.py | 16 | ||||
-rw-r--r-- | snekbox/nsjail.py | 2 |
2 files changed, 11 insertions, 7 deletions
diff --git a/snekbox/memfs.py b/snekbox/memfs.py index 035efed..abc10ad 100644 --- a/snekbox/memfs.py +++ b/snekbox/memfs.py @@ -80,10 +80,10 @@ class MemFS: def mkdir(self, path: str, chmod: int = 0o777) -> Path: """Create a directory in the tempdir.""" - f = Path(self.path, path) - f.mkdir(parents=True, exist_ok=True) - f.chmod(chmod) - return f + folder = Path(self.path, path) + folder.mkdir(parents=True, exist_ok=True) + folder.chmod(chmod) + return folder def __enter__(self) -> MemFS: # Generates a uuid tempdir @@ -93,10 +93,14 @@ class MemFS: if name not in self.assigned_names: self.path = mount_tmpfs(name, self.instance_size) self.assigned_names.add(name) - return self + break else: raise RuntimeError("Failed to generate a unique tempdir name in 10 attempts") + self.mkdir("home") + self.mkdir("dev/shm") + return self + def __exit__( self, exc_type: Type[BaseException] | None, @@ -121,7 +125,7 @@ class MemFS: # Look for any file starting with `output` for file in self.home.glob("output*"): if count > max_count: - log.warning("Maximum number of attachments reached, skipping remaining files") + log.info(f"Max attachments {max_count} reached, skipping remaining files") break if file.is_file(): count += 1 diff --git a/snekbox/nsjail.py b/snekbox/nsjail.py index 8b3f6cd..b9e85b7 100644 --- a/snekbox/nsjail.py +++ b/snekbox/nsjail.py @@ -246,7 +246,7 @@ class NsJail: ) log.info(f"Found {len(attachments)} attachments.") except AttachmentError as err: - log.warning(f"Failed to parse attachments: {err}") + log.info(f"Failed to parse attachments: {err}") return EvalResult(args, returncode, f"AttachmentError: {err}") log_lines = nsj_log.read().decode("utf-8").splitlines() |