Skip to content

Commit f7facf0

Browse files
authored
Merge pull request #1200 from SergiiDmytruk/optional-otp
init: assign CONFIG_TPM depending on /dev/tpm0 presence
2 parents 4ca4656 + 75748e8 commit f7facf0

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

initrd/bin/gui-init

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ mount_boot()
4545
exec /bin/usb-init
4646
;;
4747
m )
48-
skip_to_menu="true"
48+
skip_gpg_check="true"
4949
break
5050
;;
5151
* )
@@ -571,7 +571,9 @@ else
571571
fi
572572

573573
# detect whether any GPG keys exist in the keyring, if not, initialize that first
574-
[[ "$skip_to_menu" != "true" ]] && check_gpg_key && update_totp && update_hotp
574+
[[ "$skip_gpg_check" != "true" ]] && check_gpg_key
575+
576+
update_totp && update_hotp
575577

576578
if [[ "$HOTP" = "Success" && $CONFIG_AUTO_BOOT_TIMEOUT ]]; then
577579
prompt_auto_default_boot

initrd/init

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ hwclock -l -s
4343
. /etc/functions
4444
. /etc/config
4545

46+
# set CONFIG_TPM dynamically before init
47+
if [ -e /dev/tpm0 ]; then
48+
CONFIG_TPM='y'
49+
else
50+
CONFIG_TPM='n'
51+
fi
52+
4653
#Specify whiptail background colors cues under FBWhiptail only
4754
if [ -x /bin/fbwhiptail ]; then
4855
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
97104
exit
98105
fi
99106

107+
# Override CONFIG_TPM from /etc/config with runtime value determined above.
108+
#
109+
# Values in user config have higher priority during combining thus effectively
110+
# changing the value for the rest of the scripts which source /tmp/config.
111+
echo "export CONFIG_TPM=\"$CONFIG_TPM\"" >> /etc/config.user
112+
100113
combine_configs
101114
. /tmp/config
102115

0 commit comments

Comments
 (0)