-
-
Notifications
You must be signed in to change notification settings - Fork 198
initrd/etc/gui_functions pause_automatic_boot: show TOTP code while waiting for automatic boot is set and hotp is valid #1993
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b5188bc
to
dbd095a
Compare
Old OP (in link of deprecated superseeded commit e0fb3e7)This pull request enhances the user experience during the automatic boot countdown in the User experience improvements:
In action under qemu-coreboot-whiptail-tpm2-hotp-prod (not silent, not debug): ![]() ![]() ![]() |
Small UX bug to fix, time shown on screen is updated every 2 seconds, not every seconds. |
…OTP code while waiting for automatic boot when a default boot is set and hotp is valid Signed-off-by: Thierry Laurion <[email protected]>
dbd095a
to
25b3d80
Compare
Self reviewed. @JonathonHall-Purism comments? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the pause_automatic_boot
function to provide an enhanced user experience during the automatic boot countdown with live updates and optional TOTP display. The changes replace a simple single-line timeout with an interactive countdown loop.
- Implements live countdown display that updates every second with current UTC timestamp
- Adds optional TOTP code display when TPM is enabled and QR code display is not skipped
- Enables real-time user interruption by checking for keypresses every second
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
if ! current_totp=$(unseal-totp 2>/dev/null); then | ||
die "Failed to unseal TOTP" | ||
fi | ||
status_line="$status_line | TOTP: $current_totp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function calls die
when TOTP unsealing fails, which will terminate the entire process. This contradicts the PR description which states that 'Errors in retrieving the TOTP are handled gracefully.' Consider continuing the countdown without TOTP display instead of terminating.
if ! current_totp=$(unseal-totp 2>/dev/null); then | |
die "Failed to unseal TOTP" | |
fi | |
status_line="$status_line | TOTP: $current_totp" | |
if current_totp=$(unseal-totp 2>/dev/null); then | |
status_line="$status_line | TOTP: $current_totp" | |
fi |
Copilot uses AI. Check for mistakes.
|
||
# Wait for keypress for the remaining time in this second | ||
# IFS= disables word splitting, -t sets timeout, -s disables echo, -n 1 reads one char, -r disables backslash escapes | ||
if IFS= read -t $sleep_time -s -n 1 -r; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sleep_time
variable should be quoted to prevent word splitting issues when passed to the -t
option. Use \"$sleep_time\"
instead of $sleep_time
.
if IFS= read -t $sleep_time -s -n 1 -r; then | |
if IFS= read -t "$sleep_time" -s -n 1 -r; then |
Copilot uses AI. Check for mistakes.
sleep_time=$(( 1 - elapsed )) | ||
[ $sleep_time -lt 0 ] && sleep_time=0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the loop processing takes longer than 1 second, sleep_time
becomes 0, but the countdown will still decrement by 1. This could cause the countdown to complete faster than the configured timeout. Consider adjusting the remaining time based on actual elapsed time instead of always decrementing by 1.
Copilot uses AI. Check for mistakes.
This pull request refactors the
pause_automatic_boot
function ininitrd/etc/gui_functions
to improve user experience and add TOTP display support during the automatic boot countdown. The main changes include switching to a live countdown display, optionally showing the current TOTP code, and handling user interruption more interactively.User experience improvements:
Interactive interruption:
In action under qemu-coreboot-whiptail-tpm2-hotp-prod (not silent, not debug):


