2
# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4
# This file is free software; as a special exception the author gives
5
# unlimited permission to copy and/or distribute it, with or without
6
# modifications, as long as this notice is preserved.
8
# This program is distributed in the hope that it will be useful, but
9
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
# FIXME: Add --dry-run, use only valid email addreses, extract only given keys
15
if [ "$1" = "--dry-run" ]; then
20
if [ -z "$1" -o -z "$2" -o -z "$3" ]; then
21
echo "usage: mail-signed-keys keyring signedby signame" >&2
28
echo "mail-signed-keys: '$1': no such file" >&2
32
[ -f '.#tdb.tmp' ] && rm '.#tdb.tmp'
33
ro="--homedir . --no-options --trustdb-name=./.#tdb.tmp --dry-run --lock-never --no-default-keyring --keyring $1"
35
signedby=`gpg $ro --list-keys --with-colons $2 \
36
2>/dev/null | awk -F: '$1=="pub" {print $5; exit 0}'`
38
if [ -z "$signedby" ]; then
39
echo "mail-signed-keys: '$2': no such signator" >&2
43
if [ "$dryrun" = "0" ]; then
44
echo "About to send the the keys signed by $signedby" >&2
45
echo -n "to their owners. Do you really want to do this? (y/N)" >&2
47
[ "$REPLY" != "y" -a "$REPLY" != "Y" ] && exit 0
50
gpg $ro --check-sigs --with-colons 2>/dev/null \
51
| awk -F: -v signedby="$signedby" -v gpgopt="$ro" \
52
-v dryrun="$dryrun" -v signame="$signame" '
53
BEGIN { sendmail="/usr/lib/sendmail -oi -t " }
54
$1 == "pub" { nextkid=$5; nextuid=$10
55
if( uidcount > 0 ) { myflush() }
56
kid=nextkid; uid=nextuid; next
58
$1 == "uid" { uid=$10 ; next }
59
$1 == "sig" && $2 == "!" && $5 == signedby { uids[uidcount++] = uid; next }
60
END { if( uidcount > 0 ) { myflush() } }
64
if ( kid == signedby ) { uidcount=0; return }
65
print "sending key " substr(kid,9) " to" | "cat >&2"
66
for(i=0; i < 1; i++ ) {
67
print " " uids[i] | "cat >&2"
70
printf "To: %s", uids[i] | sendmail
73
printf ",\n %s", uids[i] | sendmail
78
printf "\n" | sendmail
79
print "Subject: I signed your key " substr(kid,9) | sendmail
81
print "Hi," | sendmail
83
print "Here you get back the signed key." | sendmail
84
print "Please send it yourself to a keyserver." | sendmail
86
print "Peace," | sendmail
87
print " " signame | sendmail
89
cmd = "gpg " gpgopt " --export -a " kid " 2>/dev/null"
90
while( (cmd | getline) > 0 ) {