From 8daa83a594a2e98f39d764422bfbdbc62c9efd44 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 19:20:00 +0200 Subject: Adding upstream version 2:4.20.0+dfsg. Signed-off-by: Daniel Baumann --- source3/script/tests/test_worm.sh | 121 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100755 source3/script/tests/test_worm.sh (limited to 'source3/script/tests/test_worm.sh') diff --git a/source3/script/tests/test_worm.sh b/source3/script/tests/test_worm.sh new file mode 100755 index 0000000..f96c8ec --- /dev/null +++ b/source3/script/tests/test_worm.sh @@ -0,0 +1,121 @@ +#!/bin/sh + +if [ $# -lt 7 ]; then + cat < $tmpfile + # make sure the directory is not too old for worm: + touch $share_test_dir + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/worm -I$SERVER_IP $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=$(eval "$cmd") + ret=$? + rm -f "$tmpfile" + + if [ $ret != 0 ]; then + printf "%s\n" "$out" + printf "failed worm smbclient run with error %s\n" "$ret" + return 1 + fi + test -e $share_test_dir/must-be-deleted && { + printf "$0: ERROR: must-be-deleted was NOT deleted\n" + return 1 + } + + # now sleep grace_period (1s) and check if worm works properly: + sleep 1 + echo " +posix +chmod 700 must-not-be-deleted +del must-not-be-deleted +del must-be-deleted-after-ctime-refresh +quit" > $tmpfile + # make sure the directory itself is not too old for worm: + touch $share_test_dir + # set a fresh ctime by doing a chmod: + chmod 644 $share_test_dir/must-be-deleted-after-ctime-refresh + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/worm -I$SERVER_IP $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=$(eval "$cmd") + test -e $share_test_dir/must-not-be-deleted || { + printf "$0: ERROR: must-not-be-deleted WAS deleted\n" + return 1 + } + # if we're not root, return here: + test "$UID" = "0" || { + return 0 + } + + test -e $share_test_dir/must-be-deleted-after-ctime-refresh && { + printf "$0: ERROR: must-be-deleted-after-ctime-refresh was NOT deleted\n" + return 1 + } + return 0 +} + + +testit "worm" \ + test_worm || + failed=$((failed + 1)) + +# +# Cleanup. +do_cleanup + +testok "$0" "$failed" -- cgit v1.2.3