From 8cf4f839ee7c97de522e6caf6a413374b812cd17 Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Tue, 7 Feb 2017 23:17:03 +0100 Subject: [PATCH 1/3] Issue #507 (#511) * Fixes #507 permissions on /var/lib/amavis --- target/start-mailserver.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index d0e83fd9..1315ee8c 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -917,7 +917,7 @@ function _fix_var_mail_permissions() { function _fix_var_amavis_permissions() { notify 'task' 'Fixing /var/lib/amavis permissions' - if [ `find /var/lib/amavis -maxdepth 3 -a \( \! -user amavis -o \! -group amavis \) | grep -c .` != 0 ]; then + if [ `find /var/lib/amavis/* -maxdepth 3 -a \( \! -user amavis -o \! -group amavis \) | grep -c .` != 0 ]; then notify 'inf' "Fixing /var/lib/amavis permissions" chown -R amavis:amavis /var/lib/amavis else From ef59fae8b321a83d8de9b60621ef4c6724d33480 Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Wed, 8 Feb 2017 23:31:56 +0100 Subject: [PATCH 2/3] Fixes #507 - Permission check on Amavis lib folder, and bring back to amavis:amavis if needed (#513) --- target/start-mailserver.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index 1315ee8c..b18d4b34 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -902,7 +902,7 @@ function fix() { } function _fix_var_mail_permissions() { - notify 'task' 'Fixing /var/mail permissions' + notify 'task' 'Checking /var/mail permissions' # Fix permissions, but skip this if 3 levels deep the user id is already set if [ `find /var/mail -maxdepth 3 -a \( \! -user 5000 -o \! -group 5000 \) | grep -c .` != 0 ]; then @@ -915,13 +915,20 @@ function _fix_var_mail_permissions() { } function _fix_var_amavis_permissions() { - notify 'task' 'Fixing /var/lib/amavis permissions' - - if [ `find /var/lib/amavis/* -maxdepth 3 -a \( \! -user amavis -o \! -group amavis \) | grep -c .` != 0 ]; then - notify 'inf' "Fixing /var/lib/amavis permissions" - chown -R amavis:amavis /var/lib/amavis + if [ "$ONE_DIR" -eq 0 ]; then + amavis_state_dir=/var/lib/amavis else - notify 'inf' "Permissions in /var/lib/amavis look OK" + amavis_state_dir=/var/mail-state/lib-amavis + fi + notify 'task' 'Checking $amavis_state_dir permissions' + + amavis_permissions_status=$(find -H $amavis_state_dir -maxdepth 3 -a \( \! -user amavis -o \! -group amavis \)) + + if [ -n "$amavis_permissions_status" ]; then + notify 'inf' "Fixing $amavis_state_dir permissions" + chown -hR amavis:amavis $amavis_state_dir + else + notify 'inf' "Permissions in $amavis_state_dir look OK" return 0 fi } From 4189374cb59c0833406ed44028595c583220760d Mon Sep 17 00:00:00 2001 From: Thomas VIAL Date: Thu, 9 Feb 2017 17:05:36 +0100 Subject: [PATCH 3/3] Adds postgrey in /var/mail-state - Fixes #514 (#515) --- target/start-mailserver.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/start-mailserver.sh b/target/start-mailserver.sh index b18d4b34..4b6ae0b3 100644 --- a/target/start-mailserver.sh +++ b/target/start-mailserver.sh @@ -957,7 +957,7 @@ function _misc_save_states() { statedir=/var/mail-state if [ "$ONE_DIR" = 1 -a -d $statedir ]; then notify 'inf' "Consolidating all state onto $statedir" - for d in /var/spool/postfix /var/lib/postfix /var/lib/amavis /var/lib/clamav /var/lib/spamassasin /var/lib/fail2ban; do + for d in /var/spool/postfix /var/lib/postfix /var/lib/amavis /var/lib/clamav /var/lib/spamassasin /var/lib/fail2ban /var/lib/postgrey; do dest=$statedir/`echo $d | sed -e 's/.var.//; s/\//-/g'` if [ -d $dest ]; then notify 'inf' " Destination $dest exists, linking $d to it"