From 61bdec807c268d1b4ffaa385f161bd4dfd012aee Mon Sep 17 00:00:00 2001 From: Herman van Rink <rink@initfour.nl> Date: Fri, 8 Apr 2022 21:24:23 +0200 Subject: [PATCH] Make the thrash filename extra obvious --- server/plugins-available/mail_plugin.inc.php | 2 +- server/scripts/handle_mailbox_soft_deleted.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php index d943ba139c..5850e527e4 100644 --- a/server/plugins-available/mail_plugin.inc.php +++ b/server/plugins-available/mail_plugin.inc.php @@ -431,7 +431,7 @@ class mail_plugin { if($old_maildir_path != $mail_config['homedir_path'] && strlen($old_maildir_path) > strlen($mail_config['homedir_path']) && !stristr($old_maildir_path, '//') && !stristr($old_maildir_path, '..') && !stristr($old_maildir_path, '*') && strlen($old_maildir_path) >= 10) { if ($mail_config['mailbox_soft_delete'] == 'y') { // Move it, adding a date based suffix. A cronjob should purge or archive. - $thrash_maildir_path = $old_maildir_path . '-' . date("YmdHis"); + $thrash_maildir_path = $old_maildir_path . '-deleted-' . date("YmdHis"); $app->system->exec_safe('mv ? ?', $old_maildir_path, $thrash_maildir_path); // Update the dir's timestamp to make filtering on age easier in any cleanup cronjob. diff --git a/server/scripts/handle_mailbox_soft_deleted.sh b/server/scripts/handle_mailbox_soft_deleted.sh index 7fea4cb839..f35a37a939 100644 --- a/server/scripts/handle_mailbox_soft_deleted.sh +++ b/server/scripts/handle_mailbox_soft_deleted.sh @@ -4,7 +4,7 @@ delay_days=7 # Test if there is something to do... to avoid 'No such file or directory' from find later. -ls /var/vmail/*/[a-z0-9.-]*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] >/dev/null 2>&1 +ls /var/vmail/*/[a-z0-9.-]*-deleted-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] >/dev/null 2>&1 if [ $? != 0 ]; then exit 0; fi @@ -36,7 +36,7 @@ echo tar cvfj "$backupfile" --remove-files "$dir" 2> >( grep -v "tar: Removin # -mtime +7 ===> Only mailboxes deleted more then 7 days ago # Test that the last dir component matches e.g. xxx-20220101094242 (14 digits) # command: xxx-`date "+%Y%m%d%H%M%S"` -find /var/vmail/*/[a-z0-9.-]*-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] -maxdepth 0 -type d -mtime +$delay_days | while read line; do +find /var/vmail/*/[a-z0-9.-]*-deleted-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9] -maxdepth 0 -type d -mtime +$delay_days | while read line; do # example $line: "/var/vmail/example.com/info-20220101094242" dir=$line -- GitLab