From 3887c5f8370dd135d82d16d68b1a6c9284147680 Mon Sep 17 00:00:00 2001 From: virusdefender Date: Fri, 7 Oct 2016 17:22:51 +0800 Subject: [PATCH] =?UTF-8?q?judger=E9=87=8D=E6=9E=84=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/Python/languages.py | 4 ++-- compiler.py | 2 +- judge_client.py | 10 ++++------ 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/client/Python/languages.py b/client/Python/languages.py index c9cd1e1..2965668 100644 --- a/client/Python/languages.py +++ b/client/Python/languages.py @@ -12,7 +12,7 @@ c_lang_config = { }, "run": { "command": "{exe_path}", - "seccomp_rule": None + "seccomp_rule": "c_cpp" }, "spj_compile": { "src_name": "spj-{spj_version}.c", @@ -42,7 +42,7 @@ cpp_lang_config = { }, "run": { "command": "{exe_path}", - "seccomp_rule": None, + "seccomp_rule": "c_cpp", "max_process_number": -1 } } diff --git a/compiler.py b/compiler.py index 6bbdf85..907d07e 100644 --- a/compiler.py +++ b/compiler.py @@ -32,7 +32,7 @@ class Compiler(object): args=[item.encode("utf-8") for item in _command[1::]], env=[("PATH=" + os.getenv("PATH")).encode("utf-8")], log_path=COMPILER_LOG_PATH, - seccomp_rule_so_path=None, + seccomp_rule_name=None, uid=LOW_PRIVILEDGE_UID, gid=LOW_PRIVILEDGE_GID) diff --git a/judge_client.py b/judge_client.py index 3f36d32..b5c4746 100644 --- a/judge_client.py +++ b/judge_client.py @@ -51,10 +51,6 @@ class JudgeClient(object): except ValueError: raise JudgeClientError("Bad test case config") - def _seccomp_rule_path(self, rule_name): - if rule_name: - return "/usr/lib/judger/librule_{rule_name}.so".format(rule_name=rule_name).encode("utf-8") - def _compare_output(self, test_case_file_id): user_output_file = os.path.join(self._submission_dir, str(test_case_file_id) + ".out") try: @@ -68,6 +64,7 @@ class JudgeClient(object): command = self._spj_config["command"].format(exe_path=self._spj_exe, in_file_path=in_file_path, user_out_file_path=user_out_file_path).split(" ") + seccomp_rule_name = self._spj_config["seccomp_rule"].encode("utf-8") if self._spj_config["seccomp_rule"] else None result = _judger.run(max_cpu_time=self._max_cpu_time * 3, max_real_time=self._max_cpu_time * 9, max_memory=self._max_memory * 3, @@ -80,7 +77,7 @@ class JudgeClient(object): args=[item.encode("utf-8") for item in command[1::]], env=[("PATH=" + os.environ.get("PATH", "")).encode("utf-8")], log_path=JUDGER_RUN_LOG_PATH, - seccomp_rule_so_path=self._seccomp_rule_path(self._spj_config["seccomp_rule"]), + seccomp_rule_name=seccomp_rule_name, uid=LOW_PRIVILEDGE_UID, gid=LOW_PRIVILEDGE_GID) @@ -97,6 +94,7 @@ class JudgeClient(object): command = self._run_config["command"].format(exe_path=self._exe_path, exe_dir=os.path.dirname(self._exe_path), max_memory=self._max_memory / 1024).split(" ") + seccomp_rule_name = self._run_config["seccomp_rule"].encode("utf-8") if self._run_config["seccomp_rule"] else None run_result = _judger.run(max_cpu_time=self._max_cpu_time, max_real_time=self._max_real_time, @@ -110,7 +108,7 @@ class JudgeClient(object): args=[item.encode("utf-8") for item in command[1::]], env=[("PATH=" + os.getenv("PATH", "")).encode("utf-8")], log_path=JUDGER_RUN_LOG_PATH, - seccomp_rule_so_path=self._seccomp_rule_path(self._run_config["seccomp_rule"]), + seccomp_rule_name=seccomp_rule_name, uid=LOW_PRIVILEDGE_UID, gid=LOW_PRIVILEDGE_GID) run_result["test_case"] = test_case_file_id