From 47f227463cde4649337f2771077cddfee9db2f83 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 2 May 2023 17:23:33 +1000 Subject: [PATCH] LDAP can now be disabled by not defining SEARCH_BASE --- include/40-relay.cf | 4 ++-- include/41-virtual.cf | 4 ++-- init | 34 +++++++++++++++++++--------------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/include/40-relay.cf b/include/40-relay.cf index d0fc42b..ab8654b 100644 --- a/include/40-relay.cf +++ b/include/40-relay.cf @@ -1,8 +1,8 @@ #relayhost = /etc/postfix/custom/relay_host relay_domains = lmdb:/etc/postfix/custom/relay_domains - ldap:/etc/postfix/custom/ldap_relay_domains +# ldap:/etc/postfix/custom/ldap_relay_domains relay_recipient_maps = lmdb:/etc/postfix/custom/relay_recipient_maps - ldap:/etc/postfix/custom/ldap_relay_recipient_maps +# ldap:/etc/postfix/custom/ldap_relay_recipient_maps transport_maps = lmdb:/etc/postfix/custom/relay_domains #transport_maps = $relay_domains #relay_transport = lmdb:/etc/postfix/custom/relay_domains <-- THIS DOESNT WORK? diff --git a/include/41-virtual.cf b/include/41-virtual.cf index 29cb5ef..8eb68a5 100644 --- a/include/41-virtual.cf +++ b/include/41-virtual.cf @@ -2,14 +2,14 @@ ##virtual_alias_domains = lmdb:/etc/postfix/custom/virtual_alias_domains ## ldap:/etc/postfix/custom/ldap_virtual_mailbox_domains virtual_alias_maps = lmdb:/etc/postfix/custom/virtual_alias_maps - ldap:/etc/postfix/custom/ldap_virtual_alias_maps +# ldap:/etc/postfix/custom/ldap_virtual_alias_maps virtual_mailbox_base = /var/mail/vhosts #virtual_mailbox_domains = @VIRTUAL_DOMAINS@ ## @note virtual_mailbox_domains cannot be a map, so the below two definitions *WONT* work ##virtual_mailbox_domains = lmdb:/etc/postfix/custom/virtual_mailbox_domains ## ldap:/etc/postfix/custom/ldap_virtual_mailbox_domains virtual_mailbox_maps = lmdb:/etc/postfix/custom/virtual_mailbox_maps - ldap:/etc/postfix/custom/ldap_virtual_mailbox_maps +# ldap:/etc/postfix/custom/ldap_virtual_mailbox_maps #virtual_transport = virtual virtual_minimum_uid = 100 virtual_uid_maps = static:5000 diff --git a/init b/init index 3b6f2c3..ed2dcbc 100755 --- a/init +++ b/init @@ -62,21 +62,25 @@ if [ -z "$@" ]; then postmap -o lmdb:${CUSTOM}/virtual_mailbox_maps # Create some default LDAP templates - if [ ! -f ${CUSTOM}/ldap_virtual_alias_maps -a -n "${LDAP_SEARCH_BASE}" ]; then - cp ${DEFAULTS}/ldap_virtual_alias_maps ${CUSTOM}/ - sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_alias_maps - fi - if [ ! -f ${CUSTOM}/ldap_virtual_mailbox_maps -a -n "${LDAP_SEARCH_BASE}" ]; then - cp ${DEFAULTS}/ldap_virtual_mailbox_maps ${CUSTOM}/ - sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_mailbox_maps - fi - if [ ! -f ${CUSTOM}/ldap_relay_domains -a -n "${LDAP_SEARCH_BASE}" ]; then - cp ${DEFAULTS}/ldap_relay_domains ${CUSTOM}/ - sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_domains - fi - if [ ! -f ${CUSTOM}/ldap_relay_recipient_maps -a -n "${LDAP_SEARCH_BASE}" ]; then - cp ${DEFAULTS}/ldap_relay_recipient_maps ${CUSTOM}/ - sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_recipient_maps + if [ -n "${LDAP_SEARCH_BASE}" ]; then + sed -i -e "s%^# ldap:% ldap:%" ${POSTFIX}/main.cf + + if [ ! -f ${CUSTOM}/ldap_virtual_alias_maps ]; then + cp ${DEFAULTS}/ldap_virtual_alias_maps ${CUSTOM}/ + sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_alias_maps + fi + if [ ! -f ${CUSTOM}/ldap_virtual_mailbox_maps ]; then + cp ${DEFAULTS}/ldap_virtual_mailbox_maps ${CUSTOM}/ + sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_virtual_mailbox_maps + fi + if [ ! -f ${CUSTOM}/ldap_relay_domains ]; then + cp ${DEFAULTS}/ldap_relay_domains ${CUSTOM}/ + sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_domains + fi + if [ ! -f ${CUSTOM}/ldap_relay_recipient_maps ]; then + cp ${DEFAULTS}/ldap_relay_recipient_maps ${CUSTOM}/ + sed -i -e "s%@THIS_HOST@%${HOSTNAME}%" -e "s%@LDAP_SEARCH_BASE@%${LDAP_SEARCH_BASE}%" ${CUSTOM}/ldap_relay_recipient_maps + fi fi newaliases