#!/bin/bash # # verifygpgmail - send email to confirm e-mail of gpg keys # Copyright (C) 2003 Jörgen Cederlöf # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA echo "Change values inside.";exit 1 me="Jorgen Cederlof " bcc="jc+verifygpgmail@lysator.liu.se" mesig="Jörgen" mykey="0xe8c80c34" policyurl="http://www.lysator.liu.se/~jc/signing-policy.html" codeurl="http://www.lysator.liu.se/~jc/verifygpgmail.sh" defaultserver="x-hkp://wwwkeys.de.pgp.net" gpg="gpg" # Change to wrapper or something if needed. for key in "$@"; do if ! echo "$key" |egrep '^[0-9a-fA-F]{8}$' >/dev/null; then echo "Keys must be in in a format like e8c80c34." >&2 echo "The argument \"$key\" is not." >&2 exit 1 fi if ! gpg --list-keys "0x$key" >/dev/null; then gpg --recv-keys "0x$key" fi if ! gpg --list-keys "0x$key" >/dev/null; then echo "Unable to retreive key $key from keyserver." exit 3 fi done for key in "$@"; do key="0x$key" addresses="$(gpg --list-keys "$key"|\ sed -n -e 's/^pub [0-9]*.\/[^ ]* [0-9-]* //p' \ -e 's/^uid *//p')" fpr="$(gpg --list-keys --with-fingerprint $key |sed 's/^/ /')" reg="something" while [ "$reg" != "" ]; do echo "About to send mail to these addresses:" echo "" echo "$addresses" echo "" echo "for the key:" echo "$fpr" echo "" echo "Press return or enter address regexp for addresses to use." read reg [ "$reg" != "" ] && addresses="$(echo "$addresses" |egrep "$reg")" done indentedaddresses="$(echo "$addresses" |sed 's/^/ /')" echo "$addresses" | while read address; do echo "Sending mail to $address" cookie="$(dd if=/dev/random bs=1 count=6 2>/dev/null | \ uuencode -m - | sed -n 2p)" if [ "$address" == "" ] || [ "$fpr" == "" ]; then echo "Very strange. Key not found." >&2 exit 2 fi name=$(echo "$address" |sed 's/ *<.*$//') enc="$($gpg --quiet --no-verbose --textmode --output - \ --encrypt --sign --armor --always-trust \ --encrypt-to $mykey -r $key <