Skip to content

Commit c55caae

Browse files
committed
fix sig mismatch regressions vs master after upgrade
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent a2ccc8f commit c55caae

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

initrd/bin/gui-init

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,8 @@ EOF
364364
debug_tpm_reset_required_state
365365
whiptail_error --title 'ERROR: TPM Reset Required' \
366366
--msgbox "Cannot generate a new TPM-backed TOTP/HOTP secret while TPM state is inconsistent.\n\nReset the TPM first (Options -> TPM/TOTP/HOTP Options -> Reset the TPM)." 0 80
367-
elif gate_reseal_with_integrity_report && (whiptail_warning --title 'Generate new TOTP/HOTP secret' \
367+
return 1
368+
elif gate_reseal_with_integrity_report && (whiptail_warning --title 'Generate new TOTP/HOTP secret' \
368369
--yesno "This will erase your old secret and replace it with a new one!\n\nDo you want to proceed?" 0 80); then
369370
if generate_totp_hotp && update_totp && BG_COLOR_MAIN_MENU="normal"; then
370371
reseal_tpm_disk_decryption_key || prompt_missing_gpg_key_action

initrd/bin/kexec-sign-config

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,11 @@ for tries in 1 2 3; do
152152
DEBUG "kexec-sign-config: using explicit signing key id ${SIGNING_KEY_ID}"
153153

154154
# Run the signing command without DO_WITH_DEBUG so that any gpg errors
155-
# print directly to the console. We still capture stderr to the debug log
156-
# (via tee) for later analysis.
155+
# print directly to the console. Stdout (the signature) goes to kexec.sig;
156+
# stderr (gpg status/error messages) goes to the log for later analysis.
157+
# Keeping them separate prevents gpg status text from corrupting the sig file.
157158
if sha256sum $param_files | \
158-
gpg --disable-dirmngr --no-auto-key-retrieve --local-user "$SIGNING_KEY_ID" --detach-sign -a 2>&1 | tee /tmp/kexec-sign.log >$paramsdir/kexec.sig; then
159+
gpg --disable-dirmngr --no-auto-key-retrieve --local-user "$SIGNING_KEY_ID" --detach-sign -a >"$paramsdir/kexec.sig" 2>/tmp/kexec-sign.log; then
159160
# successful - update the validated params
160161
check_config $paramsdir
161162

initrd/etc/functions

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,22 +106,27 @@ warn() {
106106
#
107107
# Console color: none (plain text only; targets developers reading raw output).
108108
# debug.log and /dev/kmsg receive plain text (no ANSI).
109+
# Console output goes to /dev/console directly (not stdout/stderr) to avoid
110+
# polluting callers that redirect stdout or stderr (e.g. print_tree, whiptail).
109111
#
110112
# Output modes:
111113
# Quiet (CONFIG_QUIET_MODE=y): debug.log only (no console)
112114
# Info (CONFIG_QUIET_MODE=n): debug.log only (no console)
113-
# Debug (CONFIG_DEBUG_OUTPUT=y): console + debug.log
115+
# Debug (CONFIG_DEBUG_OUTPUT=y): /dev/console + debug.log
114116
#
115117
# See doc/logging.md.
116118
DEBUG() {
117119
# Always write to debug.log - debug.log is a complete audit trail regardless of mode.
118120
echo "DEBUG: $*" >> /tmp/debug.log
119121
if [ "$CONFIG_DEBUG_OUTPUT" = "y" ]; then
120-
# debug mode: also echo to console and kmsg for ordering with other output
122+
# debug mode: also echo to console and kmsg for ordering with other output.
123+
# Use /dev/console to avoid polluting both stdout and stderr of any caller
124+
# that redirects them (e.g. print_tree >/boot/kexec_tree.txt or
125+
# whiptail_error 2>/tmp/whiptail).
121126
# fold -s -w 960 will wrap lines at 960 characters on the last space before the limit
122127
echo "DEBUG: $*" | fold -s -w 960 | while IFS= read -r line; do
123128
echo "$line" | tee -a /dev/kmsg >/dev/null
124-
echo "$line"
129+
echo "$line" >/dev/console
125130
done
126131
fi
127132
}
@@ -139,20 +144,25 @@ DEBUG() {
139144
#
140145
# Console color: none (plain text only; targets developers reading raw output).
141146
# debug.log and /dev/kmsg receive plain text (no ANSI).
147+
# Console output goes to /dev/console directly (not stdout/stderr) to avoid
148+
# polluting callers that redirect stdout or stderr (e.g. print_tree, whiptail).
142149
#
143150
# Output modes:
144151
# Quiet (CONFIG_QUIET_MODE=y): debug.log only (no console)
145152
# Info (CONFIG_QUIET_MODE=n): debug.log only (no console)
146-
# Debug (CONFIG_ENABLE_FUNCTION_TRACING_OUTPUT=y): console + debug.log
153+
# Debug (CONFIG_ENABLE_FUNCTION_TRACING_OUTPUT=y): /dev/console + debug.log
147154
#
148155
# See doc/logging.md.
149156
TRACE() {
150157
# Always write to debug.log - debug.log is a complete audit trail regardless of mode.
151158
echo "TRACE: $*" >> /tmp/debug.log
152159
if [ "$CONFIG_ENABLE_FUNCTION_TRACING_OUTPUT" = "y" ]; then
153-
# tracing mode: also echo to console and kmsg
160+
# tracing mode: also echo to console and kmsg.
161+
# Use /dev/console to avoid polluting both stdout and stderr of any caller
162+
# that redirects them (e.g. print_tree >/boot/kexec_tree.txt or
163+
# whiptail_error 2>/tmp/whiptail).
154164
echo "TRACE: $*" | tee -a /dev/kmsg >/dev/null
155-
echo "TRACE: $*"
165+
echo "TRACE: $*" >/dev/console
156166
fi
157167
}
158168

0 commit comments

Comments
 (0)