From 9eb3fa73e53c0d620b8edd17a4a5b36b5dce8f0c Mon Sep 17 00:00:00 2001 From: "Lars K.W. Gohlke" <1891171+lkwg82@users.noreply.github.com> Date: Mon, 6 Oct 2025 20:25:13 +0200 Subject: [PATCH] fix: Prevent logs leaking into config files (`FETCHMAIL_PARALLEL=1`) (#4586) --- CHANGELOG.md | 1 + target/scripts/helpers/log.sh | 8 +++----- target/scripts/startup/setup.d/fetchmail.sh | 4 ++-- test/tests/parallel/set1/fetchmail.bats | 7 +++++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b1eaa59..05ee8456 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. The format - Third-party sourced CLI tools updated ([#4557](https://github.com/docker-mailserver/docker-mailserver/pull/4557)): - `jaq` from `2.1.0` to [`2.3.0`](https://github.com/01mf02/jaq/releases/tag/v2.3.0) - `step` CLI from `0.28.2` to [`0.28.7`](https://github.com/smallstep/cli/releases/tag/v0.28.7)) + - DMS logs now all output to STDERR (formerly only warning/error logs) (#[4586](https://github.com/docker-mailserver/docker-mailserver/pull/4586)) - **Dovecot** - Updated the FTS plugin Xapian from `1.9` to [`1.9.1`](https://github.com/grosjo/fts-xapian/releases/tag/1.9.1) which adds Dovecot 2.4 compatibility ([#4557](https://github.com/docker-mailserver/docker-mailserver/pull/4557)) - **Postfix** diff --git a/target/scripts/helpers/log.sh b/target/scripts/helpers/log.sh index e4ba5ea6..91231204 100644 --- a/target/scripts/helpers/log.sh +++ b/target/scripts/helpers/log.sh @@ -104,11 +104,9 @@ function _log() { MESSAGE="$(date --rfc-3339='seconds') ${!LOG_COLOR}${LOG_LEVEL_NAME}${RESET} $(basename "${0}"): ${2}" - if [[ ${1} =~ ^(warn|error)$ ]]; then - echo -e "${MESSAGE}" >&2 - else - echo -e "${MESSAGE}" - fi + # All logs should go through to STDERR, + # STDOUT is only appropriate for expected program output + echo -e "${MESSAGE}" >&2 } # Get the value of the environment variable LOG_LEVEL if diff --git a/target/scripts/startup/setup.d/fetchmail.sh b/target/scripts/startup/setup.d/fetchmail.sh index 7ea698ea..aa1cc61c 100644 --- a/target/scripts/startup/setup.d/fetchmail.sh +++ b/target/scripts/startup/setup.d/fetchmail.sh @@ -77,8 +77,8 @@ function _setup_fetchmail_parallel() { local COUNTER=0 for RC in /etc/fetchmailrc.d/fetchmail-*.rc; do - COUNTER=$(( COUNTER + 1 )) - cat >"/etc/supervisor/conf.d/fetchmail-${COUNTER}.conf" << EOF + COUNTER=$(( COUNTER + 1 )) + cat >"/etc/supervisor/conf.d/fetchmail-${COUNTER}.conf" << EOF [program:fetchmail-${COUNTER}] startsecs=0 autostart=false diff --git a/test/tests/parallel/set1/fetchmail.bats b/test/tests/parallel/set1/fetchmail.bats index 8d62731a..fa497f6b 100644 --- a/test/tests/parallel/set1/fetchmail.bats +++ b/test/tests/parallel/set1/fetchmail.bats @@ -60,6 +60,13 @@ function teardown_file() { _should_not_have_in_config 'pop3.third-party.test. ' /etc/fetchmailrc.d/fetchmail-2.rc } +@test "(ENV FETCHMAIL_PARALLEL=1) should not have logs emitted into fetchmail-x.rc" { + export CONTAINER_NAME=${CONTAINER2_NAME} + + _should_not_have_in_config 'INFO' /etc/fetchmailrc.d/fetchmail-1.rc + _should_not_have_in_config 'INFO' /etc/fetchmailrc.d/fetchmail-2.rc +} + function _should_have_in_config() { local MATCH_CONTENT=$1 local MATCH_IN_FILE=$2