mirror of
https://github.com/tomav/docker-mailserver
synced 2025-09-01 14:55:16 +00:00
scripts: add wrapper to update Postfix configuration safely (#3484)
The new function can 1. update/append 2. update/prepend 3. initialize if non-existent options in `/etc/postfix/main.cf` in a safe and secure manner. When the container is improperly restarted, the option is not applied twice. --- Co-authored-by: Casper <casperklein@users.noreply.github.com> Co-authored-by: Brennan Kinney <5098581+polarathene@users.noreply.github.com>
This commit is contained in:
@@ -4,6 +4,15 @@ function _escape() {
|
||||
echo "${1//./\\.}"
|
||||
}
|
||||
|
||||
# Replaces a string so that it can be used inside
|
||||
# `sed` safely.
|
||||
#
|
||||
# @param ${1} = string to escape
|
||||
# @output = prints the escaped string
|
||||
function _escape_for_sed() {
|
||||
sed -E 's/[]\/$*.^[]/\\&/g' <<< "${1:?String to escape for sed is required}"
|
||||
}
|
||||
|
||||
# Returns input after filtering out lines that are:
|
||||
# empty, white-space, comments (`#` as the first non-whitespace character)
|
||||
function _get_valid_lines_from_file() {
|
||||
|
Reference in New Issue
Block a user