Skip to content

Commit

Permalink
Fix #97: Allow skipping reown and don't die on reown failure
Browse files Browse the repository at this point in the history
  • Loading branch information
bokysan committed Mar 28, 2022
1 parent 3d750cf commit 2593172
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Simple postfix relay host ("postfix null client") for your Docker containers. Ba
* [POSTFIX_message_size_limit](#postfix_message_size_limit)
* [Overriding specific postfix settings](#overriding-specific-postfix-settings)
* [ANONYMIZE_EMAILS](#anonymize_emails)
* [SKIP_ROOT_SPOOL_CHOWN](#skip_root_spool_chown)
* [DKIM / DomainKeys](#dkim--domainkeys)
* [Supplying your own DKIM keys](#supplying-your-own-dkim-keys)
* [Auto-generating the DKIM selectors through the image](#auto-generating-the-dkim-selectors-through-the-image)
Expand Down Expand Up @@ -332,6 +333,13 @@ Any Postfix [configuration option](http://www.postfix.org/postconf.5.html) can b
environment variables, e.g. `POSTFIX_allow_mail_to_commands=alias,forward,include`. Specifying no content (empty
variable) will remove that variable from postfix config.
#### SKIP_ROOT_SPOOL_CHOWN
Setting this to `1` will skip reowing in `/var/spool/postfix/` and `/var/spool/postfix/pid`. You generally do not
want to set this option unless you're running into specific issues (e.g. [#97](https://github.com/bokysan/docker-postfix/issues/97)).
If unsure, leave it as is.
#### ANONYMIZE_EMAILS
Anonymize email in Postfix logs. It mask the email content by putting `*` in the middle of the name and the domain.
Expand Down
25 changes: 22 additions & 3 deletions scripts/common-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,28 @@ setup_conf() {
}

reown_folders() {
mkdir -p /var/spool/postfix/pid /var/spool/postfix/dev
chown root: /var/spool/postfix/
chown root: /var/spool/postfix/pid
mkdir -p /var/spool/postfix/pid /var/spool/postfix/dev /var/spool/postfix/private /var/spool/postfix/public
if [[ "${SKIP_ROOT_SPOOL_CHOWN}" == "1" ]; then
warn "${emphasis}SKIP_ROOT_SPOOL_CHOWN${reset} is set. Script will not chown ${emphasis}/var/spool/postfix/${reset}. Make sure you know what you're doing."
else
debug "Reowing ${emphasis}/var/spool/postfix/${reset}"
if ! chown root: /var/spool/postfix/; then
warn "Cannot reown ${emphasis}root:${reset} for ${emphasis}/var/spool/postfix/${reset}. Your installation might be broken."
fi

if ! chown root: /var/spool/postfix/pid; then
warn "Cannot reown ${emphasis}root:${reset} for ${emphasis}/var/spool/postfix/pid/${reset}. Your installation might be broken."
fi
fi

debug "Reowing ${emphasis}/var/spool/postfix/private/${reset}"
if ! chown -R postfix:postdrop /var/spool/postfix/private; then
warn "Cannot reown ${emphasis}postfix:postdrop${reset} for ${emphasis}/var/spool/postfix/private${reset}. Your installation might be broken."
fi
debug "Reowing ${emphasis}/var/spool/postfix/public/${reset}"
if ! chown -R postfix:postdrop /var/spool/postfix/public; then
warn "Cannot reown ${emphasis}postfix:postdrop${reset} for ${emphasis}/var/spool/postfix/public${reset}. Your installation might be broken."
fi

do_postconf -e "manpage_directory=/usr/share/man"

Expand Down

0 comments on commit 2593172

Please sign in to comment.