@@ -170,16 +170,22 @@ echo "$broker_features" | grep -q " persist" && has_persist=yes
170170has_persist_encrypt=no
171171echo " $broker_features " | grep -q " persist-encrypt" && \
172172 has_persist_encrypt=yes
173+ has_persist_encrypt_dev_key=no
174+ echo " $broker_features " | grep -q " persist-encrypt-dev-key" && \
175+ has_persist_encrypt_dev_key=yes
173176has_static_memory=no
174177echo " $broker_features " | grep -q " static-memory" && \
175178 has_static_memory=yes
176179
177180# Persist-encrypt builds refuse to start without an explicit key source.
178181# CLI tests opt into the development key with -E dev (NOT for production
179- # - the key is a fixed pattern in the binary). For non-encrypt builds
180- # this stays empty so the unknown -E option doesn't trigger usage.
182+ # - the key is a fixed pattern in the binary, only linked into the
183+ # binary when --enable-broker-persist-encrypt-dev-key was passed at
184+ # configure time). For non-encrypt builds and encrypt builds without
185+ # the dev-key hook this stays empty; the encrypt-CLI tests check the
186+ # capability flag explicitly and SKIP when missing.
181187broker_dir_flags=" "
182- if [ " $has_persist_encrypt " = " yes" ]; then
188+ if [ " $has_persist_encrypt_dev_key " = " yes" ]; then
183189 broker_dir_flags=" -E dev"
184190fi
185191
@@ -1214,6 +1220,9 @@ elif [ "$has_persist" = "no" ]; then
12141220 echo " SKIP: Persist round-trip (built without --enable-broker-persist)"
12151221elif [ " $has_retained " = " no" ]; then
12161222 echo " SKIP: Persist round-trip (retained support not built)"
1223+ elif [ " $has_persist_encrypt " = " yes" ] && \
1224+ [ " $has_persist_encrypt_dev_key " = " no" ]; then
1225+ echo " SKIP: Persist round-trip (encrypt build without dev-key CLI hook)"
12171226else
12181227T27_DIR=" ${TMP_DIR} /persist_t27"
12191228mkdir -p " $T27_DIR "
@@ -1259,10 +1268,18 @@ wait $T27_SUB_PID 2>/dev/null || true
12591268TEST_PIDS=()
12601269T27_GOT=no
12611270grep -q " t27_payload" " ${TMP_DIR} /t27_sub.log" 2> /dev/null && T27_GOT=yes
1271+ # On encrypt builds broker_dir_flags includes -E dev, so T27 ends up
1272+ # exercising the encrypted-at-rest round-trip too (T31 still adds the
1273+ # specific no-plaintext-on-disk check). Annotate so the log is honest
1274+ # about what was covered.
1275+ T27_MODE=" plaintext"
1276+ if [ " $has_persist_encrypt_dev_key " = " yes" ]; then
1277+ T27_MODE=" encrypted via -E dev"
1278+ fi
12621279if [ " $T27_GOT " = " yes" ] && [ " $T27_RESTORED " = " yes" ]; then
1263- echo " PASS: Persist round-trip (restored=$T27_RESTORED delivered=$T27_GOT )"
1280+ echo " PASS: Persist round-trip ($T27_MODE ; restored=$T27_RESTORED delivered=$T27_GOT )"
12641281else
1265- echo " FAIL: Persist round-trip (restored=$T27_RESTORED delivered=$T27_GOT )"
1282+ echo " FAIL: Persist round-trip ($T27_MODE ; restored=$T27_RESTORED delivered=$T27_GOT )"
12661283 FAIL=1
12671284fi
12681285fi # has_persist + has_retained
@@ -1291,6 +1308,11 @@ mkdir -p "$T28_DIR/1"
12911308# Write a fake META file with a bogus schema version. Magic "WMQB",
12921309# then schema_ver = 0xFFFF (big endian), rec_kind = 1, body_len = 4,
12931310# body = some bytes.
1311+ # Filename "00.bin" reflects the POSIX backend's key-to-filename
1312+ # encoding: META uses a single 0x00 key byte, which wmqb_hex_encode
1313+ # (in src/mqtt_broker_persist_posix.c) renders as two lowercase hex
1314+ # chars - "00". If that encoding ever changes, update this filename
1315+ # to match.
12941316printf ' WMQB\xff\xff\x00\x01\x00\x00\x00\x04zzzz' > " $T28_DIR /1/00.bin"
12951317if [ $broker_pid != $no_pid ]; then
12961318 kill $broker_pid 2> /dev/null
@@ -1328,6 +1350,9 @@ elif [ "$has_persist" = "no" ]; then
13281350 echo " SKIP: Offline queue (built without --enable-broker-persist)"
13291351elif [ " $has_static_memory " = " yes" ]; then
13301352 echo " SKIP: Offline queue (orphan/outbound-queue is dynamic-memory only)"
1353+ elif [ " $has_persist_encrypt " = " yes" ] && \
1354+ [ " $has_persist_encrypt_dev_key " = " no" ]; then
1355+ echo " SKIP: Offline queue (encrypt build without dev-key CLI hook)"
13311356else
13321357T29_DIR=" ${TMP_DIR} /persist_t29"
13331358mkdir -p " $T29_DIR "
@@ -1399,6 +1424,9 @@ elif [ "$has_persist" = "no" ]; then
13991424 echo " SKIP: Offline queue restart (built without --enable-broker-persist)"
14001425elif [ " $has_static_memory " = " yes" ]; then
14011426 echo " SKIP: Offline queue restart (orphan/outbound-queue is dynamic-memory only)"
1427+ elif [ " $has_persist_encrypt " = " yes" ] && \
1428+ [ " $has_persist_encrypt_dev_key " = " no" ]; then
1429+ echo " SKIP: Offline queue restart (encrypt build without dev-key CLI hook)"
14021430else
14031431T30_DIR=" ${TMP_DIR} /persist_t30"
14041432mkdir -p " $T30_DIR "
@@ -1474,6 +1502,8 @@ if [ "$skip_plain" = "yes" ]; then
14741502 echo " SKIP: AES-GCM persist (plain listener disabled)"
14751503elif [ " $has_persist_encrypt " = " no" ]; then
14761504 echo " SKIP: AES-GCM persist (built without --enable-broker-persist-encrypt)"
1505+ elif [ " $has_persist_encrypt_dev_key " = " no" ]; then
1506+ echo " SKIP: AES-GCM persist (built without --enable-broker-persist-encrypt-dev-key)"
14771507elif [ " $has_retained " = " no" ]; then
14781508 echo " SKIP: AES-GCM persist (retained support not built)"
14791509else
0 commit comments