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
|
||||||
|
# 2) GpgOL_MIME_structure.txt contains a fully enveloped
|
||||||
|
# PGP payload with the proper headers.
|
||||||
|
# Of course everything can be base64 encoded as well...
|
||||||
|
for payload in msg.get_payload():
|
||||||
|
try:
|
||||||
|
if payload.get_content_type() != 'application/octet-stream':
|
||||||
|
continue
|
||||||
|
|
||||||
if payload[0].get_content_type() != 'text/plain':
|
fname = payload.get_filename(None)
|
||||||
return
|
if fname not in ['msg.gpg', 'msg.asc', 'GpgOL_MIME_structure.txt']:
|
||||||
|
continue
|
||||||
|
|
||||||
if payload[1].get_content_type() != 'application/octet-stream':
|
decode_base64(payload)
|
||||||
return
|
encpl = payload.get_payload()
|
||||||
|
# Check whether the payload is a fully enveloped PGP payload or
|
||||||
fname = payload[1].get_filename(None)
|
# just the unwrapped msg.gpg/asc file.
|
||||||
if not fname:
|
tmpmsg = message_from_string(encpl)
|
||||||
return
|
if tmpmsg.get_content_type() == 'multipart/encrypted':
|
||||||
|
msg_set_payload(msg, tmpmsg)
|
||||||
if fname not in ['msg.gpg', 'msg.asc', 'GpgOL_MIME_structure.txt']:
|
else:
|
||||||
return
|
msg_set_gpg_payload(msg, encpl, 'outlook', addpgp=True)
|
||||||
|
return
|
||||||
encpl = payload[1].get_payload()
|
except:
|
||||||
msg_set_gpg_payload(msg, encpl, 'outlook', addpgp=True)
|
# 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