From 37b29231e47a0c4458dc1c15d98588f16f07e1e2 Mon Sep 17 00:00:00 2001 From: Marius Cramer <m.cramer@pixcept.de> Date: Thu, 06 Aug 2015 03:18:44 -0400 Subject: [PATCH] - don't set password via remoting if field is empty --- server/plugins-available/maildeliver_plugin.inc.php | 40 ++++++++++++++++++++++++++++++++++------ 1 files changed, 34 insertions(+), 6 deletions(-) diff --git a/server/plugins-available/maildeliver_plugin.inc.php b/server/plugins-available/maildeliver_plugin.inc.php index 08a4998..a6f9ae5 100644 --- a/server/plugins-available/maildeliver_plugin.inc.php +++ b/server/plugins-available/maildeliver_plugin.inc.php @@ -98,8 +98,9 @@ $app->log("Mailfilter config has been changed", LOGLEVEL_DEBUG); $sieve_file = $data["new"]["maildir"].'/.sieve'; + $sieve_file_isp = $data["new"]["maildir"].'/sieve/ispconfig.sieve'; if(is_file($sieve_file)) unlink($sieve_file) or $app->log("Unable to delete file: $sieve_file", LOGLEVEL_WARN); - + if(is_file($sieve_file_isp)) unlink($sieve_file_isp) or $app->log("Unable to delete file: $sieve_file_isp", LOGLEVEL_WARN); $app->load('tpl'); //* Select sieve filter file for dovecot version @@ -120,9 +121,17 @@ $tpl->newTemplate($filter_file_template); // cc Field + $tmp_mails_arr = explode(',',$data["new"]["cc"]); + $tmp_addresses_arr = array(); + foreach($tmp_mails_arr as $address) { + if(trim($address) != '') $tmp_addresses_arr[] = array('address' => trim($address)); + } + $tpl->setVar('cc', $data["new"]["cc"]); + $tpl->setLoop('ccloop', $tmp_addresses_arr); // Custom filters + if($data["new"]["custom_mailfilter"] == 'NULL') $data["new"]["custom_mailfilter"] = ''; $tpl->setVar('custom_mailfilter', $data["new"]["custom_mailfilter"]); // Move junk @@ -156,8 +165,8 @@ $tpl->setVar('autoresponder_text', $data["new"]["autoresponder_text"]); //* Set alias addresses for autoresponder - $sql = "SELECT * FROM mail_forwarding WHERE type = 'alias' AND destination = '".$app->db->quote($data["new"]["email"])."'"; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_forwarding WHERE type = 'alias' AND destination = ?"; + $records = $app->db->queryAllRecords($sql, $data["new"]["email"]); $addresses = array(); $addresses[] = $data["new"]["email"]; @@ -172,8 +181,8 @@ $alias_addresses = array(); $email_parts = explode('@', $data["new"]["email"]); - $sql = "SELECT * FROM mail_forwarding WHERE type = 'aliasdomain' AND destination = '@".$app->db->quote($email_parts[1])."'"; - $records = $app->db->queryAllRecords($sql); + $sql = "SELECT * FROM mail_forwarding WHERE type = 'aliasdomain' AND destination = ?"; + $records = $app->db->queryAllRecords($sql, '@'.$email_parts[1]); if(is_array($records) && count($records) > 0) { $app->log("Found " . count($records) . " records (aliasdomains).", LOGLEVEL_DEBUG); foreach($records as $rec) { @@ -204,7 +213,24 @@ $tpl->setVar('addresses', $address_str); - file_put_contents($sieve_file, $tpl->grab()); + if ( ! is_dir($data["new"]["maildir"].'/sieve/') ) { + $app->system->mkdirpath($data["new"]["maildir"].'/sieve/', 0700, $mail_config['mailuser_name'], $mail_config['mailuser_group']); + } + + file_put_contents($sieve_file_isp, $tpl->grab()) or $app->log("Unable to write sieve filter file", LOGLEVEL_WARN); + if ( is_file($sieve_file_isp) ) { + $app->system->chown($sieve_file_isp,$mail_config['mailuser_name'],false); + $app->system->chgrp($sieve_file_isp,$mail_config['mailuser_group'],false); + } + chdir($data["new"]["maildir"]); + //* create symlink to activate sieve script + symlink("sieve/ispconfig.sieve", ".sieve") or $app->log("Unable to create symlink to active sieve filter", LOGLEVEL_WARN); + if (is_link(".sieve")) { + $app->system->chown(".sieve",$mail_config['mailuser_name'],true); + $app->system->chgrp(".sieve",$mail_config['mailuser_group'],true); + } + $app->system->chown($sieve_file,$mail_config['mailuser_name'],true); + $app->system->chgrp($sieve_file,$mail_config['mailuser_group'],true); unset($tpl); @@ -215,7 +241,9 @@ global $app, $conf; $sieve_file = $data["old"]["maildir"].'/.sieve'; + $sieve_file_isp = $data["old"]["maildir"].'/sieve/ispconfig.sieve'; if(is_file($sieve_file)) unlink($sieve_file) or $app->log("Unable to delete file: $sieve_file", LOGLEVEL_WARN); + if(is_file($sieve_file_isp)) unlink($sieve_file_isp) or $app->log("Unable to delete file: $sieve_file_isp", LOGLEVEL_WARN); } -- Gitblit v1.9.1