Compare commits
29 Commits
d1694bf3a4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| b99844c1b5 | |||
| 691c34fa18 | |||
| 1ca6031fea | |||
| 8234254094 | |||
| afff836253 | |||
|
|
7c05201520 | ||
|
|
0674fb1231 | ||
|
|
32980f67de | ||
|
|
7b9a6f52ca | ||
| 5a8280b767 | |||
| 7c99515e72 | |||
| ef963e89fc | |||
| 654e5738d4 | |||
| 6356876ab6 | |||
| ee892a6b33 | |||
| 7741803f71 | |||
| da1867ef91 | |||
| 8dc105be68 | |||
| 6bc490bfc1 | |||
| c6c6491ce0 | |||
| abb2941e4b | |||
| 6d516ed25a | |||
| c6909c937d | |||
| 9708c595c4 | |||
| 9c52e54182 | |||
| 849cbfa2e4 | |||
| 0a51e44b93 | |||
| 16618f9949 | |||
| b4b47d5a79 |
@@ -145,7 +145,7 @@ dbhost=""
|
|||||||
# - Cert/Key configurations
|
# - Cert/Key configurations
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
cert_base_dir="/etc/postfix/ssl"
|
cert_base_dir="/etc/dovecot/ssl"
|
||||||
server_cert=${cert_base_dir}/mailserver.crt
|
server_cert=${cert_base_dir}/mailserver.crt
|
||||||
server_key=${cert_base_dir}/mailserver.key
|
server_key=${cert_base_dir}/mailserver.key
|
||||||
dh_pem_file="${cert_base_dir}/dh_4096.pem"
|
dh_pem_file="${cert_base_dir}/dh_4096.pem"
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ detect_os_1 () {
|
|||||||
# --- Some default settings
|
# --- Some default settings
|
||||||
# -------------
|
# -------------
|
||||||
|
|
||||||
DEFAULT_SASL_AUTH_ENABLED="no"
|
DEFAULT_SASL_AUTH_ENABLED=false
|
||||||
|
DEFAULT_IS_SYMPA_LIST_SERVER=false
|
||||||
|
|
||||||
DEFAULT_QUARANTINE_DIR="/var/QUARANTINE"
|
DEFAULT_QUARANTINE_DIR="/var/QUARANTINE"
|
||||||
DEFAULT_QUARANTINE_ADMIN='postmaster\@$mydomain'
|
DEFAULT_QUARANTINE_ADMIN='postmaster\@$mydomain'
|
||||||
@@ -187,7 +188,9 @@ if [[ -z "$_HOSTNAME" ]] ; then
|
|||||||
[[ "$_HOSTNAME" = "$_HOSTNAME_SHORT" ]] && _HOSTNAME=""
|
[[ "$_HOSTNAME" = "$_HOSTNAME_SHORT" ]] && _HOSTNAME=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -z "$_SASL_AUTH_ENABLED" ]] && _SASL_AUTH_ENABLED="$DEFAULT_SASL_AUTH_ENABLED"
|
[[ -z "$_SASL_AUTH_ENABLED" ]] && _SASL_AUTH_ENABLED=${DEFAULT_SASL_AUTH_ENABLED}
|
||||||
|
|
||||||
|
[[ -z "${_IS_SYMPA_LIST_SERVER}" ]] && _IS_SYMPA_LIST_SERVER=${DEFAULT_IS_SYMPA_LIST_SERVER}
|
||||||
|
|
||||||
|
|
||||||
[[ -z "$_QUARANTINE_DIR" ]] && _QUARANTINE_DIR="$DEFAULT_QUARANTINE_DIR"
|
[[ -z "$_QUARANTINE_DIR" ]] && _QUARANTINE_DIR="$DEFAULT_QUARANTINE_DIR"
|
||||||
@@ -375,9 +378,12 @@ SASL_AUTH_ENABLED=
|
|||||||
echo ""
|
echo ""
|
||||||
echo -e "\033[32m--\033[m"
|
echo -e "\033[32m--\033[m"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Should this mail server support Cyrus SASL authentication?"
|
echo "Should this mail server support Cyrus SASL authentication? [true/yes/false/no]"
|
||||||
echo ""
|
echo ""
|
||||||
while [[ "$SASL_AUTH_ENABLED" != "yes" && "$SASL_AUTH_ENABLED" != "no" ]];do
|
while [[ "$SASL_AUTH_ENABLED" != "yes" &&
|
||||||
|
"$SASL_AUTH_ENABLED" != "true" &&
|
||||||
|
"$SASL_AUTH_ENABLED" != "no" &&
|
||||||
|
"$SASL_AUTH_ENABLED" != "false" ]];do
|
||||||
|
|
||||||
if [[ -n "$_SASL_AUTH_ENABLED" ]]; then
|
if [[ -n "$_SASL_AUTH_ENABLED" ]]; then
|
||||||
echononl "Support Cyrus SASL authentication [${_SASL_AUTH_ENABLED}]: "
|
echononl "Support Cyrus SASL authentication [${_SASL_AUTH_ENABLED}]: "
|
||||||
@@ -390,13 +396,62 @@ while [[ "$SASL_AUTH_ENABLED" != "yes" && "$SASL_AUTH_ENABLED" != "no" ]];do
|
|||||||
SASL_AUTH_ENABLED=${SASL_AUTH_ENABLED,,}
|
SASL_AUTH_ENABLED=${SASL_AUTH_ENABLED,,}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$SASL_AUTH_ENABLED" != "yes" && "$SASL_AUTH_ENABLED" != "no" ]] ; then
|
[[ -z "${SASL_AUTH_ENABLED}" ]] && SASL_AUTH_ENABLED=${_SASL_AUTH_ENABLED}
|
||||||
_SASL_AUTH_ENABLED=""
|
|
||||||
|
if [[ "$SASL_AUTH_ENABLED" != "yes" &&
|
||||||
|
"$SASL_AUTH_ENABLED" != "true" &&
|
||||||
|
"$SASL_AUTH_ENABLED" != "false" &&
|
||||||
|
"$SASL_AUTH_ENABLED" != "no" ]] ; then
|
||||||
|
SASL_AUTH_ENABLED=""
|
||||||
echo -e "\n\t\033[33m\033[1mWrong entry!\033[m\n Type 'yes' or 'no'"
|
echo -e "\n\t\033[33m\033[1mWrong entry!\033[m\n Type 'yes' or 'no'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
[[ "$SASL_AUTH_ENABLED" = "yes" ]] && SASL_AUTH_ENABLED=true
|
||||||
|
[[ "$SASL_AUTH_ENABLED" = "no" ]] && SASL_AUTH_ENABLED=false
|
||||||
|
|
||||||
|
|
||||||
|
if ! ${SASL_AUTH_ENABLED} ; then
|
||||||
|
|
||||||
|
IS_SYMPA_LIST_SERVER=""
|
||||||
|
echo ""
|
||||||
|
echo -e "\033[32m--\033[m"
|
||||||
|
echo ""
|
||||||
|
echo "Are Sympa List Services provided? - [true/yes/false/no]"
|
||||||
|
echo ""
|
||||||
|
echononl "Sympa List Server? [$_IS_SYMPA_LIST_SERVER]: "
|
||||||
|
|
||||||
|
read IS_SYMPA_LIST_SERVER
|
||||||
|
if [[ -z "${IS_SYMPA_LIST_SERVER}" ]] ; then
|
||||||
|
IS_SYMPA_LIST_SERVER="$_IS_SYMPA_LIST_SERVER"
|
||||||
|
fi
|
||||||
|
IS_SYMPA_LIST_SERVER=${IS_SYMPA_LIST_SERVER,,}
|
||||||
|
|
||||||
|
while [[ "$IS_SYMPA_LIST_SERVER" != "yes" && \
|
||||||
|
"$IS_SYMPA_LIST_SERVER" != "true" && \
|
||||||
|
"$IS_SYMPA_LIST_SERVER" != "no" && \
|
||||||
|
"$IS_SYMPA_LIST_SERVER" != "false" ]]; do
|
||||||
|
|
||||||
|
echo -e "\n\t\033[33m\033[1mWrong value was given!!\033[m\n"
|
||||||
|
|
||||||
|
echononl "Sympa List Server? [$_IS_SYMPA_LIST_SERVER]: "
|
||||||
|
read IS_SYMPA_LIST_SERVER
|
||||||
|
if [[ -z "${IS_SYMPA_LIST_SERVER}" ]] ; then
|
||||||
|
IS_SYMPA_LIST_SERVER=false
|
||||||
|
fi
|
||||||
|
IS_SYMPA_LIST_SERVER=${IS_SYMPA_LIST_SERVER,,}
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "$IS_SYMPA_LIST_SERVER" = 'yes' || "$IS_SYMPA_LIST_SERVER" = 'true' ]] ; then
|
||||||
|
IS_SYMPA_LIST_SERVER=true
|
||||||
|
else
|
||||||
|
IS_SYMPA_LIST_SERVER=false
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
IS_SYMPA_LIST_SERVER=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -704,7 +759,6 @@ else
|
|||||||
fi
|
fi
|
||||||
if ! $DB_IN_USE ; then
|
if ! $DB_IN_USE ; then
|
||||||
echo -e "[3] \033[37m\033[1mSkip (No Database in use)\033[m"
|
echo -e "[3] \033[37m\033[1mSkip (No Database in use)\033[m"
|
||||||
_DB_TYPE="None"
|
|
||||||
else
|
else
|
||||||
echo "[3] Skip (No Database in use)"
|
echo "[3] Skip (No Database in use)"
|
||||||
fi
|
fi
|
||||||
@@ -855,6 +909,7 @@ echo -e "\tIPv4 address...........................: $IPV4"
|
|||||||
echo -e "\tIPv6 address...........................: $IPV6"
|
echo -e "\tIPv6 address...........................: $IPV6"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\tSASL AUTH support......................: $SASL_AUTH_ENABLED"
|
echo -e "\tSASL AUTH support......................: $SASL_AUTH_ENABLED"
|
||||||
|
echo -e "\tSupport sympa mailinglists.............: ${IS_SYMPA_LIST_SERVER}"
|
||||||
echo ""
|
echo ""
|
||||||
echo -e "\tQuarantine Directory ..................: $QUARANTINE_DIR"
|
echo -e "\tQuarantine Directory ..................: $QUARANTINE_DIR"
|
||||||
echo ""
|
echo ""
|
||||||
@@ -906,6 +961,7 @@ _IPV4=$IPV4
|
|||||||
_IPV6=$IPV6
|
_IPV6=$IPV6
|
||||||
|
|
||||||
_SASL_AUTH_ENABLED=$SASL_AUTH_ENABLED
|
_SASL_AUTH_ENABLED=$SASL_AUTH_ENABLED
|
||||||
|
_IS_SYMPA_LIST_SERVER=${IS_SYMPA_LIST_SERVER}
|
||||||
|
|
||||||
_QUARANTINE_DIR=$QUARANTINE_DIR
|
_QUARANTINE_DIR=$QUARANTINE_DIR
|
||||||
_QUARANTINE_ADMIN=$QUARANTINE_ADMIN
|
_QUARANTINE_ADMIN=$QUARANTINE_ADMIN
|
||||||
@@ -3299,6 +3355,18 @@ if $INSTALL_CLAMAV_UNOFFICIAL_SIGS ; then
|
|||||||
if [[ "$?" -ne 0 ]] ; then
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
installation_failed=true
|
installation_failed=true
|
||||||
error "$(cat $tmp_err_msg)"
|
error "$(cat $tmp_err_msg)"
|
||||||
|
|
||||||
|
warn "command was:
|
||||||
|
|
||||||
|
git clone https://github.com/extremeshok/clamav-unofficial-sigs.git /tmp/clamav-unofficial-sigs"
|
||||||
|
echononl "continue anyway [yes/no]: "
|
||||||
|
read OK
|
||||||
|
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||||
|
echononl "Wrong entry! - repeat [yes/nno]: "
|
||||||
|
read OK
|
||||||
|
done
|
||||||
|
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
|
||||||
fi
|
fi
|
||||||
if ! $installation_failed ; then
|
if ! $installation_failed ; then
|
||||||
echo_ok
|
echo_ok
|
||||||
@@ -4198,10 +4266,49 @@ use strict;
|
|||||||
# !! smtpd_proxy_filter - see master.cf !!
|
# !! smtpd_proxy_filter - see master.cf !!
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#\$inet_socket_port = [10024, 10026];
|
EOF
|
||||||
|
|
||||||
|
if ${SASL_AUTH_ENABLED} ; then
|
||||||
|
cat << EOF >> "${_config_file}"
|
||||||
|
\$inet_socket_port = [10024, 10026];
|
||||||
#\$inet_socket_port = [10024, 10029];
|
#\$inet_socket_port = [10024, 10029];
|
||||||
#\$inet_socket_port = [10024, 10026, 10029];
|
#\$inet_socket_port = [10024, 10026, 10029];
|
||||||
|
|
||||||
|
\$interface_policy{'10026'} = 'ORIGINATING';
|
||||||
|
\$policy_bank{'ORIGINATING'} = {
|
||||||
|
originating => 1, # declare that mail was submitted by our smtp client
|
||||||
|
bypass_spam_checks_maps => (1),
|
||||||
|
bypass_virus_checks_maps => (0),
|
||||||
|
remove_existing_spam_headers => 1,
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
cat << EOF >> "${_config_file}"
|
||||||
|
#\$inet_socket_port = [10024, 10026];
|
||||||
|
\$inet_socket_port = [10024, 10029];
|
||||||
|
#\$inet_socket_port = [10024, 10026, 10029];
|
||||||
|
|
||||||
|
\$interface_policy{'10024'} = 'INBOUND';
|
||||||
|
\$interface_policy{'10029'} = 'VIRUSONLY';
|
||||||
|
|
||||||
|
# Inbound: Spam + Virus
|
||||||
|
\$policy_bank{'INBOUND'} = { };
|
||||||
|
|
||||||
|
# Outbound: nur Virus
|
||||||
|
\$policy_bank{'VIRUSONLY'} = {
|
||||||
|
bypass_spam_checks_maps => [1],
|
||||||
|
bypass_header_checks_maps => [1],
|
||||||
|
final_spam_destiny => D_PASS,
|
||||||
|
originating => 1,
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << EOF >> "${_config_file}"
|
||||||
|
|
||||||
# Bypass spam checking fro trusted networks
|
# Bypass spam checking fro trusted networks
|
||||||
#
|
#
|
||||||
#\$interface_policy{'10026'} = 'TRUSTED';
|
#\$interface_policy{'10026'} = 'TRUSTED';
|
||||||
@@ -4317,7 +4424,8 @@ read_hash(\%whitelist_sender, '/etc/postfix/sender_whitelist');
|
|||||||
# Spam-Schwellwerte
|
# Spam-Schwellwerte
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
|
|
||||||
\$sa_tag_level_deflt = 1.9; # ab hier Info-Header
|
#\$sa_tag_level_deflt = 1.9; # ab hier Info-Header
|
||||||
|
\$sa_tag_level_deflt = -999; # immer header schreiben (Debug-freundlich)
|
||||||
\$sa_tag2_level_deflt = 5.1; # ab hier X-Spam-Flag: YES
|
\$sa_tag2_level_deflt = 5.1; # ab hier X-Spam-Flag: YES
|
||||||
\$sa_kill_level_deflt = 9.51; # high-spam - final destiny (DISCARD)
|
\$sa_kill_level_deflt = 9.51; # high-spam - final destiny (DISCARD)
|
||||||
\$sa_dsn_cutoff_level = 20.1; # ab hier keine DSN mehr
|
\$sa_dsn_cutoff_level = 20.1; # ab hier keine DSN mehr
|
||||||
@@ -4415,15 +4523,99 @@ if (-r \$policy_banks_file) {
|
|||||||
## - it which domains are local using the @local_domains_maps variable,
|
## - it which domains are local using the @local_domains_maps variable,
|
||||||
## - which by default is set to the value of \$mydomain & its subdomains:
|
## - which by default is set to the value of \$mydomain & its subdomains:
|
||||||
## -
|
## -
|
||||||
#@local_domains_maps = ( ["."] );
|
EOF
|
||||||
|
|
||||||
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
|
installation_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
## - get rid of "Open Relay" warnings in amavis logfile.
|
if [[ "${DB_TYPE}" = "PostgreSQL" ]] || \
|
||||||
## -
|
[[ "${DB_TYPE}" = "MySQL" ]] && \
|
||||||
\$interface_policy{'10024'} = 'ORIGINATING';
|
! ${IS_SYMPA_LIST_SERVER}; then
|
||||||
\$policy_bank{'ORIGINATING'} = {
|
|
||||||
originating => 1, # declare that mail was submitted by our smtp client
|
if [[ "$DB_TYPE" = "PostgreSQL" ]]; then
|
||||||
};
|
_db="pgsql"
|
||||||
|
else
|
||||||
|
_db="mysql"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
@local_domains_maps = (
|
||||||
|
[qw(${HOSTNAME} localhost)],
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
|
installation_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -f "/etc/postfix/${_db}_virtual_domains_maps.cf" ]]; then
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
|
||||||
|
# Domains, die als virtuelle Mailbox-Domains gehostet sind:
|
||||||
|
'${_db}:/etc/postfix/${_db}_virtual_domains_maps.cf',
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
|
installation_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [[ -f "/etc/postfix/${_db}_relay-domain-maps.cf" ]]; then
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
|
||||||
|
# Domains, die als Relay Domains akzeptiert werden:
|
||||||
|
'${_db}:/etc/postfix/${_db}_relay-domain-maps.cf',
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
|
installation_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if grep -iq -E "^\s*btree:/etc/postfix/relay_domains" "/etc/postfix/main.cf" > /dev/null 2>&1 ; then
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
|
||||||
|
# weiter Domains, die als Relay Domains akzeptiert werden
|
||||||
|
'btree:/etc/postfix/relay_domains',
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
|
installation_failed=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
);
|
||||||
|
EOF
|
||||||
|
|
||||||
|
else
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<'EOF'
|
||||||
|
@local_domains_maps = ( ["."] );
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
|
installation_failed=true
|
||||||
|
error "$(cat $tmp_err_msg)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
|
||||||
|
|
||||||
## - If you get am error like:
|
## - If you get am error like:
|
||||||
## -
|
## -
|
||||||
@@ -4435,6 +4627,7 @@ if (-r \$policy_banks_file) {
|
|||||||
#\$inet_socket_bind = undef;
|
#\$inet_socket_bind = undef;
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ "$?" -ne 0 ]] ; then
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
installation_failed=true
|
installation_failed=true
|
||||||
error "$(cat $tmp_err_msg)"
|
error "$(cat $tmp_err_msg)"
|
||||||
@@ -4442,33 +4635,42 @@ fi
|
|||||||
|
|
||||||
if [[ "$DB_TYPE" = "PostgreSQL" ]]; then
|
if [[ "$DB_TYPE" = "PostgreSQL" ]]; then
|
||||||
|
|
||||||
cat >> /etc/amavis/conf.d/50-user <<EOF
|
if [[ -n "${DB_NAME}" ]] && [[ -n "${DB_HOST}" ]] && [[ -n "${DB_USER}" ]] && [[ -n "${DB_PASS}" ]] ; then
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
|
||||||
## - lookup for local domains in PostgreSQL database
|
## - lookup for local domains in PostgreSQL database
|
||||||
## -
|
## -
|
||||||
@lookup_sql_dsn = (
|
#@lookup_sql_dsn = (
|
||||||
['DBI:Pg:database=${DB_NAME};host=${DB_HOST}', '$DB_USER', '$DB_PASS']
|
# ['DBI:Pg:database=${DB_NAME};host=${DB_HOST}', '$DB_USER', '$DB_PASS']
|
||||||
);
|
#);
|
||||||
\$sql_select_policy = 'SELECT \\'Y\\' AS local FROM domain WHERE \\'@\\' || domain IN (%k);';
|
#\$sql_select_policy = 'SELECT \\'Y\\' AS local FROM domain WHERE \\'@\\' || domain IN (%k);';
|
||||||
EOF
|
EOF
|
||||||
if [[ "$?" -ne 0 ]] ; then
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
installation_failed=true
|
installation_failed=true
|
||||||
error "$(cat $tmp_err_msg)"
|
error "$(cat $tmp_err_msg)"
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif [[ "$DB_TYPE" = "MySQL" ]];then
|
elif [[ "$DB_TYPE" = "MySQL" ]];then
|
||||||
cat >> /etc/amavis/conf.d/50-user <<EOF
|
|
||||||
|
if [[ -n "${DB_NAME}" ]] && [[ -n "${DB_HOST}" ]] && [[ -n "${DB_USER}" ]] && [[ -n "${DB_PASS}" ]] ; then
|
||||||
|
|
||||||
|
cat >> /etc/amavis/conf.d/50-user <<EOF
|
||||||
|
|
||||||
## - lookup for local domains in MySQL database
|
## - lookup for local domains in MySQL database
|
||||||
## -
|
## -
|
||||||
@lookup_sql_dsn = (
|
#@lookup_sql_dsn = (
|
||||||
['DBI:mysql:database=${DB_NAME};host=${DB_HOST}', '$DB_USER', '$DB_PASS']
|
# ['DBI:mysql:database=${DB_NAME};host=${DB_HOST}', '$DB_USER', '$DB_PASS']
|
||||||
);
|
#);
|
||||||
\$sql_select_policy = 'SELECT "Y" AS local FROM domain WHERE CONCAT("@", domain) IN (%k)';
|
#\$sql_select_policy = 'SELECT "Y" AS local FROM domain WHERE CONCAT("@", domain) IN (%k)';
|
||||||
EOF
|
EOF
|
||||||
if [[ "$?" -ne 0 ]] ; then
|
if [[ "$?" -ne 0 ]] ; then
|
||||||
installation_failed=true
|
installation_failed=true
|
||||||
error "$(cat $tmp_err_msg)"
|
error "$(cat $tmp_err_msg)"
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
@@ -4996,6 +5198,7 @@ fi
|
|||||||
## - localhost:10025 inet n - y - - smtpd
|
## - localhost:10025 inet n - y - - smtpd
|
||||||
## - -o content_filter=
|
## - -o content_filter=
|
||||||
## - -o smtpd_proxy_filter=
|
## - -o smtpd_proxy_filter=
|
||||||
|
## - -o smtpd_milters=
|
||||||
## - -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
## - -o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
||||||
## - -o smtpd_client_restrictions=
|
## - -o smtpd_client_restrictions=
|
||||||
## - -o smtpd_helo_restrictions=
|
## - -o smtpd_helo_restrictions=
|
||||||
@@ -5059,7 +5262,7 @@ while IFS='' read -r _line || [[ -n $_line ]] ; do
|
|||||||
smtp inet n - y - - smtpd
|
smtp inet n - y - - smtpd
|
||||||
-o content_filter=amavisfeed:[127.0.0.1]:10024
|
-o content_filter=amavisfeed:[127.0.0.1]:10024
|
||||||
EOF
|
EOF
|
||||||
if [[ "$SASL_AUTH_ENABLED" = "no" ]] ; then
|
if ! ${SASL_AUTH_ENABLED} ; then
|
||||||
cat >> $postfix_master_cf << EOF
|
cat >> $postfix_master_cf << EOF
|
||||||
-o smtpd_sasl_auth_enable=no
|
-o smtpd_sasl_auth_enable=no
|
||||||
EOF
|
EOF
|
||||||
@@ -5070,6 +5273,8 @@ EOF
|
|||||||
localhost:10025 inet n - y - - smtpd
|
localhost:10025 inet n - y - - smtpd
|
||||||
-o content_filter=
|
-o content_filter=
|
||||||
-o smtpd_proxy_filter=
|
-o smtpd_proxy_filter=
|
||||||
|
-o smtpd_milters=
|
||||||
|
-o milter_macro_daemon_name=ORIGINATING
|
||||||
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
||||||
-o smtpd_client_restrictions=
|
-o smtpd_client_restrictions=
|
||||||
-o smtpd_helo_restrictions=
|
-o smtpd_helo_restrictions=
|
||||||
@@ -5078,15 +5283,6 @@ localhost:10025 inet n - y - - smtpd
|
|||||||
-o smtpd_data_restrictions=
|
-o smtpd_data_restrictions=
|
||||||
-o mynetworks=127.0.0.0/8,[::1]/128
|
-o mynetworks=127.0.0.0/8,[::1]/128
|
||||||
-o receive_override_options=no_unknown_recipient_checks
|
-o receive_override_options=no_unknown_recipient_checks
|
||||||
EOF
|
|
||||||
if [[-n "$(which opendmarc)" ]] ; then
|
|
||||||
cat >> $postfix_master_cf << EOF
|
|
||||||
# IMPORTANT: no opendmarc here!
|
|
||||||
#-o smtpd_milters=local:/opendmarc/opendmarc.sock
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
cat >> $postfix_master_cf << EOF
|
|
||||||
#-o mynetworks=127.0.0.0/8,[::1]/128,${IPV4}/32
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -5100,7 +5296,7 @@ EOF
|
|||||||
${additional_smtp_port} inet n - y - - smtpd
|
${additional_smtp_port} inet n - y - - smtpd
|
||||||
-o content_filter=amavisfeed:[127.0.0.1]:10024
|
-o content_filter=amavisfeed:[127.0.0.1]:10024
|
||||||
EOF
|
EOF
|
||||||
if [[ "$SASL_AUTH_ENABLED" = "no" ]] ; then
|
if ! ${SASL_AUTH_ENABLED} ; then
|
||||||
cat >> $postfix_master_cf << EOF
|
cat >> $postfix_master_cf << EOF
|
||||||
-o smtpd_sasl_auth_enable=no
|
-o smtpd_sasl_auth_enable=no
|
||||||
EOF
|
EOF
|
||||||
@@ -5115,7 +5311,7 @@ EOF
|
|||||||
_found=true
|
_found=true
|
||||||
cat >> $postfix_master_cf << EOF
|
cat >> $postfix_master_cf << EOF
|
||||||
submission inet n - y - 20 smtpd
|
submission inet n - y - 20 smtpd
|
||||||
-o content_filter=amavisfeed:[127.0.0.1]:10024
|
-o content_filter=amavisfeed:[127.0.0.1]:10026
|
||||||
-o smtpd_tls_security_level=encrypt
|
-o smtpd_tls_security_level=encrypt
|
||||||
-o smtpd_sasl_auth_enable=yes
|
-o smtpd_sasl_auth_enable=yes
|
||||||
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
||||||
@@ -5132,6 +5328,8 @@ EOF
|
|||||||
localhost:10025 inet n - y - - smtpd
|
localhost:10025 inet n - y - - smtpd
|
||||||
-o content_filter=
|
-o content_filter=
|
||||||
-o smtpd_proxy_filter=
|
-o smtpd_proxy_filter=
|
||||||
|
-o smtpd_milters=
|
||||||
|
-o milter_macro_daemon_name=ORIGINATING
|
||||||
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
||||||
-o smtpd_client_restrictions=
|
-o smtpd_client_restrictions=
|
||||||
-o smtpd_helo_restrictions=
|
-o smtpd_helo_restrictions=
|
||||||
@@ -5141,12 +5339,6 @@ localhost:10025 inet n - y - - smtpd
|
|||||||
-o mynetworks=127.0.0.0/8,[::1]/128
|
-o mynetworks=127.0.0.0/8,[::1]/128
|
||||||
-o receive_override_options=no_unknown_recipient_checks
|
-o receive_override_options=no_unknown_recipient_checks
|
||||||
EOF
|
EOF
|
||||||
if [[ -n "$(which opendmarc)" ]] ; then
|
|
||||||
cat >> $postfix_master_cf << EOF
|
|
||||||
# IMPORTANT: no opendmarc here!
|
|
||||||
#-o smtpd_milters=local:/opendmarc/opendmarc.sock
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $amavisfeed_present ; then
|
if ! $amavisfeed_present ; then
|
||||||
@@ -5167,7 +5359,7 @@ EOF
|
|||||||
_found=true
|
_found=true
|
||||||
cat >> $postfix_master_cf << EOF
|
cat >> $postfix_master_cf << EOF
|
||||||
smtps inet n - y - - smtpd
|
smtps inet n - y - - smtpd
|
||||||
-o content_filter=amavisfeed:[127.0.0.1]:10024
|
-o content_filter=amavisfeed:[127.0.0.1]:10026
|
||||||
-o smtpd_tls_wrappermode=yes
|
-o smtpd_tls_wrappermode=yes
|
||||||
-o smtpd_sasl_auth_enable=yes
|
-o smtpd_sasl_auth_enable=yes
|
||||||
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
||||||
@@ -5184,6 +5376,8 @@ EOF
|
|||||||
localhost:10025 inet n - y - - smtpd
|
localhost:10025 inet n - y - - smtpd
|
||||||
-o content_filter=
|
-o content_filter=
|
||||||
-o smtpd_proxy_filter=
|
-o smtpd_proxy_filter=
|
||||||
|
-o smtpd_milters=
|
||||||
|
-o milter_macro_daemon_name=ORIGINATING
|
||||||
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
||||||
-o smtpd_client_restrictions=
|
-o smtpd_client_restrictions=
|
||||||
-o smtpd_helo_restrictions=
|
-o smtpd_helo_restrictions=
|
||||||
@@ -5193,12 +5387,6 @@ localhost:10025 inet n - y - - smtpd
|
|||||||
-o mynetworks=127.0.0.0/8,[::1]/128
|
-o mynetworks=127.0.0.0/8,[::1]/128
|
||||||
-o receive_override_options=no_unknown_recipient_checks
|
-o receive_override_options=no_unknown_recipient_checks
|
||||||
EOF
|
EOF
|
||||||
if [[ -n "$(which opendmarc)" ]] ; then
|
|
||||||
cat >> $postfix_master_cf << EOF
|
|
||||||
# IMPORTANT: no opendmarc here!
|
|
||||||
#-o smtpd_milters=local:/opendmarc/opendmarc.sock
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $amavisfeed_present ; then
|
if ! $amavisfeed_present ; then
|
||||||
@@ -5220,6 +5408,8 @@ EOF
|
|||||||
localhost:10025 inet n - y - - smtpd
|
localhost:10025 inet n - y - - smtpd
|
||||||
-o content_filter=
|
-o content_filter=
|
||||||
-o smtpd_proxy_filter=
|
-o smtpd_proxy_filter=
|
||||||
|
-o smtpd_milters=
|
||||||
|
-o milter_macro_daemon_name=ORIGINATING
|
||||||
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
-o smtpd_authorized_xforward_hosts=127.0.0.0/8,[::1]/128
|
||||||
-o smtpd_client_restrictions=
|
-o smtpd_client_restrictions=
|
||||||
-o smtpd_helo_restrictions=
|
-o smtpd_helo_restrictions=
|
||||||
@@ -5229,12 +5419,6 @@ localhost:10025 inet n - y - - smtpd
|
|||||||
-o mynetworks=127.0.0.0/8,[::1]/128
|
-o mynetworks=127.0.0.0/8,[::1]/128
|
||||||
-o receive_override_options=no_unknown_recipient_checks
|
-o receive_override_options=no_unknown_recipient_checks
|
||||||
EOF
|
EOF
|
||||||
if [[ -n "$(which opendmarc)" ]] ; then
|
|
||||||
cat >> $postfix_master_cf << EOF
|
|
||||||
# IMPORTANT: no opendmarc here!
|
|
||||||
#-o smtpd_milters=local:/opendmarc/opendmarc.sock
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -726,8 +726,11 @@ fi
|
|||||||
|
|
||||||
if grep -q -E "^\s*#?\s*non_smtpd_milters\s*=" ${main_cf_file} ; then
|
if grep -q -E "^\s*#?\s*non_smtpd_milters\s*=" ${main_cf_file} ; then
|
||||||
|
|
||||||
ensure_dkim_var "non_smtpd_milters" > "${tmp_main_cf_file}"
|
# In case of sympa, DKIM signatures will be added by sympa list manager
|
||||||
cp "${tmp_main_cf_file}" "${main_cf_file}"
|
if ! which sympa ; then
|
||||||
|
ensure_dkim_var "non_smtpd_milters" > "${tmp_main_cf_file}"
|
||||||
|
cp "${tmp_main_cf_file}" "${main_cf_file}"
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
|||||||
@@ -26,8 +26,15 @@ opendmarc_socket_file="${opendmarc_socket_dir}/opendmarc.sock"
|
|||||||
config_file_name_value_parameters="
|
config_file_name_value_parameters="
|
||||||
AuthservID|HOSTNAME
|
AuthservID|HOSTNAME
|
||||||
TrustedAuthservIDs|HOSTNAME
|
TrustedAuthservIDs|HOSTNAME
|
||||||
PidFile|/run/opendmarc/opendmarc.pid
|
PidFile|/run/opendmarc/opendmarc.pid"
|
||||||
RejectFailures|true
|
if which sympa ; then
|
||||||
|
config_file_name_value_parameters="$config_file_name_value_parameters
|
||||||
|
RejectFailures|false"
|
||||||
|
else
|
||||||
|
config_file_name_value_parameters="$config_file_name_value_parameters
|
||||||
|
RejectFailures|true"
|
||||||
|
fi
|
||||||
|
config_file_name_value_parameters="$config_file_name_value_parameters
|
||||||
Syslog|true
|
Syslog|true
|
||||||
SyslogFacility|mail
|
SyslogFacility|mail
|
||||||
IgnoreHosts|${opendmarc_base_dir}/ignore.hosts
|
IgnoreHosts|${opendmarc_base_dir}/ignore.hosts
|
||||||
@@ -881,26 +888,26 @@ else
|
|||||||
error "$(cat $log_file)"
|
error "$(cat $log_file)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echononl " Set Variable non_smtpd_milters at '/etc/postfix/main.cf'.."
|
#echononl " Set Variable non_smtpd_milters at '/etc/postfix/main.cf'.."
|
||||||
if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*opendkim.sock" /etc/postfix/main.cf 2> /dev/null) ; then
|
#if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*opendkim.sock" /etc/postfix/main.cf 2> /dev/null) ; then
|
||||||
if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*$(basename "${opendmarc_socket_file}")" /etc/postfix/main.cf); then
|
# if $(grep -q -E "^\s*non_smtpd_milters\s*=\s*.*$(basename "${opendmarc_socket_file}")" /etc/postfix/main.cf); then
|
||||||
echo_skipped
|
# echo_skipped
|
||||||
else
|
# else
|
||||||
perl -i -n -p -e "s&^\s*(non_smtpd_milters\s*=.*opendkim.sock)&\1,local:/$(basename "${opendmarc_socket_dir}")/$(basename "${opendmarc_socket_file}")&" \
|
# perl -i -n -p -e "s&^\s*(non_smtpd_milters\s*=.*opendkim.sock)&\1,local:/$(basename "${opendmarc_socket_dir}")/$(basename "${opendmarc_socket_file}")&" \
|
||||||
/etc/postfix/main.cf > $log_file 2>&1
|
# /etc/postfix/main.cf > $log_file 2>&1
|
||||||
if [[ $? -eq 0 ]] ; then
|
# if [[ $? -eq 0 ]] ; then
|
||||||
echo_ok
|
# echo_ok
|
||||||
postfix_needs_restart=true
|
# postfix_needs_restart=true
|
||||||
else
|
# else
|
||||||
echo_failed
|
# echo_failed
|
||||||
error "$(cat $log_file)"
|
# error "$(cat $log_file)"
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
else
|
#else
|
||||||
|
#
|
||||||
echo_skipped
|
# echo_skipped
|
||||||
warn "non_smtpd_milters is not adjusted. Complete Postfix configuration (main.cf) manually\!"
|
# warn "non_smtpd_milters is not adjusted. Complete Postfix configuration (main.cf) manually\!"
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
|
|
||||||
echononl " Set Variable smtpd_milters at '/etc/postfix/main.cf'.."
|
echononl " Set Variable smtpd_milters at '/etc/postfix/main.cf'.."
|
||||||
@@ -975,53 +982,53 @@ EOF
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if grep -q -E "^\s*#?\s*non_smtpd_milters\s*=" ${main_cf_file} ; then
|
#if grep -q -E "^\s*#?\s*non_smtpd_milters\s*=" ${main_cf_file} ; then
|
||||||
|
|
||||||
ensure_dmarc_var "non_smtpd_milters" > "${tmp_main_cf_file}"
|
|
||||||
cp "${tmp_main_cf_file}" "${main_cf_file}"
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
cat <<EOF >> /etc/postfix/main.cf 2> $log_file
|
|
||||||
|
|
||||||
# Was sind non_smtpd_milters?
|
|
||||||
#
|
#
|
||||||
# non_smtpd_milters gilt für alle Postfix-Prozesse, die Mails verarbeiten, aber NICHT
|
# ensure_dmarc_var "non_smtpd_milters" > "${tmp_main_cf_file}"
|
||||||
# der smtpd-Daemon sind.
|
# cp "${tmp_main_cf_file}" "${main_cf_file}"
|
||||||
#
|
#
|
||||||
# Das betrifft z. B.:
|
#else
|
||||||
#
|
#
|
||||||
# cleanup Header/Content-Bereinigung
|
# cat <<EOF >> /etc/postfix/main.cf 2> $log_file
|
||||||
# qmgr Queue-Manager
|
|
||||||
# lmtp / smtp Auslieferung nach extern
|
|
||||||
# local lokale Zustellung
|
|
||||||
#
|
#
|
||||||
# Das sind z. B.:
|
## Was sind non_smtpd_milters?
|
||||||
#
|
##
|
||||||
# - interne Bounces (MAILER-DAEMON)
|
## non_smtpd_milters gilt für alle Postfix-Prozesse, die Mails verarbeiten, aber NICHT
|
||||||
#
|
## der smtpd-Daemon sind.
|
||||||
# - Cron-Mails vom Server
|
##
|
||||||
#
|
## Das betrifft z. B.:
|
||||||
# - Weiterleitungen, die Postfix selbst generiert
|
##
|
||||||
#
|
## cleanup Header/Content-Bereinigung
|
||||||
# - Mails, die über sendmail CLI gesendet werden
|
## qmgr Queue-Manager
|
||||||
#
|
## lmtp / smtp Auslieferung nach extern
|
||||||
# - Mails, die Amavis über LMTP zurückgibt
|
## local lokale Zustellung
|
||||||
#
|
##
|
||||||
# - etc.
|
## Das sind z. B.:
|
||||||
#
|
##
|
||||||
#
|
## - interne Bounces (MAILER-DAEMON)
|
||||||
# DKIM soll auch die ausgehenden Mails signieren, die nicht über smtpd daemon versendet werden.
|
##
|
||||||
non_smtpd_milters = $opendmarc_socket_string
|
## - Cron-Mails vom Server
|
||||||
EOF
|
##
|
||||||
fi
|
## - Weiterleitungen, die Postfix selbst generiert
|
||||||
postfix_needs_restart=true
|
##
|
||||||
if [[ $? -eq 0 ]] ; then
|
## - Mails, die über sendmail CLI gesendet werden
|
||||||
echo_ok
|
##
|
||||||
else
|
## - Mails, die Amavis über LMTP zurückgibt
|
||||||
echo_failed
|
##
|
||||||
error "$(cat $log_file)"
|
## - etc.
|
||||||
fi
|
##
|
||||||
|
##
|
||||||
|
## DKIM soll auch die ausgehenden Mails signieren, die nicht über smtpd daemon versendet werden.
|
||||||
|
#non_smtpd_milters = $opendmarc_socket_string
|
||||||
|
#EOF
|
||||||
|
#fi
|
||||||
|
#postfix_needs_restart=true
|
||||||
|
#if [[ $? -eq 0 ]] ; then
|
||||||
|
# echo_ok
|
||||||
|
#else
|
||||||
|
# echo_failed
|
||||||
|
# error "$(cat $log_file)"
|
||||||
|
#fi
|
||||||
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -171,8 +171,10 @@ fi
|
|||||||
if [[ -z "$_RELAY_HOST" ]]; then
|
if [[ -z "$_RELAY_HOST" ]]; then
|
||||||
_IS_RELAY_HOST=$DEFAULT_IS_RELAY_HOST
|
_IS_RELAY_HOST=$DEFAULT_IS_RELAY_HOST
|
||||||
else
|
else
|
||||||
_IS_RELAY_HOST="$_RELAY_HOST"
|
_IS_RELAY_HOST="${_RELAY_HOST,,}"
|
||||||
fi
|
fi
|
||||||
|
[[ "${_IS_RELAY_HOST}" == "yes" ]] && _IS_RELAY_HOST=true
|
||||||
|
[[ "${_IS_RELAY_HOST}" == "no" ]] && _IS_RELAY_HOST=false
|
||||||
|
|
||||||
if [[ -z "$_LISTEN_ON_ADDITIONAL_RELAY_PORT" ]] ; then
|
if [[ -z "$_LISTEN_ON_ADDITIONAL_RELAY_PORT" ]] ; then
|
||||||
_LISTEN_ON_ADDITIONAL_RELAY_PORT=${DEFAULT_LISTEN_ON_ADDITIONAL_RELAY_PORT}
|
_LISTEN_ON_ADDITIONAL_RELAY_PORT=${DEFAULT_LISTEN_ON_ADDITIONAL_RELAY_PORT}
|
||||||
@@ -1071,7 +1073,18 @@ debugLevel = 1
|
|||||||
# HELO_reject = Null - Only reject HELO Fail for Null sender (SPF Classic)
|
# HELO_reject = Null - Only reject HELO Fail for Null sender (SPF Classic)
|
||||||
# HELO_reject = False - Never reject/defer on HELO, append header only.
|
# HELO_reject = False - Never reject/defer on HELO, append header only.
|
||||||
# HELO_reject = No_Check - Never check HELO.
|
# HELO_reject = No_Check - Never check HELO.
|
||||||
|
EOF
|
||||||
|
if ${IS_SYMPA_LIST_SERVER} ; then
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
|
HELO_reject = False
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
HELO_reject = SPF_Not_Pass
|
HELO_reject = SPF_Not_Pass
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
|
|
||||||
# Mail From rejection policy. Options are:
|
# Mail From rejection policy. Options are:
|
||||||
# Mail_From_reject = SPF_Not_Pass - Reject if result not Pass/None/Tempfail.
|
# Mail_From_reject = SPF_Not_Pass - Reject if result not Pass/None/Tempfail.
|
||||||
@@ -1084,7 +1097,18 @@ HELO_reject = SPF_Not_Pass
|
|||||||
# MAIL FROM-Adresse reagiert. Ein Fehler tritt auf, wenn die IP-Adresse des sendenden
|
# MAIL FROM-Adresse reagiert. Ein Fehler tritt auf, wenn die IP-Adresse des sendenden
|
||||||
# Servers nicht den SPF-Einträgen der Domain in der MAIL FROM-Adresse entspricht.
|
# Servers nicht den SPF-Einträgen der Domain in der MAIL FROM-Adresse entspricht.
|
||||||
#
|
#
|
||||||
|
EOF
|
||||||
|
if ${IS_SYMPA_LIST_SERVER} ; then
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
|
Mail_From_reject = False
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
Mail_From_reject = Fail
|
Mail_From_reject = Fail
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
|
|
||||||
# Policy for rejecting due to SPF PermError. Options are:
|
# Policy for rejecting due to SPF PermError. Options are:
|
||||||
# PermError_reject = True
|
# PermError_reject = True
|
||||||
@@ -1096,7 +1120,18 @@ Mail_From_reject = Fail
|
|||||||
#
|
#
|
||||||
# Wenn PermError_reject auf True gesetzt ist, wird die E-Mail abgewiesen (rejected),
|
# Wenn PermError_reject auf True gesetzt ist, wird die E-Mail abgewiesen (rejected),
|
||||||
#
|
#
|
||||||
|
EOF
|
||||||
|
if ${IS_SYMPA_LIST_SERVER} ; then
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
|
PermError_reject = False
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
PermError_reject = True
|
PermError_reject = True
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> "${_file}"
|
||||||
|
|
||||||
# Policy for deferring messages due to SPF TempError. Options are:
|
# Policy for deferring messages due to SPF TempError. Options are:
|
||||||
# TempError_Defer = True
|
# TempError_Defer = True
|
||||||
@@ -1109,7 +1144,7 @@ PermError_reject = True
|
|||||||
# Wenn TempError_Defer auf True gesetzt ist, wird die E-Mail vorübergehend zurückgewiesen
|
# Wenn TempError_Defer auf True gesetzt ist, wird die E-Mail vorübergehend zurückgewiesen
|
||||||
# (deferred), und der empfangende Server versucht später erneut, die E-Mail zuzustelle
|
# (deferred), und der empfangende Server versucht später erneut, die E-Mail zuzustelle
|
||||||
#
|
#
|
||||||
TempError_Defer = Defer
|
TempError_Defer = True
|
||||||
|
|
||||||
# Type of header to insert to document SPF result. Can be Received-SPF (SPF)
|
# Type of header to insert to document SPF result. Can be Received-SPF (SPF)
|
||||||
# or Authentication Results (AR). It cannot be both.
|
# or Authentication Results (AR). It cannot be both.
|
||||||
@@ -2111,9 +2146,24 @@ smtp_tls_security_level=dane
|
|||||||
smtpd_tls_loglevel = 1
|
smtpd_tls_loglevel = 1
|
||||||
smtp_tls_loglevel = 1
|
smtp_tls_loglevel = 1
|
||||||
|
|
||||||
|
|
||||||
|
# TLS RSA keys path
|
||||||
smtpd_tls_cert_file = $_TLS_CERT_FILE
|
smtpd_tls_cert_file = $_TLS_CERT_FILE
|
||||||
smtpd_tls_key_file = $_TLS_KEY_FILE
|
smtpd_tls_key_file = $_TLS_KEY_FILE
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ -f "/etc/postfix/ssl/mailserver-ecdsa.crt" &&
|
||||||
|
-f "/etc/postfix/ssl/mailserver-ecdsa.key" ]] ; then
|
||||||
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
|
# TLS ECDSA keys path
|
||||||
|
smtpd_tls_eccert_file = /etc/postfix/ssl/mailserver-ecdsa.crt
|
||||||
|
smtpd_tls_eckey_file = /etc/postfix/ssl/mailserver-ecdsa.key
|
||||||
|
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
|
|
||||||
## - File with DH parameters that the Postfix SMTP server should use with EDH ciphers.
|
## - File with DH parameters that the Postfix SMTP server should use with EDH ciphers.
|
||||||
## -
|
## -
|
||||||
@@ -2681,7 +2731,7 @@ EOF
|
|||||||
|
|
||||||
if [[ -n "$(which postfwd)" ]] ; then
|
if [[ -n "$(which postfwd)" ]] ; then
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
127.0.0.1:10040_time_limit = 3600
|
#127.0.0.1:10040_time_limit = 3600
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
@@ -2699,7 +2749,7 @@ if [[ -n "$(which policyd-spf)" ]] ; then
|
|||||||
# policyd-spf unix - n n - 0 spawn
|
# policyd-spf unix - n n - 0 spawn
|
||||||
# user=policyd-spf argv=/usr/bin/policyd-spf
|
# user=policyd-spf argv=/usr/bin/policyd-spf
|
||||||
#
|
#
|
||||||
policyd-spf_time_limit = 3600
|
#policyd-spf_time_limit = 3600
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -2876,6 +2926,16 @@ smtpd_recipient_restrictions =
|
|||||||
# \$relay_recipient_maps, and \$relay_recipient_maps is not null.
|
# \$relay_recipient_maps, and \$relay_recipient_maps is not null.
|
||||||
#
|
#
|
||||||
reject_unlisted_recipient,
|
reject_unlisted_recipient,
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [[ -n "$(which policyd-spf)" ]] ; then
|
||||||
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
|
# Check Postfix policy service ..
|
||||||
|
#
|
||||||
|
check_policy_service unix:private/policy-spf
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
# reject_unauth_destination
|
# reject_unauth_destination
|
||||||
#
|
#
|
||||||
# Reject the request unless one of the following is true:
|
# Reject the request unless one of the following is true:
|
||||||
@@ -2898,21 +2958,16 @@ smtpd_recipient_restrictions =
|
|||||||
# managed by the verify(8) server; see http://www.postfix.org/ADDRESS_VERIFICATION_README.html
|
# managed by the verify(8) server; see http://www.postfix.org/ADDRESS_VERIFICATION_README.html
|
||||||
# for more details
|
# for more details
|
||||||
reject_unverified_recipient,
|
reject_unverified_recipient,
|
||||||
EOF
|
|
||||||
|
|
||||||
if [[ -n "$(which policyd-spf)" ]] ; then
|
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
|
||||||
# Check Postfix policy service ..
|
|
||||||
#
|
|
||||||
check_policy_service unix:private/policy-spf
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
|
||||||
# Policyd-Weight
|
# Policyd-Weight
|
||||||
#check_policy_service inet:127.0.0.1:12525,
|
#check_policy_service inet:127.0.0.1:12525,
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# DEPRECATED permit_mx_backup
|
||||||
|
#
|
||||||
|
# warning: support for restriction "permit_mx_backup" will be removed from Postfix;
|
||||||
# permit Backup MX
|
# permit Backup MX
|
||||||
permit_mx_backup,
|
# permit_mx_backup,
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
# permit, if all restrictions so far passed
|
# permit, if all restrictions so far passed
|
||||||
permit
|
permit
|
||||||
|
|
||||||
@@ -2953,8 +3008,13 @@ smtpd_relay_restrictions =
|
|||||||
# managed by the verify(8) server; see http://www.postfix.org/ADDRESS_VERIFICATION_README.html
|
# managed by the verify(8) server; see http://www.postfix.org/ADDRESS_VERIFICATION_README.html
|
||||||
# for more details
|
# for more details
|
||||||
reject_unverified_recipient,
|
reject_unverified_recipient,
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# DEPRECATED permit_mx_backup
|
||||||
|
#
|
||||||
|
# warning: support for restriction "permit_mx_backup" will be removed from Postfix;
|
||||||
# permit Backup MX
|
# permit Backup MX
|
||||||
permit_mx_backup,
|
# permit_mx_backup,
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
# permit, if all restrictions so far passed
|
# permit, if all restrictions so far passed
|
||||||
permit
|
permit
|
||||||
|
|
||||||
@@ -2989,6 +3049,16 @@ else
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ${IS_SYMPA_LIST_SERVER} || ${IS_RELAY_HOST}; then
|
||||||
|
|
||||||
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
|
|
||||||
|
# Default: alles was nicht explizit überschrieben wird (pickup/local/sympa/cron/...)
|
||||||
|
content_filter = amavisfeed:[127.0.0.1]:10029
|
||||||
|
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "$(which opendkim)" ]] || [[ -n "$(which opendmarc)" ]] ; then
|
if [[ -n "$(which opendkim)" ]] || [[ -n "$(which opendmarc)" ]] ; then
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
|
|
||||||
@@ -3058,20 +3128,24 @@ EOF
|
|||||||
#
|
#
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ -n "$(which opendkim)" ]] && [[ -n "$(which opendmarc)" ]] ; then
|
if ${IS_SYMPA_LIST_SERVER} ; then
|
||||||
|
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
non_smtpd_milters = local:/opendkim/opendkim.sock,local:/opendmarc/opendmarc.sock
|
# DKIM signing takes place in the Sympa list manager.
|
||||||
|
non_smtpd_milters =
|
||||||
EOF
|
EOF
|
||||||
elif [[ -n "$(which opendkim)" ]] ; then
|
elif [[ -n "$(which opendkim)" ]] ; then
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
non_smtpd_milters = local:/opendkim/opendkim.sock
|
non_smtpd_milters = local:/opendkim/opendkim.sock
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
non_smtpd_milters = local:/opendmarc/opendmarc.sock
|
non_smtpd_milters =
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
cat <<EOF >> /etc/postfix/main.cf
|
cat <<EOF >> /etc/postfix/main.cf
|
||||||
|
|
||||||
|
|
||||||
@@ -4073,6 +4147,14 @@ else
|
|||||||
dmarc_pipe_present=false
|
dmarc_pipe_present=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if ${LISTEN_ON_ADDITIONAL_RELAY_PORT} ; then
|
||||||
|
if grep -iq -E "^${ADDITIONAL_RELAY_LISTEN_PORT}\s+" $postfix_master_cf > /dev/null 2>&1 ; then
|
||||||
|
additional_relay_port_present=true
|
||||||
|
else
|
||||||
|
additional_relay_port_present=false
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
_found=false
|
_found=false
|
||||||
echononl " Create new file \"${postfix_master_cf}\""
|
echononl " Create new file \"${postfix_master_cf}\""
|
||||||
if [[ -f "${postfix_master_cf}.$backup_date" ]]; then
|
if [[ -f "${postfix_master_cf}.$backup_date" ]]; then
|
||||||
@@ -4091,7 +4173,6 @@ submission inet n - y - 20 smtpd
|
|||||||
-o smtpd_tls_security_level=encrypt
|
-o smtpd_tls_security_level=encrypt
|
||||||
-o smtpd_sasl_auth_enable=yes
|
-o smtpd_sasl_auth_enable=yes
|
||||||
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
||||||
#-o milter_macro_daemon_name=ORIGINATING
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if ! $smtps_present ; then
|
if ! $smtps_present ; then
|
||||||
@@ -4100,13 +4181,14 @@ smtps inet n - y - - smtpd
|
|||||||
-o smtpd_tls_wrappermode=yes
|
-o smtpd_tls_wrappermode=yes
|
||||||
-o smtpd_sasl_auth_enable=yes
|
-o smtpd_sasl_auth_enable=yes
|
||||||
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
||||||
#-o milter_macro_daemon_name=ORIGINATING
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
elif $LISTEN_ON_ADDITIONAL_RELAY_PORT ; then
|
elif $LISTEN_ON_ADDITIONAL_RELAY_PORT ; then
|
||||||
cat >> $postfix_master_cf << EOF
|
if ! ${additional_relay_port_present} ; then
|
||||||
|
cat >> $postfix_master_cf << EOF
|
||||||
${ADDITIONAL_RELAY_LISTEN_PORT} inet n - y - - smtpd
|
${ADDITIONAL_RELAY_LISTEN_PORT} inet n - y - - smtpd
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@@ -4119,7 +4201,6 @@ submission inet n - y - 20 smtpd
|
|||||||
-o smtpd_tls_security_level=encrypt
|
-o smtpd_tls_security_level=encrypt
|
||||||
-o smtpd_sasl_auth_enable=yes
|
-o smtpd_sasl_auth_enable=yes
|
||||||
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
||||||
# -o milter_macro_daemon_name=ORIGINATING
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
@@ -4133,7 +4214,6 @@ smtps inet n - y - - smtpd
|
|||||||
-o smtpd_tls_wrappermode=yes
|
-o smtpd_tls_wrappermode=yes
|
||||||
-o smtpd_sasl_auth_enable=yes
|
-o smtpd_sasl_auth_enable=yes
|
||||||
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
-o smtpd_client_restrictions=permit_sasl_authenticated,reject
|
||||||
# -o milter_macro_daemon_name=ORIGINATING
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
@@ -4156,7 +4236,7 @@ EOF
|
|||||||
|
|
||||||
# - Add support for policyd-spf service
|
# - Add support for policyd-spf service
|
||||||
# -
|
# -
|
||||||
if ! $(grep -iq -E "^policyd-spf\s+" "$postfix_master_cf" 2> /dev/null) ; then
|
if ! grep -iq -E "^policy-spf\s+" "$postfix_master_cf" 2> /dev/null ; then
|
||||||
cat <<EOF >> $postfix_master_cf
|
cat <<EOF >> $postfix_master_cf
|
||||||
|
|
||||||
policy-spf unix - n n - 0 spawn
|
policy-spf unix - n n - 0 spawn
|
||||||
@@ -4167,7 +4247,7 @@ EOF
|
|||||||
|
|
||||||
# - Add transport definitions for only sending over IPv4/IPv6
|
# - Add transport definitions for only sending over IPv4/IPv6
|
||||||
# -
|
# -
|
||||||
if ! $(grep -iq -E "^smtp-ipv4-only\s+" "$postfix_master_cf" 2> /dev/null) ; then
|
if ! grep -iq -E "^smtp-ipv4-only\s+" "$postfix_master_cf" 2> /dev/null ; then
|
||||||
cat <<EOF >> $postfix_master_cf
|
cat <<EOF >> $postfix_master_cf
|
||||||
|
|
||||||
smtp-ipv4-only unix - - n - - smtp
|
smtp-ipv4-only unix - - n - - smtp
|
||||||
@@ -4175,7 +4255,7 @@ smtp-ipv4-only unix - - n - - smtp
|
|||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! $(grep -iq -E "^smtp-ipv6-only\s+" "$postfix_master_cf" 2> /dev/null) ; then
|
if ! grep -iq -E "^smtp-ipv6-only\s+" "$postfix_master_cf" 2> /dev/null ; then
|
||||||
cat <<EOF >> $postfix_master_cf
|
cat <<EOF >> $postfix_master_cf
|
||||||
|
|
||||||
smtp-ipv6-only unix - - n - - smtp
|
smtp-ipv6-only unix - - n - - smtp
|
||||||
|
|||||||
@@ -938,6 +938,16 @@ done
|
|||||||
if $_failed ; then
|
if $_failed ; then
|
||||||
echo_failed
|
echo_failed
|
||||||
error "$(cat $log_file)"
|
error "$(cat $log_file)"
|
||||||
|
|
||||||
|
echononl "\tcontinue anyway [yes/no]: "
|
||||||
|
read OK
|
||||||
|
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
|
||||||
|
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
|
||||||
|
echononl "Wrong entry! - repeat [yes/nno]: "
|
||||||
|
read OK
|
||||||
|
done
|
||||||
|
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
|
||||||
|
|
||||||
else
|
else
|
||||||
echo_ok
|
echo_ok
|
||||||
fi
|
fi
|
||||||
@@ -2198,7 +2208,11 @@ fi
|
|||||||
|
|
||||||
echo -e "\n\n\t\033[37m\033[1mConfigure Postfix Admin\033[m\n"
|
echo -e "\n\n\t\033[37m\033[1mConfigure Postfix Admin\033[m\n"
|
||||||
|
|
||||||
if [[ $MAJOR_VERSION -eq 3 ]] && [[ $MINOR_VERSION -gt 0 ]]; then
|
if [[ $MAJOR_VERSION -gt 3 ]] ; then
|
||||||
|
pfa_conf_file="${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.local.php"
|
||||||
|
cp -a "${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.inc.php" "$pfa_conf_file"
|
||||||
|
|
||||||
|
elif [[ $MAJOR_VERSION -eq 3 ]] && [[ $MINOR_VERSION -gt 0 ]] ; then
|
||||||
pfa_conf_file="${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.local.php"
|
pfa_conf_file="${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.local.php"
|
||||||
cp -a "${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.inc.php" "$pfa_conf_file"
|
cp -a "${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}/config.inc.php" "$pfa_conf_file"
|
||||||
else
|
else
|
||||||
@@ -2207,7 +2221,6 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# - Use 'Re: $SUBJECT' as the default subject template for vacation
|
# - Use 'Re: $SUBJECT' as the default subject template for vacation
|
||||||
# - in postfixadmin
|
# - in postfixadmin
|
||||||
# -
|
# -
|
||||||
|
|||||||
40
set-policyd-spf-config-for-listserver.sh
Executable file
40
set-policyd-spf-config-for-listserver.sh
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
CONF="/etc/postfix-policyd-spf-python/policyd-spf.conf"
|
||||||
|
BACKUP="${CONF}.$(date +%Y%m%d-%H%M%S).bak"
|
||||||
|
|
||||||
|
if [[ ! -f "$CONF" ]]; then
|
||||||
|
echo "ERROR: Config not found: $CONF" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp -a -- "$CONF" "$BACKUP"
|
||||||
|
|
||||||
|
ensure_kv() {
|
||||||
|
local key="$1"
|
||||||
|
local value="$2"
|
||||||
|
|
||||||
|
# Prüfen ob es eine AKTIVE (nicht auskommentierte) Zeile gibt
|
||||||
|
if grep -Eq "^[[:space:]]*${key}[[:space:]]*=" "$CONF"; then
|
||||||
|
# Nur erste aktive Zeile ersetzen
|
||||||
|
sed -ri "0,/^[[:space:]]*${key}[[:space:]]*=.*/s//${key} = ${value}/" "$CONF"
|
||||||
|
else
|
||||||
|
# Anfügen mit Leerzeile + Kommentar
|
||||||
|
cat >>"$CONF" <<EOF
|
||||||
|
|
||||||
|
# --- Mailinglist-friendly SPF policy (added by script) ---
|
||||||
|
${key} = ${value}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_kv "HELO_reject" "False"
|
||||||
|
ensure_kv "Mail_From_reject" "False"
|
||||||
|
ensure_kv "PermError_reject" "False"
|
||||||
|
ensure_kv "TempError_Defer" "True"
|
||||||
|
|
||||||
|
echo "Updated: $CONF"
|
||||||
|
echo "Backup : $BACKUP"
|
||||||
|
|
||||||
|
exit
|
||||||
285
set_amavis_local_domains_maps.sh
Executable file
285
set_amavis_local_domains_maps.sh
Executable file
@@ -0,0 +1,285 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# amavis-local-domains-auto.sh
|
||||||
|
#
|
||||||
|
# Zweck
|
||||||
|
# -----
|
||||||
|
# Ersetzt in /etc/amavis/conf.d/50-user die lokale Domains-Definition
|
||||||
|
#
|
||||||
|
# @local_domains_maps = ( ["."] );
|
||||||
|
#
|
||||||
|
# durch eine dynamische Definition, die aus der (effektiv aktiven) Postfix-
|
||||||
|
# Konfiguration ermittelt wird (pgsql oder mysql). Damit werden Spam-Header
|
||||||
|
# nur für Domains geschrieben, die Postfix tatsächlich als "lokal/relay" kennt.
|
||||||
|
#
|
||||||
|
# WICHTIG:
|
||||||
|
# - Das Skript ändert NUR dann etwas, wenn die Zeile exakt ( ["."] ); ist.
|
||||||
|
# - Backups werden IMMER nach /etc/amavis/ geschrieben (nicht neben die Datei).
|
||||||
|
# - DB-Typ wird automatisch aus "postconf -n" erkannt (robust inkl. includes).
|
||||||
|
#
|
||||||
|
# Features
|
||||||
|
# --------
|
||||||
|
# - Auto-Detect Backend: pgsql | mysql (aus Postfix-Maps)
|
||||||
|
# - Optionaler Fallback: wenn DB nicht erkennbar, dann auf ( ["."] ); setzen
|
||||||
|
# (standardmäßig AUS, weil produktiver Betrieb)
|
||||||
|
# - Dry-run Modus
|
||||||
|
# - Optional reload/restart von amavis
|
||||||
|
# - Atomare Aktualisierung (schreibt erst tmp, dann mv)
|
||||||
|
#
|
||||||
|
# Nutzung
|
||||||
|
# -------
|
||||||
|
# sudo ./amavis-local-domains-auto.sh --dry-run
|
||||||
|
# sudo ./amavis-local-domains-auto.sh --apply --reload
|
||||||
|
# sudo ./amavis-local-domains-auto.sh --apply --restart
|
||||||
|
#
|
||||||
|
# Optional:
|
||||||
|
# sudo ./amavis-local-domains-auto.sh --apply --allow-fallback-all
|
||||||
|
#
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Konfigurierbare Pfade
|
||||||
|
# ----------------------------
|
||||||
|
AMAVIS_50="${AMAVIS_50:-/etc/amavis/conf.d/50-user}"
|
||||||
|
|
||||||
|
# Backup-Verzeichnis (gewünscht: /etc/amavis/)
|
||||||
|
BACKUP_DIR="${BACKUP_DIR:-/etc/amavis}"
|
||||||
|
|
||||||
|
# Optional: Dateimap für relay_domains (falls vorhanden)
|
||||||
|
RELAY_BTREE_DEFAULT="/etc/postfix/relay_domains"
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Schalter / Optionen
|
||||||
|
# ----------------------------
|
||||||
|
DO_APPLY=false
|
||||||
|
DO_DRY_RUN=false
|
||||||
|
DO_RESTART=false
|
||||||
|
DO_RELOAD=false
|
||||||
|
ALLOW_FALLBACK_ALL=false
|
||||||
|
|
||||||
|
# Optional overrides
|
||||||
|
HOST_FQDN_OVERRIDE=""
|
||||||
|
RELAY_BTREE_OVERRIDE=""
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<'EOF'
|
||||||
|
Usage:
|
||||||
|
amavis-local-domains-auto.sh [OPTIONS]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
--dry-run Show what would change, do not modify files
|
||||||
|
--apply Apply change (only if @local_domains_maps is exactly ( ["."] );)
|
||||||
|
--restart Restart amavis after apply
|
||||||
|
--reload Reload amavis after apply (preferred if supported)
|
||||||
|
--allow-fallback-all If DB backend not detectable, replace with ( ["."] ); anyway
|
||||||
|
(default: fail safely / do nothing)
|
||||||
|
--host-fqdn FQDN Override hostname -f used in the block
|
||||||
|
--relay-btree PATH Override btree file path (default: /etc/postfix/relay_domains)
|
||||||
|
-h, --help Show this help
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
sudo ./amavis-local-domains-auto.sh --dry-run
|
||||||
|
sudo ./amavis-local-domains-auto.sh --apply --reload
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
die(){ echo "ERROR: $*" >&2; exit 1; }
|
||||||
|
log(){ echo "INFO: $*" >&2; }
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Argumente parsen
|
||||||
|
# ----------------------------
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--dry-run) DO_DRY_RUN=true; shift ;;
|
||||||
|
--apply) DO_APPLY=true; shift ;;
|
||||||
|
--restart) DO_RESTART=true; shift ;;
|
||||||
|
--reload) DO_RELOAD=true; shift ;;
|
||||||
|
--allow-fallback-all) ALLOW_FALLBACK_ALL=true; shift ;;
|
||||||
|
--host-fqdn) HOST_FQDN_OVERRIDE="${2:-}"; shift 2 ;;
|
||||||
|
--relay-btree) RELAY_BTREE_OVERRIDE="${2:-}"; shift 2 ;;
|
||||||
|
-h|--help) usage; exit 0 ;;
|
||||||
|
*) die "Unknown option: $1" ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! $DO_DRY_RUN && ! $DO_APPLY; then
|
||||||
|
die "Choose one: --dry-run or --apply"
|
||||||
|
fi
|
||||||
|
if $DO_RESTART && $DO_RELOAD; then
|
||||||
|
die "Choose only one: --restart or --reload"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Sanity Checks
|
||||||
|
# ----------------------------
|
||||||
|
command -v postconf >/dev/null || die "postconf not found"
|
||||||
|
[[ -r "$AMAVIS_50" ]] || die "Missing $AMAVIS_50"
|
||||||
|
[[ -d "$BACKUP_DIR" ]] || die "Backup dir missing: $BACKUP_DIR"
|
||||||
|
[[ -w "$BACKUP_DIR" ]] || die "Backup dir not writable: $BACKUP_DIR"
|
||||||
|
|
||||||
|
HOST_FQDN="${HOST_FQDN_OVERRIDE:-$(hostname -f 2>/dev/null || hostname)}"
|
||||||
|
RELAY_BTREE="${RELAY_BTREE_OVERRIDE:-$RELAY_BTREE_DEFAULT}"
|
||||||
|
|
||||||
|
# Regex: exakt @local_domains_maps = ( ["."] );
|
||||||
|
DOTLINE_REGEX='^[[:space:]]*@local_domains_maps[[:space:]]*=[[:space:]]*\([[:space:]]*\[[[:space:]]*"\."[[:space:]]*\][[:space:]]*\)[[:space:]]*;[[:space:]]*$'
|
||||||
|
|
||||||
|
if ! grep -qE "$DOTLINE_REGEX" "$AMAVIS_50"; then
|
||||||
|
log "No change: @local_domains_maps is not exactly ( [\".\"] );"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# DB-Typ + Map-Dateien aus Postfix ermitteln
|
||||||
|
# (postconf -n berücksichtigt includes, master.d, etc.)
|
||||||
|
# ----------------------------
|
||||||
|
VMD_LINE="$(postconf -n virtual_mailbox_domains 2>/dev/null || true)"
|
||||||
|
RD_LINE="$(postconf -n relay_domains 2>/dev/null || true)"
|
||||||
|
|
||||||
|
extract_db_map() {
|
||||||
|
# Findet den ersten Token, der :pgsql: oder :mysql: enthält
|
||||||
|
# und gibt "scheme|/path/to/map.cf" aus.
|
||||||
|
local line="$1"
|
||||||
|
for tok in $line; do
|
||||||
|
tok="${tok%,}"
|
||||||
|
if [[ "$tok" == *":pgsql:"* ]]; then
|
||||||
|
echo "pgsql|${tok##*:pgsql:}"
|
||||||
|
return 0
|
||||||
|
elif [[ "$tok" == *":mysql:"* ]]; then
|
||||||
|
echo "mysql|${tok##*:mysql:}"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
DB_SCHEME=""
|
||||||
|
VDOM_CF=""
|
||||||
|
RELAY_CF=""
|
||||||
|
|
||||||
|
if out="$(extract_db_map "$VMD_LINE")"; then
|
||||||
|
DB_SCHEME="${out%%|*}"
|
||||||
|
VDOM_CF="${out##*|}"
|
||||||
|
else
|
||||||
|
if $ALLOW_FALLBACK_ALL; then
|
||||||
|
DB_SCHEME="all"
|
||||||
|
else
|
||||||
|
die "Could not detect pgsql/mysql from postfix virtual_mailbox_domains. Use --allow-fallback-all to force."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$DB_SCHEME" != "all" ]]; then
|
||||||
|
if out="$(extract_db_map "$RD_LINE")"; then
|
||||||
|
rd_scheme="${out%%|*}"
|
||||||
|
rd_cf="${out##*|}"
|
||||||
|
if [[ "$rd_scheme" == "$DB_SCHEME" ]]; then
|
||||||
|
RELAY_CF="$rd_cf"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
[[ -r "$VDOM_CF" ]] || die "Detected map not readable: $VDOM_CF"
|
||||||
|
if [[ -n "$RELAY_CF" ]]; then
|
||||||
|
[[ -r "$RELAY_CF" ]] || die "Detected relay map not readable: $RELAY_CF"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Replacement-Block bauen (in temp Datei)
|
||||||
|
# ----------------------------
|
||||||
|
TMPDIR="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$TMPDIR"' EXIT
|
||||||
|
BLOCKFILE="$TMPDIR/block.txt"
|
||||||
|
|
||||||
|
if [[ "$DB_SCHEME" == "all" ]]; then
|
||||||
|
cat >"$BLOCKFILE" <<'EOF'
|
||||||
|
@local_domains_maps = ( ["."] );
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "@local_domains_maps = ("
|
||||||
|
echo " [qw(${HOST_FQDN} localhost)],"
|
||||||
|
echo ""
|
||||||
|
echo " # Domains, die als virtuelle Mailbox-Domains gehostet sind:"
|
||||||
|
echo " '${DB_SCHEME}:${VDOM_CF}',"
|
||||||
|
if [[ -n "$RELAY_CF" ]]; then
|
||||||
|
echo ""
|
||||||
|
echo " # Domains, die als relay_domains akzeptiert werden:"
|
||||||
|
echo " '${DB_SCHEME}:${RELAY_CF}',"
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo " # relay_domains DB-map nicht erkannt – wird übersprungen"
|
||||||
|
fi
|
||||||
|
echo " 'btree:${RELAY_BTREE}',"
|
||||||
|
echo ");"
|
||||||
|
} >"$BLOCKFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Geplante Änderung anzeigen
|
||||||
|
# ----------------------------
|
||||||
|
log "Detected backend: ${DB_SCHEME}"
|
||||||
|
if [[ "$DB_SCHEME" != "all" ]]; then
|
||||||
|
log "virtual_mailbox_domains map: ${DB_SCHEME}:${VDOM_CF}"
|
||||||
|
if [[ -n "$RELAY_CF" ]]; then
|
||||||
|
log "relay_domains map: ${DB_SCHEME}:${RELAY_CF}"
|
||||||
|
else
|
||||||
|
log "relay_domains map: (not detected / not used)"
|
||||||
|
fi
|
||||||
|
log "btree relay domains: btree:${RELAY_BTREE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $DO_DRY_RUN; then
|
||||||
|
echo "----- Would replace this line in $AMAVIS_50 -----"
|
||||||
|
echo '@local_domains_maps = ( ["."] );'
|
||||||
|
echo "----- With this block -----"
|
||||||
|
cat "$BLOCKFILE"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Backup in /etc/amavis/ erstellen
|
||||||
|
# ----------------------------
|
||||||
|
STAMP="$(date +%F_%H%M%S)"
|
||||||
|
BACKUP_FILE="${BACKUP_DIR}/50-user.bak.${STAMP}"
|
||||||
|
cp -a "$AMAVIS_50" "$BACKUP_FILE"
|
||||||
|
log "Backup created: $BACKUP_FILE"
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Datei neu schreiben (atomar)
|
||||||
|
# - Wir ersetzen nur die exakt passende (["."]) Zeile durch den neuen Block.
|
||||||
|
# ----------------------------
|
||||||
|
OUTFILE="$TMPDIR/50-user.new"
|
||||||
|
|
||||||
|
awk -v blockfile="$BLOCKFILE" '
|
||||||
|
BEGIN {
|
||||||
|
while ((getline line < blockfile) > 0) {
|
||||||
|
newblock = newblock line "\n"
|
||||||
|
}
|
||||||
|
close(blockfile)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
if ($0 ~ /^[[:space:]]*@local_domains_maps[[:space:]]*=[[:space:]]*\([[:space:]]*\[[[:space:]]*"\."[[:space:]]*\][[:space:]]*\)[[:space:]]*;[[:space:]]*$/) {
|
||||||
|
printf "%s", newblock
|
||||||
|
} else {
|
||||||
|
print
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' "$AMAVIS_50" > "$OUTFILE"
|
||||||
|
|
||||||
|
mv "$OUTFILE" "$AMAVIS_50"
|
||||||
|
log "Updated $AMAVIS_50"
|
||||||
|
|
||||||
|
# ----------------------------
|
||||||
|
# Optionaler Reload/Restart von amavis
|
||||||
|
# ----------------------------
|
||||||
|
if $DO_RELOAD; then
|
||||||
|
log "Reloading amavis..."
|
||||||
|
systemctl reload amavis || die "amavis reload failed"
|
||||||
|
elif $DO_RESTART; then
|
||||||
|
log "Restarting amavis..."
|
||||||
|
systemctl restart amavis || die "amavis restart failed"
|
||||||
|
else
|
||||||
|
log "No service action requested (--reload/--restart)."
|
||||||
|
fi
|
||||||
|
|
||||||
|
log "Done."
|
||||||
|
|
||||||
Reference in New Issue
Block a user