From e803b6b130de39af0684aaf6bed1f7c75550565e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Wed, 23 May 2018 17:51:07 +0100 Subject: [PATCH] Remove ip addresses from email logs --- src/freedombone-base-email | 20 ++++++++++++++++++++ src/freedombone-upgrade | 1 + src/freedombone-utils-setup | 3 +++ 3 files changed, 24 insertions(+) diff --git a/src/freedombone-base-email b/src/freedombone-base-email index 71b266ec..84ac0374 100755 --- a/src/freedombone-base-email +++ b/src/freedombone-base-email @@ -1694,4 +1694,24 @@ function install_email { mark_completed "${FUNCNAME[0]}" } +function remove_ip_addresses_from_email_logs { + { echo '#!/bin/bash'; + echo 'if [ -f /var/log/exim4/mainlog ]; then'; + echo " if grep -q '\\[' /var/log/exim4/mainlog; then"; + echo " tail -n 50 /var/log/exim4/mainlog | sed 's/\\[[^][]*\\]//g' > /tmp/.exim4_mainlog"; + echo ' chown Debian-exim:adm /tmp/.exim4_mainlog'; + echo ' mv /tmp/.exim4_mainlog /var/log/exim4/mainlog'; + echo ' fi'; + echo 'fi'; + echo 'if [ -f /var/log/exim4/rejectlog ]; then'; + echo " if grep -q '\\[' /var/log/exim4/rejectlog; then"; + echo " tail -n 50 /var/log/exim4/rejectlog | sed 's/\\[[^][]*\\]//g' > /tmp/.exim4_rejectlog"; + echo ' chown Debian-exim:adm /tmp/.exim4_rejectlog'; + echo ' mv /tmp/.exim4_rejectlog /var/log/exim4/rejectlog'; + echo ' fi'; + echo 'fi'; } > /usr/bin/exim_log_tidy + chown +x /usr/bin/exim_log_tidy + cron_add_mins 1 '/usr/bin/exim_log_tidy' +} + # NOTE: deliberately no exit 0 diff --git a/src/freedombone-upgrade b/src/freedombone-upgrade index 94c408ca..e5891212 100755 --- a/src/freedombone-upgrade +++ b/src/freedombone-upgrade @@ -107,6 +107,7 @@ if [ -d "$PROJECT_DIR" ]; then apt-get -yq -t stretch-backports install certbot email_install_tls email_disable_chunking + remove_ip_addresses_from_email_logs rm /etc/exim4/exim4.conf.template.bak* email_update_onion_domain prevent_mail_process_overrun diff --git a/src/freedombone-utils-setup b/src/freedombone-utils-setup index ba2a43ef..cf892569 100755 --- a/src/freedombone-utils-setup +++ b/src/freedombone-utils-setup @@ -1096,6 +1096,9 @@ function setup_email { function_check install_email install_email + function_check remove_ip_addresses_from_email_logs + remove_ip_addresses_from_email_logs + function_check create_procmail create_procmail