summary refs log tree commit diff
path: root/contrib/mgpg
blob: 26c7e5e0ddc6097113f097085cefe4d5bdeb52dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/sh -e

tmp=$(mktemp -t mgpg.XXXXXX)
trap "rm -f '$tmp'" INT TERM EXIT

{
	echo "Content-Type: $PIPE_CONTENTTYPE"
	echo
	cat
} > "$tmp"

n=$(mshow -t "$tmp" | awk -F: '
	/: application\/pgp-encrypted/ {supported = 1}
	/: application\/octet-stream/ {if (supported) print $1}')

if [ "$n" ]; then
	mshow -O "$tmp" "$n" | gpg -d 2>&1 || exit 0
	exit 64
fi
exit 63