postfix: wrap IPv6 CIDRs in square brackets for RELAYNETS

The RELAYNETS environment variable is used for configuring both postfix
`mynetworks` and rspamd `local_networks`. Postfix requires IPv6
addresses to be wrapped in square brackets (eg. [2001:db8::]/64).
master
Pim van den Berg 3 years ago
parent 9743639693
commit d495052b52

@ -6,6 +6,7 @@ import shutil
import multiprocessing
import logging as log
import sys
import re
from podop import run_server
from pwd import getpwnam
@ -50,6 +51,10 @@ os.environ["LMTP_ADDRESS"] = system.get_host_address_from_environment("LMTP", "i
os.environ["POSTFIX_LOG_SYSLOG"] = os.environ.get("POSTFIX_LOG_SYSLOG","local")
os.environ["POSTFIX_LOG_FILE"] = os.environ.get("POSTFIX_LOG_FILE", "")
# Postfix requires IPv6 addresses to be wrapped in square brackets
if 'RELAYNETS' in os.environ:
os.environ["RELAYNETS"] = re.sub(r'([0-9a-fA-F]+:[0-9a-fA-F:]+)/', '[\\1]/', os.environ["RELAYNETS"])
for postfix_file in glob.glob("/conf/*.cf"):
conf.jinja(postfix_file, os.environ, os.path.join("/etc/postfix", os.path.basename(postfix_file)))

@ -0,0 +1 @@
postfix: wrap IPv6 CIDRs in square brackets for RELAYNETS
Loading…
Cancel
Save