gpgverify 848 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. set -e
  3. set -u
  4. TMPDIR=${TMPDIR:-"/tmp"}
  5. GPGSTATUS=$(mktemp -p "${TMPDIR}" GPGSTATUS.XXXXXX)
  6. trap 'rm -f -- "${GPGSTATUS:?}"' EXIT
  7. GPGLOGS=$(mktemp -p "${TMPDIR}" GPGLOGS.XXXXXX)
  8. trap 'rm -f -- "${GPGLOGS:?}"' EXIT
  9. DEFGPGOPT="--no-default-keyring --batch --no-tty --no-options --exit-on-status-write-error --no-greeting --with-colons --keyring /srv/keyring.debian.org/keyrings/debian-keyring.gpg"
  10. /usr/bin/gpg ${DEFGPGOPT} --status-file ${GPGSTATUS} --logger-file ${GPGLOGS} $3 $4 -
  11. declare -A TOKENS
  12. while read gpgtag TOKEN something; do
  13. TOKENS[$TOKEN]=1
  14. done < <(cat ${GPGSTATUS})
  15. # Heyho, we just verified, but git verify-commit is silly and wants to redo our work...
  16. cat ${GPGSTATUS}
  17. rm -f ${GPGSTATUS}
  18. rm -f ${GPGLOGS}
  19. if [[ ${TOKENS[VALIDSIG]} == 1 ]] && [[ ${TOKENS[GOODSIG]} == 1 ]]; then
  20. exit 0
  21. else
  22. exit 1
  23. fi