This commit is contained in:
+5
-1
@@ -2,12 +2,16 @@ FROM "alpine:3.23"
|
|||||||
LABEL maintainer="Cabillot Julien <dockerimages@cabillot.eu>"
|
LABEL maintainer="Cabillot Julien <dockerimages@cabillot.eu>"
|
||||||
|
|
||||||
COPY entrypoint.sh /entrypoint.sh
|
COPY entrypoint.sh /entrypoint.sh
|
||||||
|
COPY patch.py /tmp/patch.py
|
||||||
|
|
||||||
RUN apk add --no-cache offlineimap openssl && \
|
RUN apk add --no-cache offlineimap openssl && \
|
||||||
adduser -D offlineimap && \
|
adduser -D offlineimap && \
|
||||||
# Force SECLEVEL=1 in imaplib2 to allow connecting to servers with weak DH keys (DH_KEY_TOO_SMALL)
|
# Force SECLEVEL=1 in imaplib2 to allow connecting to servers with weak DH keys (DH_KEY_TOO_SMALL)
|
||||||
# This is required because OpenSSL 3.x in Alpine 3.23 defaults to SECLEVEL=2
|
# This is required because OpenSSL 3.x in Alpine 3.23 defaults to SECLEVEL=2
|
||||||
sed -i 's/ctx = ssl.SSLContext(ssl_version)/ctx = ssl.SSLContext(ssl_version)\n ctx.set_ciphers("DEFAULT:@SECLEVEL=1")/' /usr/lib/python3.*/site-packages/imaplib2/imaplib2.py
|
sed -i 's/ctx = ssl.SSLContext(ssl_version)/ctx = ssl.SSLContext(ssl_version)\n ctx.set_ciphers("DEFAULT:@SECLEVEL=1")/' /usr/lib/python3.*/site-packages/imaplib2/imaplib2.py && \
|
||||||
|
# Patch offlineimap email generator bug for defective messages
|
||||||
|
python3 /tmp/patch.py && rm /tmp/patch.py
|
||||||
|
|
||||||
COPY --chown=offlineimap offlineimaprc.*.tmpl /home/offlineimap/
|
COPY --chown=offlineimap offlineimaprc.*.tmpl /home/offlineimap/
|
||||||
|
|
||||||
# Add Tini
|
# Add Tini
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
import sys, os
|
||||||
|
|
||||||
|
maildir_path = "/usr/lib/python3.12/site-packages/offlineimap/folder/Maildir.py"
|
||||||
|
with open(maildir_path, "r") as f:
|
||||||
|
maildir = f.read()
|
||||||
|
maildir = maildir.replace(
|
||||||
|
"fd.write(msg.as_bytes(policy=output_policy))",
|
||||||
|
"try:\n fd.write(msg.as_bytes(policy=output_policy))\n except UnicodeEncodeError:\n fd.write(msg.as_string(policy=output_policy).encode('utf-8'))"
|
||||||
|
)
|
||||||
|
with open(maildir_path, "w") as f:
|
||||||
|
f.write(maildir)
|
||||||
|
|
||||||
|
imap_path = "/usr/lib/python3.12/site-packages/offlineimap/folder/IMAP.py"
|
||||||
|
with open(imap_path, "r") as f:
|
||||||
|
imap_py = f.read()
|
||||||
|
|
||||||
|
imap_patch = """
|
||||||
|
def get_msg_bytes(msg, policy):
|
||||||
|
try:
|
||||||
|
return msg.as_bytes(policy=policy)
|
||||||
|
except UnicodeEncodeError:
|
||||||
|
return msg.as_string(policy=policy).encode('utf-8')
|
||||||
|
"""
|
||||||
|
imap_py = imap_patch + imap_py.replace("msg.as_bytes(policy=output_policy)", "get_msg_bytes(msg, output_policy)")
|
||||||
|
with open(imap_path, "w") as f:
|
||||||
|
f.write(imap_py)
|
||||||
Reference in New Issue
Block a user