diff --git a/README.md b/README.md index 9221eb6..0f43eae 100644 --- a/README.md +++ b/README.md @@ -81,10 +81,11 @@ comprised of minimal setups of as well as two custom services that are integrated with these two: -- `chatmaild/src/chatmaild/dictproxy.py` implements +- `chatmaild/src/chatmaild/doveauth.py` implements create-on-login account creation semantics and is used by Dovecot during login authentication and by Postfix - which in turn uses Dovecot SASL to authenticate users + which in turn uses [Dovecot SASL](https://doc.dovecot.org/configuration_manual/authentication/dict/#complete-example-for-authenticating-via-a-unix-socket) + to authenticate users to send mails for them. - `chatmaild/src/chatmaild/filtermail.py` prevents diff --git a/chatmaild/pyproject.toml b/chatmaild/pyproject.toml index 9dfd147..8655149 100644 --- a/chatmaild/pyproject.toml +++ b/chatmaild/pyproject.toml @@ -10,7 +10,7 @@ dependencies = [ ] [project.scripts] -doveauth-dictproxy = "chatmaild.dictproxy:main" +doveauth = "chatmaild.doveauth:main" filtermail = "chatmaild.filtermail:main" [tool.pytest.ini_options] diff --git a/chatmaild/src/chatmaild/dictproxy.py b/chatmaild/src/chatmaild/doveauth.py similarity index 100% rename from chatmaild/src/chatmaild/dictproxy.py rename to chatmaild/src/chatmaild/doveauth.py diff --git a/chatmaild/src/chatmaild/doveauth-dictproxy.service b/chatmaild/src/chatmaild/doveauth.service similarity index 56% rename from chatmaild/src/chatmaild/doveauth-dictproxy.service rename to chatmaild/src/chatmaild/doveauth.service index d08fd61..1792fba 100644 --- a/chatmaild/src/chatmaild/doveauth-dictproxy.service +++ b/chatmaild/src/chatmaild/doveauth.service @@ -2,7 +2,7 @@ Description=Dict authentication proxy for dovecot [Service] -ExecStart=/usr/local/bin/doveauth-dictproxy /run/dovecot/doveauth.socket vmail /home/vmail/passdb.sqlite +ExecStart=/usr/local/bin/doveauth /run/dovecot/doveauth.socket vmail /home/vmail/passdb.sqlite Restart=always RestartSec=30 diff --git a/deploy-chatmail/src/deploy_chatmail/__init__.py b/deploy-chatmail/src/deploy_chatmail/__init__.py index a9d11c4..8279485 100644 --- a/deploy-chatmail/src/deploy_chatmail/__init__.py +++ b/deploy-chatmail/src/deploy_chatmail/__init__.py @@ -7,6 +7,7 @@ from pathlib import Path from pyinfra import host from pyinfra.operations import apt, files, server, systemd from pyinfra.facts.files import File +from pyinfra.facts.systemd import SystemdEnabled from .acmetool import deploy_acmetool @@ -34,8 +35,17 @@ def _install_chatmaild() -> None: commands=[f"pip install --break-system-packages {remote_path}"], ) + # disable legacy doveauth-dictproxy.service + if host.get_fact(SystemdEnabled).get("doveauth-dictproxy.service"): + systemd.service( + name="Disable legacy doveauth-dictproxy.service", + service="doveauth-dictproxy.service", + running=False, + enabled=False, + ) + for fn in ( - "doveauth-dictproxy", + "doveauth", "filtermail", ): files.put( diff --git a/tests/chatmaild/test_dictproxy.py b/tests/chatmaild/test_doveauth.py similarity index 93% rename from tests/chatmaild/test_dictproxy.py rename to tests/chatmaild/test_doveauth.py index 409eeb7..e15b5af 100644 --- a/tests/chatmaild/test_dictproxy.py +++ b/tests/chatmaild/test_doveauth.py @@ -5,8 +5,8 @@ import threading import queue import traceback -import chatmaild.dictproxy -from chatmaild.dictproxy import get_user_data, lookup_passdb, handle_dovecot_request +import chatmaild.doveauth +from chatmaild.doveauth import get_user_data, lookup_passdb, handle_dovecot_request from chatmaild.database import Database, DBError @@ -30,7 +30,7 @@ def test_dont_overwrite_password_on_wrong_login(db): def test_nocreate_file(db, monkeypatch, tmpdir): p = tmpdir.join("nocreate") p.write("") - monkeypatch.setattr(chatmaild.dictproxy, "NOCREATE_FILE", str(p)) + monkeypatch.setattr(chatmaild.doveauth, "NOCREATE_FILE", str(p)) lookup_passdb(db, "newuser1@something.org", "zequ0Aimuchoodaechik") assert not get_user_data(db, "newuser1@something.org")