mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/tglx/remail.git
synced 2024-11-08 13:42:36 +01:00
remail/mail: Handle Outlook GPG plugin proper
The Outlook GPG plugin works in interesting two variants: 1) msg.asc or msc.gpg provided as a plain attachement without PGP envelope 2) GpgOL_MIME_structure.txt contains a fully enveloped PGP payload with the proper headers. Of course everything can be base64 encoded and the number of payload sections is variable as well. Implement the handling for #2 so it can coexist with the existing workaround for #1. Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
8ada1c09b3
commit
d7b8db9b96
1 changed files with 32 additions and 18 deletions
|
@ -364,26 +364,40 @@ def msg_sanitize_outlook(msg):
|
||||||
if ct != 'multipart/mixed':
|
if ct != 'multipart/mixed':
|
||||||
return
|
return
|
||||||
|
|
||||||
# The bogus outlook mails consist of a text/plain and an attachment
|
# Try to find the payload part which actually contains the
|
||||||
payload = msg.get_payload()
|
# magically wrapped outlook GPG data.
|
||||||
if len(payload) != 2:
|
# Two variants:
|
||||||
return
|
# 1) msg.asc or msc.gpg provided as a plain attachement
|
||||||
|
# without PGP envelope
|
||||||
if payload[0].get_content_type() != 'text/plain':
|
# 2) GpgOL_MIME_structure.txt contains a fully enveloped
|
||||||
return
|
# PGP payload with the proper headers.
|
||||||
|
# Of course everything can be base64 encoded as well...
|
||||||
if payload[1].get_content_type() != 'application/octet-stream':
|
for payload in msg.get_payload():
|
||||||
return
|
try:
|
||||||
|
if payload.get_content_type() != 'application/octet-stream':
|
||||||
fname = payload[1].get_filename(None)
|
continue
|
||||||
if not fname:
|
|
||||||
return
|
|
||||||
|
|
||||||
|
fname = payload.get_filename(None)
|
||||||
if fname not in ['msg.gpg', 'msg.asc', 'GpgOL_MIME_structure.txt']:
|
if fname not in ['msg.gpg', 'msg.asc', 'GpgOL_MIME_structure.txt']:
|
||||||
return
|
continue
|
||||||
|
|
||||||
encpl = payload[1].get_payload()
|
decode_base64(payload)
|
||||||
|
encpl = payload.get_payload()
|
||||||
|
# Check whether the payload is a fully enveloped PGP payload or
|
||||||
|
# just the unwrapped msg.gpg/asc file.
|
||||||
|
tmpmsg = message_from_string(encpl)
|
||||||
|
if tmpmsg.get_content_type() == 'multipart/encrypted':
|
||||||
|
msg_set_payload(msg, tmpmsg)
|
||||||
|
else:
|
||||||
msg_set_gpg_payload(msg, encpl, 'outlook', addpgp=True)
|
msg_set_gpg_payload(msg, encpl, 'outlook', addpgp=True)
|
||||||
|
return
|
||||||
|
except:
|
||||||
|
# If one of the above operations fails badly, just ignore it.
|
||||||
|
# The unmodified message can either be handled or it will be
|
||||||
|
# moderated/frozen. The admin has to deal with it anyway. This
|
||||||
|
# avoids a gazillion of conditionals and checks in the above
|
||||||
|
# code.
|
||||||
|
continue
|
||||||
|
|
||||||
def decode_base64(msg):
|
def decode_base64(msg):
|
||||||
#
|
#
|
||||||
|
|
Loading…
Reference in a new issue