From 4b0c9e4376ddd7f101201693691ce4f1077d1688 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Tue, 16 Sep 2025 09:43:18 +0200 Subject: [PATCH 1/3] WIP: dovecot 2.4 support --- modoboa_installer/scripts/base.py | 1 + modoboa_installer/scripts/dovecot.py | 92 ++-- .../dovecot/{ => 2.3}/conf.d/10-auth.conf | 0 .../dovecot/{ => 2.3}/conf.d/10-mail.conf | 0 .../{ => 2.3}/conf.d/10-master.conf.tpl | 0 .../{ => 2.3}/conf.d/10-ssl-keys.try.tpl | 0 .../dovecot/{ => 2.3}/conf.d/10-ssl.conf.tpl | 0 .../{ => 2.3}/conf.d/15-mailboxes.conf | 0 .../dovecot/{ => 2.3}/conf.d/20-imap.conf | 0 .../dovecot/{ => 2.3}/conf.d/20-lmtp.conf.tpl | 0 .../{ => 2.3}/conf.d/20-managesieve.conf | 0 .../dovecot/{ => 2.3}/conf.d/90-quota.conf | 0 .../{ => 2.3}/conf.d/90-sieve.conf.tpl | 0 .../{ => 2.3}/conf.d/auth-oauth2.conf.ext | 0 .../{ => 2.3}/conf.d/auth-sql.conf.ext | 0 .../conf.d/dovecot-oauth2.conf.ext.tpl | 0 .../{ => 2.3}/dovecot-dict-sql.conf.ext.tpl | 0 .../dovecot-sql-master-mysql.conf.ext.tpl | 0 .../dovecot-sql-master-postgres.conf.ext.tpl | 0 .../{ => 2.3}/dovecot-sql-mysql.conf.ext.tpl | 0 .../dovecot-sql-postgres.conf.ext.tpl | 0 .../files/dovecot/{ => 2.3}/dovecot.conf.tpl | 0 .../files/dovecot/2.4/conf.d/10-auth.conf | 122 +++++ .../files/dovecot/2.4/conf.d/10-mail.conf.tpl | 417 ++++++++++++++++++ .../dovecot/2.4/conf.d/10-master.conf.tpl | 167 +++++++ .../dovecot/2.4/conf.d/10-ssl-keys.try.tpl | 6 + .../files/dovecot/2.4/conf.d/10-ssl.conf.tpl | 59 +++ .../files/dovecot/2.4/conf.d/20-imap.conf | 109 +++++ .../files/dovecot/2.4/conf.d/20-lmtp.conf.tpl | 53 +++ .../2.4/conf.d/30-dict-server.conf.tpl | 42 ++ .../files/dovecot/2.4/conf.d/90-quota.conf | 79 ++++ .../dovecot/2.4/conf.d/90-sieve.conf.tpl | 118 +++++ .../2.4/conf.d/auth-oauth2.conf.ext.tpl | 24 + .../2.4/conf.d/auth-sql-mysql.conf.ext.tpl | 195 ++++++++ .../2.4/conf.d/auth-sql-postgres.conf.ext.tpl | 193 ++++++++ .../files/dovecot/2.4/dovecot.conf.tpl | 87 ++++ .../custom_after_sieve/spam-to-junk.sieve.tpl | 0 modoboa_installer/scripts/modoboa.py | 4 +- 38 files changed, 1737 insertions(+), 31 deletions(-) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/10-auth.conf (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/10-mail.conf (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/10-master.conf.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/10-ssl-keys.try.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/10-ssl.conf.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/15-mailboxes.conf (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/20-imap.conf (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/20-lmtp.conf.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/20-managesieve.conf (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/90-quota.conf (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/90-sieve.conf.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/auth-oauth2.conf.ext (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/auth-sql.conf.ext (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/conf.d/dovecot-oauth2.conf.ext.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/dovecot-dict-sql.conf.ext.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/dovecot-sql-master-mysql.conf.ext.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/dovecot-sql-master-postgres.conf.ext.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/dovecot-sql-mysql.conf.ext.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/dovecot-sql-postgres.conf.ext.tpl (100%) rename modoboa_installer/scripts/files/dovecot/{ => 2.3}/dovecot.conf.tpl (100%) create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-mail.conf.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl-keys.try.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl.conf.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/20-imap.conf create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/20-lmtp.conf.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-quota.conf create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-sieve.conf.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-oauth2.conf.ext.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-mysql.conf.ext.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/dovecot.conf.tpl rename modoboa_installer/scripts/files/dovecot/{conf.d => }/custom_after_sieve/spam-to-junk.sieve.tpl (100%) diff --git a/modoboa_installer/scripts/base.py b/modoboa_installer/scripts/base.py index a9a8290..e71b645 100644 --- a/modoboa_installer/scripts/base.py +++ b/modoboa_installer/scripts/base.py @@ -45,6 +45,7 @@ class Installer: @property def modoboa_2_2_or_greater(self): + return True # Check if modoboa version > 2.2 modoboa_version = python.get_package_version( "modoboa", diff --git a/modoboa_installer/scripts/dovecot.py b/modoboa_installer/scripts/dovecot.py index 00dd8c7..6d27d96 100644 --- a/modoboa_installer/scripts/dovecot.py +++ b/modoboa_installer/scripts/dovecot.py @@ -5,7 +5,6 @@ import os import pwd import shutil import stat -import uuid from .. import database from .. import package @@ -16,52 +15,87 @@ from . import base class Dovecot(base.Installer): - """Dovecot installer.""" appname = "dovecot" packages = { "deb": [ - "dovecot-imapd", "dovecot-lmtpd", "dovecot-managesieved", - "dovecot-sieve"], + "dovecot-imapd", + "dovecot-lmtpd", + "dovecot-managesieved", + "dovecot-sieve" + ], "rpm": [ "dovecot", "dovecot-pigeonhole"] } - config_files = [ - "dovecot.conf", - "dovecot-dict-sql.conf.ext", - "conf.d/10-ssl.conf", - "conf.d/10-master.conf", - "conf.d/20-lmtp.conf", - "conf.d/10-ssl-keys.try", - "conf.d/dovecot-oauth2.conf.ext", - ] + per_version_config_files = { + "2.3": [ + "dovecot.conf", + "dovecot-dict-sql.conf.ext", + "conf.d/10-ssl.conf", + "conf.d/10-master.conf", + "conf.d/20-lmtp.conf", + "conf.d/10-ssl-keys.try", + "conf.d/dovecot-oauth2.conf.ext", + ], + "2.4": [ + "dovecot.conf", + "conf.d/10-mail.conf", + "conf.d/10-master.conf", + "conf.d/10-ssl.conf", + "conf.d/10-ssl-keys.try", + "conf.d/20-lmtp.conf", + "conf.d/30-dict-server.conf", + "conf.d/auth-oauth2.conf.ext", + ] + } with_user = True + @property + def version(self) -> str: + if not hasattr(self, "_version"): + self._version = package.backend.get_installed_version("dovecot-core")[:3] + return self._version + def setup_user(self): """Setup mailbox user.""" super().setup_user() self.mailboxes_owner = self.app_config["mailboxes_owner"] system.create_user(self.mailboxes_owner, self.home_dir) - def get_config_files(self): - """Additional config files.""" - _config_files = self.config_files + def _get_config_files_for_version(self, version: str) -> list[str]: + files = self.per_version_config_files[version] + if version == "2.4": + files += [ + f"conf.d/auth-sql-{self.dbengine}.conf.ext=conf.d/auth-sql.conf.ext" + ] + else: + files += [ + f"dovecot-sql-{self.dbengine}.conf.ext=dovecot-sql.conf.ext", + f"dovecot-sql-master-{self.dbengine}.conf.ext=dovecot-sql-master.conf.ext" + ] + result = [] + for path in files: + if "=" not in path: + result.append(f"{version}/{path}={path}") + else: + src, dst = path.split("=") + result.append(f"{version}/{src}={dst}") + return result + def get_config_files(self) -> list[str]: + """Additional config files.""" + _config_files = self._get_config_files_for_version(self.version) + _config_files.append( + f"postlogin-{self.dbengine}.sh=/usr/local/bin/postlogin.sh" + ) if self.app_config["move_spam_to_junk"]: _config_files += [ - "conf.d/custom_after_sieve/spam-to-junk.sieve", - "conf.d/90-sieve.conf", + "custom_after_sieve/spam-to-junk.sieve=conf.d/custom_after_sieve/spam-to-junk.sieve", + f"{self.version}/conf.d/90-sieve.conf=conf.d/90-sieve.conf", ] - return _config_files + [ - "dovecot-sql-{}.conf.ext=dovecot-sql.conf.ext" - .format(self.dbengine), - "dovecot-sql-master-{}.conf.ext=dovecot-sql-master.conf.ext" - .format(self.dbengine), - "postlogin-{}.sh=/usr/local/bin/postlogin.sh" - .format(self.dbengine), - ] + return _config_files def get_packages(self): """Additional packages.""" @@ -99,7 +133,7 @@ class Dovecot(base.Installer): or package.backend.get_installed_version("openssl").startswith("3"): ssl_protocols = "!SSLv3" if ssl_protocol_parameter == "ssl_min_protocol": - ssl_protocols = "TLSv1" + ssl_protocols = "TLSv1.2" if "centos" in utils.dist_name(): protocols = "protocols = imap lmtp sieve" extra_protocols = self.config.get("dovecot", "extra_protocols") @@ -149,7 +183,7 @@ class Dovecot(base.Installer): def post_run(self): """Additional tasks.""" - if self.dbengine == "postgres": + if self.version == "2.3" and self.dbengine == "postgres": dbname = self.config.get("modoboa", "dbname") dbuser = self.config.get("modoboa", "dbuser") dbpassword = self.config.get("modoboa", "dbpassword") @@ -162,7 +196,7 @@ class Dovecot(base.Installer): dbname, dbuser, dbpassword, self.get_file_path("fix_modoboa_postgres_schema.sql") ) - for f in glob.glob("{}/*".format(self.get_file_path("conf.d"))): + for f in glob.glob(f"{self.version}/{self.get_file_path('conf.d')}/*"): if os.path.isfile(f): utils.copy_file(f, "{}/conf.d".format(self.config_dir)) # Make postlogin script executable diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/10-auth.conf b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-auth.conf similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/10-auth.conf rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-auth.conf diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/10-mail.conf b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-mail.conf similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/10-mail.conf rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-mail.conf diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-master.conf.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/10-master.conf.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-master.conf.tpl diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/10-ssl-keys.try.tpl b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-ssl-keys.try.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/10-ssl-keys.try.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-ssl-keys.try.tpl diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/10-ssl.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-ssl.conf.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/10-ssl.conf.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/10-ssl.conf.tpl diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/15-mailboxes.conf b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/15-mailboxes.conf similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/15-mailboxes.conf rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/15-mailboxes.conf diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/20-imap.conf b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/20-imap.conf similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/20-imap.conf rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/20-imap.conf diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/20-lmtp.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/20-lmtp.conf.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/20-lmtp.conf.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/20-lmtp.conf.tpl diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/20-managesieve.conf b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/20-managesieve.conf similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/20-managesieve.conf rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/20-managesieve.conf diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/90-quota.conf b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/90-quota.conf similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/90-quota.conf rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/90-quota.conf diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/90-sieve.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/90-sieve.conf.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/90-sieve.conf.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/90-sieve.conf.tpl diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/auth-oauth2.conf.ext b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/auth-oauth2.conf.ext similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/auth-oauth2.conf.ext rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/auth-oauth2.conf.ext diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/auth-sql.conf.ext b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/auth-sql.conf.ext similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/auth-sql.conf.ext rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/auth-sql.conf.ext diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/dovecot-oauth2.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.3/conf.d/dovecot-oauth2.conf.ext.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/dovecot-oauth2.conf.ext.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/conf.d/dovecot-oauth2.conf.ext.tpl diff --git a/modoboa_installer/scripts/files/dovecot/dovecot-dict-sql.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.3/dovecot-dict-sql.conf.ext.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/dovecot-dict-sql.conf.ext.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/dovecot-dict-sql.conf.ext.tpl diff --git a/modoboa_installer/scripts/files/dovecot/dovecot-sql-master-mysql.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-master-mysql.conf.ext.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/dovecot-sql-master-mysql.conf.ext.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-master-mysql.conf.ext.tpl diff --git a/modoboa_installer/scripts/files/dovecot/dovecot-sql-master-postgres.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-master-postgres.conf.ext.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/dovecot-sql-master-postgres.conf.ext.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-master-postgres.conf.ext.tpl diff --git a/modoboa_installer/scripts/files/dovecot/dovecot-sql-mysql.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-mysql.conf.ext.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/dovecot-sql-mysql.conf.ext.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-mysql.conf.ext.tpl diff --git a/modoboa_installer/scripts/files/dovecot/dovecot-sql-postgres.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-postgres.conf.ext.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/dovecot-sql-postgres.conf.ext.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/dovecot-sql-postgres.conf.ext.tpl diff --git a/modoboa_installer/scripts/files/dovecot/dovecot.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.3/dovecot.conf.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/dovecot.conf.tpl rename to modoboa_installer/scripts/files/dovecot/2.3/dovecot.conf.tpl diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf new file mode 100644 index 0000000..4227467 --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf @@ -0,0 +1,122 @@ +#log_debug=category=auth +#auth_debug_passwords = yes +## +## Authentication processes +## + +# Enable LOGIN command and all other plaintext authentications even if +# SSL/TLS is not used (LOGINDISABLED capability). Note that if the remote IP +# matches the local IP (ie. you're connecting from the same computer), the +# connection is considered secure and plaintext authentication is allowed, +# unless ssl = required. +#auth_allow_cleartext = yes + +# Authentication cache size (e.g. 10M). 0 means it's disabled. Note that +# bsdauth, PAM and vpopmail require cache_key to be set for caching to be used. +#auth_cache_size = 0 +# Time to live for cached data. After TTL expires the cached record is no +# longer used, *except* if the main database lookup returns internal failure. +# We also try to handle password changes automatically: If user's previous +# authentication was successful, but this one wasn't, the cache isn't used. +# For now this works only with plaintext authentication. +#auth_cache_ttl = 1 hour +# TTL for negative hits (user not found, password mismatch). +# 0 disables caching them completely. +#auth_cache_negative_ttl = 1 hour + +# Space separated list of realms for SASL authentication mechanisms that need +# them. You can leave it empty if you don't want to support multiple realms. +# Many clients simply use the first one listed here, so keep the default realm +# first. +#auth_realms = +# +# Default realm/domain to use if none was specified. This is used for both +# SASL realms and appending @domain to username in plaintext logins. +#auth_default_domain = + +# List of allowed characters in username. If the user-given username contains +# a character not listed in here, the login automatically fails. This is just +# an extra check to make sure user can't exploit any potential quote escaping +# vulnerabilities with SQL/LDAP databases. If you want to allow all characters, +# set this value to empty. +#auth_username_chars = abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890.-_@ + +# Username character translations before it's looked up from databases. The +# value contains series of from -> to characters. For example "#@/@" means +# that '#' and '/' characters are translated to '@'. +#auth_username_translation = + +# Username formatting before it's looked up from databases. +auth_username_format = %{user|lower} +#auth_username_format = %{user|username|lower} + +# If you want to allow master users to log in by specifying the master +# username within the normal username string (ie. not using SASL mechanism's +# support for it), you can specify the separator character here. The format +# is then . UW-IMAP uses "*" as the +# separator, so that could be a good choice. +auth_master_user_separator = * + +# Username to use for users logging in with ANONYMOUS SASL mechanism +#auth_anonymous_username = anonymous + +# Host name to use in GSSAPI principal names. The default is to use the +# name returned by gethostname(). Use "$ALL" (with quotes) to allow all keytab +# entries. +#auth_gssapi_hostname = + +# Kerberos keytab to use for the GSSAPI mechanism. Will use the system +# default (usually /etc/krb5.keytab) if not specified. You may need to change +# the auth service to run as root to be able to read this file. +#auth_krb5_keytab = + +# Do NTLM and GSS-SPNEGO authentication using Samba's winbind daemon and +# ntlm_auth helper. +#auth_use_winbind = no + +# Path for Samba's ntlm_auth helper binary. +#auth_winbind_helper_path = /usr/bin/ntlm_auth + +# Time to delay before replying to failed authentications. +#auth_failure_delay = 2 secs + +# Require a valid SSL client certificate or the authentication fails. +#auth_ssl_require_client_cert = no + +# Take the username from client's SSL certificate, using +# X509_NAME_get_text_by_NID() which returns the subject's DN's +# CommonName. +#auth_ssl_username_from_cert = no + +# Space separated list of wanted authentication mechanisms: +# plain login digest-md5 cram-md5 ntlm anonymous gssapi +# gss-spnego xoauth2 oauthbearer +# NOTE: See also auth_allow_cleartext setting. +auth_mechanisms = plain login oauthbearer xoauth2 + +## +## Password and user databases +## + +# +# Password database is used to verify user's password (and nothing more). +# You can have multiple passdbs and userdbs. This is useful if you want to +# allow both system users (/etc/passwd) and virtual users to login without +# duplicating the system users into virtual database. +# +# +# +# User database specifies where mails are located and what user/group IDs +# own them. For single-UID configuration use "static" userdb. +# +# + +#!include auth-deny.conf.ext +#!include auth-master.conf.ext +!include auth-oauth2.conf.ext + +#!include auth-system.conf.ext +!include auth-sql.conf.ext +#!include auth-ldap.conf.ext +#!include auth-passwdfile.conf.ext +#!include auth-static.conf.ext diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-mail.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-mail.conf.tpl new file mode 100644 index 0000000..5507d7e --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-mail.conf.tpl @@ -0,0 +1,417 @@ +## +## Mailbox locations and namespaces +## + +# Location for users' mailboxes. The default is empty, which means that Dovecot +# tries to find the mailboxes automatically. This won't work if the user +# doesn't yet have any mail, so you should explicitly tell Dovecot the full +# location. +# +# If you're using mbox, giving a path to the INBOX file (eg. /var/mail/%%u) +# isn't enough. You'll also need to tell Dovecot where the other mailboxes are +# kept. This is called the "root mail directory", and it must be the first +# path given in the mail_location setting. +# +# There are a few special variables you can use, eg.: +# +# %%{user} - username +# %%{user|username} - user part in user@domain, same as %%u if there's no domain +# %%{user|domain} - domain part in user@domain, empty if there's no domain +# %%{home} - home directory +# +# See https://doc.dovecot.org/latest/core/settings/variables.html for full list +# of variables. +# +# Example: +# mail_driver = maildir +# mail_path = ~/Maildir +# mail_inbox_path = ~/Maildir/.INBOX +# + +# Debian defaults +# Note that upstream considers mbox deprecated and strongly recommends +# against its use in production environments. See further information +# at +# https://doc.dovecot.org/2.4.0/core/config/mailbox/formats/mbox.html +# mail_driver = mbox +# mail_home = /home/%%{user|username} +# mail_path = %%{home}/mail +# mail_inbox_path = /var/mail/%%{user} +mail_driver = maildir +mail_home = %{home_dir}/%%{user|domain}/%%{user|username} +mail_path = %%{home}/Maildir + +# If you need to set multiple mailbox locations or want to change default +# namespace settings, you can do it by defining namespace sections. +# +# You can have private, shared and public namespaces. Private namespaces +# are for user's personal mails. Shared namespaces are for accessing other +# users' mailboxes that have been shared. Public namespaces are for shared +# mailboxes that are managed by sysadmin. If you create any shared or public +# namespaces you'll typically want to enable ACL plugin also, otherwise all +# users can access all the shared mailboxes, assuming they have permissions +# on filesystem level to do so. +namespace inbox { + # Namespace type: private, shared or public + #type = private + + # Hierarchy separator to use. You should use the same separator for all + # namespaces or some clients get confused. '/' is usually a good one. + # The default however depends on the underlying mail storage format. + #separator = + + # Prefix required to access this namespace. This needs to be different for + # all namespaces. For example "Public/". + #prefix = + + # Physical location of the mailbox. This is in same format as + # mail location, which is also the default for it. + # mail_driver = + # mail_path = + # + # There can be only one INBOX, and this setting defines which namespace + # has it. + inbox = yes + + # If namespace is hidden, it's not advertised to clients via NAMESPACE + # extension. You'll most likely also want to set list=no. This is mostly + # useful when converting from another server with different namespaces which + # you want to deprecate but still keep working. For example you can create + # hidden namespaces with prefixes "~/mail/", "~%%u/mail/" and "mail/". + #hidden = no + + # Show the mailboxes under this namespace with LIST command. This makes the + # namespace visible for clients that don't support NAMESPACE extension. + # "children" value lists child mailboxes, but hides the namespace prefix. + #list = yes + + # Namespace handles its own subscriptions. If set to "no", the parent + # namespace handles them (empty prefix should always have this as "yes") + #subscriptions = yes + + # See 15-mailboxes.conf for definitions of special mailboxes. +} + +# Example shared namespace configuration +#namespace shared { + #type = shared + #separator = / + + # Mailboxes are visible under "shared/user@domain/" + # $user, $domain and $username are expanded to the destination user. + #prefix = shared/$user/ + + # Mail location for other users' mailboxes. Note that %%{variables} and ~/ + # expands to the logged in user's data. %%{owner_user} and %%{owner_home} + # destination user's data. + #mail_driver = maildir + #mail_path = %%{owner_home}/Maildir + #mail_index_path = ~/Maildir/shared/%%{owner_user} + + # Use the default namespace for saving subscriptions. + #subscriptions = no + + # List the shared/ namespace only if there are visible shared mailboxes. + #list = children +#} +# Should shared INBOX be visible as "shared/user" or "shared/user/INBOX"? +#mail_shared_explicit_inbox = no + +# System user and group used to access mails. If you use multiple, userdb +# can override these by returning uid or gid fields. You can use either numbers +# or names. +#mail_uid = +#mail_gid = + +# Group to enable temporarily for privileged operations. Currently this is +# used only with INBOX when either its initial creation or dotlocking fails. +# Typically this is set to "mail" to give access to /var/mail. +mail_privileged_group = mail + +# Grant access to these supplementary groups for mail processes. Typically +# these are used to set up access to shared mailboxes. Note that it may be +# dangerous to set these if users can create symlinks (e.g. if "mail" group is +# set here, ln -s /var/mail ~/mail/var could allow a user to delete others' +# mailboxes, or ln -s /secret/shared/box ~/mail/mybox would allow reading it). +#mail_access_groups = + +# Allow full filesystem access to clients. There's no access checks other than +# what the operating system does for the active UID/GID. It works with both +# maildir and mboxes, allowing you to prefix mailboxes names with eg. /path/ +# or ~user/. +#mail_full_filesystem_access = no + +# Dictionary for key=value mailbox attributes. This is used for example by +# URLAUTH and METADATA extensions. +#mail_attribute { +# dict file { +# path = %%{home}/Maildir/dovecot-attributes +# } +#} + +# A comment or note that is associated with the server. This value is +# accessible for authenticated users through the IMAP METADATA server +# entry "/shared/comment". +#mail_server_comment = "" + +# Indicates a method for contacting the server administrator. According to +# RFC 5464, this value MUST be a URI (e.g., a mailto: or tel: URL), but that +# is currently not enforced. Use for example mailto:admin@example.com. This +# value is accessible for authenticated users through the IMAP METADATA server +# entry "/shared/admin". +#mail_server_admin = + +## +## Mail processes +## + +# Don't use mmap() at all. This is required if you store indexes to shared +# filesystems (NFS or clustered filesystem). +#mmap_disable = no + +# Rely on O_EXCL to work when creating dotlock files. NFS supports O_EXCL +# since version 3, so this should be safe to use nowadays by default. +#dotlock_use_excl = yes + +# When to use fsync() or fdatasync() calls: +# optimized (default): Whenever necessary to avoid losing important data +# always: Useful with e.g. NFS when write()s are delayed +# never: Never use it (best performance, but crashes can lose data) +#mail_fsync = optimized + +# Locking method for index files. Alternatives are fcntl, flock and dotlock. +# Dotlocking uses some tricks which may create more disk I/O than other locking +# methods. NFS users: flock doesn't work, remember to change mmap_disable. +#lock_method = fcntl + +# Directory where mails can be temporarily stored. Usually it's used only for +# mails larger than >= 128 kB. It's used by various parts of Dovecot, for +# example LDA/LMTP while delivering large mails or zlib plugin for keeping +# uncompressed mails. +#mail_temp_dir = /tmp + +# Valid UID range for users, defaults to 500 and above. This is mostly +# to make sure that users can't log in as daemons or other system users. +# Note that denying root logins is hardcoded to dovecot binary and can't +# be done even if first_valid_uid is set to 0. +#first_valid_uid = 500 +#last_valid_uid = 0 + +# Valid GID range for users, defaults to non-root/wheel. Users having +# non-valid GID as primary group ID aren't allowed to log in. If user +# belongs to supplementary groups with non-valid GIDs, those groups are +# not set. +#first_valid_gid = 1 +#last_valid_gid = 0 + +# Maximum allowed length for mail keyword name. It's only forced when trying +# to create new keywords. +#mail_max_keyword_length = 50 + +# ':' separated list of directories under which chrooting is allowed for mail +# processes (ie. /var/mail will allow chrooting to /var/mail/foo/bar too). +# This setting doesn't affect login_chroot, mail_chroot or auth chroot +# settings. If this setting is empty, "/./" in home dirs are ignored. +# WARNING: Never add directories here which local users can modify, that +# may lead to root exploit. Usually this should be done only if you don't +# allow shell access for users. +#valid_chroot_dirs = + +# Default chroot directory for mail processes. This can be overridden for +# specific users in user database by giving /./ in user's home directory +# (eg. /home/./user chroots into /home). Note that usually there is no real +# need to do chrooting, Dovecot doesn't allow users to access files outside +# their mail directory anyway. If your home directories are prefixed with +# the chroot directory, append "/." to mail_chroot. +#mail_chroot = + +# UNIX socket path to master authentication server to find users. +# This is used by imap (for shared users) and lda. +#auth_socket_path = /var/run/dovecot/auth-userdb + +# Directory where to look up mail plugins. +#mail_plugin_dir = /usr/lib/dovecot + +# Space separated list of plugins to load for all services. Plugins specific to +# IMAP, LDA, etc. are added to this list in their own .conf files. +#mail_plugins = +# +# To add plugins, use +#mail_plugins { +# plugin = yes +#} +mail_plugins { + quota = yes + quota_clone = yes +} + +## +## Mailbox handling optimizations +## + +# Mailbox list indexes can be used to optimize IMAP STATUS commands. They are +# also required for IMAP NOTIFY extension to be enabled. +#mailbox_list_index = yes + +# Trust mailbox list index to be up-to-date. This reduces disk I/O at the cost +# of potentially returning out-of-date results after e.g. server crashes. +# The results will be automatically fixed once the folders are opened. +#mailbox_list_index_very_dirty_syncs = yes + +# Should INBOX be kept up-to-date in the mailbox list index? By default it's +# not, because most of the mailbox accesses will open INBOX anyway. +#mailbox_list_index_include_inbox = no + +# The minimum number of mails in a mailbox before updates are done to cache +# file. This allows optimizing Dovecot's behavior to do less disk writes at +# the cost of more disk reads. +#mail_cache_min_mail_count = 0 + +# When IDLE command is running, mailbox is checked once in a while to see if +# there are any new mails or other changes. This setting defines the minimum +# time to wait between those checks. Dovecot can also use inotify and +# kqueue to find out immediately when changes occur. +#mailbox_idle_check_interval = 30 secs + +# Save mails with CR+LF instead of plain LF. This makes sending those mails +# take less CPU, especially with sendfile() syscall with Linux and FreeBSD. +# But it also creates a bit more disk I/O which may just make it slower. +# Also note that if other software reads the mboxes/maildirs, they may handle +# the extra CRs wrong and cause problems. +#mail_save_crlf = no + +# Max number of mails to keep open and prefetch to memory. This only works with +# some mailbox formats and/or operating systems. +#mail_prefetch_count = 0 + +# How often to scan for stale temporary files and delete them (0 = never). +# These should exist only after Dovecot dies in the middle of saving mails. +#mail_temp_scan_interval = 1w + +# How many slow mail accesses sorting can perform before it returns failure. +# With IMAP the reply is: NO [LIMIT] Requested sort would have taken too long. +# The untagged SORT reply is still returned, but it's likely not correct. +#mail_sort_max_read_count = 0 + +protocol !indexer-worker { + # If folder vsize calculation requires opening more than this many mails from + # disk (i.e. mail sizes aren't in cache already), return failure and finish + # the calculation via indexer process. Disabled by default. This setting must + # be 0 for indexer-worker processes. + #mail_vsize_bg_after_count = 0 +} + +## +## Maildir-specific settings +## + +# By default LIST command returns all entries in maildir beginning with a dot. +# Enabling this option makes Dovecot return only entries which are directories. +# This is done by stat()ing each entry, so it causes more disk I/O. +# (For systems setting struct dirent->d_type, this check is free and it's +# done always regardless of this setting) +#maildir_stat_dirs = no + +# When copying a message, do it with hard links whenever possible. This makes +# the performance much better, and it's unlikely to have any side effects. +#maildir_copy_with_hardlinks = yes + +# Assume Dovecot is the only MUA accessing Maildir: Scan cur/ directory only +# when its mtime changes unexpectedly or when we can't find the mail otherwise. +#maildir_very_dirty_syncs = no + +# If enabled, Dovecot doesn't use the S= in the Maildir filenames for +# getting the mail's physical size, except when recalculating Maildir++ quota. +# This can be useful in systems where a lot of the Maildir filenames have a +# broken size. The performance hit for enabling this is very small. +#maildir_broken_filename_sizes = no + +# Always move mails from new/ directory to cur/, even when the \Recent flags +# aren't being reset. +#maildir_empty_new = no + +## +## mbox-specific settings +## + +# Which locking methods to use for locking mbox. There are four available: +# dotlock: Create .lock file. This is the oldest and most NFS-safe +# solution. If you want to use /var/mail/ like directory, the users +# will need write access to that directory. +# dotlock_try: Same as dotlock, but if it fails because of permissions or +# because there isn't enough disk space, just skip it. +# fcntl : Use this if possible. Works with NFS too if lockd is used. +# flock : May not exist in all systems. Doesn't work with NFS. +# lockf : May not exist in all systems. Doesn't work with NFS. +# +# You can use multiple locking methods; if you do the order they're declared +# in is important to avoid deadlocks if other MTAs/MUAs are using multiple +# locking methods as well. Some operating systems don't allow using some of +# them simultaneously. +#mbox_read_locks = fcntl +#mbox_write_locks = dotlock fcntl + +# Maximum time to wait for lock (all of them) before aborting. +#mbox_lock_timeout = 5 mins + +# If dotlock exists but the mailbox isn't modified in any way, override the +# lock file after this much time. +#mbox_dotlock_change_timeout = 2 mins + +# When mbox changes unexpectedly we have to fully read it to find out what +# changed. If the mbox is large this can take a long time. Since the change +# is usually just a newly appended mail, it'd be faster to simply read the +# new mails. If this setting is enabled, Dovecot does this but still safely +# fallbacks to re-reading the whole mbox file whenever something in mbox isn't +# how it's expected to be. The only real downside to this setting is that if +# some other MUA changes message flags, Dovecot doesn't notice it immediately. +# Note that a full sync is done with SELECT, EXAMINE, EXPUNGE and CHECK +# commands. +#mbox_dirty_syncs = yes + +# Like mbox_dirty_syncs, but don't do full syncs even with SELECT, EXAMINE, +# EXPUNGE or CHECK commands. If this is set, mbox_dirty_syncs is ignored. +#mbox_very_dirty_syncs = no + +# Delay writing mbox headers until doing a full write sync (EXPUNGE and CHECK +# commands and when closing the mailbox). This is especially useful for POP3 +# where clients often delete all mails. The downside is that our changes +# aren't immediately visible to other MUAs. +#mbox_lazy_writes = yes + +# If mbox size is smaller than this (e.g. 100k), don't write index files. +# If an index file already exists it's still read, just not updated. +#mbox_min_index_size = 0 + +# Mail header selection algorithm to use for MD5 POP3 UIDLs when +# pop3_uidl_format=%%m. For backwards compatibility we use apop3d inspired +# algorithm, but it fails if the first Received: header isn't unique in all +# mails. An alternative algorithm is "all" that selects all headers. +#mbox_md5 = apop3d + +## +## mdbox-specific settings +## + +# Maximum dbox file size until it's rotated. +#mdbox_rotate_size = 10M + +# Maximum dbox file age until it's rotated. Typically in days. Day begins +# from midnight, so 1d = today, 2d = yesterday, etc. 0 = check disabled. +#mdbox_rotate_interval = 0 + +# When creating new mdbox files, immediately preallocate their size to +# mdbox_rotate_size. This setting currently works only in Linux with some +# filesystems (ext4, xfs). +#mdbox_preallocate_space = no + +# Settings to control adding $HasAttachment or $HasNoAttachment keywords. +# By default, all MIME parts with Content-Disposition=attachment, or inlines +# with filename parameter are consired attachments. +# add-flags - Add the keywords when saving new mails or when fetching can +# do it efficiently. +# content-type=type or !type - Include/exclude content type. Excluding will +# never consider the matched MIME part as attachment. Including will only +# negate an exclusion (e.g. content-type=!foo/* content-type=foo/bar). +# exclude-inlined - Exclude any Content-Disposition=inline MIME part. +#mail_attachment_detection_options = diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl new file mode 100644 index 0000000..b3a83d4 --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl @@ -0,0 +1,167 @@ +#default_process_limit = 100 +#default_client_limit = 1000 + +# Default VSZ (virtual memory size) limit for service processes. This is mainly +# intended to catch and kill processes that leak memory before they eat up +# everything. +#default_vsz_limit = 256M + +# Login user is internally used by login processes. This is the most untrusted +# user in Dovecot system. It shouldn't have access to anything at all. +#default_login_user = dovenull + +# Internal user is used by unprivileged processes. It should be separate from +# login user, so that login processes can't disturb other processes. +#default_internal_user = dovecot + +service imap-login { + inet_listener imap { + #port = 143 + } + inet_listener imaps { + #port = 993 + #ssl = yes + } + + # Number of connections to handle before starting a new process. Typically + # the only useful values are 0 (unlimited) or 1. 1 is more secure, but 0 + # is faster. + #service_restart_request_count = 1 + + # Number of processes to always keep waiting for more connections. + #process_min_avail = 0 + + # If you set service_restart_request_count=0, you probably need to grow this. + #vsz_limit = 256M # default +} + +service pop3-login { + inet_listener pop3 { + #port = 110 + } + inet_listener pop3s { + #port = 995 + #ssl = yes + } +} + +service submission-login { + inet_listener submission { + #port = 587 + } + inet_listener submissions { + #port = 465 + } +} + +service lmtp { + unix_listener lmtp { + #mode = 0666 + } + + # Create inet listener only if you can't use the above UNIX socket + #inet_listener lmtp { + # Avoid making LMTP visible for the entire internet + #listen = 127.0.0.1 + #port = 24 + #} + + unix_listener /var/spool/postfix/private/dovecot-lmtp { + mode = 0600 + user = postfix + group = postfix + } +} + +service imap { + # Most of the memory goes to mmap()ing files. You may need to increase this + # limit if you have huge mailboxes. + #vsz_limit = 256M # default + + # Max. number of IMAP processes (connections) + #process_limit = 1024 + + executable = imap postlogin +} + +service pop3 { + # Max. number of POP3 processes (connections) + #process_limit = 1024 + executable = imap postlogin +} + +service submission { + # Max. number of SMTP Submission processes (connections) + #process_limit = 1024 +} + +service postlogin { + executable = script-login /usr/local/bin/postlogin.sh + user = %modoboa_user + unix_listener postlogin { + } +} + +service stats { + # To allow modoboa to access available cipher list. + unix_listener stats-reader { + user = %{mailboxes_owner} + group = %{mailboxes_owner} + mode = 0660 + } + + unix_listener stats-writer { + user = %{mailboxes_owner} + group = %{mailboxes_owner} + mode = 0660 + } +} + + +service auth { + # auth_socket_path points to this userdb socket by default. It's typically + # used by dovecot-lda, doveadm, possibly imap process, etc. Users that have + # full permissions to this socket are able to get a list of all usernames and + # get the results of everyone's userdb lookups. + # + # The default 0666 mode allows anyone to connect to the socket, but the + # userdb lookups will succeed only if the userdb returns an "uid" field that + # matches the caller process's UID. Also if caller's uid or gid matches the + # socket's uid or gid the lookup succeeds. Anything else causes a failure. + # + # To give the caller full permissions to lookup all users, set the mode to + # something else than 0666 and Dovecot lets the kernel enforce the + # permissions (e.g. 0777 allows everyone full permissions). + unix_listener auth-userdb { + #mode = 0666 + user = %{mailboxes_owner} + #group = + } + + # Postfix smtp-auth + unix_listener /var/spool/postfix/private/auth { + mode = 0666 + user = postfix + group = postfix + } + + # Auth process is run as this user. + #user = $SET:default_internal_user +} + +service auth-worker { + # Auth worker process is run as root by default, so that it can access + # /etc/shadow. If this isn't necessary, the user should be changed to + # $SET:default_internal_user. + #user = root +} + +service dict { + # If dict proxy is used, mail processes should have access to its socket. + # For example: mode=0660, group=vmail and global mail_access_groups=vmail + unix_listener dict { + mode = 0600 + user = %{mailboxes_owner} + #group = + } +} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl-keys.try.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl-keys.try.tpl new file mode 100644 index 0000000..2c48f5d --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl-keys.try.tpl @@ -0,0 +1,6 @@ +# PEM encoded X.509 SSL/TLS certificate and private key. They're opened before +# dropping root privileges, so keep the key file unreadable by anyone but +# root. Included doc/mkcert.sh can be used to easily generate self-signed +# certificate, just make sure to update the domains in dovecot-openssl.cnf +ssl_server_cert_file = %tls_cert_file +ssl_server_key_file = %tls_key_file \ No newline at end of file diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl.conf.tpl new file mode 100644 index 0000000..64dada4 --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-ssl.conf.tpl @@ -0,0 +1,59 @@ +## +## SSL settings +## + +# SSL/TLS support: yes, no, required. +ssl = yes + +# PEM encoded X.509 SSL/TLS certificate and private key. By default, Debian +# installs a self-signed certificate. This is useful for testing, but you +# should obtain a real certificate from a recognized certificate authority. +# +# These files are opened before dropping root privileges, so keep the key file +# unreadable by anyone but root. Included /usr/share/dovecot/mkcert.sh can be +# used to easily generate self-signed certificate, just make sure to update the +# domains in dovecot-openssl.cnf +# +# Preferred permissions: root:root 0444 +# ssl_server_cert_file = /etc/dovecot/private/dovecot.pem +# Preferred permissions: root:root 0400 +# ssl_server_key_file = /etc/dovecot/private/dovecot.key +!include_try /etc/dovecot/conf.d/10-ssl-keys.try + +# If key file is password protected, give the password here. Alternatively +# give it when starting dovecot with -p parameter. Since this file is often +# world-readable, you may want to place this setting instead to a different +# root owned 0600 file by using ssl_key_password = ) instead of full path +# syntax. +# +#lmtp_client_workarounds { +# whitespace-before-path = yes +#} + +protocol lmtp { + mail_plugins { + quota = yes + sieve = yes + } + postmaster_address = %postmaster_address + + # This strips the domain name before delivery, since the default + # userdb in Debian is /etc/passwd, which doesn't include domain + # names in the user. If you're using a different userdb backend + # that does include domain names, you may wish to remove this. See + # https://doc.dovecot.org/2.4.0/howto/lmtp/exim.html and + # https://doc.dovecot.org/2.4.0/core/summaries/settings.html#auth_username_format + # auth_username_format = %%{user | username} +} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl new file mode 100644 index 0000000..23996ff --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl @@ -0,0 +1,42 @@ +## +## Dictionary server settings +## + +# Dictionary can be used to store key=value lists. This is used by several +# plugins. The dictionary can be accessed either directly or though a +# dictionary server. The following dict block maps dictionary names to URIs +# when the server is used. These can then be referenced using URIs in format +# "proxy::". + +dict_server { + dict quota { + driver = sql + sql_driver = %db_driver + hostname = %dbhost + dbname = %modoboa_dbname + user = %modoboa_dbuser + password = %modoboa_dbpassword + + dict_map priv/quota/storage { + sql_table = admin_quota + username_field = username + value_field bytes { + type = uint + } + } + + dict_map priv/quota/messages { + sql_table = admin_quota + username_field = username + value_field messages { + type = uint + } + } + } +} + +quota_clone { + dict proxy { + name = quota + } +} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-quota.conf b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-quota.conf new file mode 100644 index 0000000..499439f --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-quota.conf @@ -0,0 +1,79 @@ +## +## Quota configuration. +## + +# Note that you also have to enable quota plugin in mail_plugins setting. +## + +## +## Quota limits +## + +# Quota limits are set using "quota_rule" parameters. To get per-user quota +# limits, you can set/override them by returning "quota_rule" extra field +# from userdb. It's also possible to give mailbox-specific limits, for example +# to give additional 100 MB when saving to Trash: + +#mail_plugins { +# quota = yes +#} + +quota "User quota" { +# storage_size = 1G +} +# +#namespace inbox { +# mailbox Trash { +# quota_storage_extra = 100M +# } +#} + +## +## Quota warnings +## + +# You can execute a given command when user exceeds a specified quota limit. +# Each quota root has separate limits. Only the command for the first +# exceeded limit is excecuted, so put the highest limit first. +# The commands are executed via script service by connecting to the named +# UNIX socket (quota-warning below). +# Note that % needs to be escaped as %%, otherwise "% " expands to empty. + +#quota "User quota" { +# warning warn-95 { +# quota_storage_percentage = 95 +# execute quota-warning { +# args = 95 %{user} +# } +# } +# warning warn-80 { +# quota_storage_percentage = 80 +# execute quota-warning { +# args = 80 %{user} +# } +# } +#} + +# Example quota-warning service. The unix listener's permissions should be +# set in a way that mail processes can connect to it. Below example assumes +# that mail processes run as vmail user. If you use mode=0666, all system users +# can generate quota warnings to anyone. +#service quota-warning { +# executable = script /usr/local/bin/quota-warning.sh +# user = dovecot +# unix_listener quota-warning { +# user = vmail +# } +#} + +## +## Quota backends +## + +# Multiple backends are supported: +# count: Default and recommended, quota driver tracks the quota internally within Dovecot's index files. +# maildir: Maildir++ quota +# fs: Read-only support for filesystem quota +#quota "User quota" { +# driver = count +#} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-sieve.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-sieve.conf.tpl new file mode 100644 index 0000000..835418d --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/90-sieve.conf.tpl @@ -0,0 +1,118 @@ +## +## Settings for the Sieve interpreter +## + +# Do not forget to enable the Sieve plugin in 15-lda.conf and 20-lmtp.conf +# by adding it to the respective mail_plugins { sieve = yes } settings. + +# See https://doc.dovecot.org/latest/core/plugins/sieve.html + +# Personal sieve script location +#sieve_script personal { +# driver = file +# path = ~/sieve +# active_path = ~/.dovecot.sieve +#} + +# Default sieve script location +#sieve_script default { +# type = default +# name = default +# driver = file +# path = /etc/dovecot/sieve/default/ +#} + +%{do_move_spam_to_junk}sieve_script after { +%{do_move_spam_to_junk} type = after +%{do_move_spam_to_junk} path = /etc/dovecot/conf.d/custom_after_sieve +%{do_move_spam_to_junk}} + + +# Which Sieve language extensions are available to users. By default, all +# supported extensions are available, except for deprecated extensions or +# those that are still under development. Some system administrators may want +# to disable certain Sieve extensions or enable those that are not available +# by default. This setting can use 'yes' and 'no' to specify differences relative +# to the default. For example `imapflags = yes' will enable the +# deprecated imapflags extension in addition to all extensions were already +# enabled by default. +#sieve_extensions { +# mboxmetadata = yes +# vnd.dovecot.debug = yes +#} + +# Which Sieve language extensions are ONLY available in global scripts. This +# can be used to restrict the use of certain Sieve extensions to administrator +# control, for instance when these extensions can cause security concerns. +# This setting has higher precedence than the `sieve_extensions' setting +# (above), meaning that the extensions enabled with this setting are never +# available to the user's personal script no matter what is specified for the +# `sieve_extensions' setting. The syntax of this setting is similar to the +# `sieve_extensions' setting, with the difference that extensions are +# enabled or disabled for exclusive use in global scripts. Currently, no +# extensions are marked as such by default. +#sieve_global_extensions = + +# The Pigeonhole Sieve interpreter can have plugins of its own. Using this +# setting, the used plugins can be specified. Check the Dovecot documentation +# https://doc.dovecot.org/latest/core/plugins/sieve.html + +#sieve_plugins = sieve_imapsieve sieve_extprograms +#sieve_pipe_bin_dir = /usr/share/dovecot-pigeonhole/sieve +#sieve_execute_bin_dir = /usr/share/dovecot-pigeonhole/sieve +#sieve_global_extensions { +# vnd.dovecot.pipe = yes +# vnd.dovecot.execute = yes +#} +#imapsieve_url = + +# The separator that is expected between the :user and :detail +# address parts introduced by the subaddress extension. This may +# also be a sequence of characters (e.g. '--'). The current +# implementation looks for the separator from the left of the +# localpart and uses the first one encountered. The :user part is +# left of the separator and the :detail part is right. This setting +# is also used by Dovecot's LMTP service. +#recipient_delimiter = +-_ + +# The maximum size of a Sieve script. The compiler will refuse to compile any +# script larger than this limit. If set to 0, no limit on the script size is +# enforced. +#sieve_max_script_size = 1M + +# The maximum number of actions that can be performed during a single script +# execution. If set to 0, no limit on the total number of actions is enforced. +#sieve_max_actions = 32 + +# The maximum number of redirect actions that can be performed during a single +# script execution. If set to 0, no redirect actions are allowed. +#sieve_max_redirects = 4 + +# The maximum number of personal Sieve scripts a single user can have. If set +# to 0, no limit on the number of scripts is enforced. +# (Currently only relevant for ManageSieve) +#sieve_quota_script_count = 0 + +# The maximum amount of disk storage a single user's scripts may occupy. If +# set to 0, no limit on the used amount of disk storage is enforced. +# (Currently only relevant for ManageSieve) +#sieve_quota_storage_size = 0 + + +#mailbox Spam { +## From elsewhere to Spam folder +# sieve_script report-spam { +# type = before +# cause = copy +# path = /etc/dovecot/report-spam.sieve +# } +#} + +## From Spam folder to elsewhere +#imapsieve_from Spam { +# sieve_script report-ham { +# type = before +# cause = copy +# path = /etc/dovecot/report-ham.sieve +# } +#} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-oauth2.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-oauth2.conf.ext.tpl new file mode 100644 index 0000000..5291b95 --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-oauth2.conf.ext.tpl @@ -0,0 +1,24 @@ +auth_mechanisms { + xoauth2 = yes + oauthbearer = yes +} + +oauth2 { + introspection_mode = post + introspection_url = %{oauth2_introspection_url} + #force_introspection = yes + username_attribute = username +} + +# with local validation +#oauth2 { +# introspection_mode = local +# username_attribute = email +# oauth2_local_validation { +# dict fs { +# fs posix { +# prefix = /etc/dovecot/oauth2-keys/ +# } +# } +# } +#} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-mysql.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-mysql.conf.ext.tpl new file mode 100644 index 0000000..ffcc25a --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-mysql.conf.ext.tpl @@ -0,0 +1,195 @@ +# Authentication for SQL users. Included from auth.conf. +# +# + +# For the sql passdb module, you'll need a database with a table that +# contains fields for at least the username and password. If you want to +# use the user@domain syntax, you might want to have a separate domain +# field as well. +# +# If your users all have the same uig/gid, and have predictable home +# directories, you can use the static userdb module to generate the home +# dir based on the username and domain. In this case, you won't need fields +# for home, uid, or gid in the database. +# +# If you prefer to use the sql userdb module, you'll want to add fields +# for home, uid, and gid. Here is an example table: +# +# CREATE TABLE users ( +# username VARCHAR(128) NOT NULL, +# domain VARCHAR(128) NOT NULL, +# password VARCHAR(64) NOT NULL, +# home VARCHAR(255) NOT NULL, +# uid INTEGER NOT NULL, +# gid INTEGER NOT NULL, +# active CHAR(1) DEFAULT 'Y' NOT NULL +# ); + +# Database driver: mysql, pgsql, sqlite +sql_driver = %db_driver + +# Database connection string. This is driver-specific setting. +# +# HA / round-robin load-balancing is supported by giving multiple host +# settings, like: host=sql1.host.org host=sql2.host.org +# +# pgsql: +# For available options, see the PostgreSQL documention for the +# PQconnectdb function of libpq. +# Use maxconns=n (default 5) to change how many connections Dovecot can +# create to pgsql. +# +# mysql: +# Basic options emulate PostgreSQL option names: +# host, port, user, password, dbname +# +# But also adds some new settings: +# client_flags - See MySQL manual +# ssl_ca, ssl_ca_path - Set either one or both to enable SSL +# ssl_cert, ssl_key - For sending client-side certificates to server +# ssl_cipher - Set minimum allowed cipher security (default: HIGH) +# option_file - Read options from the given file instead of +# the default my.cnf location +# option_group - Read options from the given group (default: client) +# +# You can connect to UNIX sockets by using host: host=/var/run/mysql.sock +# Note that currently you can't use spaces in parameters. +# +# sqlite: +# The path to the database file. +# +# Examples: +# mysql 192.168.1.1 { +# dbname = users +# } +# mysql sql.example.com { +# ssl = yes +# user = virtual +# password = blarg +# dbname = virtual +# } +# sqlite /etc/dovecot/authdb.sqlite { +# } +# +#mysql /var/run/mysqld/mysqld.sock { +# user = dovecot +# password = dvmail +# dbname = dovecot +#} +#mysql localhost { +# ... +#} +mysql %dbhost { + port = %dbport + dbname = %modoboa_dbname + user = %modoboa_dbuser + password = %modoboa_dbpassword +} + +#passdb sql { +# default_password_scheme = SHA256 + +# passdb query to retrieve the password. It can return fields: +# password - The user's password. This field must be returned. +# user - user@domain from the database. Needed with case-insensitive lookups. +# username and domain - An alternative way to represent the "user" field. +# +# The "user" field is often necessary with case-insensitive lookups to avoid +# e.g. "name" and "nAme" logins creating two different mail directories. If +# your user and domain names are in separate fields, you can return "username" +# and "domain" fields instead of "user". +# +# The query can also return other fields which have a special meaning, see +# https://doc.dovecot.org/latest/core/config/auth/passdb.html#extra-fields +# +# Commonly used available substitutions (see https://doc.dovecot.org/latest/core/settings/variables.html +# for full list): +# %{user} = entire user@domain +# %{user|username} = user part of user@domain +# %{user|domain} = domain part of user@domain +# +# Note that these can be used only as input to SQL query. If the query outputs +# any of these substitutions, they're not touched. Otherwise it would be +# difficult to have eg. usernames containing '%' characters. +# +# Example: +# query = SELECT userid AS user, pw AS password \ +# FROM users WHERE userid = '%u' AND active = 'Y' +# +# query = \ +# SELECT userid as username, domain, password \ +# FROM users WHERE userid = '%{user|username}' AND domain = '%{user|domain}' +#} + +passdb sql { + query = SELECT email AS user, password FROM core_user u INNER JOIN admin_mailbox mb ON u.id=mb.user_id INNER JOIN admin_domain dom ON mb.domain_id=dom.id WHERE (mb.is_send_only=0 OR '%%{protocol}' NOT IN ('imap', 'pop3')) AND u.email='%%{user}' AND u.is_active=1 AND dom.enabled=1 +} + +#userdb sql { +# userdb query to retrieve the user information. It can return fields: +# uid - System UID (overrides mail_uid setting) +# gid - System GID (overrides mail_gid setting) +# home - Home directory +# mail_driver - Mail driver +# mail_path - Mail storage path +# +# None of these are strictly required. If you use a single UID and GID, and +# home or mail directory fits to a template string, you could use userdb static +# instead. For a list of all fields that can be returned, see +# Examples: +# query = SELECT home, uid, gid FROM users WHERE userid = '%%{user}' +# query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%%{user}' +# query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%%{user}' +# +# query = \ +# SELECT home, uid, gid \ +# FROM users WHERE userid = '%%{user|username}' AND domain = '%%{user|domain}' + +# Query to get a list of all usernames. +# iterate_query = SELECT username AS user,domain FROM users + +# userdb_ldap { +# iterate_fields { +# home = /var/vmail/%%{home} +# } +# } +#} + +userdb sql { + query = SELECT '%{home_dir}/%%{user|domain}/%%{user|username}' AS home, %mailboxes_owner_uid as uid, %mailboxes_owner_gid as gid, CONCAT(mb.quota, 'M') AS quota_storage_size FROM admin_mailbox mb INNER JOIN admin_domain dom ON mb.domain_id=dom.id INNER JOIN core_user u ON u.id=mb.user_id WHERE (mb.is_send_only=0 OR '%%{protocol}' NOT IN ('imap', 'pop3', 'lmtp')) AND mb.address='%%{user|username}' AND dom.name='%%{user|domain}' + iterate_query = SELECT email AS user FROM core_user +} + +#passdb static { +# fields { +# user=%%{user|username|lower} +# noauthenticate=yes +# } +## you can remove next line if you want to always normalize your usernames +# skip = authenticated +#} + +# "prefetch" user database means that the passdb already provided the +# needed information and there's no need to do a separate userdb lookup. +# +#userdb prefetch { +#} + +#userdb static { +# fields { +# user=%%{user|lower} +# } +# you can remove next line if you want to always normalize your usernames +# skip = found +#} + +# If you don't have any user-specific settings, you can avoid the user_query +# by using userdb static instead of userdb sql, for example: +# +#userdb static { + #fields { + # uid = vmail + # gid = vmail + # home = /var/vmail/%%{user} + #} +#} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl new file mode 100644 index 0000000..9363642 --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl @@ -0,0 +1,193 @@ +# Authentication for SQL users. Included from auth.conf. +# +# + +# For the sql passdb module, you'll need a database with a table that +# contains fields for at least the username and password. If you want to +# use the user@domain syntax, you might want to have a separate domain +# field as well. +# +# If your users all have the same uig/gid, and have predictable home +# directories, you can use the static userdb module to generate the home +# dir based on the username and domain. In this case, you won't need fields +# for home, uid, or gid in the database. +# +# If you prefer to use the sql userdb module, you'll want to add fields +# for home, uid, and gid. Here is an example table: +# +# CREATE TABLE users ( +# username VARCHAR(128) NOT NULL, +# domain VARCHAR(128) NOT NULL, +# password VARCHAR(64) NOT NULL, +# home VARCHAR(255) NOT NULL, +# uid INTEGER NOT NULL, +# gid INTEGER NOT NULL, +# active CHAR(1) DEFAULT 'Y' NOT NULL +# ); + +# Database driver: mysql, pgsql, sqlite +sql_driver = %db_driver + +# Database connection string. This is driver-specific setting. +# +# HA / round-robin load-balancing is supported by giving multiple host +# settings, like: host=sql1.host.org host=sql2.host.org +# +# pgsql: +# For available options, see the PostgreSQL documention for the +# PQconnectdb function of libpq. +# Use maxconns=n (default 5) to change how many connections Dovecot can +# create to pgsql. +# +# mysql: +# Basic options emulate PostgreSQL option names: +# host, port, user, password, dbname +# +# But also adds some new settings: +# client_flags - See MySQL manual +# ssl_ca, ssl_ca_path - Set either one or both to enable SSL +# ssl_cert, ssl_key - For sending client-side certificates to server +# ssl_cipher - Set minimum allowed cipher security (default: HIGH) +# option_file - Read options from the given file instead of +# the default my.cnf location +# option_group - Read options from the given group (default: client) +# +# You can connect to UNIX sockets by using host: host=/var/run/mysql.sock +# Note that currently you can't use spaces in parameters. +# +# sqlite: +# The path to the database file. +# +# Examples: +# mysql 192.168.1.1 { +# dbname = users +# } +# mysql sql.example.com { +# ssl = yes +# user = virtual +# password = blarg +# dbname = virtual +# } +# sqlite /etc/dovecot/authdb.sqlite { +# } +# +#mysql /var/run/mysqld/mysqld.sock { +# user = dovecot +# password = dvmail +# dbname = dovecot +#} +#mysql localhost { +# ... +#} +pgsql %dbhost { + port = %dbport + dbname = %modoboa_dbname + user = %modoboa_dbuser + password = %modoboa_dbpassword +} + +#passdb sql { +# default_password_scheme = SHA256 + +# passdb query to retrieve the password. It can return fields: +# password - The user's password. This field must be returned. +# user - user@domain from the database. Needed with case-insensitive lookups. +# username and domain - An alternative way to represent the "user" field. +# +# The "user" field is often necessary with case-insensitive lookups to avoid +# e.g. "name" and "nAme" logins creating two different mail directories. If +# your user and domain names are in separate fields, you can return "username" +# and "domain" fields instead of "user". +# +# The query can also return other fields which have a special meaning, see +# https://doc.dovecot.org/latest/core/config/auth/passdb.html#extra-fields +# +# Commonly used available substitutions (see https://doc.dovecot.org/latest/core/settings/variables.html +# for full list): +# %%{user} = entire user@domain +# %%{user|username} = user part of user@domain +# %%{user|domain} = domain part of user@domain +# +# Note that these can be used only as input to SQL query. If the query outputs +# any of these substitutions, they're not touched. Otherwise it would be +# difficult to have eg. usernames containing '%%' characters. +# +# Example: +# query = SELECT userid AS user, pw AS password \ +# FROM users WHERE userid = '%%u' AND active = 'Y' +# +# query = \ +# SELECT userid as username, domain, password \ +# FROM users WHERE userid = '%%{user|username}' AND domain = '%%{user|domain}' +#} +passdb sql { + query = SELECT email AS user, password FROM core_user u INNER JOIN admin_mailbox mb ON u.id=mb.user_id INNER JOIN admin_domain dom ON mb.domain_id=dom.id WHERE (mb.is_send_only IS NOT TRUE OR '%%{protocol}' NOT IN ('imap', 'pop3')) AND email='%%{user}' AND is_active AND dom.enabled +} + +#userdb sql { +# userdb query to retrieve the user information. It can return fields: +# uid - System UID (overrides mail_uid setting) +# gid - System GID (overrides mail_gid setting) +# home - Home directory +# mail_driver - Mail driver +# mail_path - Mail storage path +# +# None of these are strictly required. If you use a single UID and GID, and +# home or mail directory fits to a template string, you could use userdb static +# instead. For a list of all fields that can be returned, see +# Examples: +# query = SELECT home, uid, gid FROM users WHERE userid = '%%{user}' +# query = SELECT dir AS home, user AS uid, group AS gid FROM users where userid = '%%{user}' +# query = SELECT home, 501 AS uid, 501 AS gid FROM users WHERE userid = '%%{user}' +# +# query = \ +# SELECT home, uid, gid \ +# FROM users WHERE userid = '%%{user|username}' AND domain = '%%{user|domain}' + +# Query to get a list of all usernames. +# iterate_query = SELECT username AS user,domain FROM users + +# userdb_ldap { +# iterate_fields { +# home = /var/vmail/%%{home} +# } +# } +#} +userdb sql { + query = SELECT '%{home_dir}/%%{user|domain}/%%{user|username}' AS home, %mailboxes_owner_uid as uid, %mailboxes_owner_gid as gid, mb.quota || 'M' AS quota_storage_size FROM admin_mailbox mb INNER JOIN admin_domain dom ON mb.domain_id=dom.id INNER JOIN core_user u ON u.id=mb.user_id WHERE (mb.is_send_only IS NOT TRUE OR '%%{protocol}' NOT IN ('imap', 'pop3', 'lmtp')) AND mb.address='%%{user|username}' AND dom.name='%%{user|domain}' + iterate_query = SELECT email AS user FROM core_user +} + +#passdb static { +# fields { +# user=%%{user|username|lower} +# noauthenticate=yes +# } +## you can remove next line if you want to always normalize your usernames +# skip = authenticated +#} + +# "prefetch" user database means that the passdb already provided the +# needed information and there's no need to do a separate userdb lookup. +# +#userdb prefetch { +#} + +#userdb static { +# fields { +# user=%%{user|lower} +# } +# you can remove next line if you want to always normalize your usernames +# skip = found +#} + +# If you don't have any user-specific settings, you can avoid the user_query +# by using userdb static instead of userdb sql, for example: +# +#userdb static { + #fields { + # uid = vmail + # gid = vmail + # home = /var/vmail/%%{user} + #} +#} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/dovecot.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/dovecot.conf.tpl new file mode 100644 index 0000000..4361c59 --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/dovecot.conf.tpl @@ -0,0 +1,87 @@ +## Dovecot configuration file + +# If you're in a hurry, see https://doc.dovecot.org/latest/core/config/guides/quick.html + +# "doveconf -n" command gives a clean output of the changed settings. Use it +# instead of copy&pasting files when posting to the Dovecot mailing list. + +# '#' character and everything after it is treated as comments. Extra spaces +# and tabs are ignored. If you want to use either of these explicitly, put the +# value inside quotes, eg.: key = "# char and trailing whitespace " + +# Default values are shown for each setting, it's not required to uncomment +# those. These are exceptions to this though: No sections (e.g. namespace {}) +# or plugin settings are added by default, they're listed only as examples. +# Paths are also just examples with the real defaults being based on configure +# options. The paths listed here are for configure --prefix=/usr/local +# --sysconfdir=/usr/local/etc --localstatedir=/var + +dovecot_config_version = 2.4.0 +dovecot_storage_version = 2.4.0 + +# Protocols we want to be serving. +%protocols +!include_try /usr/share/dovecot/protocols.d/*.protocol + +# A comma separated list of IPs or hosts where to listen in for connections. +# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces. +# If you want to specify non-default ports or anything more complex, +# edit conf.d/master.conf. +#listen = *, :: + +# Base directory where to store runtime data. +#base_dir = /var/run/dovecot/ + +# Name of this instance. In multi-instance setup doveadm and other commands +# can use -i to select which instance is used (an alternative +# to -c ). The instance name is also added to Dovecot processes +# in ps output. +#instance_name = dovecot + +# Greeting message for clients. +#login_greeting = Dovecot ready. + +# Space separated list of trusted network ranges. Connections from these +# IPs are allowed to override their IP addresses and ports (for logging and +# for authentication checks). disable_plaintext_auth is also ignored for +# these networks, unless ssl=required. +# Typically you'd specify your IMAP proxy servers here. +#login_trusted_networks = + +# With proxy_maybe=yes if proxy destination matches any of these IPs, don't do +# proxying. This isn't necessary normally, but may be useful if the destination +# IP is e.g. a load balancer's IP. +#auth_proxy_self = + +# Show more verbose process titles (in ps). Currently shows user name and +# IP address. Useful for seeing who are actually using the IMAP processes +# (eg. shared mailboxes or if same uid is used for multiple accounts). +#verbose_proctitle = yes + +# Should all processes be killed when Dovecot master process shuts down. +# Setting this to "no" means that Dovecot can be upgraded without +# forcing existing client connections to close (although that could also be +# a problem if the upgrade is e.g. because of a security fix). +#shutdown_clients = yes + +# If non-zero, run mail commands via this many connections to doveadm server, +# instead of running them directly in the same process. +#doveadm_worker_count = 0 +# UNIX socket or host:port used for connecting to doveadm server +#doveadm_socket_path = doveadm-server + +# Space separated list of environment variables that are preserved on Dovecot +# startup and passed down to all of its child processes. You can also give +# key=value pairs to always set specific settings. +#import_environment { +# TZ=%%{env:TZ} +#} + +# Most of the actual configuration gets included below. The filenames are +# first sorted by their ASCII value and parsed in that order. The 00-prefixes +# in filenames are intended to make it easier to understand the ordering. +!include conf.d/*.conf + +# A config file can also tried to be included without giving an error if +# it's not found: +!include_try local.conf diff --git a/modoboa_installer/scripts/files/dovecot/conf.d/custom_after_sieve/spam-to-junk.sieve.tpl b/modoboa_installer/scripts/files/dovecot/custom_after_sieve/spam-to-junk.sieve.tpl similarity index 100% rename from modoboa_installer/scripts/files/dovecot/conf.d/custom_after_sieve/spam-to-junk.sieve.tpl rename to modoboa_installer/scripts/files/dovecot/custom_after_sieve/spam-to-junk.sieve.tpl diff --git a/modoboa_installer/scripts/modoboa.py b/modoboa_installer/scripts/modoboa.py index babf7eb..cca890e 100644 --- a/modoboa_installer/scripts/modoboa.py +++ b/modoboa_installer/scripts/modoboa.py @@ -27,7 +27,7 @@ class Modoboa(base.Installer): "build-essential", "python3-dev", "libxml2-dev", "libxslt-dev", "libjpeg-dev", "librrd-dev", "rrdtool", "libffi-dev", "cron", "libssl-dev", "redis-server", "supervisor", "pkg-config", - "libcairo2-dev" + "libcairo2-dev", "libmagic-dev" ], "rpm": [ "gcc", "gcc-c++", "python3-devel", "libxml2-devel", "libxslt-devel", @@ -71,7 +71,7 @@ class Modoboa(base.Installer): def _setup_venv(self): """Prepare a dedicated virtualenv.""" python.setup_virtualenv(self.venv_path, sudo_user=self.user) - packages = ["rrdtool"] + packages = [] version = self.config.get("modoboa", "version") extras = "postgresql" if self.dbengine != "postgres": From 9e12fa3dda9ed9994da040fe3627fefc07182ded Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Tue, 16 Sep 2025 09:44:54 +0200 Subject: [PATCH 2/3] Removed temp. change --- modoboa_installer/scripts/base.py | 1 - 1 file changed, 1 deletion(-) diff --git a/modoboa_installer/scripts/base.py b/modoboa_installer/scripts/base.py index e71b645..a9a8290 100644 --- a/modoboa_installer/scripts/base.py +++ b/modoboa_installer/scripts/base.py @@ -45,7 +45,6 @@ class Installer: @property def modoboa_2_2_or_greater(self): - return True # Check if modoboa version > 2.2 modoboa_version = python.get_package_version( "modoboa", From b95bf5848897730e825459282bc688494af713d1 Mon Sep 17 00:00:00 2001 From: Antoine Nguyen Date: Tue, 16 Sep 2025 15:40:27 +0200 Subject: [PATCH 3/3] Configuration fixes --- modoboa_installer/scripts/dovecot.py | 6 ++-- .../files/dovecot/2.4/conf.d/10-auth.conf | 2 +- .../dovecot/2.4/conf.d/10-master.conf.tpl | 7 +++++ .../files/dovecot/2.4/conf.d/20-imap.conf | 3 +- .../2.4/conf.d/30-dict-server.conf.tpl | 11 +++++-- .../2.4/conf.d/auth-master-mysql.conf.ext.tpl | 28 +++++++++++++++++ .../conf.d/auth-master-postgres.conf.ext.tpl | 30 +++++++++++++++++++ .../2.4/conf.d/auth-sql-postgres.conf.ext.tpl | 10 ++++--- 8 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-mysql.conf.ext.tpl create mode 100644 modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-postgres.conf.ext.tpl diff --git a/modoboa_installer/scripts/dovecot.py b/modoboa_installer/scripts/dovecot.py index 6d27d96..9ed8a05 100644 --- a/modoboa_installer/scripts/dovecot.py +++ b/modoboa_installer/scripts/dovecot.py @@ -67,7 +67,8 @@ class Dovecot(base.Installer): files = self.per_version_config_files[version] if version == "2.4": files += [ - f"conf.d/auth-sql-{self.dbengine}.conf.ext=conf.d/auth-sql.conf.ext" + f"conf.d/auth-sql-{self.dbengine}.conf.ext=conf.d/auth-sql.conf.ext", + f"conf.d/auth-master-{self.dbengine}.conf.ext=conf.d/auth-master.conf.ext", ] else: files += [ @@ -166,7 +167,8 @@ class Dovecot(base.Installer): "modoboa_2_2_or_greater": "" if self.modoboa_2_2_or_greater else "#", "not_modoboa_2_2_or_greater": "" if not self.modoboa_2_2_or_greater else "#", "do_move_spam_to_junk": "" if self.app_config["move_spam_to_junk"] else "#", - "oauth2_introspection_url": oauth2_introspection_url + "oauth2_introspection_url": oauth2_introspection_url, + "radicale_user": self.config.get("radicale", "user"), }) return context diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf index 4227467..f501a88 100644 --- a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-auth.conf @@ -112,7 +112,7 @@ auth_mechanisms = plain login oauthbearer xoauth2 # #!include auth-deny.conf.ext -#!include auth-master.conf.ext +!include auth-master.conf.ext !include auth-oauth2.conf.ext #!include auth-system.conf.ext diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl index b3a83d4..1566e4a 100644 --- a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/10-master.conf.tpl @@ -145,6 +145,13 @@ service auth { group = postfix } + %{radicale_enabled}unix_listener auth-radicale { + %{radicale_enabled} mode = 0666 + %{radicale_enabled} user = %{radicale_user} + %{radicale_enabled} group = %{radicale_user} + %{radicale_enabled} type = auth-legacy + %{radicale_enabled}} + # Auth process is run as this user. #user = $SET:default_internal_user } diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/20-imap.conf b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/20-imap.conf index 2827ca6..7000da8 100644 --- a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/20-imap.conf +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/20-imap.conf @@ -99,8 +99,7 @@ protocol imap { # Space separated list of plugins to load (default is global mail_plugins). mail_plugins { - imap_quota = yes - imap_sieve = yes + quota = yes } # Maximum number of IMAP connections allowed for a user from each IP address. diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl index 23996ff..21118bc 100644 --- a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/30-dict-server.conf.tpl @@ -9,13 +9,18 @@ # "proxy::". dict_server { + pgsql %dbhost { + parameters { + port = %dbport + dbname = %modoboa_dbname + user = %modoboa_dbuser + password = %modoboa_dbpassword + } + } dict quota { driver = sql sql_driver = %db_driver hostname = %dbhost - dbname = %modoboa_dbname - user = %modoboa_dbuser - password = %modoboa_dbpassword dict_map priv/quota/storage { sql_table = admin_quota diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-mysql.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-mysql.conf.ext.tpl new file mode 100644 index 0000000..ec0a1ed --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-mysql.conf.ext.tpl @@ -0,0 +1,28 @@ +# Authentication for master users. Included from auth.conf. + +# By adding master=yes setting inside a passdb you make the passdb a list +# of "master users", who can log in as anyone else. +# + +# Example master user passdb using passwd-file. You can use any passdb though. +#passdb master-passwd-file { +# driver = passwd-file +# master = yes +# passwd_file_path = /etc/dovecot/master-users +#} + +sql_driver = %db_driver + +mysql %dbhost { + port = %dbport + dbname = %modoboa_dbname + user = %modoboa_dbuser + password = %modoboa_dbpassword +} + +passdb db1 { + driver = sql + sql_query = SELECT email AS user, password FROM core_user WHERE email='%%{user}' and is_active=1 and master_user=1 + master = yes + result_success = continue +} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-postgres.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-postgres.conf.ext.tpl new file mode 100644 index 0000000..c4692d7 --- /dev/null +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-master-postgres.conf.ext.tpl @@ -0,0 +1,30 @@ +# Authentication for master users. Included from auth.conf. + +# By adding master=yes setting inside a passdb you make the passdb a list +# of "master users", who can log in as anyone else. +# + +# Example master user passdb using passwd-file. You can use any passdb though. +#passdb master-passwd-file { +# driver = passwd-file +# master = yes +# passwd_file_path = /etc/dovecot/master-users +#} + +sql_driver = %db_driver + +pgsql %dbhost { + parameters { + port = %dbport + dbname = %modoboa_dbname + user = %modoboa_dbuser + password = %modoboa_dbpassword + } +} + +passdb db1 { + driver = sql + sql_query = SELECT email AS user, password FROM core_user WHERE email='%%{user}' and is_active and master_user + master = yes + result_success = continue +} diff --git a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl index 9363642..9055dc8 100644 --- a/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl +++ b/modoboa_installer/scripts/files/dovecot/2.4/conf.d/auth-sql-postgres.conf.ext.tpl @@ -80,10 +80,12 @@ sql_driver = %db_driver # ... #} pgsql %dbhost { - port = %dbport - dbname = %modoboa_dbname - user = %modoboa_dbuser - password = %modoboa_dbpassword + parameters { + port = %dbport + dbname = %modoboa_dbname + user = %modoboa_dbuser + password = %modoboa_dbpassword + } } #passdb sql {