Support Dovecot 2.4 on Ubuntu 26.04

This commit is contained in:
parkel committed 2026-11-21 02:00:40 +01:00
1 parent b53f6ba8d6
commit 4ae4809dc6
5 files changed
+94 -10

No files matched your search

@@ -14,6 +14,7 @@ from django.test import SimpleTestCase
from coulobre.mail_node import MailboxSpec, main
from coulobre.mail_node_apply import (
apply_mailbox,
check_dovecot_maildir,
credential_path,
ensure_mail_home,
mailbox_status,
@@ -258,6 +259,31 @@ class MailboxApplyTests(SimpleTestCase):
class MailboxCommandTests(SimpleTestCase):
def test_dovecot_24_checks_the_maildir_driver_and_path(self):
with patch(
"coulobre.mail_node_apply.run",
side_effect=["2.4.2 (build)", "maildir", "~/Maildir"],
):
check_dovecot_maildir()
def test_dovecot_24_rejects_an_unmanaged_driver_or_path(self):
for settings in (["mdbox"], ["maildir", "~/other"]):
with (
self.subTest(settings=settings),
patch("coulobre.mail_node_apply.run", side_effect=["2.4.2", *settings]),
self.assertRaisesMessage(ValueError, "mail_driver and mail_path"),
):
check_dovecot_maildir()
def test_dovecot_23_checks_the_legacy_maildir_setting(self):
with patch(
"coulobre.mail_node_apply.run",
side_effect=["2.3.21 (build)", "maildir:~/Maildir"],
) as command:
check_dovecot_maildir()
command.assert_called_with("doveconf", "-h", "mail_location")
def test_password_tool_errors_omit_sensitive_input_and_output(self):
command = ("doveadm", "pw", "-s", "SHA512-CRYPT")
with (
+15 -2
View File
@@ -347,8 +347,7 @@ def check_services(mailbox):
local_domains = run("postconf", "-hx", "mydestination")
if mailbox.domain in re.split(r"[\s,]+", local_domains.lower()):
raise ValueError("The requested mail domain is a local Postfix destination.")
if run("doveconf", "-h", "mail_location") != "maildir:~/Maildir":
raise ValueError("Configure Dovecot mail_location for the managed Maildir.")
check_dovecot_maildir()
first_uid = int(run("doveconf", "-h", "first_valid_uid"))
last_uid = int(run("doveconf", "-h", "last_valid_uid"))
if account.pw_uid < first_uid or (last_uid and account.pw_uid > last_uid):
@@ -365,6 +364,20 @@ def check_services(mailbox):
return account, auth_group
def check_dovecot_maildir():
version = re.match(r"(\d+)\.(\d+)", run("dovecot", "--version"))
if version and tuple(map(int, version.groups())) >= (2, 4):
if (
run("doveconf", "-h", "mail_driver") != "maildir"
or run("doveconf", "-h", "mail_path") != "~/Maildir"
):
raise ValueError(
"Configure Dovecot mail_driver and mail_path for the managed Maildir."
)
elif run("doveconf", "-h", "mail_location") != "maildir:~/Maildir":
raise ValueError("Configure Dovecot mail_location for the managed Maildir.")
def dovecot_home(mailbox):
return run("doveadm", "user", "-f", "home", mailbox.address, missing_exit=67)