Skip to content

Commit

Permalink
Only run sq-keyring-linter if package is installed.
Browse files Browse the repository at this point in the history
Improve error codes in validate-gpg-key.sh script.
  • Loading branch information
rocodes committed Sep 26, 2023
1 parent a5b9edf commit 4f0d255
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions admin/bin/validate-gpg-key.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ declare -r fingerprint="$2"
printf "Creating temporary GPG config dir for testing key import...\n"
temporary_gpg_homedir="$(mktemp -d)"
export GNUPGHOME="${temporary_gpg_homedir}"
export KEY_MISMATCH=1
export SQLINT_FAIL=2
export KEY_MISMATCH=11
export SQLINT_FAIL=12


function cleanup_temporary_gpg_homedir() {
Expand All @@ -42,7 +42,7 @@ function report_error() {
elif [[ $1 -eq $SQLINT_FAIL ]]; then
printf "Failed! Fingerprint matches but key failed sq-keyring-linter.\n"
exit 2
else # Unreachable
else
printf "Failed! Specified fingerprint has failed validation.\n"
exit 3
fi
Expand Down Expand Up @@ -71,14 +71,15 @@ printf "\t Fingerprint: %s\n" "${fingerprint}"

gpg2 --fingerprint "$fingerprint" || report_error $KEY_MISMATCH

# Validate against Seqouia's key linter, which checks whether OpenPGP certificates
# use a SHA-1 based binding signature
# Opportunistically validate against Seqouia's key linter, which checks whether
# OpenPGP certificates use a SHA-1 based binding signature
# (see https://sequoia-pgp.org/blog/2023/02/01/202302-happy-sha1-day/).
# Note: it is possible that the key has been updated on another admin workstation,
# but the updated pubkey has not been transferred to this workstation.
printf "Validating that key is supported...\n"
gpg2 --export "$fingerprint" | sq-keyring-linter || report_error $SQLINT_FAIL

# but the updated pubkey has not been transferred to this workstation.
if [[ $(dpkg-query -W -f='${Status}' sq-keyring-linter) == "install ok installed" ]]; then
printf "Validating that key is supported...\n"
gpg2 --export "$fingerprint" | sq-keyring-linter || report_error $SQLINT_FAIL
fi

printf "Success! Specified fingerprint matches pubkey file.\n"
exit 0

0 comments on commit 4f0d255

Please sign in to comment.