X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=gpg-mailkeys%2Fgpg-mailkeys;h=cacaf1dfac3637ac23b29c69ce1f8341d085e063;hb=5cdf211ddf69c879b6b223c33ee22dab836a8da2;hp=ef8683845ea2d732b36283e0e068607263dadcb8;hpb=793ff15f23460922296a67a67596efb7adab221d;p=pgp-tools.git diff --git a/gpg-mailkeys/gpg-mailkeys b/gpg-mailkeys/gpg-mailkeys index ef86838..cacaf1d 100755 --- a/gpg-mailkeys/gpg-mailkeys +++ b/gpg-mailkeys/gpg-mailkeys @@ -1,12 +1,16 @@ #! /bin/sh +# +# gpg-mailkeys: mail out just signed keys to their owners +# +# $Id$ set -e -VERSION="0.4.0" +VERSION='$Rev$' if [ -z "$*" ]; then - echo "Send people their newly signed GPG key by mail." - echo "Usage: $0 keyid ..." + printf "Send people their newly signed GPG key by mail.\n" + printf "Usage: $0 keyid ...\n" exit 1 fi @@ -34,20 +38,21 @@ fi FAILKEYS= while [ -n "$1" ]; do - echo -n "[$1] " + printf "[$1] " TEMPFILE=`mktemp -t gpg2mail.XXXXXX` ADDR=`gpg --with-colons --fixed-list-mode --list-key $1 | sed -e 's/^uid:[^re][^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:<]*<[^:>]*>\):.*/@@uid@@ \1/' -e '/^@@uid@@ /!d' -e 's/([^)]*)//g' -e 's/ */ /g' -e 's/^@@uid@@ //' | head -1` if [ -z "$ADDR" ]; then - echo "(no usable user ids)" + printf "(no usable user ids)\n" FAILKEYS="$FAILKEYS:$1" shift 1 continue fi - BOUNDARY="ksp-$$-boundary-$RANDOM" + NANOTIME=`date +%s-%N` + BOUNDARY="ksp-$$-boundary-$NANOTIME" - echo -n "$ADDR:" + printf "$ADDR:" if [ $FROM ]; then - echo >$TEMPFILE "From: $NAME <$FROM>" + printf >$TEMPFILE "From: $NAME <$FROM>\n" fi cat << EOM >> $TEMPFILE To: $ADDR @@ -55,7 +60,7 @@ Subject: $SUBJECT User-Agent: gpg-mailkeys/$VERSION MIME-Version: 1.0 Content-Type: multipart/mixed; micalg=pgp-sha1; - protocol="application/pgp-signature"; boundary="$BOUNDARY" + boundary="$BOUNDARY" Content-Disposition: inline @@ -71,29 +76,28 @@ $TEXT EOM if [ -f ~/.signature ]; - then echo "--=20" >> $TEMPFILE + then printf -- "--=20\n" >> $TEMPFILE cat ~/.signature >> $TEMPFILE fi cat << EOM >> $TEMPFILE --$BOUNDARY -Content-Type: text/plain; charset=us-ascii -Content-Disposition: attachment; filename="$1.sig" +Content-Type: application/pgp-keys +Content-Disposition: attachment; filename="$1.asc" `gpg --armor --export $1` --$BOUNDARY-- EOM - echo -n " sending" - /usr/sbin/sendmail -t <$TEMPFILE + printf " sending" + /usr/sbin/sendmail -ti <$TEMPFILE rm $TEMPFILE - echo " done." + printf " done.\n" shift 1 done if [ -n "$FAILKEYS" ]; then - echo - echo "Note: The following keys could not be sent:" - echo "$FAILKEYS" | tr ':' '\n' | sed -e '/^ *$/d' -e 's/^/ /' + printf "\nNote: The following keys could not be sent:\n" + printf "$FAILKEYS\n" | tr ':' '\n' | sed -e '/^ *$/d' -e 's/^/ /' fi