]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: add a test that verifies unlink works when "force user" is set
authorRalph Boehme <slow@samba.org>
Mon, 25 Jan 2021 10:48:32 +0000 (11:48 +0100)
committerJeremy Allison <jra@samba.org>
Tue, 26 Jan 2021 02:55:28 +0000 (02:55 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14617

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/samba3.blackbox.force-user-unlink [new file with mode: 0644]
source3/script/tests/test_force_user_unlink.sh [new file with mode: 0755]
source3/selftest/tests.py

diff --git a/selftest/knownfail.d/samba3.blackbox.force-user-unlink b/selftest/knownfail.d/samba3.blackbox.force-user-unlink
new file mode 100644 (file)
index 0000000..6761bd8
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.force-user-unlink.test_forced_user_can_delete\(maptoguest:local\)
diff --git a/source3/script/tests/test_force_user_unlink.sh b/source3/script/tests/test_force_user_unlink.sh
new file mode 100755 (executable)
index 0000000..8607653
--- /dev/null
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Test unlink on share with "force user"
+#
+# Copyright (C) 2021 Ralph Boehme
+
+incdir=$(dirname $0)/../../../testprogs/blackbox
+. $incdir/subunit.sh
+. $incdir/common_test_fns.inc
+
+smbclient="$BINDIR/smbclient"
+error_inject_conf=$(dirname ${SMB_CONF_PATH})/error_inject.conf
+failed=0
+
+test_forced_user_can_delete() {
+    out=$($smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "rm dir/file")
+    if [ $? -ne 0 ] ; then
+       echo $out
+       return 1
+    fi
+    tmp=$(echo $out | grep NT_STATUS_ )
+    if [ $? -eq 0 ] ; then
+       return 1
+    fi
+    return 0
+}
+
+echo "error_inject:unlinkat = EACCES" > ${error_inject_conf}
+
+$smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "mkdir dir" || failed=`expr $failed + 1`
+$smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "put WHATSNEW.txt dir/file" || failed=`expr $failed + 1`
+
+testit "test_forced_user_can_delete" test_forced_user_can_delete || failed=`expr $failed + 1`
+
+rm ${error_inject_conf}
+
+# Clean up after ourselves.
+$smbclient -U $DOMAIN/$USERNAME%$PASSWORD //$SERVER_IP/force_user_error_inject -c "del dir/file; rmdir dir"
+
+testok $0 $failed
index 0250eb116840c7997a4d533a4adc81eecad23589..6f65bf5ef9d71901ff5abbeb188cd1c4610ac7d5 100755 (executable)
@@ -1189,6 +1189,11 @@ plantestsuite(
      "bin/samba-tool",
      '$DNSNAME'])
 
+plantestsuite("samba3.blackbox.force-user-unlink",
+              "maptoguest:local",
+              [os.path.join(samba3srcdir,
+                            "script/tests/test_force_user_unlink.sh")])
+
 def planclusteredmembertestsuite(tname, prefix):
     '''Define a clustered test for the clusteredmember environment'''