diff --git a/tests/Python_and_core/testcase/seccomp/test.py b/tests/Python_and_core/testcase/seccomp/test.py index 8617afe..659fc29 100644 --- a/tests/Python_and_core/testcase/seccomp/test.py +++ b/tests/Python_and_core/testcase/seccomp/test.py @@ -109,7 +109,7 @@ class SeccompTest(base.BaseTestCase): config["exe_path"] = self._compile_c("write_file_openat.c") config["output_path"] = config["error_path"] = self.output_path() path = os.path.join(self.workspace, "file3.txt") - config["args"] = [self.workspace, "file3.txt", "w"] + config["args"] = [path, "w"] result = _judger.run(**config) # without seccomp self.assertEqual(result["result"], _judger.RESULT_SUCCESS) @@ -132,7 +132,7 @@ class SeccompTest(base.BaseTestCase): config["exe_path"] = self._compile_c("write_file_openat.c") config["output_path"] = config["error_path"] = self.output_path() path = os.path.join(self.workspace, "file4.txt") - config["args"] = [self.workspace, "file4.txt", "w+"] + config["args"] = [path, "w+"] result = _judger.run(**config) # without seccomp self.assertEqual(result["result"], _judger.RESULT_SUCCESS) diff --git a/tests/test_src/seccomp/write_file_openat.c b/tests/test_src/seccomp/write_file_openat.c index 75cda60..316f0b0 100644 --- a/tests/test_src/seccomp/write_file_openat.c +++ b/tests/test_src/seccomp/write_file_openat.c @@ -1,26 +1,20 @@ -#include +#include #include #include #include -#include -#include -#include -#include int main(int argc, char *argv[]) { - DIR *dir = opendir(argv[1]); - int dir_fd = dirfd(dir); int flags; - if (!strcmp(argv[3], "w")) { + if (!strcmp(argv[2], "w")) { flags = O_WRONLY | O_CREAT; } else { flags = O_RDWR | O_CREAT; } - int fd = openat(dir_fd, argv[2], flags, 0755); + int fd = openat(0, argv[1], flags, 0755); if (fd < 0) { - return errno; + return errno; } close(fd); return 0; -} \ No newline at end of file +}