From 7cf6cc2c9176b43ea7278cbcfc7b6dd8e2ce07fe Mon Sep 17 00:00:00 2001 From: holger krekel Date: Thu, 19 Oct 2023 01:02:24 +0200 Subject: [PATCH] remove filtermail split and LMTP backend --- chatmaild/src/chatmaild/filtermail.py | 16 +++++----------- ...termail-before.service => filtermail.service} | 2 +- deploy-chatmail/src/deploy_chatmail/__init__.py | 7 +++++-- .../src/deploy_chatmail/postfix/master.cf.j2 | 1 - 4 files changed, 11 insertions(+), 15 deletions(-) rename chatmaild/src/chatmaild/{filtermail-before.service => filtermail.service} (71%) diff --git a/chatmaild/src/chatmaild/filtermail.py b/chatmaild/src/chatmaild/filtermail.py index 389be15a..859b628d 100644 --- a/chatmaild/src/chatmaild/filtermail.py +++ b/chatmaild/src/chatmaild/filtermail.py @@ -7,9 +7,8 @@ from email.parser import BytesParser from email import policy from email.utils import parseaddr -from aiosmtpd.lmtp import LMTP -from aiosmtpd.smtp import SMTP -from aiosmtpd.controller import UnixSocketController, Controller +from aiosmtpd.lmtp import SMTP +from aiosmtpd.controller import Controller from smtplib import SMTP as SMTPClient @@ -112,21 +111,16 @@ class SMTPController(Controller): return SMTP(self.handler, **self.SMTP_kwargs) -async def asyncmain_beforequeue(loop, port): +async def asyncmain_beforequeue(port): Controller(BeforeQueueHandler(), hostname="127.0.0.1", port=port).start() def main(): args = sys.argv[1:] - assert len(args) == 2 + assert len(args) == 1 logging.basicConfig(level=logging.INFO) loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) - if args[0] == "afterqueue": - task = asyncmain_afterqueue(loop, args[1]) - elif args[0] == "beforequeue": - task = asyncmain_beforequeue(loop, port=int(args[1])) - else: - raise SystemExit(1) + task = asyncmain_beforequeue(port=int(args[1])) loop.create_task(task) loop.run_forever() diff --git a/chatmaild/src/chatmaild/filtermail-before.service b/chatmaild/src/chatmaild/filtermail.service similarity index 71% rename from chatmaild/src/chatmaild/filtermail-before.service rename to chatmaild/src/chatmaild/filtermail.service index 0351c0b8..fec5ba4f 100644 --- a/chatmaild/src/chatmaild/filtermail-before.service +++ b/chatmaild/src/chatmaild/filtermail.service @@ -2,7 +2,7 @@ Description=Chatmail Postfix BeforeQeue filter [Service] -ExecStart=/usr/local/bin/filtermail beforequeue 10080 +ExecStart=/usr/local/bin/filtermail 10080 Restart=always RestartSec=30 diff --git a/deploy-chatmail/src/deploy_chatmail/__init__.py b/deploy-chatmail/src/deploy_chatmail/__init__.py index e152d925..a86bd3f1 100644 --- a/deploy-chatmail/src/deploy_chatmail/__init__.py +++ b/deploy-chatmail/src/deploy_chatmail/__init__.py @@ -34,9 +34,12 @@ def _install_chatmaild() -> None: commands=[f"pip install --break-system-packages {remote_path}"], ) - for fn in ("doveauth-dictproxy", "filtermail-before", ): + for fn in ( + "doveauth-dictproxy", + "filtermail", + ): files.put( - name=f"upload {fn}.service", + name=f"Upload {fn}.service", src=importlib.resources.files("chatmaild") .joinpath(f"{fn}.service") .open("rb"), diff --git a/deploy-chatmail/src/deploy_chatmail/postfix/master.cf.j2 b/deploy-chatmail/src/deploy_chatmail/postfix/master.cf.j2 index 34c0efe9..04d03b9f 100644 --- a/deploy-chatmail/src/deploy_chatmail/postfix/master.cf.j2 +++ b/deploy-chatmail/src/deploy_chatmail/postfix/master.cf.j2 @@ -33,7 +33,6 @@ submission inet n - y - - smtpd -o smtpd_relay_restrictions=permit_sasl_authenticated,reject -o milter_macro_daemon_name=ORIGINATING -o smtpd_proxy_filter=127.0.0.1:10080 - -o content_filter=filter:unix:private/filtermail-afterqueue smtps inet n - y - - smtpd -o syslog_name=postfix/smtps -o smtpd_tls_wrappermode=yes