@@ -216,18 +216,22 @@ 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+ $ app ->system ->chown ($ sieve_file_isp ,$ mail_config ['mailuser_name ' ],false );
223+ $ app ->system ->chgrp ($ sieve_file_isp ,$ mail_config ['mailuser_group ' ],false );
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 " )) {
228- lchown (".sieve " ,$ mail_config ['mailuser_name ' ]);
229- lchgrp (".sieve " ,$ mail_config ['mailuser_group ' ]);
229+ $ app -> system -> chown (".sieve " ,$ mail_config ['mailuser_name ' ], true );
230+ $ app -> system -> chgrp (".sieve " ,$ mail_config ['mailuser_group ' ], true );
230231 }
232+ $ app ->system ->chown ($ sieve_file ,$ mail_config ['mailuser_name ' ],true );
233+ $ app ->system ->chgrp ($ sieve_file ,$ mail_config ['mailuser_group ' ],true );
234+
231235 unset($ tpl );
232236
233237 }
0 commit comments