From 4ae4809dc6778540dc3c6c91f1cccbb4d82b01a7 Mon Sep 17 00:00:00 2001 From: Peter van Arkel Date: Sat, 21 Nov 2026 02:00:40 +0100 Subject: [PATCH] Support Dovecot 2.4 on Ubuntu 26.04 --- deploy/dovecot/coulobre-2.4.conf.example | 30 ++++++++++++++++++++ docs/deployment.md | 4 +-- docs/development.md | 27 ++++++++++++++---- src/coulobre/hosting/test_mail_node_apply.py | 26 +++++++++++++++++ src/coulobre/mail_node_apply.py | 17 +++++++++-- 5 files changed, 94 insertions(+), 10 deletions(-) create mode 100644 deploy/dovecot/coulobre-2.4.conf.example diff --git a/deploy/dovecot/coulobre-2.4.conf.example b/deploy/dovecot/coulobre-2.4.conf.example new file mode 100644 index 0000000..f6f4526 --- /dev/null +++ b/deploy/dovecot/coulobre-2.4.conf.example @@ -0,0 +1,30 @@ +dovecot_config_version = 2.4.0 +dovecot_storage_version = 2.4.0 +protocols = imap lmtp + +ssl = required +ssl_server_cert_file = /etc/ssl/coulobre-mail/fullchain.pem +ssl_server_key_file = /etc/ssl/coulobre-mail/privkey.pem + +mail_driver = maildir +mail_path = ~/Maildir +# Set both values to the UID of coulobre-vmail. +first_valid_uid = 103 +last_valid_uid = 103 + +auth_username_format = %{user | lower} +auth_cache_size = 0 +passdb passwd-file { + passwd_file_path = /etc/dovecot/coulobre-users +} +userdb passwd-file { + passwd_file_path = /etc/dovecot/coulobre-users +} + +service lmtp { + unix_listener /var/spool/postfix/private/dovecot-lmtp { + user = postfix + group = postfix + mode = 0600 + } +} diff --git a/docs/deployment.md b/docs/deployment.md index 68474fa..3a7b10c 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -276,8 +276,8 @@ finishes. Use **Retry publishing** if the current revision failed. ## Provision local mailboxes from the panel -Set up [Postfix and Dovecot 2.3](development.md#apply-a-mailbox-manifest) on the -Ubuntu 24.04 panel host and enable the +Set up [Postfix and Dovecot](development.md#apply-a-mailbox-manifest) on the +Ubuntu 24.04 or 26.04 panel host and enable the [mailbox provisioning socket](development.md#enable-local-mailbox-provisioning). Install the dedicated worker that connects to that socket. diff --git a/docs/development.md b/docs/development.md index 038fb0d..9eb7d8e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -316,11 +316,11 @@ coulobre-mail-node inspect coulobre-mailbox-1.json ### Apply a mailbox manifest -Use an Ubuntu 24.04 mail node with Postfix, Dovecot 2.3 and the `dovecot-imapd` -and `dovecot-lmtpd` packages. Install Coulobre in a root-owned virtual -environment on the node. Use a Postfix hostname outside the set of hosted -mail domains and keep those domains in Postfix's virtual mailbox address -class. See the [Postfix virtual domain guide](https://www.postfix.org/VIRTUAL_README.html). +Use Ubuntu 24.04 with Dovecot 2.3 or Ubuntu 26.04 with Dovecot 2.4. Install +Postfix, `dovecot-imapd`, and `dovecot-lmtpd`. Install Coulobre in a root-owned +virtual environment on the node. Use a Postfix hostname outside the set of +hosted mail domains and keep those domains in Postfix's virtual mailbox +address class. See the [Postfix virtual domain guide](https://www.postfix.org/VIRTUAL_README.html). On a fresh mail node, create the virtual mail user and empty lookup files. @@ -341,6 +341,8 @@ virtual_transport = lmtp:unix:private/dovecot-lmtp smtpd_reject_unlisted_recipient = yes ``` +#### Dovecot 2.3 on Ubuntu 24.04 + Replace the stock `auth-system.conf.ext` include in Dovecot's `10-auth.conf` with the following virtual user configuration. Configure Dovecot's TLS certificate and keep encrypted client authentication enabled on a public @@ -378,7 +380,20 @@ service lmtp { } ``` -Start Postfix and Dovecot with these settings and apply the manifest. +#### Dovecot 2.4 on Ubuntu 26.04 + +For a fresh, dedicated mail node, use the +[Dovecot 2.4 configuration example](../deploy/dovecot/coulobre-2.4.conf.example) +as `/etc/dovecot/dovecot.conf`. Set the certificate and key paths for the mail +hostname. Use the output of `id -u coulobre-vmail` for both UID settings. +For an existing mail node, follow the +[Dovecot upgrade guide](https://doc.dovecot.org/2.4.2/installation/upgrade/2.3-to-2.4.html) +to migrate its configuration and retain its Maildirs and Coulobre registry. + +#### Install the mailbox + +Start Postfix first to initialize its spool directory, then start Dovecot so +it can bind the LMTP socket. Apply the manifest once both services are running. ```sh sudo /opt/coulobre/bin/coulobre-mail-node apply coulobre-mailbox-1.json diff --git a/src/coulobre/hosting/test_mail_node_apply.py b/src/coulobre/hosting/test_mail_node_apply.py index dc0e060..ae363aa 100644 --- a/src/coulobre/hosting/test_mail_node_apply.py +++ b/src/coulobre/hosting/test_mail_node_apply.py @@ -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 ( diff --git a/src/coulobre/mail_node_apply.py b/src/coulobre/mail_node_apply.py index cf8b0cf..66bf940 100644 --- a/src/coulobre/mail_node_apply.py +++ b/src/coulobre/mail_node_apply.py @@ -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)