Rsyslog logging for postfix, optional logging to file, no logging of test requests

master
Michael Wyraz 5 years ago
parent 6518ef19af
commit e979743226

@ -12,7 +12,7 @@ RUN pip3 install socrate==0.2.0
RUN pip3 install "podop>0.2.5" RUN pip3 install "podop>0.2.5"
# Image specific layers under this line # Image specific layers under this line
RUN apk add --no-cache postfix postfix-pcre cyrus-sasl-plain cyrus-sasl-login RUN apk add --no-cache postfix postfix-pcre cyrus-sasl-plain rsyslog cyrus-sasl-login
COPY conf /conf COPY conf /conf
COPY start.py /start.py COPY start.py /start.py

@ -2,9 +2,6 @@
# General # General
############### ###############
# Logging configuration
maillog_file = /dev/stdout
# Main domain and hostname # Main domain and hostname
mydomain = {{ DOMAIN }} mydomain = {{ DOMAIN }}
myhostname = {{ HOSTNAMES.split(",")[0] }} myhostname = {{ HOSTNAMES.split(",")[0] }}

@ -0,0 +1,40 @@
# rsyslog configuration file
#
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# or latest version online at http://www.rsyslog.com/doc/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html
#### Global directives ####
# Sets the directory that rsyslog uses for work files.
$WorkDirectory /var/lib/rsyslog
# Sets default permissions for all log files.
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
# Reduce repeating messages (default off).
$RepeatedMsgReduction on
#### Modules ####
# Provides support for local system logging (e.g. via logger command).
module(load="imuxsock")
#### Rules ####
# Discard messages from local test requests
:msg, contains, "connect from localhost[127.0.0.1]" ~
{% if POSTFIX_LOG_FILE %}
# Log mail logs to file
mail.* -{{LOG_FILE}}
{% endif %}
# Log mail logs to stdout
mail.* -/dev/stdout

@ -37,6 +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["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") os.environ["LMTP_ADDRESS"] = system.get_host_address_from_environment("LMTP", "imap:2525")
conf.jinja("/conf/rsyslog.conf", os.environ, "/etc/rsyslog.conf")
for postfix_file in glob.glob("/conf/*.cf"): for postfix_file in glob.glob("/conf/*.cf"):
conf.jinja(postfix_file, os.environ, os.path.join("/etc/postfix", os.path.basename(postfix_file))) conf.jinja(postfix_file, os.environ, os.path.join("/etc/postfix", os.path.basename(postfix_file)))
@ -61,6 +64,9 @@ if "RELAYUSER" in os.environ:
conf.jinja("/conf/sasl_passwd", os.environ, path) conf.jinja("/conf/sasl_passwd", os.environ, path)
os.system("postmap {}".format(path)) os.system("postmap {}".format(path))
# Start rsyslog
os.system("/usr/sbin/rsyslogd -n &")
# Run Podop and Postfix # Run Podop and Postfix
multiprocessing.Process(target=start_podop).start() multiprocessing.Process(target=start_podop).start()
os.system("/usr/libexec/postfix/post-install meta_directory=/etc/postfix create-missing") os.system("/usr/libexec/postfix/post-install meta_directory=/etc/postfix create-missing")

@ -147,6 +147,9 @@ Log messages equal or higher than this priority will be printed.
Can be one of: CRITICAL, ERROR, WARNING, INFO, DEBUG or NOTSET. Can be one of: CRITICAL, ERROR, WARNING, INFO, DEBUG or NOTSET.
See the `python docs`_ for more information. See the `python docs`_ for more information.
``POSTFIX_LOG_FILE`` enables postfix logging to the given file (in addition to log to stdout).
Log rotation should be done externally.
.. _`python docs`: https://docs.python.org/3.6/library/logging.html#logging-levels .. _`python docs`: https://docs.python.org/3.6/library/logging.html#logging-levels
Antivirus settings Antivirus settings

Loading…
Cancel
Save