tests: Show smbd returns wrong error code when creating on r/o fs
authorVolker Lendecke <vl@samba.org>
Mon, 26 Jun 2023 12:54:00 +0000 (14:54 +0200)
committerVolker Lendecke <vl@samba.org>
Mon, 26 Jun 2023 15:53:36 +0000 (15:53 +0000)
Bug: https://bugzilla.samba.org/show_bug.cgi?id=15402
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
selftest/knownfail.d/rofs [new file with mode: 0644]
source3/script/tests/test_rofs.sh [new file with mode: 0755]
source3/selftest/tests.py

diff --git a/selftest/knownfail.d/rofs b/selftest/knownfail.d/rofs
new file mode 100644 (file)
index 0000000..dd13077
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.rofs_error.*
\ No newline at end of file
diff --git a/source3/script/tests/test_rofs.sh b/source3/script/tests/test_rofs.sh
new file mode 100755 (executable)
index 0000000..72901e5
--- /dev/null
@@ -0,0 +1,34 @@
+#!/usr/bin/env bash
+# Test smbd handling EROFS when creating a file
+# Copyright (C) 2023 Volker Lendecke
+
+if [ $# -ne 4 ]; then
+       echo Usage: $0 SERVERCONFFILE SMBCLIENT SERVER SHARE
+       exit 1
+fi
+
+CONF=$1
+shift 1
+SMBCLIENT=$1
+shift 1
+SERVER=$1
+shift 1
+SHARE=$1
+shift 1
+
+incdir=$(dirname $0)/../../../testprogs/blackbox
+. $incdir/subunit.sh
+
+error_inject_conf=$(dirname ${SERVERCONFFILE})/error_inject.conf
+echo "error_inject:openat_create = EROFS" >${error_inject_conf}
+
+failed=0
+
+out=$(${SMBCLIENT} //${SERVER}/${SHARE} ${CONF} -U${USER}%${PASSWORD} \
+                  -c "put VERSION")
+testit_grep "Expect MEDIA_WRITE_PROTECTED" NT_STATUS_MEDIA_WRITE_PROTECTED \
+    echo "$out" || failed=$(expr $failed + 1)
+
+>${error_inject_conf}
+
+testok $0 $failed
index 2bc4d37209564776bba88f3915d729ddb0923197..b1e33595ad8aad7c92647e1cedba06b48199e4aa 100755 (executable)
@@ -1447,6 +1447,13 @@ plantestsuite("samba3.blackbox.chdir-cache", "simpleserver:local",
                '$PREFIX',
                'simpleserver'])
 
+plantestsuite("samba3.blackbox.rofs_error", "simpleserver",
+              [os.path.join(samba3srcdir, "script/tests/test_rofs.sh"),
+               configuration,
+               os.path.join(bindir(), "smbclient"),
+               '$SERVER_IP',
+               "error_inject"])
+
 plantestsuite("samba3.blackbox.zero_readsize",
               "simpleserver:local",
               [os.path.join(samba3srcdir,