summaryrefslogtreecommitdiff
path: root/src/share/ma/list_certifiers
blob: 5a0388e5a998db81b47492a6938f382c10266385 (plain)
  1. # -*-shell-script-*-
  2. # This should be sourced by bash (though we welcome changes to make it POSIX sh compliant)
  3. # Monkeysphere authentication list-certifiers subcommand
  4. #
  5. # The monkeysphere scripts are written by:
  6. # Jameson Rollins <jrollins@fifthhorseman.net>
  7. # Jamie McClelland <jm@mayfirst.org>
  8. # Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  9. #
  10. # They are Copyright 2008-2009, and are all released under the GPL,
  11. # version 3 or later.
  12. # list the host certifiers
  13. list_certifiers() {
  14. local keys
  15. local key
  16. local authfpr
  17. # find trusted keys in sphere keychain
  18. log debug "finding trusted keys..."
  19. # FIXME: this assumes that the keygrip (16 hex chars) is unique; we're
  20. # only searching by keygrip at the moment.
  21. authgrip=$(core_fingerprint | cut -b 25-40)
  22. # We're walking the list of known signatures, and extracting all trust
  23. # signatures made by the core fingerprint and known to the sphere
  24. # keyring.
  25. # for each one of these, we're printing (colon-delimited): the
  26. # fingerprint, the trust depth, the trust level (60 == marginal, 120
  27. # == full), and the domain regex (if any):
  28. gpg_sphere "--fingerprint --with-colons --fixed-list-mode --check-sigs" | \
  29. cut -f 1,2,5,8,9,10 -d: | \
  30. egrep '^(fpr:::::|sig:!:'"$authgrip"':[[:digit:]]+ [[:digit:]]+:)' | \
  31. while IFS=: read -r type validity grip trustparams trustdomain fpr ; do
  32. case $type in
  33. 'fpr') # this is a new key
  34. keyfpr=$fpr
  35. ;;
  36. 'sig') # print all trust signatures, including regexes if present
  37. trustdepth=${trustparams%% *}
  38. trustlevel=${trustparams##* }
  39. # FIXME: this is clumsy and not human-friendly. we should
  40. # print out more human-readable information, if possible.
  41. printf "%s:%d:%d:%s\n" "$keyfpr" "$trustdepth" "$trustlevel" "$trustdomain"
  42. ;;
  43. esac
  44. done
  45. }