]>
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.
64 if [ -z "$SENDMAIL_ARGS" ]; then
74 TEMPFILE
=`mktemp -t gpg2mail.XXXXXX`
75 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`
76 if [ -z "$ADDR" ]; then
77 printf "(no usable user ids)\n"
78 FAILKEYS
="$FAILKEYS:$1"
82 NANOTIME
=`date +%s-%N`
83 BOUNDARY
="ksp-$$-boundary-$NANOTIME"
87 printf >$TEMPFILE "From: $NAME <$FROM>\n"
89 cat << EOM >> $TEMPFILE
92 User-Agent: gpg-mailkeys/$VERSION
94 Content-Type: multipart/mixed; micalg=pgp-sha1;
96 Content-Disposition: inline
101 Content-Type: text/plain; charset=$LOCAL_CHARSET
102 Content-Disposition: inline
103 Content-Transfer-Encoding: quoted-printable
106 `echo "$TEXT" | qprint -e`
110 if [ -f ~
/.signature
];
111 then printf -- "--=20\n" >> $TEMPFILE
112 qprint
-e ~
/.signature
>> $TEMPFILE
115 cat << EOM >> $TEMPFILE
118 Content-Type: application/pgp-keys
119 Content-Disposition: attachment; filename="$1.asc"
121 `gpg --armor --export $1`
126 /usr
/sbin
/sendmail
$SENDMAIL_ARGS -ti <$TEMPFILE
132 if [ -n "$FAILKEYS" ]; then
133 printf "\nNote: The following keys could not be sent:\n"
134 printf "$FAILKEYS\n" |
tr ':' '\n' |
sed -e '/^ *$/d' -e 's/^/ /'