]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
CI: add a test for bug 14882
authorRalph Boehme <slow@samba.org>
Fri, 29 Oct 2021 04:27:38 +0000 (06:27 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 4 Nov 2021 19:04:31 +0000 (19:04 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14882

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

diff --git a/selftest/knownfail.d/samba3.blackbox.smbXsrv_client_dead_rec b/selftest/knownfail.d/samba3.blackbox.smbXsrv_client_dead_rec
new file mode 100644 (file)
index 0000000..16f8446
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.smbXsrv_client_dead_rec.check_panic\(fileserver:local\)
diff --git a/source3/script/tests/test_smbXsrv_client_dead_rec.sh b/source3/script/tests/test_smbXsrv_client_dead_rec.sh
new file mode 100755 (executable)
index 0000000..0ed10e7
--- /dev/null
@@ -0,0 +1,76 @@
+#!/bin/bash
+#
+# Test smbd doesn't crash if there an existing dead record for a client with a
+# specific client-guid in smbXsrv_client_global.tdb
+#
+
+if [ $# -lt 2 ]; then
+    echo Usage: test_smbXsrv_client_dead_rec.sh SERVERCONFFILE IP SHARENAME
+    exit 1
+fi
+
+CONF=$1
+SERVER=$2
+SHARE=$3
+
+SMBCLIENT="$BINDIR/smbclient"
+SMBSTATUS="$BINDIR/smbstatus"
+
+SMBD_LOG_FILE="$SMBD_TEST_LOG"
+if [ -n "$SMBD_DONT_LOG_STDOUT" ]; then
+       SMBD_LOG_FILE=$(dirname "$SMBD_TEST_LOG")/logs/log.smbd
+fi
+SMBD_LOG_FILE=$(realpath "$SMBD_LOG_FILE")
+
+incdir=$(dirname "$0")/../../../testprogs/blackbox
+. "$incdir"/subunit.sh
+
+failed=0
+
+cd "$SELFTEST_TMPDIR" || exit 1
+
+#
+# Note if we already have any panics in the smbd log.
+#
+panic_count_0=$(grep -c PANIC "$SMBD_LOG_FILE")
+
+# Create the smbclient communication pipes.
+rm -f smbclient-stdin smbclient-stdout smbclient-stderr
+mkfifo smbclient-stdin smbclient-stdout smbclient-stderr
+
+CLI_FORCE_INTERACTIVE=1; export CLI_FORCE_INTERACTIVE
+
+# Connect a first time
+${SMBCLIENT} //"${SERVER}"/"${SHARE}" -U"${USER}"%"${PASSWORD}" \
+            --option="libsmb:client_guid=6112f7d3-9528-4a2a-8861-0ca129aae6c4" \
+            < smbclient-stdin > smbclient-stdout 2>smbclient-stderr &
+CLIENT_PID=$!
+
+exec 100>smbclient-stdin  101<smbclient-stdout 102<smbclient-stderr
+
+export UID_WRAPPER_ROOT=1
+SMBD_PID=$(UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 "$SMBSTATUS" -p "$CONF" | awk '/^[0-9]+/ {print $1}' | sort -u)
+
+# Kill the first connection, leaves dead record in smbXsrv_client_global.tdb
+kill -KILL "$SMBD_PID"
+kill $CLIENT_PID
+
+# Connect a second time
+unset CLI_FORCE_INTERACTIVE
+${SMBCLIENT} //"${SERVER}"/"${SHARE}" -U"${USER}"%"${PASSWORD}" \
+            --option="libsmb:client_guid=6112f7d3-9528-4a2a-8861-0ca129aae6c4" \
+            -c exit
+
+rm -f smbclient-stdin smbclient-stdout aio_outstanding_testfile
+
+#
+# Ensure the panic count didn't change.
+#
+# BUG: https://bugzilla.samba.org/show_bug.cgi?id=14882
+#
+panic_count_1=$(grep -c PANIC "$SMBD_LOG_FILE")
+
+testit "check_panic" test "$panic_count_0" -eq "$panic_count_1" ||
+        failed=$(expr $failed + 1)
+
+testok "$0" "$failed"
index 41ed728a03e738472884ec4417b23d7499f64663..bb47851bbc6fe869c124bd241989910037e4f5f8 100755 (executable)
@@ -1193,6 +1193,13 @@ plantestsuite("samba3.blackbox.smbclient.encryption_off", "simpleserver",
                "$USERNAME", "$PASSWORD", "$SERVER",
                smbclient3])
 
+plantestsuite("samba3.blackbox.smbXsrv_client_dead_rec", "fileserver:local",
+              [os.path.join(samba3srcdir,
+                            "script/tests/test_smbXsrv_client_dead_rec.sh"),
+               configuration,
+               '$SERVER_IP',
+               "tmp"])
+
 for env in ['fileserver', 'simpleserver']:
     plantestsuite("samba3.blackbox.smbclient.encryption", env,
                   [os.path.join(samba3srcdir, "script/tests/test_smbclient_encryption.sh"),