]>
git.sthu.org Git - pgp-tools.git/blob - gpg-mailkeys/gpg-mailkeys
3 # gpg-mailkeys: mail out just signed keys to their owners
12 printf "Send people their newly signed GPG key by mail.\n"
13 printf "Usage: $0 keyid ...\n"
17 if [ -e ~
/.gpg-mailkeysrc
] ; then
20 if [ -n "$EMAIL" ]; then
23 if [ -z "$SUBJECT" ]; then
24 SUBJECT
="Your signed GPG key"
26 if [ -z "$NAME" ]; then
27 NAME
=`getent passwd $USER | cut -d: -f5 | cut -d, -f1`
29 if [ -z "$TEXT" ]; then
32 Here is your signed GPG key.
42 TEMPFILE
=`mktemp -t gpg2mail.XXXXXX`
43 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`
44 if [ -z "$ADDR" ]; then
45 printf "(no usable user ids)\n"
46 FAILKEYS
="$FAILKEYS:$1"
50 NANOTIME
=`date +%s-%N`
51 BOUNDARY
="ksp-$$-boundary-$NANOTIME"
55 printf >$TEMPFILE "From: $NAME <$FROM>\n"
57 cat << EOM >> $TEMPFILE
60 User-Agent: gpg-mailkeys/$VERSION
62 Content-Type: multipart/mixed; micalg=pgp-sha1;
64 Content-Disposition: inline
69 Content-Type: text/plain; charset=us-ascii
70 Content-Disposition: inline
71 Content-Transfer-Encoding: quoted-printable
78 if [ -f ~
/.signature
];
79 then printf -- "--=20\n" >> $TEMPFILE
80 cat ~
/.signature
>> $TEMPFILE
83 cat << EOM >> $TEMPFILE
86 Content-Type: application/pgp-keys
87 Content-Disposition: attachment; filename="$1.asc"
89 `gpg --armor --export $1`
94 /usr
/sbin
/sendmail
-ti <$TEMPFILE
100 if [ -n "$FAILKEYS" ]; then
101 printf "\nNote: The following keys could not be sent:\n"
102 printf "$FAILKEYS\n" |
tr ':' '\n' |
sed -e '/^ *$/d' -e 's/^/ /'