You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
oem-factory-reset: unify booleen y/n variable usage and double check logic. Also move USB Security dongle capability detection under code already checking for USB Security Dongle's smartcard presence.
Copy file name to clipboardExpand all lines: initrd/bin/oem-factory-reset
+24-23Lines changed: 24 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -641,14 +641,14 @@ generate_checksums() {
641
641
[ -z"$param_files" ] &&
642
642
whiptail_error_die "No kexec parameter files to sign"
643
643
644
-
if [ "$GPG_GEN_KEY_IN_MEMORY"="1"-a"$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD"="0" ];then
645
-
#The local keyring is still valid since no key has been moved to smartcard
646
-
#Local keyring passwd is ADMIN_PIN. We need to set USER_PIN to ADMIN_PIN
644
+
if [ "$GPG_GEN_KEY_IN_MEMORY"="y"-a"$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD"="n" ];then
645
+
#The local keyring used to generate in memory subkeys is still valid since no key has been moved to smartcard
646
+
#Local keyring passwd is ADMIN_PIN. We need to set USER_PIN to ADMIN_PIN to be able to sign next in this boot session
647
647
DEBUG "Setting GPG User PIN to GPG Admin PIN so local keyring can be used to detach-sign kexec files next"
648
648
USER_PIN=$ADMIN_PIN
649
649
fi
650
650
651
-
DEBUG "Detach-signing boot files under kexec.sig: $param_files"
651
+
DEBUG "Detach-signing boot files under kexec.sig: ${param_files}"
652
652
if sha256sum $param_files2>/dev/null | gpg \
653
653
--pinentry-mode loopback \
654
654
--passphrase "${USER_PIN}" \
@@ -841,9 +841,6 @@ mount_boot
841
841
# We show current integrity measurements status and time
842
842
report_integrity_measurements
843
843
844
-
# Determine gpg algorithm to be used, based on available usb-token
845
-
usb_security_token_capabilities_check
846
-
847
844
# Clear the screen
848
845
clear
849
846
@@ -888,7 +885,7 @@ if [ "$use_defaults" == "n" -o "$use_defaults" == "N" ]; then
888
885
if [ "$prompt_output"=="y" \
889
886
-o"$prompt_output"=="Y" ] \
890
887
;then
891
-
GPG_GEN_KEY_IN_MEMORY=1
888
+
GPG_GEN_KEY_IN_MEMORY="y"
892
889
echo" ++++ Master key and subkeys will be generated in memory, backed up to dedicated LUKS container +++"
893
890
echo -e -n "Would you like in-memory generated subkeys to be copied to USB Security Dongle's smartcard?\n (Highly recommended so the smartcard is used on daily basis and backup is kept safe, but not required) [Y/n]: "
894
891
read -n 1 prompt_output
@@ -897,15 +894,16 @@ if [ "$use_defaults" == "n" -o "$use_defaults" == "N" ]; then
897
894
-o"$prompt_output"=="N" ];then
898
895
warn "Subkeys will NOT be copied to USB Security Dongle's smartcard"
899
896
warn "Your GPG key material backup thumb drive should be cloned to a second thumb drive for redundancy for production environements"
900
-
GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD=0
897
+
GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD="n"
901
898
else
902
899
echo"++++ Subkeys will be copied to USB Security Dongle's smartcard ++++"
903
900
warn "Please keep your GPG key material backup thumb drive safe"
904
-
GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD=1
901
+
GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD="y"
905
902
fi
906
903
else
907
904
echo"GPG key material will be generated on USB Security Dongle's smartcard without backup"
908
-
GPG_GEN_KEY_IN_MEMORY=0
905
+
GPG_GEN_KEY_IN_MEMORY="n"
906
+
GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD="n"
909
907
fi
910
908
911
909
# Dynamic messages to be given to user in terms of security components that will be applied
@@ -918,12 +916,12 @@ if [ "$use_defaults" == "n" -o "$use_defaults" == "N" ]; then
# Only show GPG User PIN as affected component if GPG_GEN_KEY_IN_MEMORY variable is empty/not existing or GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD is set to 1
926
-
if [ -z"$GPG_GEN_KEY_IN_MEMORY"-o"$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD"="1" ];then
924
+
if [ "$GPG_GEN_KEY_IN_MEMORY"="n"-o"$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD"="y" ];then
927
925
CUSTOM_PASS_AFFECTED_COMPONENTS+="GPG User PIN\n"
928
926
fi
929
927
@@ -975,7 +973,7 @@ if [ "$use_defaults" == "n" -o "$use_defaults" == "N" ]; then
975
973
#USER PIN not required in case of GPG_GEN_KEY_IN_MEMORY=1 while GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD=0
976
974
# That is, if keys were NOT generated in memory (on smartcard only) or
977
975
# if keys were generated in memory but are to be moved from local keyring to smartcard
978
-
if [ "$GPG_GEN_KEY_IN_MEMORY"="0"-o"$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD"="1" ];then
976
+
if [ "$GPG_GEN_KEY_IN_MEMORY"="n"-o"$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD"="y" ];then
979
977
while [[ ${#USER_PIN}-lt 8 ]] || [[ ${#USER_PIN}-gt$MAX_HOTP_GPG_PIN_LENGTH ]];do
980
978
echo -e -n "\nThis PIN should be between 8 to $MAX_HOTP_GPG_PIN_LENGTH characters in length.\n"
981
979
echo -e -n "Enter desired GPG User PIN: "
@@ -1040,7 +1038,7 @@ if [ "$ADMIN_PIN" == "" ]; then ADMIN_PIN=${ADMIN_PIN_DEF}; fi
1040
1038
1041
1039
## sanity check the USB, GPG key, and boot device before proceeding further
1042
1040
1043
-
if [ "$GPG_GEN_KEY_IN_MEMORY"=="0" ];then
1041
+
if [ "$GPG_GEN_KEY_IN_MEMORY"="n" ];then
1044
1042
# Prompt to insert USB drive if desired
1045
1043
echo -e -n "\nWould you like to export your public key to an USB drive? [y/N]: "
1046
1044
read -n 1 prompt_output
@@ -1070,8 +1068,8 @@ if [ "$GPG_GEN_KEY_IN_MEMORY" == "0" ]; then
1070
1068
fi
1071
1069
fi
1072
1070
1073
-
# ensure USB Security Dongle connected if GPG_GEN_KEY_IN_MEMORY=0
1074
-
if [ "$GPG_GEN_KEY_IN_MEMORY"=="0" ];then
1071
+
# ensure USB Security Dongle connected if GPG_GEN_KEY_IN_MEMORY=n or if GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD=y
1072
+
if [ "$GPG_GEN_KEY_IN_MEMORY"="n"-o"$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD"="y" ];then
1075
1073
echo -e "\nChecking for USB Security Dongle...\n"
1076
1074
enable_usb
1077
1075
if! gpg --card-status >/dev/null 2>&1;then
@@ -1081,6 +1079,9 @@ if [ "$GPG_GEN_KEY_IN_MEMORY" == "0" ]; then
1081
1079
whiptail_error_die "Unable to detect USB Security Dongle:\n\n${ERROR}"
1082
1080
fi
1083
1081
fi
1082
+
1083
+
#Now that USB Security Dongle is detected, we can check its capabilities and limitations
0 commit comments