jaromail

a commandline tool to easily and privately handle your e-mail
git clone git://parazyd.org/jaromail.git
Log | Files | Refs | Submodules | README

commit d30e1d068f173f7851671dbcbfd69680e2cb86ae
parent b7562c964df4943c4ee0a4a7381ad3c9a0a3ef5b
Author: Jaromil <jaromil@dyne.org>
Date:   Sat, 17 Jan 2015 16:51:22 +0100

new extras script to download automatically all missing gpg keys found in signatures inside pub keyring

Diffstat:
Aextras/gnupg-mass-recv/README.md | 12++++++++++++
Aextras/gnupg-mass-recv/gnupg-mass-recv | 44++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/extras/gnupg-mass-recv/README.md b/extras/gnupg-mass-recv/README.md @@ -0,0 +1,12 @@ +GnuPG mass-recv script, version 0.1 +by Jaromil + +This is a simple Zsh script that uses gnupg to download all missing ID +found in all signed keys from one's keyring. + +Beware that by running this script your keyring will be populated by a +lot more keys. The script shows its operation and needs the option -f +to force its execution and really modify the GnuPG keyring in +$HOME/.gnupg. + + diff --git a/extras/gnupg-mass-recv/gnupg-mass-recv b/extras/gnupg-mass-recv/gnupg-mass-recv @@ -0,0 +1,44 @@ +#!/usr/bin/env zsh + +# uncomment to really download keys and modify the pub keyring +# DRYRUN=1 + +zmodload zsh/pcre + +command -v jaro > /dev/null 2>/dev/null +[[ $? = 0 ]] || { + print "Error: jaro not found in path. Install Jaro Mail." + return 1 +} + +print "Import all keys found in public keyring signatures" + +if [[ -r gnupg-mass-recv.cache ]]; then + print "gathering signatures from cache file..." + _addrs=`cat gnupg-mass-recv.cache` +else + print "gathering all signatures in public keyring..." + _addrs=`gpg --batch --with-colons --list-sigs | awk -F: '{print $5 " " $10}'| tee gnupg-mass-recv.cache` + +fi +print "parsing the signatures for unkown IDs..." +typeset -A received +received=() +for i in ${(f)_addrs}; do + [[ "$i" =~ "User ID not found" ]] && { + nid=${i[(w)1]} + [[ "$received[$nid]" = 1 ]] && { + print "$nid - duplicate" + continue + } + received+=($nid 1) + print "$nid - receiving" + [[ $DRYRUN = 1 ]] || { + gpg --recv-key ${nid} + } + continue + } + print $i +done +print "Received ${#received} new keys" +