blob: c21e2fce3ef2f6d6de586c43ba30e116ec9220df (
plain) (
blame)
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
|
#!/bin/sh
# msign PLAINMSG - generate a PGP/MIME signed message
[ -f "$1" ] || exit 1
if command -v gpg2 >/dev/null; then
GPG=gpg2
else
GPG=gpg
fi
IFS='
'
TMPD=$(mktemp -d -t msign.XXXXXX)
trap "rm -rf '$TMPD'" INT TERM EXIT
FROM=$(maddr -a -h from "$1" | sed 1q)
[ "$FROM" ] && key="--default-key=$FROM"
awk '/^$/,0' "$1" | mmime | sed 's/$/
/' >"$TMPD"/content
$GPG $key --armor --detach-sign -o "$TMPD"/signature.asc "$TMPD"/content ||
exit $?
{
sed '/^$/q' "$1"
printf '#mblaze/raw %s/content\n' "$TMPD"
printf '#application/pgp-signature %s/signature.asc\n' "$TMPD"
} |
mmime -t 'multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"'
|