From ca6ea6465c73ae49f2aa7b19b17e501c9cb325e3 Mon Sep 17 00:00:00 2001 From: Michael Wyraz Date: Sat, 23 Jan 2021 16:16:07 +0100 Subject: [PATCH] make syslog optional --- core/postfix/conf/main.cf | 5 +++++ core/postfix/start.py | 9 ++++++--- docs/configuration.rst | 12 ++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/core/postfix/conf/main.cf b/core/postfix/conf/main.cf index 10143f29..1e2e9e8a 100644 --- a/core/postfix/conf/main.cf +++ b/core/postfix/conf/main.cf @@ -2,6 +2,11 @@ # General ############### +{% if POSTFIX_LOG_SYSLOG != "local" %} +# Logging configuration +maillog_file = /dev/stdout +{% endif %} + # Main domain and hostname mydomain = {{ DOMAIN }} myhostname = {{ HOSTNAMES.split(",")[0] }} diff --git a/core/postfix/start.py b/core/postfix/start.py index d942c8f1..4509da40 100755 --- a/core/postfix/start.py +++ b/core/postfix/start.py @@ -37,8 +37,9 @@ os.environ["ADMIN_ADDRESS"] = system.get_host_address_from_environment("ADMIN", os.environ["ANTISPAM_MILTER_ADDRESS"] = system.get_host_address_from_environment("ANTISPAM_MILTER", "antispam:11332") os.environ["LMTP_ADDRESS"] = system.get_host_address_from_environment("LMTP", "imap:2525") -conf.jinja("/conf/rsyslog.conf", os.environ, "/etc/rsyslog.conf") +os.environ["LMTP_ADDRESS"] = system.get_host_address_from_environment("LMTP", "imap:2525") +os.environ["POSTFIX_LOG_SYSLOG"] = os.environ.get("POSTFIX_LOG_SYSLOG","disabled") for postfix_file in glob.glob("/conf/*.cf"): conf.jinja(postfix_file, os.environ, os.path.join("/etc/postfix", os.path.basename(postfix_file))) @@ -64,8 +65,10 @@ if "RELAYUSER" in os.environ: conf.jinja("/conf/sasl_passwd", os.environ, path) os.system("postmap {}".format(path)) -# Start rsyslog -os.system("/usr/sbin/rsyslogd -n &") +if os.environ["POSTFIX_LOG_SYSLOG"]=="local": + # Configure and start local rsyslog server + conf.jinja("/conf/rsyslog.conf", os.environ, "/etc/rsyslog.conf") + os.system("/usr/sbin/rsyslogd -n &") # Run Podop and Postfix multiprocessing.Process(target=start_podop).start() diff --git a/docs/configuration.rst b/docs/configuration.rst index 78d147fa..24045b15 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -190,3 +190,15 @@ When using ``*_ADDRESS``, the hostnames must be full-qualified hostnames. Otherw resolve the hostnames. +Maillog setitngs +---------------- + +By default, all services log directly to stdout/stderr. Logs can be collected by any docker log processing solution. + +In some situations, a separate mail log is required (e.g. for legal reasons). Postfix can be configured to write the logs to a +syslog server that stores the log files to a volume. It can be configured by the following options: + +- ``POSTFIX_LOG_SYSLOG``: (default: ``disabled``) set to ``local`` to enable a local syslog server for postfix +- ``POSTFIX_LOG_FILE``: The file to log the maillog to + +