From 491c30b19482af8670f38db4edee2b9b5f67981b Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Fri, 25 Apr 2025 10:06:35 +1200 Subject: [PATCH] fix: `setup email list` should only work with `ACCOUNT_PROVISIONER=FILE` (#4453) --------- Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> Co-authored-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com> --- CHANGELOG.md | 1 + docs/content/config/environment.md | 6 ++++++ target/bin/listmailuser | 4 ++++ target/scripts/startup/variables-stack.sh | 15 +++++++++++++-- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0abef183..d3410f37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ All notable changes to this project will be documented in this file. The format - Added a compatibility note for a Dovecot + Solr 9.8 breaking change ([#4433](https://github.com/docker-mailserver/docker-mailserver/pull/4433)) - **Internal:** - Refactored `setup config dkim` (`open-dkim`) ([#4375](https://github.com/docker-mailserver/docker-mailserver/pull/4375)) + - `setup email list` and the default `ENABLE_QUOTAS=1` ENV now better communicates when config is incompatible ([#4453](https://github.com/docker-mailserver/docker-mailserver/pull/4453)) ## [v15.0.2](https://github.com/docker-mailserver/docker-mailserver/releases/tag/v15.0.2) diff --git a/docs/content/config/environment.md b/docs/content/config/environment.md index 2c2364cb..3f8d2fac 100644 --- a/docs/content/config/environment.md +++ b/docs/content/config/environment.md @@ -247,6 +247,12 @@ Set the mailbox size limit for all users. If set to zero, the size will be unlim See [mailbox quota][docs-accounts-quota]. +!!! info "Compatibility" + + This feature is presently only compatible with `ACCOUNT_PROVISIONER=FILE`. + + When using a different provisioner (or `SMTP_ONLY=1`) this ENV will instead default to `0`. + ##### POSTFIX_MESSAGE_SIZE_LIMIT Set the message size limit for all users. If set to zero, the size will be unlimited (not recommended!). Size is in bytes. diff --git a/target/bin/listmailuser b/target/bin/listmailuser index 1253c448..226bc1af 100755 --- a/target/bin/listmailuser +++ b/target/bin/listmailuser @@ -8,6 +8,10 @@ source /usr/local/bin/helpers/index.sh source /etc/dms-settings 2>/dev/null function _main() { + if [[ ${ACCOUNT_PROVISIONER} != 'FILE' ]]; then + _exit_with_error "This command is only compatible with 'ACCOUNT_PROVISIONER=FILE'" + fi + local DATABASE_ACCOUNTS='/tmp/docker-mailserver/postfix-accounts.cf' local DATABASE_VIRTUAL='/tmp/docker-mailserver/postfix-virtual.cf' diff --git a/target/scripts/startup/variables-stack.sh b/target/scripts/startup/variables-stack.sh index 8c75d9c1..8f138119 100644 --- a/target/scripts/startup/variables-stack.sh +++ b/target/scripts/startup/variables-stack.sh @@ -62,7 +62,7 @@ function __environment_variables_general_setup() { VARS[DMS_VMAIL_UID]="${DMS_VMAIL_UID:=5000}" VARS[DMS_VMAIL_GID]="${DMS_VMAIL_GID:=5000}" - # user-customizable are last + # user-customizable are next _log 'trace' 'Setting anti-spam & anti-virus environment variables' @@ -106,7 +106,6 @@ function __environment_variables_general_setup() { VARS[ENABLE_POP3]="${ENABLE_POP3:=0}" VARS[ENABLE_IMAP]="${ENABLE_IMAP:=1}" VARS[ENABLE_POSTGREY]="${ENABLE_POSTGREY:=0}" - VARS[ENABLE_QUOTAS]="${ENABLE_QUOTAS:=1}" VARS[ENABLE_RSPAMD]="${ENABLE_RSPAMD:=0}" VARS[ENABLE_RSPAMD_REDIS]="${ENABLE_RSPAMD_REDIS:=${ENABLE_RSPAMD}}" VARS[ENABLE_SASLAUTHD]="${ENABLE_SASLAUTHD:=0}" @@ -167,6 +166,18 @@ function __environment_variables_general_setup() { VARS[SUPERVISOR_LOGLEVEL]="${SUPERVISOR_LOGLEVEL:=warn}" VARS[TZ]="${TZ:=}" VARS[UPDATE_CHECK_INTERVAL]="${UPDATE_CHECK_INTERVAL:=1d}" + + _log 'trace' 'Setting environment variables that require other variables to be set first' + + # The Dovecot Quotas feature is presently only supported with the default FILE account provisioner, + # Enforce disabling the feature, unless it's been explicitly set via ENV (to avoid mismatch between + # explicit ENV and sourcing from /etc/dms-settings) + if [[ ${ACCOUNT_PROVISIONER} != 'FILE' || ${SMTP_ONLY} -eq 1 ]] && [[ ${ENABLE_QUOTAS:-1} -eq 1 ]]; then + _log 'debug' "The 'ENABLE_QUOTAS' feature is enabled (by default) but is not compatible with your config. Disabling" + VARS[ENABLE_QUOTAS]="${ENABLE_QUOTAS:=0}" + else + VARS[ENABLE_QUOTAS]="${ENABLE_QUOTAS:=1}" + fi } function __environment_variables_log_level() {