]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-selftest: add tests for winbindd_cache.tdb sanity
authorGünther Deschner <gd@samba.org>
Fri, 25 Jul 2025 15:58:59 +0000 (17:58 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 8 Dec 2025 08:56:33 +0000 (08:56 +0000)
Guenther

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15963

Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
selftest/knownfail
source3/script/tests/test_winbind_cache_sanity.sh [new file with mode: 0755]
source3/selftest/tests.py

index ab2d79d7114edb6ee29eafd4ef5e4ce84921471b..e077fbc85530c8b9ae9cff5e390beaf63c8957d7 100644 (file)
 
 # We currently don't send referrals for LDAP modify of non-replicated attrs
 ^samba4.ldap.rodc.python\(rodc\).__main__.RodcTests.test_modify_nonreplicated.*
+
+# Currently winbindd_cache.tdb is not working as expected
+^samba3.winbind_cache_sanity.WINBINDD_CACHE_VERSION.*
+^samba3.winbind_cache_sanity.SEQNUM.*
+^samba3.winbind_cache_sanity.NDR.*
diff --git a/source3/script/tests/test_winbind_cache_sanity.sh b/source3/script/tests/test_winbind_cache_sanity.sh
new file mode 100755 (executable)
index 0000000..65d4e4c
--- /dev/null
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+if [ $# -lt 2 ]; then
+       cat <<EOF
+Usage: test_winbind_cache_sanity.sh DOMAIN CACHE
+EOF
+       exit 1
+fi
+
+DOMAIN="$1"
+CACHE="$2"
+shift 2
+ADDARGS="$*"
+
+TDBTOOL=tdbtool
+if test -x "$BINDIR"/tdbtool; then
+       TDBTOOL=$BINDIR/tdbtool
+fi
+DBWRAP_TOOL=$BINDIR/dbwrap_tool
+WBINFO=$BINDIR/wbinfo
+
+incdir=$(dirname "$0")/../../../testprogs/blackbox
+. "$incdir"/subunit.sh
+
+
+#################################################
+## Test "$CACHE" presence
+#################################################
+
+testit "$CACHE presence" \
+       test -r "$CACHE" \
+       || failed=$((failed + 1))
+
+
+#################################################
+## Test very simple wbinfo query to fill up cache with NDR/ and SEQNUM/ entries
+#################################################
+
+separator=$("$WBINFO" --separator)
+
+testit "calling wbinfo -n$DOMAIN$separator to fillup cache" \
+       "$VALGRIND" "$WBINFO" -n "$DOMAIN$separator" \
+       "$ADDARGS" \
+       || failed=$((failed + 1))
+
+
+#################################################
+## Test "WINBINDD_CACHE_VERSION" presence
+#################################################
+
+KEY="WINBINDD_CACHE_VERSION"
+WINBINDD_CACHE_VER2=2
+
+testit "$KEY presence via dbwrap" \
+       "$VALGRIND" "$DBWRAP_TOOL" --persistent "$CACHE" fetch $KEY uint32 \
+       "$ADDARGS" \
+       || failed=$((failed + 1))
+
+#tdbtool will never fail so we have to parse the output...
+testit_grep "$KEY presence via tdbtool" "data 4 bytes" \
+       "$VALGRIND" "$TDBTOOL" "$CACHE" show "$KEY\\00" \
+       "$ADDARGS" \
+       || failed=$((failed + 1))
+
+current_ver=$("$DBWRAP_TOOL" --persistent "$CACHE" fetch $KEY uint32)
+
+testit "$KEY value via dbwrap to be WINBINDD_CACHE_VER2" \
+       test "$current_ver" = $WINBINDD_CACHE_VER2 \
+       || failed=$((failed + 1))
+
+
+#################################################
+## Test "SEQNUM/$DOMAIN" presence
+#################################################
+
+KEY="SEQNUM/$DOMAIN"
+
+testit "$KEY SEQNUM presence via dbwrap" \
+       "$VALGRIND" "$DBWRAP_TOOL" --persistent "$CACHE" exists "$KEY" \
+       "$ADDARGS" \
+       || failed=$((failed + 1))
+
+#tdbtool will never fail so we have to parse the output...
+testit_grep "$KEY SEQNUM presence via tdbtool" "data 8 bytes" \
+       "$VALGRIND" "$TDBTOOL" "$CACHE" show "$KEY\\00" \
+       "$ADDARGS" \
+       || failed=$((failed + 1))
+
+
+#################################################
+## Test "NDR/$DOMAIN/3/\09\00\00\00\00\00\00\00\09\00\00\00$DOMAIN\00\00\00\00\01\00\00\00\00\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00" presence
+## this is the resulting cache entry for a simple
+## wbinfo -n $DOMAIN\ query
+#################################################
+
+opnum=$($PYTHON -c'from samba.dcerpc.winbind import wbint_LookupName; print(wbint_LookupName.opnum())')
+KEY="NDR/$DOMAIN/$opnum/\\09\\00\\00\\00\\00\\00\\00\\00\\09\\00\\00\\00$DOMAIN\\00\\00\\00\\00\\01\\00\\00\\00\\00\\00\\00\\00\\01\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00\\00"
+
+#DBWRAP_TOOL does not support non-null terminated keys so it cannot find it...
+#testit "$KEY NDR presence via dbwrap" \
+#      "$VALGRIND" "$DBWRAP_TOOL" --persistent $CACHE exists $KEY \
+#      "$ADDARGS" \
+#      || failed=$((failed + 1))
+
+#tdbtool will never fail so we have to parse the output...
+# key 59 bytes
+testit_grep "$KEY NDR presence via tdbtool" "data 44 bytes" \
+       "$VALGRIND" "$TDBTOOL" "$CACHE" show "$KEY" \
+       "$ADDARGS" \
+       || failed=$((failed + 1))
+
+testok "$0" "$failed"
index 02046bcf1cb22de8d6a11da094cf96e1b26d18aa..7cad85fc4cbccc31ba9f913854a15b0fab18b806 100755 (executable)
@@ -718,6 +718,10 @@ plantestsuite("samba3.winbind_call_depth_trace", env,
               [os.path.join(srcdir(),
                             "source3/script/tests/test_winbind_call_depth_trace.sh"),
                smbcontrol, configuration, '$PREFIX', env])
+plantestsuite("samba3.winbind_cache_sanity", env,
+              [os.path.join(srcdir(),
+                            "source3/script/tests/test_winbind_cache_sanity.sh"),
+               '$DOMAIN', '$LOCK_DIR/winbindd_cache.tdb'])
 
 env = "fl2008r2dc:local"
 plantestsuite("samba3.wbinfo_user_info", env,