From 8f04c131cb71295d2f496fa7889d0e6995baf77c Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Fri, 3 Jun 2022 09:47:11 -0700 Subject: [PATCH] Add --skip-file-rwx-check opt test Add a simple test using tail to check that processes can't be restored by default when the r/w/x mode of an open file changes, unless --skip-file-rwx-check is used. Signed-off-by: Younes Manton --- scripts/ci/run-ci-tests.sh | 1 + test/Makefile | 2 +- test/others/skip-file-rwx-check/Makefile | 7 +++++ test/others/skip-file-rwx-check/run.sh | 37 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 test/others/skip-file-rwx-check/Makefile create mode 100755 test/others/skip-file-rwx-check/run.sh diff --git a/scripts/ci/run-ci-tests.sh b/scripts/ci/run-ci-tests.sh index 8d9de6e55..3760a65e3 100755 --- a/scripts/ci/run-ci-tests.sh +++ b/scripts/ci/run-ci-tests.sh @@ -260,6 +260,7 @@ if [ -n "$TRAVIS" ] || [ -n "$CIRCLECI" ]; then # Error (criu/tty.c:1014): tty: Don't have tty to inherit session from, aborting make -C test/others/shell-job/ run fi +make -C test/others/skip-file-rwx-check/ run make -C test/others/rpc/ run ./test/zdtm.py run -t zdtm/static/env00 --sibling diff --git a/test/Makefile b/test/Makefile index 8416b1961..e8fcffe3f 100644 --- a/test/Makefile +++ b/test/Makefile @@ -12,7 +12,7 @@ all: $(MAKE) zdtm-freezer .PHONY: all -TESTS = unix-callback mem-snap rpc libcriu mounts/ext security pipes crit socketpairs overlayfs mnt-ext-dev shell-job +TESTS = unix-callback mem-snap rpc libcriu mounts/ext security pipes crit socketpairs overlayfs mnt-ext-dev shell-job skip-file-rwx-check other: for t in $(TESTS); do \ diff --git a/test/others/skip-file-rwx-check/Makefile b/test/others/skip-file-rwx-check/Makefile new file mode 100644 index 000000000..419d592b7 --- /dev/null +++ b/test/others/skip-file-rwx-check/Makefile @@ -0,0 +1,7 @@ +.PHONY: run clean + +run: + ./run.sh + +clean: + rm -rf testfile *.img dump.log restore-expected-fail.log restore.log stats-dump stats-restore diff --git a/test/others/skip-file-rwx-check/run.sh b/test/others/skip-file-rwx-check/run.sh new file mode 100755 index 000000000..0803d78ec --- /dev/null +++ b/test/others/skip-file-rwx-check/run.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail +set -o xtrace + +source ../env.sh + +make clean +touch testfile +chmod +w testfile +tail --follow testfile & +tailpid=$! +if ! "$criu" dump --tree=$tailpid --shell-job --verbosity=4 --log-file=dump.log +then + kill $tailpid + echo "Failed to dump process as expected" + echo FAIL + exit 1 +fi +chmod -w testfile +if "$criu" restore --restore-detached --shell-job --verbosity=4 --log-file=restore-expected-fail.log +then + kill $tailpid + echo "Unexpectedly restored process with reference to a file who's r/w/x perms changed when --skip-file-rwx-check option was not used" + echo FAIL + exit 1 +fi +if ! "$criu" restore --skip-file-rwx-check --restore-detached --shell-job --verbosity=4 --log-file=restore.log +then + echo "Failed to restore process with reference to a file who's r/w/x perms changed when --skip-file-rwx-check option was used" + echo FAIL + exit 1 +fi +kill $tailpid +echo PASS