File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 11import os
22import shutil
3- import sys
43
4+ from dmoj .cptbox .isolate import DeniedSyscall , protection_fault
55from dmoj .executors .script_executor import ScriptExecutor
66
77
@@ -27,12 +27,11 @@ def get_security(self, launch_kwargs=None):
2727 sec = super ().get_security (launch_kwargs )
2828 allowed = set (self .get_allowed_exec ())
2929
30- def handle_execve (debugger ):
31- path = sec .get_full_path (debugger , debugger .readstr (debugger .uarg0 ))
32- if path in allowed :
33- return True
34- print ('Not allowed to use command:' , path , file = sys .stderr )
35- return False
30+ def handle_execve (debugger ) -> None :
31+ path = sec .get_full_path_unnormalized (debugger , debugger .readstr (debugger .uarg0 ))
32+ path = '/' + os .path .normpath (path ).lstrip ('/' )
33+ if path not in allowed :
34+ raise DeniedSyscall (protection_fault , f'Not allowed to use command: { path } ' )
3635
3736 sec [sys_execve ] = handle_execve
3837 sec [sys_eaccess ] = sec [sys_access ]
You can’t perform that action at this time.
0 commit comments