From b989889e5f867f845b8fe3c745ffb860d1aac333 Mon Sep 17 00:00:00 2001 From: Sergii Dmytruk Date: Sat, 20 Aug 2022 00:21:39 +0300 Subject: [PATCH 1/2] init: assign CONFIG_TPM depending on /dev/tpm0 presence Signed-off-by: Sergii Dmytruk --- initrd/init | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/initrd/init b/initrd/init index cdc75543..a9f31350 100755 --- a/initrd/init +++ b/initrd/init @@ -43,6 +43,13 @@ hwclock -l -s . /etc/functions . /etc/config +# set CONFIG_TPM dynamically before init +if [ -e /dev/tpm0 ]; then + CONFIG_TPM='y' +else + CONFIG_TPM='n' +fi + #Specify whiptail background colors cues under FBWhiptail only if [ -x /bin/fbwhiptail ]; then export BG_COLOR_WARNING="${CONFIG_WARNING_BG_COLOR:-"--background-gradient 0 0 0 150 125 0"}" @@ -97,6 +104,12 @@ if [ "$boot_option" = "r" ]; then exit fi +# Override CONFIG_TPM from /etc/config with runtime value determined above. +# +# Values in user config have higher priority during combining thus effectively +# changing the value for the rest of the scripts which source /tmp/config. +echo "export CONFIG_TPM=\"$CONFIG_TPM\"" >> /etc/config.user + combine_configs . /tmp/config From 75748e86b7373b5becb5f51e35b07c20d3b43ca5 Mon Sep 17 00:00:00 2001 From: Sergii Dmytruk Date: Sat, 20 Aug 2022 23:57:01 +0300 Subject: [PATCH 2/2] gui-init: fix TOTP/HOTP initialization on missing OS Skip only GPG key check, but always init TOTP and HOTP. Signed-off-by: Sergii Dmytruk --- initrd/bin/gui-init | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/initrd/bin/gui-init b/initrd/bin/gui-init index afcf28eb..bbb5f156 100755 --- a/initrd/bin/gui-init +++ b/initrd/bin/gui-init @@ -45,7 +45,7 @@ mount_boot() exec /bin/usb-init ;; m ) - skip_to_menu="true" + skip_gpg_check="true" break ;; * ) @@ -571,7 +571,9 @@ else fi # detect whether any GPG keys exist in the keyring, if not, initialize that first -[[ "$skip_to_menu" != "true" ]] && check_gpg_key && update_totp && update_hotp +[[ "$skip_gpg_check" != "true" ]] && check_gpg_key + +update_totp && update_hotp if [[ "$HOTP" = "Success" && $CONFIG_AUTO_BOOT_TIMEOUT ]]; then prompt_auto_default_boot