From: Andreas Schneider Date: Fri, 14 Nov 2025 08:50:47 +0000 (+0100) Subject: s3:tests: Use awk for parsing hexkeys X-Git-Tag: tdb-1.4.15~62 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d638f2101f523e42becf7a3cf2547fcf6752b02;p=thirdparty%2Fsamba.git s3:tests: Use awk for parsing hexkeys This just uses valid hex values and doesn't rely on special positions. Signed-off-by: Andreas Schneider Reviewed-by: Martin Schwenke Reviewed-by: Anoop C S Autobuild-User(master): Martin Schwenke Autobuild-Date(master): Thu Jan 15 08:01:36 UTC 2026 on atb-devel-224 --- diff --git a/source3/script/tests/test_net_tdb.sh b/source3/script/tests/test_net_tdb.sh index dc1db226571..46fc4a6943a 100755 --- a/source3/script/tests/test_net_tdb.sh +++ b/source3/script/tests/test_net_tdb.sh @@ -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}"