From 17111a0ea2456ca2ce74ca585329f881ef50eeb7 Mon Sep 17 00:00:00 2001 From: FDHoho007 Date: Sat, 27 Dec 2025 00:15:28 +0100 Subject: [PATCH] fix: LDAP - Enable `check-for-changes.sh` support (#4627) * fix: Enable change detection support for `ACCOUNT_PROVISIONER=LDAP` * fix(test/rspamd_full): Explicitly wait for the `rspamd_proxy` port to be available before testing --- CHANGELOG.md | 1 + target/scripts/check-for-changes.sh | 12 +++++++----- target/scripts/start-mailserver.sh | 2 +- test/helper/common.bash | 8 ++++++++ test/tests/parallel/set1/spam_virus/rspamd_dkim.bats | 1 + test/tests/parallel/set1/spam_virus/rspamd_full.bats | 1 + .../parallel/set1/spam_virus/rspamd_partly.bats | 1 + 7 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0324cd03..4f63380e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. The format - **Internal:** - `ENABLE_QUOTAS=1` - When an alias has multiple addresses, the first local mailbox address found will be used for the Dovecot dummy account workaround ([#4581](https://github.com/docker-mailserver/docker-mailserver/pull/4581)) + - Change Detection service - Added support for responding to updated DMS config (_Rspamd and TLS certificates_) to `ACCOUNT_PROVISIONER=LDAP` ([#4627](https://github.com/docker-mailserver/docker-mailserver/pull/4627)) - **Tests:** - Make the helper method `_get_container_ip()` compatible with Docker 29 ([#4606](https://github.com/docker-mailserver/docker-mailserver/pull/4606)) diff --git a/target/scripts/check-for-changes.sh b/target/scripts/check-for-changes.sh index 9546cd06..8dbac251 100755 --- a/target/scripts/check-for-changes.sh +++ b/target/scripts/check-for-changes.sh @@ -1,8 +1,5 @@ #!/bin/bash -# TODO: Adapt for compatibility with LDAP -# Only the cert renewal change detection may be relevant for LDAP? - # CHKSUM_FILE global is imported from this file: # shellcheck source=./helpers/index.sh source /usr/local/bin/helpers/index.sh @@ -63,7 +60,8 @@ function _handle_changes() { # Variable to identify any config updates dependent upon vhost changes. local VHOST_UPDATED=0 # These two configs are the source for /etc/postfix/vhost (managed mail domains) - if [[ ${CHANGED} =~ ${DMS_DIR}/postfix-(accounts|virtual).cf ]]; then + if [[ ${ACCOUNT_PROVISIONER} == 'FILE' ]] \ + && [[ ${CHANGED} =~ ${DMS_DIR}/postfix-(accounts|virtual).cf ]]; then _log 'trace' 'Regenerating vhosts (Postfix)' # Regenerate via `helpers/postfix.sh`: _create_postfix_vhost @@ -72,7 +70,11 @@ function _handle_changes() { fi _ssl_changes - _postfix_dovecot_changes + # TODO: Consider support relay host config change support for other provisioners + if [[ ${ACCOUNT_PROVISIONER} == 'FILE' ]]; then + _postfix_dovecot_changes + fi + _rspamd_changes _log 'debug' 'Reloading services due to detected changes' diff --git a/target/scripts/start-mailserver.sh b/target/scripts/start-mailserver.sh index a6295ed8..6fd65ade 100755 --- a/target/scripts/start-mailserver.sh +++ b/target/scripts/start-mailserver.sh @@ -156,8 +156,8 @@ function _register_functions() { [[ ${ENABLE_FETCHMAIL} -eq 1 ]] && _register_start_daemon '_start_daemon_fetchmail' [[ ${ENABLE_CLAMAV} -eq 1 ]] && _register_start_daemon '_start_daemon_clamav' [[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_start_daemon '_start_daemon_amavis' - [[ ${ACCOUNT_PROVISIONER} == 'FILE' ]] && _register_start_daemon '_start_daemon_changedetector' [[ ${ENABLE_GETMAIL} -eq 1 ]] && _register_start_daemon '_start_daemon_getmail' + _register_start_daemon '_start_daemon_changedetector' } # ------------------------------------------------------------ diff --git a/test/helper/common.bash b/test/helper/common.bash index 97640d2e..b00a23e4 100644 --- a/test/helper/common.bash +++ b/test/helper/common.bash @@ -269,6 +269,14 @@ function _wait_for_smtp_port_in_container_to_respond() { done } +# Wait for RSPAMD port (11332) to become ready. +# +# @param ${1} = name of the container [OPTIONAL] +function _wait_for_rspamd_port_in_container() { + local CONTAINER_NAME=$(__handle_container_name "${1:-}") + _wait_for_tcp_port_in_container 11332 +} + # Checks whether a service is running inside a container (${1}). # # @param ${1} = service name diff --git a/test/tests/parallel/set1/spam_virus/rspamd_dkim.bats b/test/tests/parallel/set1/spam_virus/rspamd_dkim.bats index a852b060..f5e030b5 100644 --- a/test/tests/parallel/set1/spam_virus/rspamd_dkim.bats +++ b/test/tests/parallel/set1/spam_virus/rspamd_dkim.bats @@ -24,6 +24,7 @@ function setup_file() { _common_container_setup 'CUSTOM_SETUP_ARGUMENTS' _wait_for_service rspamd-redis _wait_for_service rspamd + _wait_for_rspamd_port_in_container } # We want each test to start with a clean state. diff --git a/test/tests/parallel/set1/spam_virus/rspamd_full.bats b/test/tests/parallel/set1/spam_virus/rspamd_full.bats index 961731fa..e5c63c6e 100644 --- a/test/tests/parallel/set1/spam_virus/rspamd_full.bats +++ b/test/tests/parallel/set1/spam_virus/rspamd_full.bats @@ -40,6 +40,7 @@ function setup_file() { _wait_for_service rspamd-redis _wait_for_service rspamd + _wait_for_rspamd_port_in_container _wait_for_service clamav _wait_for_service postfix _wait_for_smtp_port_in_container diff --git a/test/tests/parallel/set1/spam_virus/rspamd_partly.bats b/test/tests/parallel/set1/spam_virus/rspamd_partly.bats index a1afc9a3..e3dd64e5 100644 --- a/test/tests/parallel/set1/spam_virus/rspamd_partly.bats +++ b/test/tests/parallel/set1/spam_virus/rspamd_partly.bats @@ -33,6 +33,7 @@ function setup_file() { _wait_for_service rspamd-redis _wait_for_service rspamd + _wait_for_rspamd_port_in_container _wait_for_service amavis _wait_for_service postfix _wait_for_smtp_port_in_container