summaryrefslogtreecommitdiff
path: root/hebrew/pine/files/pgpdecode
blob: 1849ed714a5fb2eecb510e4ba557ff3bee103b76 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /bin/sh
# ---------- pgpdecode ---------
# 21.03.96 Roland Rosenfeld <roland@spinnaker.rhein.de>
#
# Sun Mar 24 12:01:21 MET 1996 Andreas Klemm <andreas@knobel.gun.de>
# The tmp files in the original version were world readable for
# the short time of unpacking, setting suitable umask prevents this
#
# Wed Sep 16 21:35:43 WST 1997 Anthony Di Pietro <anthony@dino.omen.com.au>
# Modified to work with both PGP v2 and PGP v5.
# Now uses mktemp to prevent symlink attack and tmp races.

umask 077

MYNAME=`basename $0`

STDOUT=`mktemp -q /tmp/${MYNAME}.XXXXXX`
if [ $? -ne 0 ]
then
  echo "$0: Can't create temporary file to decode message."
  exit 1
fi

trap "rm -f $STDOUT ; exit" 0 1 2 15

STDERR=`mktemp -q /tmp/${MYNAME}.XXXXXX`
if [ $? -ne 0 ]
then
  echo "$0: Can't create temporary file to decode message."
  exit 1
fi

trap "rm -f $STDOUT $STDERR; exit" 0 1 2 15

if [ -x @@PREFIX@@/bin/pgpv ]
then
  pgpv 2>&1 > $STDOUT |tee $STDERR > /dev/tty
else
  pgp -f 2>&1 > $STDOUT |tee $STDERR > /dev/tty
fi

cat $STDERR | \
grep -v '^No files specified.  Using stdin.$' | \
grep -v '^Opening file \"stdout\" type text.$' | \
grep -v '^Opening file \"stdout\" type binary.$' | \
grep -v '^Opening file \"/dev/null\" type text.$' | \
grep -v '^Opening file \"/dev/null\" type binary.$' | \
grep -v '^$'| \
sed -e 's/^/| /'
echo ""
cat $STDOUT