Skip to content

Commit 9deb5bf

Browse files
authored
Merge pull request #2059 from tlaurion/fix_totp_loop_on_duk_when_not_resealed_and_on_pass_error
etc/functions - show_totp_until_esc : fix TOTP loop by flushing input before ESC wait
2 parents 97466bd + fa3c24f commit 9deb5bf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

initrd/etc/functions

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,14 @@ show_totp_until_esc() {
16471647
local last_totp_time=0 last_totp=""
16481648
printf "\n" # reserve a line for updates
16491649

1650+
# Clear any pending keystrokes before we start displaying the TOTP.
1651+
# In particular, a stray Escape key from the previous passphrase
1652+
# prompt could be sitting in the input buffer and would cause the
1653+
# function to immediately return on the next iteration, confusing
1654+
# the user when they try to hit Esc again. Drain stdin until it's
1655+
# empty.
1656+
while IFS= read -r -t 0 -n 1 junk; do :; done
1657+
16501658
# Poll frequently (200ms) for responsiveness, but only refresh the
16511659
# displayed timestamp/TOTP when the displayed second changes. Cache
16521660
# the TOTP for a short interval to avoid repeated unseal calls.

0 commit comments

Comments
 (0)