Hello all

JT pointed out that the mime-verify-signature-filter-Skript didn't work
properly with all messages. This version is now corrected and should
work (hopefully) with all kind of mime/pgp-Signed mails. Sorry for the
inconvenience.

-- 
cu
  --== Jerri ==--
Homepage:       http://www.jerri.de/   ICQ: 54160208
#!/bin/sh

# To get a good name which isn't overwritten
tempname=check_sign-$RANDOM-$$-$(date +"%Y%m%d%H%M%S")

# Create a temporary dir
mkdir /tmp/$tempname
cd /tmp/$tempname

# backup the original mail
cat > mail

# Get the signature
munpack -q mail > /dev/null 2>&1

# Get the signed part
boundary=`cat mail | grep boundary | sed -e "s/.*boundary=\"\(.*\)\".*/\1/" | sed -e 
"s/[\/+*]/./g" | head -1`
cat mail | sed -e "1,/^--$boundary$/ d" -e "/^--$boundary$/,$ d" | sed -e "$ d" > 
signed

# Check the signature
echo "-----Output from GnuPG-----" > gpgoutput
gpg --no-tty --verify part1 signed >> gpgoutput 2>&1
echo >> gpgoutput

# Output new mail
# Header
cat mail | sed -e "/^$/,$ d" | grep -v "^[Content-|Lines]" | grep -v "protocol"

# Mailbody and output from verification
# Thanks to JT <[EMAIL PROTECTED]> to pointing out the difference between
# multipart and normal messages
if cat signed | sed -e "/^$/,$ d" | grep -q "boundary"; then
        # If multipart message (with attachments)
        boundary=`cat signed | grep boundary | sed -e "s/.*boundary=\"\(.*\)\".*/\1/" 
| sed -e "s/[\/+*]/./g" | head -1`
        cat signed | awk "BEGIN {nummer=0} /^--$boundary\$/ {nummer++; if (nummer==2) 
{system(\"/bin/cat gpgoutput\")}} {print}"
else
        # Just a plain mail
        cat signed gpgoutput
fi

# Delete tempdir and files therein
cd /
rm -rf /tmp/$tempname

Attachment: msg23086/pgp00000.pgp
Description: PGP signature

Reply via email to