Skip to content

Commit 2ebadd7

Browse files
author
jwarnier
committed
improve maildirmake and remove yet other execs
1 parent ea4f7ad commit 2ebadd7

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

server/lib/classes/system.inc.php

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,18 +1188,31 @@ function maildirmake($maildir_path, $user = '', $subfolder = '') {
11881188

11891189
if($subfolder != '') {
11901190
$dir = escapeshellarg($maildir_path.'/.'.$subfolder);
1191-
$dir_cur = escapeshellarg($maildir_path.'/.'.$subfolder.'/cur');
1192-
$dir_new = escapeshellarg($maildir_path.'/.'.$subfolder.'/new');
1193-
$dir_tmp = escapeshellarg($maildir_path.'/.'.$subfolder.'/tmp');
11941191
} else {
11951192
$dir = escapeshellarg($maildir_path);
1196-
$dir_cur = escapeshellarg($maildir_path.'/cur');
1197-
$dir_new = escapeshellarg($maildir_path.'/new');
1198-
$dir_tmp = escapeshellarg($maildir_path.'/tmp');
1193+
}
1194+
1195+
if($user != '' && $user != 'root' && $this->is_user($user)) {
1196+
$user = escapeshellarg($user);
1197+
// I assume that the name of the (vmail group) is the same as the name of the mail user in ISPConfig 3
1198+
$group = $user;
1199+
chown($dir,$user);
1200+
chgrp($dir,$group);
1201+
1202+
$chown_mdsub = true;
11991203
}
12001204

1201-
exec("mkdir -p $dir_cur $dir_new $dir_tmp");
1202-
exec("chmod 0700 $dir $dir_cur $dir_new $dir_tmp");
1205+
$maildirsubs = array('cur','new','tmp');
1206+
1207+
foreach ($maildirsubs as $mdsub) {
1208+
mkdir($dir.'/'.$mdsub, 0700, true);
1209+
if ($chown_mdsub) {
1210+
chown($dir.'/'.$mdsub, $user);
1211+
chgrp($dir.'/'.$mdsub, $group);
1212+
}
1213+
}
1214+
1215+
chmod($dir, 0700);
12031216

12041217
if($user != '' && $this->is_user($user) && $user != 'root') {
12051218
$user = escapeshellarg($user);

0 commit comments

Comments
 (0)