#! /usr/bin/awk -f # # Send recently signed keys to their owners # # Author/Maintainer: Roland Mas # # This program is copyright (C) 2001-2002, Roland Mas # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # History: # - 2001-07-?? - [Roland] First writing. My very first awk script. # - 2002-08-21 1.0 [Roland] Cleaned up code, and added flexibility through # command line options. # # Simple use: # $ gpg --list-sigs | gpg-mail-signed-keys # This will send all the keys that were signed today by the first # secret key in your keyring # # Complex use: # $ gpg --list-sigs | gpg-mail-signed-keys date=2002-08-.. mykeyid=144843f5 myemail="Roland Mas " # This will send all the keys signed on all dates matching the given # pattern by the specified key, using the specified email address as # the originating address for the sent mails. BEGIN { "date +%Y-%m-%d" | getline date ; "gpg --list-secret-keys | grep ^sec | cut -c12-19" | getline mykeyid ; "gpg --list-secret-keys | grep ^sec | cut -c32-" | getline myemail ; } /^pub/ { pub = $2 ; email = "" ; for (i = 4 ; i <= NF ; i++) email = email $i " " ; uid = email ; } /^uid/ { uid = "" ; for (i = 2 ; i <= NF ; i++) uid = uid $i " " ; } $0 ~ "^sig . " toupper (mykeyid) " " date { sig = $3 ; for (i = 4 ; i <= NF ; i++) sig = sig " " $i ; keyid = "0x" substr (pub, 7) ; block = "" ; command = "gpg --export --armour " keyid " > key.gpg" ; system (command) ; print "Hello,\n" > "/tmp/sync-keys.tmp" ; print " I have recently signed your PGP/GnuPG key " keyid >> "/tmp/sync-keys.tmp" ; print ". I have already uploaded it to several keyservers. " >> "/tmp/sync-keys.tmp" ; print "Just in case, I attached it to this message. " >> "/tmp/sync-keys.tmp" ; print "If you haven't already done so, please consider " >> "/tmp/sync-keys.tmp" ; print "signing my key 0x" toupper (mykeyid) " too. " >> "/tmp/sync-keys.tmp" ; print "Of course, only sign it if you consider I've shown " >> "/tmp/sync-keys.tmp" ; print "you enough credentials for you to trust my key.\n" >> "/tmp/sync-keys.tmp" ; command = "fmt -w 72 -c -t /tmp/sync-keys.tmp > msg.txt" ; system (command) ; print "Thanks.\n-- \n" myemail >> "msg.txt" ; close ("msg.txt") command = "mutt -s \"Your PGP/GnuPG key\" -a key.gpg -c \"" myemail "\" \"" uid "\"< msg.txt" ; if ( match ( uid, /\@/ ) > 0) { print "Sending key " keyid " to " uid ; system (command) ; } close ("/tmp/sync-keys.tmp") ; }