/usr/bin/gpg-mailkeys is in signing-party 2.2-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | #! /bin/sh
#
# gpg-mailkeys: mail out just signed keys to their owners
#
# $Id: gpg-mailkeys 764 2015-01-22 22:48:30Z guilhem-guest $
set -e
VERSION='$Rev: 764 $'
# Define the charset used in the text message of the mail
LOCAL_CHARSET=""
##
# Get the local charset.
#
# The local charset is deduced from the charset used by both ~/.gpg-mailkeysrc
# and ~/.signature. If none of these files exist, the local charset is assumed
# to be us-ascii.
get_local_charset ()
{
local charset="us-ascii"
local file_list="$HOME/.signature $HOME/.gpg-mailkeysrc"
for filename in $file_list; do
if [ -e $filename ]; then
charset=`file --mime-encoding $filename | cut -d ' ' -f 2`
break
fi
done;
LOCAL_CHARSET=$charset
}
if [ -z "$*" ]; then
printf "Send people their newly signed GPG key by mail.\n"
printf "Usage: $0 keyid ...\n"
exit 1
fi
if [ -e ~/.gpg-mailkeysrc ] ; then
. ~/.gpg-mailkeysrc
fi
if [ -n "$EMAIL" ]; then
FROM="$EMAIL"
fi
if [ -z "$FROM" ]; then
echo "Error: No EMAIL set in ~/.gpg-mailkeysrc and no FROM set in environment."
exit 1
fi
if [ -z "$SUBJECT" ]; then
SUBJECT="Your signed GPG key"
fi
if [ -z "$NAME" ]; then
NAME=`getent passwd $USER | cut -d: -f5 | cut -d, -f1`
fi
if [ -z "$TEXT" ]; then
TEXT="Hi,
Here is your signed GPG key.
Enjoy,
$NAME"
fi
get_local_charset
FAILKEYS=
while [ -n "$1" ]; do
printf "[$1] "
TEMPFILE=`mktemp -t gpg2mail.XXXXXX`
ADDR=`${GNUPGBIN:-gpg} --with-colons --fixed-list-mode --list-key $1 | sed -e 's/^uid:[^rei:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:[^:]*:\([^:<]*<[^:>]*>\):.*/@@uid@@ \1/' -e '/^@@uid@@ /!d' -e 's/([^)]*)//g' -e 's/ */ /g' -e 's/^@@uid@@ //' | head -1`
if [ -z "$ADDR" ]; then
printf "(no usable user ids)\n"
FAILKEYS="$FAILKEYS:$1"
shift 1
continue
fi
NANOTIME=`date +%s-%N`
BOUNDARY="ksp-$$-boundary-$NANOTIME"
printf "$ADDR:"
printf >$TEMPFILE "From: $NAME <$FROM>\n"
cat << EOM >> $TEMPFILE
To: $ADDR
Subject: $SUBJECT
User-Agent: gpg-mailkeys/$VERSION
MIME-Version: 1.0
Content-Type: multipart/mixed; micalg=pgp-sha1;
boundary="$BOUNDARY"
Content-Disposition: inline
--$BOUNDARY
Content-Type: text/plain; charset=$LOCAL_CHARSET
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
`echo "$TEXT" | qprint -e`
EOM
if [ -f ~/.signature ];
then printf -- "--=20\n" >> $TEMPFILE
qprint -e ~/.signature >> $TEMPFILE
fi
cat << EOM >> $TEMPFILE
--$BOUNDARY
Content-Type: application/pgp-keys
Content-Disposition: attachment; filename="$1.asc"
`${GNUPGBIN:-gpg} --armor --export $1`
--$BOUNDARY--
EOM
printf " sending"
${SENDMAIL:-/usr/sbin/sendmail} $SENDMAIL_ARGS -ti <$TEMPFILE
rm $TEMPFILE
printf " done.\n"
shift 1
done
if [ -n "$FAILKEYS" ]; then
printf "\nNote: The following keys could not be sent:\n"
printf "$FAILKEYS\n" | tr ':' '\n' | sed -e '/^ *$/d' -e 's/^/ /'
fi
|