install_amavis.sh: open amavis port 10026 whenever submission/smtps use it

master.cf submission/smtps are always rewritten to
content_filter=amavisfeed:[127.0.0.1]:10026, but amavis only listened on
10026 if Cyrus SASL was enabled. Hosts authenticating via Dovecot SASL
(answer 'no') got [10024, 10029], so submitted mail was deferred with
"connect to 127.0.0.1:10026: Connection refused".

Now 10026 (ORIGINATING) is opened if SASL is enabled or master.cf contains
submission/smtps; 10029 (VIRUSONLY) is opened as before if 10026 is not
needed, or if main.cf content_filter points to 10029 (relay/sympa hosts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
chrisandClaude Opus 5.5 committed 2026-11-13 00:45:13 +01:00
1 parent 787749f4d6
commit 5429768e28
1 file changed
+38 -9
+38 -9
View File
@@ -4268,11 +4268,43 @@ use strict;
#
EOF
if ${SASL_AUTH_ENABLED} ; then
# - Port 10026 (policy bank ORIGINATING)
# -
# - Needed whenever master.cf contains submission or smtps: further below
# - both are rewritten to 'content_filter=amavisfeed:[127.0.0.1]:10026'.
# - install_postfix_advanced.sh creates submission/smtps on every host that
# - is not a relay host - independent of Cyrus SASL (most hosts authenticate
# - via Dovecot SASL and answer the Cyrus SASL question with 'no').
# -
# - Port 10029 (policy bank VIRUSONLY)
# -
# - Target of 'content_filter' in main.cf on relay hosts and sympa list
# - servers (see install_postfix_advanced.sh).
# -
if ${SASL_AUTH_ENABLED} \
|| grep -qiE "^(submission|smtps)\s+" /etc/postfix/master.cf 2> /dev/null ; then
amavis_originating_port=true
else
amavis_originating_port=false
fi
if ! ${amavis_originating_port} \
|| postconf -h content_filter 2> /dev/null | grep -q ':10029' ; then
amavis_virusonly_port=true
else
amavis_virusonly_port=false
fi
amavis_listen_ports="10024"
${amavis_originating_port} && amavis_listen_ports="${amavis_listen_ports}, 10026"
${amavis_virusonly_port} && amavis_listen_ports="${amavis_listen_ports}, 10029"
cat << EOF >> "${_config_file}"
\$inet_socket_port = [${amavis_listen_ports}];
EOF
if ${amavis_originating_port} ; then
cat << EOF >> "${_config_file}"
\$inet_socket_port = [10024, 10026];
#\$inet_socket_port = [10024, 10029];
#\$inet_socket_port = [10024, 10026, 10029];
\$interface_policy{'10026'} = 'ORIGINATING';
\$policy_bank{'ORIGINATING'} = {
@@ -4282,13 +4314,10 @@ if ${SASL_AUTH_ENABLED} ; then
remove_existing_spam_headers => 1,
};
EOF
fi
else
if ${amavis_virusonly_port} ; then
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';