fix: Prevent logs leaking into config files (FETCHMAIL_PARALLEL=1)#4586
Conversation
interferes with reading from STDOUT ;)
4682838 to
573fdc8
Compare
|
I tried to run the tests locally, but I use podman and even after adjusting |
polarathene
left a comment
There was a problem hiding this comment.
I am in support of DMS emitting all logs it emits to STDERR 👍
This particular issue could be resolved however by ensuring your config file you supply has a final new line present.
The scripts could also resolve it with:
- Calling the helper prior to the while loop, then reading the file contents in afterwards.
- Adjusting the single
infolog from the helper to be awarnlevel log.
The proposed change is sufficient, so as long as tests pass I'm good with that :)
I'll apply the feedback suggestions so we can check all is good in the test suite.
Reference - Reproduction
services:
dms:
image: ghcr.io/docker-mailserver/docker-mailserver:15.1
hostname: mail.example.test
environment:
ENABLE_FETCHMAIL: 1
FETCHMAIL_PARALLEL: 1
configs:
- source: dms-accounts
target: /tmp/docker-mailserver/postfix-accounts.cf
- source: fetchmail
target: /tmp/docker-mailserver/fetchmail.cf
configs:
fetchmail:
# `|-` instead of `|` will prevent appending a new line to the file content:
content: |-
poll 'mail.remote.test' proto imap
user '[email protected]'
pass 'secret'
is '[email protected]'
no sslcertck
dms-accounts:
content: |
[email protected]|{SHA512-CRYPT}$$6$$sbgFRCmQ.KWS5ryb$$EsWrlYosiadgdUOxCBHY0DQ3qFbeudDhNMqHs6jZt.8gmxUwiLVy738knqkHD4zj4amkb296HFqQ3yDq4UXt8.# No final new line at user provided config:
$ docker compose exec dms bash -c 'tail -c1 /tmp/docker-mailserver/fetchmail.cf | wc -l'
0
# Internal copy differs (includes globals/defaults and final new line):
$ docker compose exec dms bash -c 'tail -c1 /etc/fetchmail | wc -l'
1
# Log line stored as first line of each split config file generated:
$ docker compose exec dms bash -c 'cat /etc/fetchmailrc.d/*'
2025-10-06 03:32:59+00:00 INFO start-mailserver.sh: File '/etc/fetchmailrc' was missing a final newline - this has been fixed
set daemon 300
set syslog
poll 'mail.remote.test' proto imap
user '[email protected]'
pass 'secret'
is '[email protected]'
no sslcertck
# Original unused config:
$ docker compose exec dms bash -c 'cat /etc/fetchmailrc'
# General options
set daemon 300
set syslog
# Fetch rules
poll 'mail.remote.test' proto imap
user '[email protected]'
pass 'secret'
is '[email protected]'
no sslcertckThe internal copy is fine as we don't do a direct copy, this adds a new line for us implicitly:
docker-mailserver/target/scripts/startup/setup.d/fetchmail.sh
Lines 9 to 16 in d0a915b
While Parallel feature does something similar, but only after we've processed their user provided config (NOTE: The commentary is a bit inaccurate for the DEFAULT_FILE var as well mind you):
docker-mailserver/target/scripts/startup/setup.d/fetchmail.sh
Lines 30 to 44 in d0a915b
docker-mailserver/target/scripts/startup/setup.d/fetchmail.sh
Lines 55 to 62 in d0a915b
|
NOTE: I have reverted your unrelated change for a separate fetchmail cache per instance, unless you can provide more information to justify that being necessary it seems like it'd not provide much good?
|
FETCHMAIL_PARALLEL=1)
polarathene
left a comment
There was a problem hiding this comment.
LGTM 👍 Thanks for spotting this issue and contributing a fix ❤️
|
Not related to this PR: From the naming, I wouldn't expect a |
|
@casperklein it is BASH, the language which is making use almost only of sideeffects 😁 |
Description
fixes fetchmail in parallel mode, when logging is added as first line
results in
explanation:
this reads from STDOUT and adds the log as well to the rc file
target/scripts/startup/setup.d/fetchmail.sh(line >54)target/scripts/helpers/utils.shbelow
because of
target/scripts/helpers/logs.shType of change
Checklist
docs/)CHANGELOG.md