From ffb4e7ad8eb668394059a9ecb9ae66486fb0f3f5 Mon Sep 17 00:00:00 2001 From: Jeff Volkenant Date: Thu, 23 Dec 2021 10:59:07 -0800 Subject: [PATCH] #2073: Move postgrey database under $STORAGE_ROOT --- setup/mail-postfix.sh | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/setup/mail-postfix.sh b/setup/mail-postfix.sh index 196d371d..9c276eba 100755 --- a/setup/mail-postfix.sh +++ b/setup/mail-postfix.sh @@ -233,10 +233,31 @@ tools/editconf.py /etc/postfix/main.cf \ # As a matter of fact RFC is not strict about retry timer so postfix and # other MTA have their own intervals. To fix the problem of receiving # e-mails really latter, delay of greylisting has been set to -# 180 seconds (default is 300 seconds). +# 180 seconds (default is 300 seconds). We will move the postgrey database +# under $STORAGE_ROOT. This prevents a "warming up" that would have occured +# previously with a migrated or reinstalled OS. We will specify this new path +# with the --dbdir=... option. Arguments within POSTGREY_OPTS can not have spaces, +# including dbdir. This is due to the way the init script sources the +# /etc/default/postgrey file. --dbdir=... either needs to be a path without spaces +# (luckily $STORAGE_ROOT does not currently work with spaces), or it needs to be a +# symlink without spaces that can point to a folder with spaces). We'll just assume +# $STORAGE_ROOT won't have spaces to simplify things. tools/editconf.py /etc/default/postgrey \ - POSTGREY_OPTS=\"'--inet=127.0.0.1:10023 --delay=180'\" + POSTGREY_OPTS=\""--inet=127.0.0.1:10023 --delay=180 --dbdir=$STORAGE_ROOT/mail/postgrey"\" +# Make destination postgrey database directory under $STORAGE_ROOT +mkdir -p $STORAGE_ROOT/mail/postgrey + +# If the $STORAGE_ROOT/mail/postgrey is empty, copy the postgrey database over from the old location +if [ ! "$(ls -A $STORAGE_ROOT/mail/postgrey)" ]; then + # Stop the service + service postgrey stop + # Copy over the databse, we didn't cp -p to preserve perms since we have to chown the newly created directory above anyway + cp /var/lib/postgrey/* $STORAGE_ROOT/mail/postgrey/ +fi +# Fix permissions +chown -R postgrey:postgrey $STORAGE_ROOT/mail/postgrey/ +chmod 700 $STORAGE_ROOT/mail/postgrey/ # We are going to setup a newer whitelist for postgrey, the version included in the distribution is old cat > /etc/cron.daily/mailinabox-postgrey-whitelist << EOF;