mirror of
https://github.com/linuxboot/heads.git
synced 2024-12-19 21:17:55 +00:00
initrd/bin/gui-init: retry TOTP in case of error
On platforms using CONFIG_BOOT_EXTRA_TTYS multiple processes may try to access TPM at the same time, failing with EBUSY. The order of execution is unpredictable, so the error may appear on main console, secondary one, or neither of them if the calls are sufficiently staggered. Try up to three times (including previous one) with small delays in case of error, instead of immediately scaring users with "you've been pwned" message. Signed-off-by: Krystian Hebel <krystian.hebel@3mdeb.com>
This commit is contained in:
parent
9a72749675
commit
f7066d020d
@ -174,10 +174,22 @@ update_totp()
|
||||
TRACE "Under /bin/gui-init:update_totp"
|
||||
# update the TOTP code
|
||||
date=`date "+%Y-%m-%d %H:%M:%S %Z"`
|
||||
tries=0
|
||||
if [ "$CONFIG_TPM" != "y" ]; then
|
||||
TOTP="NO TPM"
|
||||
else
|
||||
TOTP=`unseal-totp`
|
||||
# On platforms using CONFIG_BOOT_EXTRA_TTYS multiple processes may try to
|
||||
# access TPM at the same time, failing with EBUSY. The order of execution
|
||||
# is unpredictable, so the error may appear on main console, secondary one,
|
||||
# or neither of them if the calls are sufficiently staggered. Try up to
|
||||
# three times (including previous one) with small delays in case of error,
|
||||
# instead of immediately scaring users with "you've been pwned" message.
|
||||
while [ $? -ne 0 ] && [ $tries -lt 2 ]; do
|
||||
sleep 0.5
|
||||
((tries++))
|
||||
TOTP=`unseal-totp`
|
||||
done
|
||||
if [ $? -ne 0 ]; then
|
||||
BG_COLOR_MAIN_MENU=$BG_COLOR_ERROR
|
||||
if [ "$skip_to_menu" = "true" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user