]>
git.sthu.org Git - pgp-tools.git/blob - gpg-mailkeys/gpg-mailkeys
3 # gpg-mailkeys: mail out just signed keys to their owners
11 # Define the charset used in the text message of the mail
15 # Get the local charset.
17 # The local charset is deduced from the charset used by both ~/.gpg-mailkeysrc
18 # and ~/.signature. If none of these files exist, the local charset is assumed
23 local charset
="us-ascii"
24 local file_list
="$HOME/.signature $HOME/.gpg-mailkeysrc"
26 for filename
in $file_list; do
28 if [ -e $filename ]; then
29 charset
=`file --mime-encoding $filename | cut -d ' ' -f 2`
35 LOCAL_CHARSET
=$charset
39 printf "Send people their newly signed GPG key by mail.\n"
40 printf "Usage: $0 keyid ...\n"
44 if [ -e ~
/.gpg-mailkeysrc
] ; then
47 if [ -n "$EMAIL" ]; then
50 if [ -z "$SUBJECT" ]; then
51 SUBJECT
="Your signed GPG key"
53 if [ -z "$NAME" ]; then
54 NAME
=`getent passwd $USER | cut -d: -f5 | cut -d, -f1`
56 if [ -z "$TEXT" ]; then
59 Here is your signed GPG key.
71 TEMPFILE
=`mktemp -t gpg2mail.XXXXXX`
72 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`
73 if [ -z "$ADDR" ]; then
74 printf "(no usable user ids)\n"
75 FAILKEYS
="$FAILKEYS:$1"
79 NANOTIME
=`date +%s-%N`
80 BOUNDARY
="ksp-$$-boundary-$NANOTIME"
84 printf >$TEMPFILE "From: $NAME <$FROM>\n"
86 cat << EOM >> $TEMPFILE
89 User-Agent: gpg-mailkeys/$VERSION
91 Content-Type: multipart/mixed; micalg=pgp-sha1;
93 Content-Disposition: inline
98 Content-Type: text/plain; charset=$LOCAL_CHARSET
99 Content-Disposition: inline
100 Content-Transfer-Encoding: quoted-printable
103 `echo "$TEXT" | qprint -e`
107 if [ -f ~
/.signature
];
108 then printf -- "--=20\n" >> $TEMPFILE
109 qprint
-e ~
/.signature
>> $TEMPFILE
112 cat << EOM >> $TEMPFILE
115 Content-Type: application/pgp-keys
116 Content-Disposition: attachment; filename="$1.asc"
118 `gpg --armor --export $1`
123 /usr
/sbin
/sendmail
-ti <$TEMPFILE
129 if [ -n "$FAILKEYS" ]; then
130 printf "\nNote: The following keys could not be sent:\n"
131 printf "$FAILKEYS\n" |
tr ':' '\n' |
sed -e '/^ *$/d' -e 's/^/ /'