From 7972151d0448b99e0ba28c819a698757c27c1d55 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Thu, 23 Oct 2014 13:13:09 -0400
Subject: [PATCH] Merge branch 'stable-3.0.5'
---
server/plugins-available/mail_plugin.inc.php | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/server/plugins-available/mail_plugin.inc.php b/server/plugins-available/mail_plugin.inc.php
index 81ba6ce..5ac0951 100644
--- a/server/plugins-available/mail_plugin.inc.php
+++ b/server/plugins-available/mail_plugin.inc.php
@@ -138,10 +138,11 @@
$maildomain_path .= '/Maildir';
}
- //* When the mail user dir exists but it is not a valid maildir, remove it
+ //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
- exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
- $app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
+ if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
+ exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail");
+ $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
}
//* Create the maildir, if it doesn not exist, set permissions, set quota.
@@ -302,10 +303,11 @@
$maildomain_path .= '/Maildir';
}
- //* When the mail user dir exists but it is not a valid maildir, remove it
+ //* When the mail user dir exists but it is not a valid maildir, move it to corrupted maildir folder
if(!empty($maildomain_path) && is_dir($maildomain_path) && !is_dir($maildomain_path.'/new') && !is_dir($maildomain_path.'/cur')) {
- exec("su -c 'rm -rf ".escapeshellcmd($data['new']['maildir'])."' vmail");
- $app->log('Removed invalid maildir and rebuild it: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
+ if(!is_dir($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'])) $app->system->mkdirpath($mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id'], 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
+ exec("su -c 'mv -f ".escapeshellcmd($data['new']['maildir'])." ".$mail_config['homedir_path'].'/corrupted/'.$data['new']['mailuser_id']."' vmail");
+ $app->log('Moved invalid maildir to corrupted Maildirs folder: '.escapeshellcmd($data['new']['maildir']), LOGLEVEL_WARN);
}
//* Create the maildir, if it doesn not exist, set permissions, set quota.
--
Gitblit v1.9.1