aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2019-12-28 21:27:45 -0800
committerGravatar MarkKoz <[email protected]>2019-12-28 21:44:40 -0800
commit25219587c0ac2239d42fb82ad32f6c86d2da6e27 (patch)
tree3beca2f39b77076491527f315da0dbeaa05cd866
parentMount /usr/lib so ctypes can use libffi (diff)
Test shared memory is disabled
Co-authored-by: 0xf0f <[email protected]>
-rw-r--r--tests/test_nsjail.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py
index bb176d9..00ca89c 100644
--- a/tests/test_nsjail.py
+++ b/tests/test_nsjail.py
@@ -122,3 +122,30 @@ class NsJailTests(unittest.TestCase):
"INFO:snekbox.nsjail:pid=20 ([STANDALONE MODE]) exited with status: 2, (PIDs left: 0)",
log.output
)
+
+ def test_shm_and_tmp_not_mounted(self):
+ for path in ("/dev/shm", "/run/shm", "/tmp"):
+ with self.subTest(path=path):
+ code = dedent(f"""
+ with open('{path}/test', 'wb') as file:
+ file.write(bytes([255]))
+ """).strip()
+
+ result = self.nsjail.python3(code)
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("No such file or directory", result.stdout)
+ self.assertEqual(result.stderr, None)
+
+ def test_multiprocessing_shared_memory_disabled(self):
+ code = dedent("""
+ from multiprocessing.shared_memory import SharedMemory
+ try:
+ SharedMemory('test', create=True, size=16)
+ except FileExistsError:
+ pass
+ """).strip()
+
+ result = self.nsjail.python3(code)
+ self.assertEqual(result.returncode, 1)
+ self.assertIn("Function not implemented", result.stdout)
+ self.assertEqual(result.stderr, None)