2023-02-27 19:21:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-05-25 23:01:41 +00:00
|
|
|
function _setup_spoof_protection() {
|
2023-05-24 07:06:59 +00:00
|
|
|
if [[ ${SPOOF_PROTECTION} -eq 1 ]]; then
|
2023-02-27 19:21:45 +00:00
|
|
|
_log 'trace' 'Enabling and configuring spoof protection'
|
|
|
|
|
2023-05-24 07:06:59 +00:00
|
|
|
if [[ ${ACCOUNT_PROVISIONER} == 'LDAP' ]]; then
|
|
|
|
if [[ -z ${LDAP_QUERY_FILTER_SENDERS} ]]; then
|
2023-02-27 19:21:45 +00:00
|
|
|
postconf 'smtpd_sender_login_maps = ldap:/etc/postfix/ldap-users.cf ldap:/etc/postfix/ldap-aliases.cf ldap:/etc/postfix/ldap-groups.cf'
|
|
|
|
else
|
|
|
|
postconf 'smtpd_sender_login_maps = ldap:/etc/postfix/ldap-senders.cf'
|
|
|
|
fi
|
|
|
|
else
|
2023-05-24 07:06:59 +00:00
|
|
|
if [[ -f /etc/postfix/regexp ]]; then
|
2023-02-27 19:21:45 +00:00
|
|
|
postconf 'smtpd_sender_login_maps = unionmap:{ texthash:/etc/postfix/virtual, hash:/etc/aliases, pcre:/etc/postfix/maps/sender_login_maps.pcre, pcre:/etc/postfix/regexp }'
|
|
|
|
else
|
|
|
|
postconf 'smtpd_sender_login_maps = texthash:/etc/postfix/virtual, hash:/etc/aliases, pcre:/etc/postfix/maps/sender_login_maps.pcre'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
_log 'debug' 'Spoof protection is disabled'
|
2023-03-03 14:55:32 +00:00
|
|
|
# shellcheck disable=SC2016
|
|
|
|
postconf 'mua_sender_restrictions = $dms_smtpd_sender_restrictions'
|
2023-02-27 19:21:45 +00:00
|
|
|
fi
|
|
|
|
}
|