From 50b9c3738b97f19bc4ec22b9685f868d02e6a526 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 6 Jan 2024 20:08:54 +0000 Subject: [PATCH] doveauth: fix home directory returned from lookup_passdb It is currently unused, but better have it correct in case of enabling debugging options such as rawlogs. --- chatmaild/src/chatmaild/doveauth.py | 2 +- chatmaild/src/chatmaild/tests/test_doveauth.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/chatmaild/src/chatmaild/doveauth.py b/chatmaild/src/chatmaild/doveauth.py index a5e978ae..b95f2240 100644 --- a/chatmaild/src/chatmaild/doveauth.py +++ b/chatmaild/src/chatmaild/doveauth.py @@ -91,7 +91,7 @@ def lookup_passdb(db, config: Config, user, cleartext_password): VALUES (?, ?, ?)""" conn.execute(q, (user, encrypted_password, int(time.time()))) return dict( - home=f"/home/vmail/{user}", + home=f"/home/vmail/mail/{config.mail_domain}/{user}", uid="vmail", gid="vmail", password=encrypted_password, diff --git a/chatmaild/src/chatmaild/tests/test_doveauth.py b/chatmaild/src/chatmaild/tests/test_doveauth.py index 8c967b94..74b647cb 100644 --- a/chatmaild/src/chatmaild/tests/test_doveauth.py +++ b/chatmaild/src/chatmaild/tests/test_doveauth.py @@ -61,7 +61,10 @@ def test_handle_dovecot_request(db, example_config): assert res assert res[0] == "O" and res.endswith("\n") userdata = json.loads(res[1:].strip()) - assert userdata["home"] == "/home/vmail/some42123@chat.example.org" + assert ( + userdata["home"] + == "/home/vmail/mail/chat.example.org/some42123@chat.example.org" + ) assert userdata["uid"] == userdata["gid"] == "vmail" assert userdata["password"].startswith("{SHA512-CRYPT}")