diff --git a/install_amavis.sh b/install_amavis.sh index 464562e..0202cd2 100755 --- a/install_amavis.sh +++ b/install_amavis.sh @@ -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';