From 4def6c2214a260f06ef50e45721f2bd89a768f5b Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 19 Dec 2017 07:11:05 +0100 Subject: [PATCH] mail/postfix: merge version 0.3 from master --- mail/postfix/Makefile | 2 +- .../Postfix/Api/RecipientController.php | 205 ++++++++++++++++++ .../OPNsense/Postfix/Api/SenderController.php | 205 ++++++++++++++++++ .../Postfix/Api/ServiceController.php | 7 +- .../OPNsense/Postfix/DomainController.php | 46 ++-- .../OPNsense/Postfix/GeneralController.php | 50 ++--- .../OPNsense/Postfix/RecipientController.php | 33 +++ .../OPNsense/Postfix/SenderController.php | 33 +++ .../forms/dialogEditPostfixRecipient.xml | 20 ++ .../Postfix/forms/dialogEditPostfixSender.xml | 20 ++ .../app/models/OPNsense/Postfix/General.xml | 4 - .../app/models/OPNsense/Postfix/Menu/Menu.xml | 2 + .../app/models/OPNsense/Postfix/Recipient.php | 30 +++ .../app/models/OPNsense/Postfix/Recipient.xml | 25 +++ .../app/models/OPNsense/Postfix/Sender.php | 30 +++ .../app/models/OPNsense/Postfix/Sender.xml | 25 +++ .../app/views/OPNsense/Postfix/general.volt | 18 +- .../app/views/OPNsense/Postfix/recipient.volt | 110 ++++++++++ .../app/views/OPNsense/Postfix/sender.volt | 110 ++++++++++ .../templates/OPNsense/Postfix/main.cf | 4 +- .../OPNsense/Postfix/recipient_access | 7 +- .../templates/OPNsense/Postfix/sender_access | 7 +- 22 files changed, 928 insertions(+), 65 deletions(-) create mode 100644 mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/RecipientController.php create mode 100644 mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/SenderController.php create mode 100644 mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/RecipientController.php create mode 100644 mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/SenderController.php create mode 100644 mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixRecipient.xml create mode 100644 mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixSender.xml create mode 100644 mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Recipient.php create mode 100644 mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Recipient.xml create mode 100644 mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sender.php create mode 100644 mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sender.xml create mode 100644 mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/recipient.volt create mode 100644 mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/sender.volt diff --git a/mail/postfix/Makefile b/mail/postfix/Makefile index 47d3ecec4..34ae93dc2 100644 --- a/mail/postfix/Makefile +++ b/mail/postfix/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= postfix -PLUGIN_VERSION= 0.2 +PLUGIN_VERSION= 0.3 PLUGIN_COMMENT= SMTP mail relay PLUGIN_DEPENDS= postfix-sasl PLUGIN_MAINTAINER= m.muenz@gmail.com diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/RecipientController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/RecipientController.php new file mode 100644 index 000000000..a37ae7ba1 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/RecipientController.php @@ -0,0 +1,205 @@ +request->isGet()) { + $mdlRecipient = new Recipient(); + $result['recipient'] = $mdlRecipient->getNodes(); + } + return $result; + } + + public function setAction() + { + $result = array("result"=>"failed"); + if ($this->request->isPost()) { + // load model and update with provided data + $mdlRecipient = new Recipient(); + $mdlRecipient->setNodes($this->request->getPost("recipient")); + // perform validation + $valMsgs = $mdlRecipient->performValidation(); + foreach ($valMsgs as $field => $msg) { + if (!array_key_exists("validations", $result)) { + $result["validations"] = array(); + } + $result["validations"]["recipient.".$msg->getField()] = $msg->getMessage(); + } + // serialize model to config and save + if ($valMsgs->count() == 0) { + $mdlRecipient->serializeToConfig(); + Config::getInstance()->save(); + $result["result"] = "saved"; + } + } + return $result; + } + + public function searchRecipientAction() + { + $this->sessionClose(); + $mdlRecipient = $this->getModel(); + $grid = new UIModelGrid($mdlRecipient->recipients->recipient); + return $grid->fetchBindRequest( + $this->request, + array("enabled", "address", "action" ) + ); + } + + public function getRecipientAction($uuid = null) + { + $mdlRecipient = $this->getModel(); + if ($uuid != null) { + $node = $mdlRecipient->getNodeByReference('recipients.recipient.' . $uuid); + if ($node != null) { + // return node + return array("recipient" => $node->getNodes()); + } + } else { + $node = $mdlRecipient->recipients->recipient->add(); + return array("recipient" => $node->getNodes()); + } + return array(); + } + + public function addRecipientAction() + { + $result = array("result" => "failed"); + if ($this->request->isPost() && $this->request->hasPost("recipient")) { + $result = array("result" => "failed", "validations" => array()); + $mdlRecipient = $this->getModel(); + $node = $mdlRecipient->recipients->recipient->Add(); + $node->setNodes($this->request->getPost("recipient")); + $valMsgs = $mdlRecipient->performValidation(); + foreach ($valMsgs as $field => $msg) { + $fieldnm = str_replace($node->__reference, "recipient", $msg->getField()); + $result["validations"][$fieldnm] = $msg->getMessage(); + } + if (count($result['validations']) == 0) { + unset($result['validations']); + // save config if validated correctly + $mdlRecipient->serializeToConfig(); + Config::getInstance()->save(); + unset($result['validations']); + $result["result"] = "saved"; + } + } + return $result; + } + + public function delRecipientAction($uuid) + { + $result = array("result" => "failed"); + if ($this->request->isPost()) { + $mdlRecipient = $this->getModel(); + if ($uuid != null) { + if ($mdlRecipient->recipients->recipient->del($uuid)) { + $mdlRecipient->serializeToConfig(); + Config::getInstance()->save(); + $result['result'] = 'deleted'; + } else { + $result['result'] = 'not found'; + } + } + } + return $result; + } + + public function setRecipientAction($uuid) + { + if ($this->request->isPost() && $this->request->hasPost("recipient")) { + $mdlSetting = $this->getModel(); + if ($uuid != null) { + $node = $mdlSetting->getNodeByReference('recipients.recipient.' . $uuid); + if ($node != null) { + $result = array("result" => "failed", "validations" => array()); + $recipientInfo = $this->request->getPost("recipient"); + $node->setNodes($recipientInfo); + $valMsgs = $mdlSetting->performValidation(); + foreach ($valMsgs as $field => $msg) { + $fieldnm = str_replace($node->__reference, "recipient", $msg->getField()); + $result["validations"][$fieldnm] = $msg->getMessage(); + } + if (count($result['validations']) == 0) { + // save config if validated correctly + $mdlSetting->serializeToConfig(); + Config::getInstance()->save(); + $result = array("result" => "saved"); + } + return $result; + } + } + } + return array("result" => "failed"); + } + + public function toggle_handler($uuid, $elements, $element) + { + $result = array("result" => "failed"); + if ($this->request->isPost()) { + $mdlSetting = $this->getModel(); + if ($uuid != null) { + $node = $mdlSetting->getNodeByReference($elements . '.'. $element .'.' . $uuid); + if ($node != null) { + if ($node->enabled->__toString() == "1") { + $result['result'] = "Disabled"; + $node->enabled = "0"; + } else { + $result['result'] = "Enabled"; + $node->enabled = "1"; + } + // if item has toggled, serialize to config and save + $mdlSetting->serializeToConfig(); + Config::getInstance()->save(); + } + } + } + return $result; + } + + public function toggleRecipientAction($uuid) + { + return $this->toggle_handler($uuid, 'recipients', 'recipient'); + } +} diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/SenderController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/SenderController.php new file mode 100644 index 000000000..0dded2fed --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/SenderController.php @@ -0,0 +1,205 @@ +request->isGet()) { + $mdlSender = new Sender(); + $result['sender'] = $mdlSender->getNodes(); + } + return $result; + } + + public function setAction() + { + $result = array("result"=>"failed"); + if ($this->request->isPost()) { + // load model and update with provided data + $mdlSender = new Sender(); + $mdlSender->setNodes($this->request->getPost("sender")); + // perform validation + $valMsgs = $mdlSender->performValidation(); + foreach ($valMsgs as $field => $msg) { + if (!array_key_exists("validations", $result)) { + $result["validations"] = array(); + } + $result["validations"]["sender.".$msg->getField()] = $msg->getMessage(); + } + // serialize model to config and save + if ($valMsgs->count() == 0) { + $mdlSender->serializeToConfig(); + Config::getInstance()->save(); + $result["result"] = "saved"; + } + } + return $result; + } + + public function searchSenderAction() + { + $this->sessionClose(); + $mdlSender = $this->getModel(); + $grid = new UIModelGrid($mdlSender->senders->sender); + return $grid->fetchBindRequest( + $this->request, + array("enabled", "address", "action" ) + ); + } + + public function getSenderAction($uuid = null) + { + $mdlSender = $this->getModel(); + if ($uuid != null) { + $node = $mdlSender->getNodeByReference('senders.sender.' . $uuid); + if ($node != null) { + // return node + return array("sender" => $node->getNodes()); + } + } else { + $node = $mdlSender->senders->sender->add(); + return array("sender" => $node->getNodes()); + } + return array(); + } + + public function addSenderAction() + { + $result = array("result" => "failed"); + if ($this->request->isPost() && $this->request->hasPost("sender")) { + $result = array("result" => "failed", "validations" => array()); + $mdlSender = $this->getModel(); + $node = $mdlSender->senders->sender->Add(); + $node->setNodes($this->request->getPost("sender")); + $valMsgs = $mdlSender->performValidation(); + foreach ($valMsgs as $field => $msg) { + $fieldnm = str_replace($node->__reference, "sender", $msg->getField()); + $result["validations"][$fieldnm] = $msg->getMessage(); + } + if (count($result['validations']) == 0) { + unset($result['validations']); + // save config if validated correctly + $mdlSender->serializeToConfig(); + Config::getInstance()->save(); + unset($result['validations']); + $result["result"] = "saved"; + } + } + return $result; + } + + public function delSenderAction($uuid) + { + $result = array("result" => "failed"); + if ($this->request->isPost()) { + $mdlSender = $this->getModel(); + if ($uuid != null) { + if ($mdlSender->senders->sender->del($uuid)) { + $mdlSender->serializeToConfig(); + Config::getInstance()->save(); + $result['result'] = 'deleted'; + } else { + $result['result'] = 'not found'; + } + } + } + return $result; + } + + public function setSenderAction($uuid) + { + if ($this->request->isPost() && $this->request->hasPost("sender")) { + $mdlSetting = $this->getModel(); + if ($uuid != null) { + $node = $mdlSetting->getNodeByReference('senders.sender.' . $uuid); + if ($node != null) { + $result = array("result" => "failed", "validations" => array()); + $senderInfo = $this->request->getPost("sender"); + $node->setNodes($senderInfo); + $valMsgs = $mdlSetting->performValidation(); + foreach ($valMsgs as $field => $msg) { + $fieldnm = str_replace($node->__reference, "sender", $msg->getField()); + $result["validations"][$fieldnm] = $msg->getMessage(); + } + if (count($result['validations']) == 0) { + // save config if validated correctly + $mdlSetting->serializeToConfig(); + Config::getInstance()->save(); + $result = array("result" => "saved"); + } + return $result; + } + } + } + return array("result" => "failed"); + } + + public function toggle_handler($uuid, $elements, $element) + { + $result = array("result" => "failed"); + if ($this->request->isPost()) { + $mdlSetting = $this->getModel(); + if ($uuid != null) { + $node = $mdlSetting->getNodeByReference($elements . '.'. $element .'.' . $uuid); + if ($node != null) { + if ($node->enabled->__toString() == "1") { + $result['result'] = "Disabled"; + $node->enabled = "0"; + } else { + $result['result'] = "Enabled"; + $node->enabled = "1"; + } + // if item has toggled, serialize to config and save + $mdlSetting->serializeToConfig(); + Config::getInstance()->save(); + } + } + } + return $result; + } + + public function toggleSenderAction($uuid) + { + return $this->toggle_handler($uuid, 'senders', 'sender'); + } +} diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/ServiceController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/ServiceController.php index 269363bfe..7d21f736f 100644 --- a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/ServiceController.php +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/ServiceController.php @@ -58,6 +58,8 @@ class ServiceController extends ApiControllerBase public function startAction() { if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); $backend = new Backend(); $response = $backend->configdRun('postfix start'); return array("response" => $response); @@ -73,6 +75,8 @@ class ServiceController extends ApiControllerBase public function stopAction() { if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); $backend = new Backend(); $response = $backend->configdRun("postfix stop"); return array("response" => $response); @@ -88,6 +92,8 @@ class ServiceController extends ApiControllerBase public function restartAction() { if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); $backend = new Backend(); $response = $backend->configdRun("postfix restart"); return array("response" => $response); @@ -121,7 +127,6 @@ class ServiceController extends ApiControllerBase $status = "unkown"; } - return array("status" => $status); } diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/DomainController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/DomainController.php index 1f4e7b844..c9ed560c0 100644 --- a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/DomainController.php +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/DomainController.php @@ -1,25 +1,30 @@ view->title = gettext("Postfix Domains"); $this->view->formDialogEditPostfixDomain = $this->getForm("dialogEditPostfixDomain"); $this->view->pick('OPNsense/Postfix/domain'); } diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/GeneralController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/GeneralController.php index 3714878b5..4a10f2c9e 100644 --- a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/GeneralController.php +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/GeneralController.php @@ -1,29 +1,30 @@ view->title = gettext("Postfix Settings"); $this->view->generalForm = $this->getForm("general"); $this->view->antispamForm = $this->getForm("antispam"); $this->view->pick('OPNsense/Postfix/general'); diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/RecipientController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/RecipientController.php new file mode 100644 index 000000000..bab463df0 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/RecipientController.php @@ -0,0 +1,33 @@ +view->formDialogEditPostfixRecipient = $this->getForm("dialogEditPostfixRecipient"); + $this->view->pick('OPNsense/Postfix/recipient'); + } +} diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/SenderController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/SenderController.php new file mode 100644 index 000000000..2fc655918 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/SenderController.php @@ -0,0 +1,33 @@ +view->formDialogEditPostfixSender = $this->getForm("dialogEditPostfixSender"); + $this->view->pick('OPNsense/Postfix/sender'); + } +} diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixRecipient.xml b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixRecipient.xml new file mode 100644 index 000000000..16dc8217b --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixRecipient.xml @@ -0,0 +1,20 @@ +
+ + recipient.enabled + + checkbox + This will enable or disable the recipient rule in this entry. + + + recipient.address + + text + Set the recipient address to match. + + + recipient.action + + dropdown + Set the action for this address. + +
diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixSender.xml b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixSender.xml new file mode 100644 index 000000000..0010f891f --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixSender.xml @@ -0,0 +1,20 @@ +
+ + sender.enabled + + checkbox + This will enable or disable the sender address to match for. + + + sender.address + + text + Set the sender address to match. + + + sender.action + + dropdown + Set the action for this address. + +
diff --git a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/General.xml b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/General.xml index 208abb098..865f8bf8e 100644 --- a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/General.xml +++ b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/General.xml @@ -60,14 +60,10 @@ encrypt - - 1 Y - - 1 Y diff --git a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Menu/Menu.xml b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Menu/Menu.xml index 6c9e95893..df2be2899 100644 --- a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Menu/Menu.xml +++ b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Menu/Menu.xml @@ -3,6 +3,8 @@ + + diff --git a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Recipient.php b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Recipient.php new file mode 100644 index 000000000..14b0017a1 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Recipient.php @@ -0,0 +1,30 @@ + + //OPNsense/postfix/recipient + Postfix recipient configuration + 1.0.0 + + + + + 1 + Y + +
+ Y +
+ + Y + + OK + REJECT + + +
+
+
+ diff --git a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sender.php b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sender.php new file mode 100644 index 000000000..145acfa96 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sender.php @@ -0,0 +1,30 @@ + + //OPNsense/postfix/sender + Postfix sender configuration + 1.0.0 + + + + + 1 + Y + +
+ Y +
+ + Y + + OK + REJECT + + +
+
+
+ diff --git a/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/general.volt b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/general.volt index 47f62653e..ece16ffdb 100644 --- a/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/general.volt +++ b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/general.volt @@ -34,21 +34,21 @@ POSSIBILITY OF SUCH DAMAGE.
{{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}} -
- +
+
-
@@ -68,7 +68,7 @@ POSSIBILITY OF SUCH DAMAGE. // check if Rspamd plugin is installed ajaxCall(url="/api/postfix/service/checkrspamd", sendData={}, callback=function(data,status) { - if (data == "0") { + if (data == "0") { $('#missing_rspamd').show(); } }); @@ -76,7 +76,7 @@ POSSIBILITY OF SUCH DAMAGE. // link save button to API set action $("#saveAct").click(function () { saveFormToEndpoint(url="/api/postfix/general/set", formid='frm_general_settings',callback_ok=function () { - $("#saveAct_progress").addClass("fa fa-spinner fa-pulse"); + $("#saveAct_progress").addClass("fa fa-spinner fa-pulse"); ajaxCall(url="/api/postfix/service/reconfigure", sendData={}, callback=function (data,status) { ajaxCall(url="/api/postfix/service/status", sendData={}, callback=function (data,status) { updateServiceStatusUI(data['status']); @@ -87,12 +87,12 @@ POSSIBILITY OF SUCH DAMAGE. }); $("#saveAct2").click(function(){ saveFormToEndpoint(url="/api/postfix/antispam/set", formid='frm_antispam_settings',callback_ok=function(){ - $("#saveAct2_progress").addClass("fa fa-spinner fa-pulse"); + $("#saveAct2_progress").addClass("fa fa-spinner fa-pulse"); ajaxCall(url="/api/postfix/service/reconfigure", sendData={}, callback=function(data,status) { ajaxCall(url="/api/postfix/service/status", sendData={}, callback=function(data,status) { updateServiceStatusUI(data['status']); }); - $("#saveAct2_progress").removeClass("fa fa-spinner fa-pulse"); + $("#saveAct2_progress").removeClass("fa fa-spinner fa-pulse"); }); }); }); diff --git a/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/recipient.volt b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/recipient.volt new file mode 100644 index 000000000..a96dcfd12 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/recipient.volt @@ -0,0 +1,110 @@ +{# + +OPNsense® is Copyright © 2014 – 2017 by Deciso B.V. +Copyright (C) 2017 Michael Muenz +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +#} + + + +
+
+ + + + + + + + + + + + + + + + + + +
{{ lang._('Enabled') }}{{ lang._('Address') }}{{ lang._('Action') }}{{ lang._('ID') }}{{ lang._('Commands') }}
+ + +
+
+
+
+ +

+
+
+ +{{ partial("layout_partials/base_dialog",['fields':formDialogEditPostfixRecipient,'id':'dialogEditPostfixRecipient','label':lang._('Edit Recipient')])}} diff --git a/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/sender.volt b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/sender.volt new file mode 100644 index 000000000..5a1d736db --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/sender.volt @@ -0,0 +1,110 @@ +{# + +OPNsense® is Copyright © 2014 – 2017 by Deciso B.V. +Copyright (C) 2017 Michael Muenz +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +#} + + + +
+
+ + + + + + + + + + + + + + + + + + +
{{ lang._('Enabled') }}{{ lang._('Address') }}{{ lang._('Action') }}{{ lang._('ID') }}{{ lang._('Commands') }}
+ + +
+
+
+
+ +

+
+
+ +{{ partial("layout_partials/base_dialog",['fields':formDialogEditPostfixSender,'id':'dialogEditPostfixSender','label':lang._('Edit Sender')])}} diff --git a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/main.cf b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/main.cf index e9596102d..e57c9cf6e 100644 --- a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/main.cf +++ b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/main.cf @@ -98,13 +98,13 @@ milter_default_action = accept {# Sender Restrictions #} {% set smtpd_recipient_restrictions=[] %} -{% if helpers.exists('OPNsense.postfix.general.check_recipient_access') %} +{% if helpers.exists('OPNsense.postfix.recipient.recipients.recipient') %} {% do smtpd_recipient_restrictions.append('check_recipient_access hash:/usr/local/etc/postfix/recipient_access') %} {% endif %} {% if helpers.exists('OPNsense.postfix.general.reject_unauth_pipelining') and OPNsense.postfix.general.reject_unauth_pipelining == '1' %} {% do smtpd_recipient_restrictions.append('reject_unauth_pipelining') %} {% endif %} -{% if helpers.exists('OPNsense.postfix.general.check_sender_access') %} +{% if helpers.exists('OPNsense.postfix.sender.senders.sender') %} {% do smtpd_recipient_restrictions.append('check_sender_access hash:/usr/local/etc/postfix/sender_access') %} {% endif %} {% if helpers.exists('OPNsense.postfix.general.reject_unknown_sender_domain') and OPNsense.postfix.general.reject_unknown_sender_domain == '1' %} diff --git a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/recipient_access b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/recipient_access index c82b63b8b..1589198bd 100644 --- a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/recipient_access +++ b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/recipient_access @@ -1,4 +1,9 @@ {% if helpers.exists('OPNsense.postfix.general.enabled') and OPNsense.postfix.general.enabled == '1' %} -{% if helpers.exists('OPNsense.postfix.general.check_recipient_access') %} +{% if helpers.exists('OPNsense.postfix.recipient.recipients.recipient') %} +{% for recipient_list in helpers.toList('OPNsense.postfix.recipient.recipients.recipient') %} +{% if recipient_list.enabled == '1' %} +{{ recipient_list.address }} {{ recipient_list.action }} +{% endif %} +{% endfor %} {% endif %} {% endif %} diff --git a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/sender_access b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/sender_access index c82b63b8b..65d527315 100644 --- a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/sender_access +++ b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/sender_access @@ -1,4 +1,9 @@ {% if helpers.exists('OPNsense.postfix.general.enabled') and OPNsense.postfix.general.enabled == '1' %} -{% if helpers.exists('OPNsense.postfix.general.check_recipient_access') %} +{% if helpers.exists('OPNsense.postfix.sender.senders.sender') %} +{% for sender_list in helpers.toList('OPNsense.postfix.sender.senders.sender') %} +{% if sender_list.enabled == '1' %} +{{ sender_list.address }} {{ sender_list.action }} +{% endif %} +{% endfor %} {% endif %} {% endif %}