From 13d199bea0f39fafd2bf39516d83e20893003aa2 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Jun 2023 14:54:00 +0200 Subject: [PATCH] tests: Show smbd returns wrong error code when creating on r/o fs Bug: https://bugzilla.samba.org/show_bug.cgi?id=15402 Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- selftest/knownfail.d/rofs | 1 + source3/script/tests/test_rofs.sh | 34 ++++++++++++++++++++++++++++++++++ source3/selftest/tests.py | 7 +++++++ 3 files changed, 42 insertions(+) create mode 100644 selftest/knownfail.d/rofs create mode 100755 source3/script/tests/test_rofs.sh diff --git a/selftest/knownfail.d/rofs b/selftest/knownfail.d/rofs new file mode 100644 index 00000000000..dd130773404 --- /dev/null +++ b/selftest/knownfail.d/rofs @@ -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 index 00000000000..72901e5845a --- /dev/null +++ b/source3/script/tests/test_rofs.sh @@ -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 diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 2bc4d372095..b1e33595ad8 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -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, -- 2.11.4.GIT