Ensures permissions of /var/log/mail/ and it's contents are corrected if a volume mount differs.
History for these changes is messy (as documented in the "proper fix" link), but looks like it shouldn't really be necessary going forward (new permissions fix may be relevant to avoid the logrotate failure scenario).
/etc/cron.daily/logrotate:
error: skipping "/var/log/mail/mail.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
error: skipping "/var/log/mail/rspamd.log" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation.
run-parts: /etc/cron.daily/logrotate exited with return code 1
According to that linked discussion, correcting that mount permissions for a specific mount in the Helm chart is problematic? 🤷♂️
Chance of regression low
In addition these are runtime corrections intended for volume mounts, thus is intended as part of the DMS v15 improved restart support.
Prior to this PR these changes would have occurred much earlier during startup:
_log 'info'"Welcome to docker-mailserver ${DMS_RELEASE}"
_register_functions
_check
# Ensure DMS only adjusts config files for a new container.
# Container restarts should skip as they retain the modified config.
if [[ -f /CONTAINER_START ]];then
_log 'info''Container was restarted. Skipping most setup routines.'
# We cannot skip all setup routines because some need to run _after_
# the initial setup (and hence, they cannot be moved to the check stack).
_setup_directory_and_file_permissions
_setup_adjust_state_permissions
else
_setup
fi
# marker to check if container was restarted
date >/CONTAINER_START
# Container logs will receive updates from this log file:
MAIN_LOGFILE=/var/log/mail/mail.log
# NOTE: rsyslogd would usually create this later during `_start_daemons`, however it would already exist if the container was restarted.
touch "${MAIN_LOGFILE}"
DMS v15 is to release with the two separate call sites shown above as no maintainer presently has the time to investigate test failures introduced when moving methods those into a unified location.
Type of change
Bug fix (non-breaking change which fixes an issue)
[?] Breaking change (fix or feature that would cause existing functionality to not work as expected)
Checklist
My code follows the style guidelines of this project
I have performed a self-review of my code
I have commented my code, particularly in hard-to-understand areas
New and existing unit tests pass locally with my changes
I have added information about changes made in this PR to CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is an interim fix for DMS v15 until a proper fix can more confidently be implemented.
Changes:
History for these changes is messy (as documented in the "proper fix" link), but looks like it shouldn't really be necessary going forward (new permissions fix may be relevant to avoid the logrotate failure scenario).
Workaround for volume mounts that are too relaxed
In the kubernetes helm project, a user reports their /var/log/mail mount with 777 permissions which appears to impact logrotate service as a result:
According to that linked discussion, correcting that mount permissions for a specific mount in the Helm chart is problematic? 🤷♂️
Chance of regression low
In addition these are runtime corrections intended for volume mounts, thus is intended as part of the DMS v15 improved restart support.
Prior to this PR these changes would have occurred much earlier during startup:
docker-mailserver/target/scripts/start-mailserver.sh
Line 46 in 0294294
There is a slight chance that shifting the changes to apply at the end of _setup() introduces a regression, but it should be unlikely:
docker-mailserver/target/scripts/start-mailserver.sh
Lines 122 to 124 in 0294294
Restart support calls same two methods + (rsyslog daemon starts with /var/log/mail/mail.log):
docker-mailserver/target/scripts/start-mailserver.sh
Lines 167 to 196 in 0294294
DMS v15 is to release with the two separate call sites shown above as no maintainer presently has the time to investigate test failures introduced when moving methods those into a unified location.
Type of change
Checklist