diff --git a/.travis.yml b/.travis.yml index b156c87..bd6dde0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,11 @@ -language: python -dist: trusty -python: - - "2.7" - - "3.5" sudo: required -before_install: - - sudo apt-get -qq update - - sudo apt-get install libseccomp-dev cmake -install: - - mkdir build && cd build - - cmake .. && make && sudo make install - - cd ../bindings/Python && sudo `which python` setup.py install + +services: + - docker + script: - - cd ../../tests/Python_and_core && sudo `which python` test.py -notifications: - slack: onlinejudgeteam:BzBz8UFgmS5crpiblof17K2W + - docker build -t judger-test -f tests/Dockerfile-16.04 . + - docker run -it --rm -v $PWD:/src judger-test /bin/bash -c "chmod +x tests/runtest.sh && ./tests/runtest.sh" + + - docker build -t judger-test -f tests/Dockerfile-18.04 . + - docker run -it --rm -v $PWD:/src judger-test /bin/bash -c "chmod +x tests/runtest.sh && ./tests/runtest.sh" diff --git a/runtest.sh b/runtest.sh deleted file mode 100755 index 906a1a5..0000000 --- a/runtest.sh +++ /dev/null @@ -1,6 +0,0 @@ -rm -rf build && mkdir build && cd build && cmake .. -make || exit 1 -make install -cd ../bindings/Python && rm -rf build -python setup.py install || exit 1 -cd ../../tests/Python_and_core && python test.py diff --git a/src/rules/c_cpp.c b/src/rules/c_cpp.c index e5299d5..fcd7ee9 100644 --- a/src/rules/c_cpp.c +++ b/src/rules/c_cpp.c @@ -37,6 +37,9 @@ int c_cpp_seccomp_rules(struct config *_config) { if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open), 1, SCMP_CMP(1, SCMP_CMP_MASKED_EQ, O_WRONLY | O_RDWR, 0)) != 0) { return LOAD_SECCOMP_FAILED; } + if (seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat), 1, SCMP_CMP(2, SCMP_CMP_MASKED_EQ, O_WRONLY | O_RDWR, 0)) != 0) { + return LOAD_SECCOMP_FAILED; + } if (seccomp_load(ctx) != 0) { return LOAD_SECCOMP_FAILED; } diff --git a/tests/Dockerfile-16.04 b/tests/Dockerfile-16.04 new file mode 100644 index 0000000..9679e81 --- /dev/null +++ b/tests/Dockerfile-16.04 @@ -0,0 +1,3 @@ +FROM ubuntu:16.04 +RUN apt-get update && apt-get install -y cmake python python3 libseccomp-dev gcc g++ +WORKDIR /src diff --git a/tests/Dockerfile-18.04 b/tests/Dockerfile-18.04 new file mode 100644 index 0000000..59c3f1c --- /dev/null +++ b/tests/Dockerfile-18.04 @@ -0,0 +1,3 @@ +FROM ubuntu:18.04 +RUN apt-get update && apt-get install -y cmake python python3 python3-pip libseccomp-dev gcc g++ strace && pip3 install setuptools --upgrade +WORKDIR /src \ No newline at end of file diff --git a/tests/runtest.sh b/tests/runtest.sh new file mode 100755 index 0000000..76ed9c7 --- /dev/null +++ b/tests/runtest.sh @@ -0,0 +1,16 @@ +#! /bin/bash +set -ex +dir=$PWD +python -V +gcc -v +g++ -v + +for py in python2 python3; do + cd $dir + rm -rf build && mkdir build && cd build && cmake .. + make + make install + cd ../bindings/Python && rm -rf build + $py setup.py install + cd ../../tests/Python_and_core && $py test.py +done