using shred instead of rm on secret related files.

This commit is contained in:
Thierry Laurion 2019-02-16 12:26:51 -05:00
parent c341609488
commit 0722d42d65
No known key found for this signature in database
GPG Key ID: 79C78E6659DB658F
6 changed files with 13 additions and 12 deletions

View File

@ -38,7 +38,7 @@ for tries in 1 2 3; do
-hk 40000000 \
; then
# should be okay if this fails
rm -f /tmp/secret/sealed || true
shred -n 10 -z -u /tmp/secret/sealed || true
exit 0
fi

View File

@ -28,9 +28,9 @@ tpm unsealfile \
-of "$HOTP_SECRET" \
|| die "Unable to unseal HOTP secret"
rm -f "$HOTP_SEALED"
shred -n 10 -z -u "$HOTP_SEALED"
secret="`cat $HOTP_SECRET`"
rm -f "$HOTP_SECRET"
shred -n 10 -z -u "$HOTP_SECRET"
# Store counter in file instead of TPM for now, as it conflicts with Heads
# config TPM counter as TPM 1.2 can only increment one counter between reboots

View File

@ -43,7 +43,7 @@ if ! tpm sealfile2 \
-ix 4 0000000000000000000000000000000000000000 \
-ix 7 X \
; then
rm -f "$TOTP_SECRET"
shred -n 10 -z -u "$TOTP_SECRET"
die "Unable to seal secret"
fi
@ -79,7 +79,7 @@ if ! tpm nv_writevalue \
|| die "Unable to write sealed secret to NVRAM"
fi
rm -f "$TOTP_SEALED"
shred -n 10 -z -u "$TOTP_SEALED"
url="otpauth://totp/$HOST?secret=$secret"
secret=""

View File

@ -28,7 +28,7 @@ tpm unsealfile \
-of "$HOTP_SECRET" \
|| die "Unable to unseal HOTP secret"
rm -f "$HOTP_SEALED"
shred -n 10 -z -u "$HOTP_SEALED"
# Store counter in file instead of TPM for now, as it conflicts with Heads
# config TPM counter as TPM 1.2 can only increment one counter between reboots
@ -51,11 +51,11 @@ fi
#counter_value=$(printf "%d" 0x${counter_value})
if ! hotp $counter_value < "$HOTP_SECRET"; then
rm -f "$HOTP_SECRET"
shred -n 10 -z -u "$HOTP_SECRET"
die 'Unable to compute HOTP hash?'
fi
rm -f "$HOTP_SECRET"
shred -n 10 -z -u "$HOTP_SECRET"
#increment_tpm_counter $counter > /dev/null \
#|| die "Unable to increment tpm counter"

View File

@ -18,12 +18,12 @@ tpm unsealfile \
-of "$TOTP_SECRET" \
|| die "Unable to unseal totp secret"
rm -f "$TOTP_SEALED"
shred -n 10 -z -u "$TOTP_SEALED"
if ! totp -q < "$TOTP_SECRET"; then
rm -f "$TOTP_SECRET"
shred -n 10 -z -u "$TOTP_SECRET"
die 'Unable to compute TOTP hash?'
fi
rm -f "$TOTP_SECRET"
shred -n 10 -z -u "$TOTP_SECRET"
exit 0

View File

@ -15,6 +15,7 @@ recovery() {
# Remove any temporary secret files that might be hanging around
# but recreate the directory so that new tools can use it.
shred -n 10 -z -u /tmp/secret/* 2> /dev/null
rm -rf /tmp/secret
mkdir -p /tmp/secret
@ -234,7 +235,7 @@ replace_config() {
# then copy any remaining settings from the existing config file, minus the option you changed
grep -v "^export ${CONFIG_OPTION}=" ${CONFIG_FILE} | grep -v "^${CONFIG_OPTION}=" >> ${CONFIG_FILE}.tmp || true
sort ${CONFIG_FILE}.tmp | uniq > ${CONFIG_FILE}
rm -f ${CONFIG_FILE}.tmp
shred -n 10 -z -u ${CONFIG_FILE}.tmp
}
combine_configs() {
cat /etc/config* > /tmp/config