Skip to content

Commit bb8c6be

Browse files
committed
Refine STATUS/NOTE/INFO logging for consistent UX and accurate terminology
- doc/logging.md: Complete rewrite with clear INFO/NOTE/WARN guidance, table with sleep/blank-line columns, add measuring_trace.log to Quiet mode table - initrd/bin/cbfs-init.sh: Add STATUS_OK for flash read, streamline messages - initrd/bin/gpg-gui.sh: Change INFO to NOTE for GPG instructions - initrd/bin/gui-init.sh: Remove noisy STATUS pairs, add enable_usb for GPG, add STATUS for HOTP verification - initrd/bin/kexec-insert-key.sh: Improve DUK measuring message - initrd/bin/kexec-seal-key.sh: Add STATUS_OK for key gen, slot update, PCR read - initrd/bin/kexec-select-boot.sh: Fix "unsigned boot options" -> "boot options" - initrd/bin/lock_chip.sh: Add STATUS_OK for chipset lock - initrd/bin/network-init-recovery.sh: Add STATUS_OK for modules, clock, SSH - initrd/bin/oem-factory-reset.sh: Many STATUS_OK additions, INFO->NOTE for guidance - initrd/bin/qubes-measure-luks.sh, uefi-init.sh, usb-init.sh: Improve PCR messages - initrd/bin/seal-hotpkey.sh: Add STATUS/STATUS_OK for HOTP secret write - initrd/bin/seal-totp.sh: Change STATUS to NOTE for TOTP secret - initrd/bin/tpmr.sh: Add STATUS/STATUS_OK, INFO->WARN for unseal, add PCR extend INFO - initrd/bin/unseal-hotp.sh: Add STATUS/STATUS_OK for unseal - initrd/etc/functions.sh: PCR5 regression fix (don't auto-load USB), VID wait loop fixes (sleep 0.1, iteration cap), pcrs() formatting fix - initrd/etc/gui_functions.sh: Remove redundant STATUS_OK, add for signing key verification - initrd/init: echo->STATUS_OK, add measuring_trace.log, fix grammar - initrd/sbin/insmod.sh: Improve PCR extend message Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent 4243e7f commit bb8c6be

21 files changed

Lines changed: 251 additions & 134 deletions

doc/logging.md

Lines changed: 96 additions & 53 deletions
Large diffs are not rendered by default.

initrd/bin/cbfs-init.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ if [ -z "$CONFIG_PCR" ]; then
2424
fi
2525

2626
if [ "$CONFIG_CBFS_VIA_FLASHPROG" = "y" ]; then
27-
# Use flashrom directly, because we don't have /tmp/config with params for flash.sh yet
28-
STATUS "Reading board keys and configuration from SPI flash"
27+
# Workaround: cbfs cannot read CBFS directly on rom_hole boards
28+
# See: https://github.com/osresearch/flashtools/issues/10
29+
STATUS "Reading SPI flash with flashprog (rom_hole workaround)..."
2930
if /bin/flashprog -p internal --fmap -i COREBOOT -i FMAP -r /tmp/cbfs-init.rom; then
3031
CBFS_ARG=" -o /tmp/cbfs-init.rom"
32+
STATUS_OK "ROM read"
3133
else
3234
WARN "Failed to read board keys and configuration from SPI flash - some features may not be available"
3335
fi
@@ -47,7 +49,6 @@ for cbfsname in `echo $cbfsfiles`; do
4749
|| DIE "$filename: cbfs file read failed"
4850
if [ "$CONFIG_TPM" = "y" ]; then
4951
TRACE_FUNC
50-
INFO "Measuring $filename into TPM PCR[$CONFIG_PCR]"
5152
# Measure both the filename and its content. This
5253
# ensures that renaming files or pivoting file content
5354
# will still affect the resulting PCR measurement.
@@ -57,4 +58,4 @@ for cbfsname in `echo $cbfsfiles`; do
5758
fi
5859
fi
5960
done
60-
STATUS_OK "Board keys and configuration loaded from firmware"
61+
STATUS_OK "GPG keyring, trustdb, and board configuration extracted from firmware"

initrd/bin/gpg-gui.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ while true; do
5757
"g")
5858
confirm_gpg_card
5959
STATUS "INSTRUCTIONS:"
60-
INFO "Type 'admin' then 'generate' and follow the prompts to generate a GPG key"
61-
INFO "Type 'quit' once the key is generated to exit GPG"
60+
NOTE "Type 'admin' then 'generate' and follow the prompts to generate a GPG key"
61+
NOTE "Type 'quit' once the key is generated to exit GPG"
6262
gpg --card-edit >/tmp/gpg_card_edit_output
6363
if [ $? -eq 0 ]; then
6464
gpg_post_gen_mgmt

initrd/bin/gui-init.sh

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ gate_reseal_with_integrity_report() {
249249
# starting the NK3 CCID teardown. This safety call covers the
250250
# case where scdaemon was restarted between then and now.
251251
release_scdaemon
252-
STATUS "Checking $DONGLE_BRAND presence before sealing"
253252
DEBUG "gate_reseal_with_integrity_report: checking HOTP token presence"
253+
STATUS "Checking $DONGLE_BRAND presence before sealing"
254254
if hotp_verification info >/dev/null 2>&1; then
255-
token_ok="y"
256255
STATUS_OK "$DONGLE_BRAND present and accessible"
256+
token_ok="y"
257257
break
258258
fi
259259
DEBUG "gate_reseal_with_integrity_report: HOTP token not accessible"
@@ -285,10 +285,9 @@ generate_totp_hotp() {
285285
if [ "$CONFIG_TPM" != "y" ] && [ -x /bin/hotp_verification ]; then
286286
# If we don't have a TPM, but we have a HOTP USB Security dongle
287287
TRACE_FUNC
288-
STATUS "Generating new HOTP secret"
289288
/bin/seal-hotpkey.sh ||
290289
DIE "Failed to generate HOTP secret"
291-
elif STATUS "Generating new TOTP secret" && /bin/seal-totp.sh "$BOARD_NAME" "$tpm_owner_passphrase"; then
290+
elif /bin/seal-totp.sh "$BOARD_NAME" "$tpm_owner_passphrase"; then
292291
if [ -x /bin/hotp_verification ]; then
293292
# If we have a TPM and a HOTP USB Security dongle
294293
if [ "$CONFIG_TOTP_SKIP_QRCODE" != y ]; then
@@ -362,6 +361,7 @@ update_totp() {
362361
return 1 # Already asked to skip to menu from a prior error
363362
fi
364363

364+
DEBUG "TPM state at TOTP failure:"
365365
DEBUG "$(pcrs)"
366366

367367
totp_menu_text=$(
@@ -437,6 +437,7 @@ update_hotp() {
437437
local hotp_token_info hotp_exit attempt
438438

439439
# Ensure dongle is present; capture info for PIN counter display
440+
STATUS "Checking $DONGLE_BRAND presence"
440441
if ! hotp_token_info="$(hotp_verification info)"; then
441442
if [ "$skip_to_menu" = "true" ]; then
442443
return 1 # Already asked to skip to menu from a prior error
@@ -474,12 +475,14 @@ update_hotp() {
474475
# PIN retry count is shown only before a retry so normal boots stay silent.
475476
for attempt in 1 2 3; do
476477
# Don't output HOTP codes to screen, so as to make replay attacks harder
478+
STATUS "Verifying HOTP code"
477479
hotp_verification check "$HOTP"
478480
hotp_exit=$?
479481
case "$hotp_exit" in
480482
0)
481483
HOTP="Success"
482484
BG_COLOR_MAIN_MENU="normal"
485+
STATUS_OK "HOTP code verified"
483486
return
484487
;;
485488
4 | 7) # 4: code incorrect, 7: not a valid HOTP code — no point retrying same code
@@ -654,7 +657,6 @@ check_gpg_key() {
654657

655658
prompt_auto_default_boot() {
656659
TRACE_FUNC
657-
STATUS_OK "HOTP verification success"
658660
if pause_automatic_boot; then
659661
STATUS "Attempting default boot"
660662
attempt_default_boot
@@ -867,16 +869,17 @@ reset_tpm() {
867869
DIE "Unable to create rollback file"
868870

869871
TRACE_FUNC
870-
# As a countermeasure for existing primary handle hash, we will now force sign /boot without it
871-
# USB is already initialized at startup; run gpg --card-status to populate key stub.
872+
# As a countermeasure for existing primary handle hash, we will now force sign /boot without it.
873+
# NOTE: At seal time, PCR5 is IGNORED (not measured) - only used on HOTP board variants. So USB
874+
# modules loading here don't affect DUK seal. GPG card needs USB to be enabled first.
875+
enable_usb
872876
wait_for_gpg_card || true
873877
while true; do
874878
GPG_KEY_COUNT=$(gpg -K 2>/dev/null | wc -l)
875879
if [ "$GPG_KEY_COUNT" -eq 0 ]; then
876880
prompt_missing_gpg_key_action || return 1
877881
wait_for_gpg_card || true
878882
else
879-
STATUS_OK "TPM reset successful - updating /boot checksums and signatures"
880883
if ! update_checksums; then
881884
whiptail_error --title 'ERROR' \
882885
--msgbox "Failed to update checksums / sign default config" 0 80
@@ -896,14 +899,9 @@ reset_tpm() {
896899
fi
897900

898901
if [ -s /boot/kexec_key_devices.txt ] || [ -s /boot/kexec_key_lvm.txt ]; then
899-
STATUS_OK "TPM reset successful - resealing TPM Disk Unlock Key (DUK)"
900902
reseal_tpm_disk_decryption_key || prompt_missing_gpg_key_action
901903
fi
902-
else
903-
INFO "Returning to the main menu"
904904
fi
905-
else
906-
whiptail_error --title 'ERROR: No TPM Detected' --msgbox "This device does not have a TPM.\n\nPress OK to return to the Main Menu" 0 80
907905
fi
908906
}
909907

initrd/bin/kexec-insert-key.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if [ -r "$TMP_KEY_LVM" ]; then
2929
fi
3030

3131
# Measure the LUKS headers before we unseal the LUKS Disk Unlock Key from TPM
32-
STATUS "Measuring LUKS headers"
32+
STATUS "Measuring TPM Disk Unlock Key (DUK) into PCR[6])"
3333
cat "$TMP_KEY_DEVICES" | cut -d\ -f1 | xargs /bin/qubes-measure-luks.sh ||
3434
DIE "LUKS measure failed"
3535

@@ -65,7 +65,7 @@ fi
6565

6666
# Override PCR 4 so that user can't read the key
6767
TRACE_FUNC
68-
INFO "TPM: Extending PCR[4] to prevent any future secret unsealing"
68+
INFO "TPM: Extending PCR[4] with content of string 'generic' to prevent secret unsealing"
6969
tpmr.sh extend -ix 4 -ic generic ||
7070
DIE 'Unable to scramble PCR'
7171

initrd/bin/kexec-seal-key.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ dd \
174174
count=128 \
175175
2>/dev/null ||
176176
DIE "Unable to generate random key of 128 characters"
177+
STATUS_OK "LUKS TPM Disk Unlock Key generated"
177178

178179
previous_luks_header_version=0
179180
for dev in $key_devices; do
@@ -261,15 +262,17 @@ for dev in $key_devices; do
261262
--new-key-slot "$duk_keyslot" \
262263
"$dev" "$DUK_KEY_FILE" ||
263264
DIE "$dev: Unable to add LUKS TPM Disk Unlock Key to LUKS key slot $duk_keyslot"
265+
STATUS_OK "$dev: LUKS TPM Disk Unlock Key added to slot $duk_keyslot"
264266
done
265267

266268
# Now that we have setup the new keys, measure the PCRs
267269
# We don't care what ends up in PCR 6; we just want
268270
# to get the /tmp/luksDump.txt file. We use PCR16
269271
# since it should still be zero
270-
STATUS "Measuring LUKS headers for TPM sealing policy"
272+
STATUS "Measuring TPM Disk Unlock Key (DUK) for sealing policy (PCR[6])"
271273
echo "$key_devices" | xargs /bin/qubes-measure-luks.sh ||
272274
DIE "Unable to measure the LUKS headers"
275+
STATUS_OK "TPM Disk Unlock Key (DUK) measured for sealing policy (PCR[6])"
273276

274277
STATUS "Reading current PCR values for TPM sealing policy"
275278
pcrf="/tmp/secret/pcrf.bin"
@@ -293,6 +296,7 @@ DEBUG "Precomputing TPM future value for PCR6 sealing/unsealing of LUKS TPM Disk
293296
tpmr.sh calcfuturepcr 6 "/tmp/luksDump.txt" >>"$pcrf"
294297
# We take into consideration user files in cbfs
295298
tpmr.sh pcrread -a 7 "$pcrf"
299+
STATUS_OK "PCR values read for TPM sealing policy"
296300

297301
# tpmr.sh seal may prompt for TPM owner password; avoid DO_WITH_DEBUG here so the
298302
# prompt remains visible on console. tpmr.sh logs command details internally.

initrd/bin/kexec-select-boot.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ parse_option() {
204204
}
205205

206206
scan_options() {
207-
STATUS "Scanning for unsigned boot options"
207+
STATUS "Scanning for boot options"
208208
option_file="/tmp/kexec_options.txt"
209209
scan_boot_options "$bootdir" "$config" "$option_file"
210210
if [ ! -s $option_file ]; then
@@ -373,7 +373,7 @@ while true; do
373373
if [ ! -r "$TMP_KEY_DEVICES" ]; then
374374
# Extend PCR4 as soon as possible
375375
TRACE_FUNC
376-
INFO "TPM: Extending PCR[4] to prevent further secret unsealing"
376+
INFO "TPM: Extending PCR[4] with content of string 'generic' to prevent secret unsealing"
377377
tpmr.sh extend -ix 4 -ic generic ||
378378
DIE "Failed to extend TPM PCR[4]"
379379
fi

initrd/bin/lock_chip.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if [ -n "$APM_CNT" -a -n "$FIN_CODE" ]; then
2121
# until the next system reset.
2222
STATUS "Finalizing chipset write protection via SMI PR0 lockdown"
2323
io386 -o b -b x $APM_CNT $FIN_CODE
24+
STATUS_OK "Chipset write protection locked"
2425
else
2526
NOTE "NOT finalizing chipset - lock_chip.sh called without valid APM_CNT and FIN_CODE"
2627
fi

initrd/bin/network-init-recovery.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ ethernet_activation()
6060
insmod.sh /lib/modules/$module.ko
6161
fi
6262
done
63+
STATUS_OK "Ethernet network modules loaded"
6364
}
6465

6566
# bring up the ethernet interface
@@ -113,10 +114,10 @@ if [ -n "$dev" ]; then
113114
STATUS_OK "NTP time sync successful"
114115
fi
115116
fi
116-
STATUS "Syncing hardware clock with system time (UTC)"
117-
hwclock -w
118-
date=$(date "+%Y-%m-%d %H:%M:%S %Z")
119-
STATUS "Time: $date"
117+
STATUS "Syncing hardware clock with system time (UTC)"
118+
hwclock -w
119+
date=$(date "+%Y-%m-%d %H:%M:%S %Z")
120+
STATUS_OK "Hardware clock synced: $date"
120121
fi
121122
fi
122123
fi
@@ -133,6 +134,7 @@ if [ -n "$dev" ]; then
133134
# -B background
134135
# -R create host keys
135136
dropbear -B -R
137+
STATUS_OK "Dropbear SSH server started"
136138
fi
137139
STATUS_OK "Network setup complete"
138140
ifconfig $dev

0 commit comments

Comments
 (0)