diff --git a/.gitlab-docker-manifest.yml b/.gitlab-docker-manifest.yml index 8b38379..1eddfc3 100644 --- a/.gitlab-docker-manifest.yml +++ b/.gitlab-docker-manifest.yml @@ -1,7 +1,7 @@ x86_64:build-manifest: stage: build-manifest script: - - docker manifest create ${CI_REGISTRY_IMAGE}:${VERSION} ${CI_REGISTRY_IMAGE}:${VERSION}-x86_64 #${CI_REGISTRY_IMAGE}:${VERSION}-arm64 ${CI_REGISTRY_IMAGE}:${VERSION}armv7l + - docker manifest create ${CI_REGISTRY_IMAGE}:${VERSION} ${CI_REGISTRY_IMAGE}:${VERSION}-x86_64 #${CI_REGISTRY_IMAGE}:${VERSION}-arm64 ${CI_REGISTRY_IMAGE}:${VERSION}-armv7l - docker manifest push --purge ${CI_REGISTRY_IMAGE}:${VERSION} tags: - docker diff --git a/defaults/60-spamhaus.cf b/defaults/60-spamhaus.cf new file mode 100644 index 0000000..897ac87 --- /dev/null +++ b/defaults/60-spamhaus.cf @@ -0,0 +1,10 @@ +#smtpd_recipient_restrictions = +# reject_rhsbl_sender @SPAMHAUS_DQS_KEY@.dbl.dq.spamhaus.net=127.0.1.[2..99], +# reject_rhsbl_helo @SPAMHAUS_DQS_KEY@.dbl.dq.spamhaus.net=127.0.1.[2..99], +# reject_rhsbl_reverse_client @SPAMHAUS_DQS_KEY@.dbl.dq.spamhaus.net=127.0.1.[2..99], +# reject_rhsbl_sender @SPAMHAUS_DQS_KEY@.zrd.dq.spamhaus.net=127.0.2.[2..24], +# reject_rhsbl_helo @SPAMHAUS_DQS_KEY@.zrd.dq.spamhaus.net=127.0.2.[2..24], +# reject_rhsbl_reverse_client @SPAMHAUS_DQS_KEY@.zrd.dq.spamhaus.net=127.0.2.[2..24], +# reject_rbl_client @SPAMHAUS_DQS_KEY@.zen.dq.spamhaus.net=127.0.0.[2..255] + +rbl_reply_maps = lmdb:/etc/postfix/custom/dnsbl-reply-map diff --git a/defaults/dnsbl-reply-map b/defaults/dnsbl-reply-map new file mode 100644 index 0000000..46a77f8 --- /dev/null +++ b/defaults/dnsbl-reply-map @@ -0,0 +1,7 @@ +@SPAMHAUS_DQS_KEY@.sbl.dq.spamhaus.net=127.0.0.[2..255] $rbl_code Service unavailable; $rbl_class [$rbl_what] blocked using sbl.spamhaus.org${rbl_reason?; $rbl_reason} +@SPAMHAUS_DQS_KEY@.xbl.dq.spamhaus.net=127.0.0.[2..255] $rbl_code Service unavailable; $rbl_class [$rbl_what] blocked using xbl.spamhaus.org${rbl_reason?; $rbl_reason} +@SPAMHAUS_DQS_KEY@.pbl.dq.spamhaus.net=127.0.0.[2..255] $rbl_code Service unavailable; $rbl_class [$rbl_what] blocked using pbl.spamhaus.org${rbl_reason?; $rbl_reason} +@SPAMHAUS_DQS_KEY@.sbl-xbl.dq.spamhaus.net=127.0.0.[2..255] $rbl_code Service unavailable; $rbl_class [$rbl_what] blocked using sbl-xbl.spamhaus.org${rbl_reason?; $rbl_reason} +@SPAMHAUS_DQS_KEY@.zen.dq.spamhaus.net=127.0.0.[2..255] $rbl_code Service unavailable; $rbl_class [$rbl_what] blocked using zen.spamhaus.org${rbl_reason?; $rbl_reason} +@SPAMHAUS_DQS_KEY@.dbl.dq.spamhaus.net=127.0.1.[2..99] $rbl_code Service unavailable; $rbl_class [$rbl_what] blocked using dbl.spamhaus.org${rbl_reason?; $rbl_reason} +@SPAMHAUS_DQS_KEY@.zrd.dq.spamhaus.net=127.0.2.[2..24] $rbl_code Service unavailable; $rbl_class [$rbl_what] blocked using zrd.spamhaus.org${rbl_reason?; $rbl_reason} diff --git a/defaults/header_checks b/defaults/header_checks new file mode 100644 index 0000000..b0038b9 --- /dev/null +++ b/defaults/header_checks @@ -0,0 +1,554 @@ +# HEADER_CHECKS(5) HEADER_CHECKS(5) +# +# NAME +# header_checks - Postfix built-in content inspection +# +# SYNOPSIS +# header_checks = pcre:/etc/postfix/header_checks +# mime_header_checks = pcre:/etc/postfix/mime_header_checks +# nested_header_checks = pcre:/etc/postfix/nested_header_checks +# body_checks = pcre:/etc/postfix/body_checks +# +# milter_header_checks = pcre:/etc/postfix/milter_header_checks +# +# smtp_header_checks = pcre:/etc/postfix/smtp_header_checks +# smtp_mime_header_checks = pcre:/etc/postfix/smtp_mime_header_checks +# smtp_nested_header_checks = pcre:/etc/postfix/smtp_nested_header_checks +# smtp_body_checks = pcre:/etc/postfix/smtp_body_checks +# +# postmap -q "string" pcre:/etc/postfix/filename +# postmap -q - pcre:/etc/postfix/filename $/ +# REJECT IFRAME vulnerability exploit +# +# SEE ALSO +# cleanup(8), canonicalize and enqueue Postfix message +# pcre_table(5), format of PCRE lookup tables +# regexp_table(5), format of POSIX regular expression tables +# postconf(1), Postfix configuration utility +# postmap(1), Postfix lookup table management +# postsuper(1), Postfix janitor +# postcat(1), show Postfix queue file contents +# RFC 2045, base64 and quoted-printable encoding rules +# RFC 2047, message header encoding for non-ASCII text +# +# README FILES +# Use "postconf readme_directory" or "postconf html_direc- +# tory" to locate this information. +# DATABASE_README, Postfix lookup table overview +# CONTENT_INSPECTION_README, Postfix content inspection overview +# BUILTIN_FILTER_README, Postfix built-in content inspection +# BACKSCATTER_README, blocking returned forged mail +# +# LICENSE +# The Secure Mailer license must be distributed with this +# software. +# +# AUTHOR(S) +# Wietse Venema +# IBM T.J. Watson Research +# P.O. Box 704 +# Yorktown Heights, NY 10598, USA +# +# Wietse Venema +# Google, Inc. +# 111 8th Avenue +# New York, NY 10011, USA +# +# HEADER_CHECKS(5) +/^Received:\ from\ localhost\ \(localhost\ \[127.0.0.1\]\)/ IGNORE +/^Received:\ from\ efa-1-1.dege.au\ \(localhost\ \[127.0.0.1/ IGNORE +/^Received:\ from\ efa-1-1.dege.au\ \(localhost\ \[::1/ IGNORE +/^Received:\ from\ ov-3-1.graytech.net.au\ \(localhost\ \[127.0.0.1/ IGNORE +/^Received:\ from\ ov-3-1.graytech.net.au\ \(localhost\ \[::1/ IGNORE diff --git a/defaults/helo_access b/defaults/helo_access new file mode 100644 index 0000000..e69de29 diff --git a/defaults/recipient_canonical b/defaults/recipient_canonical new file mode 100644 index 0000000..e69de29 diff --git a/defaults/sender_access b/defaults/sender_access new file mode 100644 index 0000000..e69de29 diff --git a/defaults/sender_canonical b/defaults/sender_canonical new file mode 100644 index 0000000..e69de29 diff --git a/include/01-custom.cf b/include/01-custom.cf index 1808169..d24ed51 100644 --- a/include/01-custom.cf +++ b/include/01-custom.cf @@ -2,3 +2,29 @@ message_size_limit = 25600000 queue_minfree = 51200000 smtpd_helo_required = yes recipient_delimiter = + +disable_vrfy_command = yes +header_checks = regexp:/etc/postfix/custom/header_checks +#inet_protocols = ipv4, ipv6 +local_recipient_maps = +mailbox_size_limit = 133169152 +qmqpd_authorized_clients = 127.0.0.1 [::1] +recipient_canonical_maps = lmdb:/etc/postfix/custom/recipient_canonical +sender_canonical_maps = lmdb:/etc/postfix/custom/sender_canonical +smtp_tls_session_cache_database = lmdb:/var/lib/postfix/smtp_tls_session_cache +smtpd_client_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_rbl_client 7dizji4jgexx4lzr4bp5urjmgq.sbl.dq.spamhaus.net +smtpd_data_restrictions = reject_unauth_pipelining +smtpd_helo_restrictions = check_helo_access lmdb:/etc/postfix/custom/helo_access, reject_invalid_hostname +smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination, reject_non_fqdn_recipient, reject_unknown_recipient_domain, check_recipient_access lmdb:/etc/postfix/custom/recipient_access, +#reject_rhsbl_sender @SPAMHAUS_DQS_KEY@.dbl.dq.spamhaus.net=127.0.1.[2..99], +#reject_rhsbl_helo @SPAMHAUS_DQS_KEY@.dbl.dq.spamhaus.net=127.0.1.[2..99], +#reject_rhsbl_reverse_client @SPAMHAUS_DQS_KEY@.dbl.dq.spamhaus.net=127.0.1.[2..99], +#reject_rhsbl_sender @SPAMHAUS_DQS_KEY@.zrd.dq.spamhaus.net=127.0.2.[2..24], +#reject_rhsbl_helo @SPAMHAUS_DQS_KEY@.zrd.dq.spamhaus.net=127.0.2.[2..24], +#reject_rhsbl_reverse_client @SPAMHAUS_DQS_KEY@.zrd.dq.spamhaus.net=127.0.2.[2..24], +#reject_rbl_client @SPAMHAUS_DQS_KEY@.zen.dq.spamhaus.net=127.0.0.[2..255], + reject_unverified_recipient +rbl_reply_maps = lmdb:/etc/postfix/custom/dnsbl-reply-map +smtpd_sender_restrictions = permit_sasl_authenticated, check_sender_access lmdb:/etc/postfix/custom/sender_access, reject_non_fqdn_sender, reject_unknown_sender_domain +smtpd_use_tls = yes +unverified_recipient_reject_code = 450 +unverified_recipient_reject_reason = No user at this address diff --git a/include/20-sasl.cf b/include/20-sasl.cf index bc70e15..5d24d05 100644 --- a/include/20-sasl.cf +++ b/include/20-sasl.cf @@ -1,4 +1,4 @@ smtp_sasl_auth_enable = yes smtp_sasl_password_maps = lmdb:/etc/postfix/custom/sasl_passwd -smtp_sasl_security_options = +smtp_sasl_security_options = noplaintext, noanonymous smtpd_sasl_auth_enable = yes diff --git a/include/50-milters.cf b/include/50-milters.cf index 5fcdc96..39312f1 100644 --- a/include/50-milters.cf +++ b/include/50-milters.cf @@ -1,6 +1,6 @@ # Milter configuration - opendkim # If the OpenDKIM milter isn't available, accept the message anyway. -milter_default_action = accept +milter_default_action = tempfail # What milter communication protocol should be used to pass messages # to and from OpenDKIM? milter_protocol = 6 diff --git a/init b/init index ed2dcbc..d777c5e 100755 --- a/init +++ b/init @@ -28,6 +28,18 @@ if [ -z "$@" ]; then /usr/sbin/saslauthd -m /run/saslauthd -ca shadow /usr/sbin/opendkim -u opendkim -P /run/opendkim/opendkim.pid + if [ -n "${SPAMHAUS_DQS_KEY}" ]; then + sed -i -e "s/@SPAMHAUS_DQS_KEY@/${SPAMHAUS_DQS_KEY}/g" ${DEFAULTS}/dnsbl-reply-map ${INCLUDE_DIR}/01-custom.cf + sed -i -e "s/^#reject/ reject/" ${INCLUDE_DIR}/01-custom.cf + + if [ ! -f ${CUSTOM}/dnsbl-reply-map ]; then + cp ${DEFAULTS}/dnsbl-reply-map ${CUSTOM}/ + postmap -o lmdb:${CUSTOM}/dnsbl-reply-map + fi + + cp ${DEFAULTS}/60-spamhaus.cf ${INCLUDE_DIR}/ + fi + # Setup our postfix environment if [ -d ${INCLUDE_DIR} ]; then if ls -1 ${INCLUDE_DIR}/*.cf >/dev/null 2>&1; then @@ -83,6 +95,13 @@ if [ -z "$@" ]; then fi fi + [ ! -f ${CUSTOM}/header_checks ] && cp ${DEFAULTS}/header_checks ${CUSTOM}/ && postmap -o lmdb:${CUSTOM}/header_checks + [ ! -f ${CUSTOM}/helo_access ] && cp ${DEFAULTS}/helo_access ${CUSTOM}/ && postmap -o lmdb:${CUSTOM}/helo_access + [ ! -f ${CUSTOM}/recipient_access ] && cp ${DEFAULTS}/recipient_access ${CUSTOM}/ && postmap -o lmdb:${CUSTOM}/recipient_access + [ ! -f ${CUSTOM}/recipient_canonical ] && cp ${DEFAULTS}/recipient_canonical ${CUSTOM}/ && postmap -o lmdb:${CUSTOM}/recipient_canonical + [ ! -f ${CUSTOM}/sender_access ] && cp ${DEFAULTS}/sender_access ${CUSTOM}/ && postmap -o lmdb:${CUSTOM}/sender_access + [ ! -f ${CUSTOM}/sender_canonical ] && cp ${DEFAULTS}/sender_canonical ${CUSTOM}/ && postmap -o lmdb:${CUSTOM}/sender_canonical + newaliases postfix start