Skip to content

Commit 3062be9

Browse files
committed
- fix: point file_put_contents call to correct file
- upd: better error handling and logging
1 parent f3f4aa5 commit 3062be9

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

server/plugins-available/maildeliver_plugin.inc.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,18 +216,21 @@ function update($event_name, $data) {
216216
if ( ! is_dir($data["new"]["maildir"].'/sieve/') ) {
217217
$app->system->mkdirpath($data["new"]["maildir"].'/sieve/', 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']);
218218
}
219-
file_put_contents($sieve_file, $tpl->grab());
220-
exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($sieve_file));
221219

222-
chown($sieve_file_isp,$mail_config['mailuser_name']);
223-
chgrp($sieve_file_isp,$mail_config['mailuser_group']);
220+
file_put_contents($sieve_file_isp, $tpl->grab()) or $app->log("Unable to write sieve filter file", LOGLEVEL_WARN);
221+
if ( is_file($sieve_file_isp) ) {
222+
chown($sieve_file_isp,$mail_config['mailuser_name']);
223+
chgrp($sieve_file_isp,$mail_config['mailuser_group']);
224+
}
224225
chdir($data["new"]["maildir"]);
225226
//* create symlink to activate sieve script
226227
symlink("sieve/ispconfig.sieve", ".sieve") or $app->log("Unable to create symlink to active sieve filter", LOGLEVEL_WARN);
227228
if (is_link(".sieve")) {
228229
lchown(".sieve",$mail_config['mailuser_name']);
229230
lchgrp(".sieve",$mail_config['mailuser_group']);
230231
}
232+
exec('chown '.$mail_config['mailuser_name'].':'.$mail_config['mailuser_group'].' '.escapeshellcmd($sieve_file));
233+
231234
unset($tpl);
232235

233236
}

0 commit comments

Comments
 (0)