Skip to content

Commit b4e3add

Browse files
committed
wip fixup oem-factory-reset.sh
Signed-off-by: Thierry Laurion <insurgo@riseup.net>
1 parent 2b6c934 commit b4e3add

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

initrd/bin/oem-factory-reset.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ fi
12411241
if [ "$GPG_GEN_KEY_IN_MEMORY" = "n" ] || [ "$GPG_GEN_KEY_IN_MEMORY_COPY_TO_SMARTCARD" = "y" ]; then
12421242
enable_usb
12431243
if ! gpg --card-status >/dev/null 2>&1; then
1244-
local_whiptail_error "Can't access USB Security dongle; \nPlease remove and reinsert, then press Enter."
1244+
whiptail_error --msgbox "Can't access USB Security dongle; \nPlease remove and reinsert, then press Enter." $HEIGHT $WIDTH --title "Error"
12451245
if ! gpg --card-status >/dev/null 2>/tmp/error; then
12461246
ERROR=$(tail -n 1 /tmp/error | fold -s)
12471247
whiptail_error_die "Unable to detect USB Security dongle:\n\n${ERROR}"

initrd/bin/unseal-totp.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,30 @@ if [ "$CONFIG_TPM" = "y" ]; then
1414
rc=$?
1515
case "$rc" in
1616
2)
17-
die "No TPM primary handle. You must reset the TPM to seal secret to TPM NVRAM"
17+
echo "No TPM primary handle. You must reset the TPM to seal secret to TPM NVRAM" >&2
18+
exit 2
1819
;;
1920
3)
20-
die "TPM primary handle hash mismatch. Possible tampering; aborting unseal"
21+
echo "TPM primary handle hash mismatch. Possible tampering; aborting unseal" >&2
22+
exit 3
2123
;;
2224
*)
23-
die "TPM primary handle verification failed (code $rc)"
25+
echo "TPM primary handle verification failed (code $rc)" >&2
26+
exit "$rc"
2427
;;
2528
esac
2629
fi
2730

28-
DO_WITH_DEBUG --mask-position 5 \
29-
tpmr.sh unseal 4d47 0,1,2,3,4,7 312 "$TOTP_SECRET" || \
30-
die "Unable to unseal TOTP secret from TPM"
31+
if ! DO_WITH_DEBUG --mask-position 5 tpmr.sh unseal 4d47 0,1,2,3,4,7 312 "$TOTP_SECRET"; then
32+
echo "Unable to unseal TOTP secret from TPM" >&2
33+
exit 1
34+
fi
3135
fi
3236

3337
if ! DO_WITH_DEBUG totp -q <"$TOTP_SECRET"; then
3438
shred -n 10 -z -u "$TOTP_SECRET" 2>/dev/null
35-
die 'Unable to compute TOTP hash?'
39+
echo 'Unable to compute TOTP hash?' >&2
40+
exit 4
3641
fi
3742

3843
shred -n 10 -z -u "$TOTP_SECRET" 2>/dev/null

0 commit comments

Comments
 (0)