Skip to content

Commit 0c4be73

Browse files
committed
Bugfix: Don't remove delete mailbox under home/vmail
1 parent 93f15eb commit 0c4be73

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

server/plugins-available/mail_plugin.inc.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function onLoad() {
5353
//* Mail Domains
5454
//$app->plugins->registerEvent('mail_domain_insert',$this->plugin_name,'domain_insert');
5555
//$app->plugins->registerEvent('mail_domain_update',$this->plugin_name,'domain_update');
56-
//$app->plugins->registerEvent('mail_domain_delete',$this->plugin_name,'domain_delete');
56+
$app->plugins->registerEvent('mail_domain_delete',$this->plugin_name,'domain_delete');
5757

5858
}
5959

@@ -125,6 +125,22 @@ function user_delete($event_name,$data) {
125125
}
126126
}
127127

128+
function domain_delete($event_name,$data) {
129+
global $app, $conf;
130+
131+
// get the config
132+
$app->uses("getconf");
133+
$mail_config = $app->getconf->get_server_config($conf["server_id"], 'mail');
134+
135+
$old_maildomain_path = escapeshellcmd($mail_config['homedir_path'].'/'.$data['old']['domain']);
136+
if(!stristr($old_maildomain_path,'..') && !stristr($old_maildomain_path,'*') && strlen($old_maildomain_path) >= 10) {
137+
exec('rm -rf '.escapeshellcmd($old_maildomain_path));
138+
$app->log('Deleted the mail domain directory: '.$old_maildomain_path,LOGLEVEL_DEBUG);
139+
} else {
140+
$app->log('Possible security violation when deleting the mail domain directory: '.$old_maildomain_path,LOGLEVEL_ERROR);
141+
}
142+
}
143+
128144

129145

130146

0 commit comments

Comments
 (0)