Merge pull request #32 from QingdaoU/allow_time

allow clock_gettime syscall
This commit is contained in:
李扬 2019-07-27 17:17:43 +08:00 committed by GitHub
commit 9421828a11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 1 deletions

View File

@ -16,7 +16,8 @@ int _c_cpp_seccomp_rules(struct config *_config, bool allow_write_file) {
SCMP_SYS(access), SCMP_SYS(exit_group),
SCMP_SYS(close), SCMP_SYS(readlink),
SCMP_SYS(sysinfo), SCMP_SYS(write),
SCMP_SYS(writev), SCMP_SYS(lseek)};
SCMP_SYS(writev), SCMP_SYS(lseek),
SCMP_SYS(clock_gettime)};
int syscalls_whitelist_length = sizeof(syscalls_whitelist) / sizeof(int);
scmp_filter_ctx ctx = NULL;

View File

@ -327,3 +327,11 @@ class IntegrationTest(base.BaseTestCase):
result = _judger.run(**config)
self.assertEqual(result["result"], _judger.RESULT_SUCCESS)
def test_get_time(self):
config = self.base_config
config["exe_path"] = self._compile_c("time.c")
config["seccomp_rule_name"] = "c_cpp"
result = _judger.run(**config)
self.assertEqual(result["result"], _judger.RESULT_SUCCESS)

View File

@ -0,0 +1,7 @@
#include <time.h>
#include <stdio.h>
int main () {
clock();
return 0;
}