]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:tests: Use awk for parsing hexkeys
authorAndreas Schneider <asn@samba.org>
Fri, 14 Nov 2025 08:50:47 +0000 (09:50 +0100)
committerMartin Schwenke <martins@samba.org>
Thu, 15 Jan 2026 08:01:36 +0000 (08:01 +0000)
This just uses valid hex values and doesn't rely on special positions.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Thu Jan 15 08:01:36 UTC 2026 on atb-devel-224

source3/script/tests/test_net_tdb.sh

index dc1db226571778fbb6179c81de63d94f8aa15115..46fc4a6943a2803a9e115aca6535455c7e84cc15 100755 (executable)
@@ -58,12 +58,20 @@ echo "=== Debug Output for 'tdbtool locking.tdb hexkeys' =="
 $samba_tdbtool "$LOCKDIR/locking.tdb" hexkeys
 echo "=== End Debug Output ==="
 
-# Output of 'tdbtool hexkeys' is in this format:
-#[000] 01 FD 00 00 00 00 00 00  56 02 5C 00 00 00 00 00  ....... V.\....
-#[010] 00 00 00 00 00 00 00 00                           .......
-# Select only the hex data, remove space and join every thing together
-key=0x$("$samba_tdbtool" "$LOCKDIR/locking.tdb" hexkeys |
-       grep '\[' | cut -c 7-56 | sed -e 's/ //g' | tr -d '\n')
+# The above code produces the following output:
+#
+# === Debug Output for 'tdbtool locking.tdb hexkeys' ==
+# key 24 bytes
+# [000] 2B 00 00 00 00 00 00 00  24 40 17 03 00 00 00 00  +...... $@.....
+# [010] 00 00 00 00 00 00 00 00                           .......
+#
+# === End Debug Output ===
+#
+# Select only valid hex byte values and join them together
+key="0x$("$samba_tdbtool" "$LOCKDIR/locking.tdb" hexkeys |
+      awk '/^key/ && seen { exit }
+           /^key/ { seen=1; next }
+           /^\[/ { for(i=2; i<=NF; i++) if($i ~ /^[0-9A-Fa-f][0-9A-Fa-f]$/) printf "%s", $i }')"
 
 echo "=== Debug Output for key =="
 echo "${key}"