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

+30
View File
@@ -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
}
}
+2 -2
View File
@@ -276,8 +276,8 @@ finishes. Use **Retry publishing** if the current revision failed.
## Provision local mailboxes from the panel ## Provision local mailboxes from the panel
Set up [Postfix and Dovecot 2.3](development.md#apply-a-mailbox-manifest) on the Set up [Postfix and Dovecot](development.md#apply-a-mailbox-manifest) on the
Ubuntu 24.04 panel host and enable the Ubuntu 24.04 or 26.04 panel host and enable the
[mailbox provisioning socket](development.md#enable-local-mailbox-provisioning). [mailbox provisioning socket](development.md#enable-local-mailbox-provisioning).
Install the dedicated worker that connects to that socket. Install the dedicated worker that connects to that socket.
+21 -6
View File
@@ -316,11 +316,11 @@ coulobre-mail-node inspect coulobre-mailbox-1.json
### Apply a mailbox manifest ### Apply a mailbox manifest
Use an Ubuntu 24.04 mail node with Postfix, Dovecot 2.3 and the `dovecot-imapd` Use Ubuntu 24.04 with Dovecot 2.3 or Ubuntu 26.04 with Dovecot 2.4. Install
and `dovecot-lmtpd` packages. Install Coulobre in a root-owned virtual Postfix, `dovecot-imapd`, and `dovecot-lmtpd`. Install Coulobre in a root-owned
environment on the node. Use a Postfix hostname outside the set of hosted virtual environment on the node. Use a Postfix hostname outside the set of
mail domains and keep those domains in Postfix's virtual mailbox address hosted mail domains and keep those domains in Postfix's virtual mailbox
class. See the [Postfix virtual domain guide](https://www.postfix.org/VIRTUAL_README.html). 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. 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 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` Replace the stock `auth-system.conf.ext` include in Dovecot's `10-auth.conf`
with the following virtual user configuration. Configure Dovecot's TLS with the following virtual user configuration. Configure Dovecot's TLS
certificate and keep encrypted client authentication enabled on a public 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 ```sh
sudo /opt/coulobre/bin/coulobre-mail-node apply coulobre-mailbox-1.json sudo /opt/coulobre/bin/coulobre-mail-node apply coulobre-mailbox-1.json
@@ -14,6 +14,7 @@ from django.test import SimpleTestCase
from coulobre.mail_node import MailboxSpec, main from coulobre.mail_node import MailboxSpec, main
from coulobre.mail_node_apply import ( from coulobre.mail_node_apply import (
apply_mailbox, apply_mailbox,
check_dovecot_maildir,
credential_path, credential_path,
ensure_mail_home, ensure_mail_home,
mailbox_status, mailbox_status,
@@ -258,6 +259,31 @@ class MailboxApplyTests(SimpleTestCase):
class MailboxCommandTests(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): def test_password_tool_errors_omit_sensitive_input_and_output(self):
command = ("doveadm", "pw", "-s", "SHA512-CRYPT") command = ("doveadm", "pw", "-s", "SHA512-CRYPT")
with ( with (
+15 -2
View File
@@ -347,8 +347,7 @@ def check_services(mailbox):
local_domains = run("postconf", "-hx", "mydestination") local_domains = run("postconf", "-hx", "mydestination")
if mailbox.domain in re.split(r"[\s,]+", local_domains.lower()): if mailbox.domain in re.split(r"[\s,]+", local_domains.lower()):
raise ValueError("The requested mail domain is a local Postfix destination.") raise ValueError("The requested mail domain is a local Postfix destination.")
if run("doveconf", "-h", "mail_location") != "maildir:~/Maildir": check_dovecot_maildir()
raise ValueError("Configure Dovecot mail_location for the managed Maildir.")
first_uid = int(run("doveconf", "-h", "first_valid_uid")) first_uid = int(run("doveconf", "-h", "first_valid_uid"))
last_uid = int(run("doveconf", "-h", "last_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): 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 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): def dovecot_home(mailbox):
return run("doveadm", "user", "-f", "home", mailbox.address, missing_exit=67) return run("doveadm", "user", "-f", "home", mailbox.address, missing_exit=67)