summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2017-03-10 10:52:44 +0100
committerErich Eckner <git@eckner.net>2017-03-10 10:52:44 +0100
commitbb5317093f55fbffe7366e48c7f4475889b33ac2 (patch)
tree753488b66addf085749875ac194cf8883abd270d
parent21127ca9e27e210e17567784cae5084f4a4b5e38 (diff)
downloadsendmailadvanced-bb5317093f55fbffe7366e48c7f4475889b33ac2.tar.xz
erzeuge MIME/multipart-Nachricht beim Veschluesseln
-rwxr-xr-xsendmailadvanced.in76
1 files changed, 63 insertions, 13 deletions
diff --git a/sendmailadvanced.in b/sendmailadvanced.in
index 218e4a1..2bcc3ba 100755
--- a/sendmailadvanced.in
+++ b/sendmailadvanced.in
@@ -192,29 +192,79 @@ fi
adressatenSammeln=false
fi
${adressatenSammeln} && adressatenString="${adressatenString}${s}"
+ if ${encrypt}
+ then
+ if [ "${zeile:0:14}" == "Content-Type: " ] || [ "${zeile:0:14}" == "MIME-Version: " ]
+ then
+ continue
+ fi
+ fi
echo "${zeile}"
done
${stamp} && stempeln
- echo "${zeile}"
- (
- for hookParam in "${hooks[@]}"
- do
- body_header_hook "${hookParam}"
- done
- cat
- for hookParam in "${hooks[@]}"
+ body="$(
+ (
+ for hookParam in "${hooks[@]}"
+ do
+ body_header_hook "${hookParam}"
+ done
+ cat
+ for hookParam in "${hooks[@]}"
+ do
+ body_footer_hook "${hookParam}"
+ done
+ ) | \
+ if ${encrypt}
+ then
+ gpg -e -a -s $(gpgAdressaten | sed 's| $||')
+ else
+ cat
+ fi
+ )"
+
+ if ${encrypt}
+ then
+ boundary=""
+ while
+ echo "${body}" | \
+ grep -q "${boundary}"
do
- body_footer_hook "${hookParam}"
+ boundary="$(
+ base64 -w0 < /dev/urandom | \
+ tr -d [/+] | \
+ head -c 33
+ )"
done
- ) | \
+
+ echo 'MIME-Version: 1.0'
+ echo 'Content-Type: multipart/encrypted;'
+ echo ' protocol="application/pgp-encrypted";'
+ echo ' boundary="'"${boundary}"'"'
+ echo ''
+ echo 'This is an OpenPGP/MIME encrypted message (RFC 4880 and 3156)'
+ echo '--'"${boundary}"
+ echo 'Content-Type: application/pgp-encrypted'
+ echo 'Content-Description: PGP/MIME version identification'
+ echo ''
+ echo 'Version: 1'
+ echo ''
+ echo '--'"${boundary}"
+ echo 'Content-Type: application/octet-stream; name="encrypted.asc"'
+ echo 'Content-Description: OpenPGP encrypted message'
+ echo 'Content-Disposition: inline; filename="encrypted.asc"'
+ fi
+
+ echo "${zeile}"
+ echo "${body}"
+
if ${encrypt}
then
- gpg -e -a -s -r $(gpgAdressaten)
- else
- cat
+ echo ''
+ echo '--'"${boundary}"'--'
fi
+
) | \
(
if [ -z "${datei}" ]