diff --git a/mail/postfix/Makefile b/mail/postfix/Makefile index e4555a3db..405e292de 100644 --- a/mail/postfix/Makefile +++ b/mail/postfix/Makefile @@ -1,5 +1,5 @@ PLUGIN_NAME= postfix -PLUGIN_VERSION= 1.9 +PLUGIN_VERSION= 1.10 PLUGIN_COMMENT= SMTP mail relay PLUGIN_DEPENDS= postfix-sasl PLUGIN_MAINTAINER= m.muenz@gmail.com diff --git a/mail/postfix/pkg-descr b/mail/postfix/pkg-descr index 6a6b26bc7..4055e04a8 100644 --- a/mail/postfix/pkg-descr +++ b/mail/postfix/pkg-descr @@ -6,6 +6,10 @@ is completely different. Plugin Changelog ================ +1.10 + +* Add support for configuring sender_canonical_maps + 1.9 * Allow HA config sync via XMLRPC diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/SendercanonicalController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/SendercanonicalController.php new file mode 100644 index 000000000..162a45b4d --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/Api/SendercanonicalController.php @@ -0,0 +1,68 @@ + + * Copyright (C) 2019 Felix Matouschek + * 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. + */ + +namespace OPNsense\Postfix\Api; + +use \OPNsense\Base\ApiMutableModelControllerBase; + +class SendercanonicalController extends ApiMutableModelControllerBase +{ + protected static $internalModelName = 'sendercanonical'; + protected static $internalModelClass = '\OPNsense\Postfix\Sendercanonical'; + + public function searchSendercanonicalAction() + { + return $this->searchBase('sendercanonicals.sendercanonical', array("enabled", "from", "to")); + } + + public function getSendercanonicalAction($uuid = null) + { + return $this->getBase('sendercanonical', 'sendercanonicals.sendercanonical', $uuid); + } + + public function addSendercanonicalAction() + { + return $this->addBase('sendercanonical', 'sendercanonicals.sendercanonical'); + } + + public function delSendercanonicalAction($uuid) + { + return $this->delBase('sendercanonicals.sendercanonical', $uuid); + } + + public function setSendercanonicalAction($uuid) + { + return $this->setBase('sendercanonical', 'sendercanonicals.sendercanonical', $uuid); + } + + public function toggleSendercanonicalAction($uuid) + { + return $this->toggleBase('sendercanonicals.sendercanonical', $uuid); + } +} diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/SendercanonicalController.php b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/SendercanonicalController.php new file mode 100644 index 000000000..f099793e4 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/SendercanonicalController.php @@ -0,0 +1,39 @@ + + * Copyright (C) 2019 Felix Matouschek + * 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. + */ + +namespace OPNsense\Postfix; + +class SendercanonicalController extends \OPNsense\Base\IndexController +{ + public function indexAction() + { + $this->view->formDialogEditPostfixSendercanonical = $this->getForm("dialogEditPostfixSendercanonical"); + $this->view->pick('OPNsense/Postfix/sendercanonical'); + } +} diff --git a/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixSendercanonical.xml b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixSendercanonical.xml new file mode 100644 index 000000000..2abb78c7e --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/controllers/OPNsense/Postfix/forms/dialogEditPostfixSendercanonical.xml @@ -0,0 +1,22 @@ +
+ + sendercanonical.enabled + + checkbox + This will enable or disable the sender canonical rewriting setting. + + + sendercanonical.from + + text + Set a pattern to match line user@example.com or @example.com + + + sendercanonical.to + + + select_multiple + true + Set here how to rewrite the Rewrite From pattern. + +
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 3bcf13364..8bd3a1067 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 @@ -7,6 +7,7 @@ +
diff --git a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sendercanonical.php b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sendercanonical.php new file mode 100644 index 000000000..563fd114a --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sendercanonical.php @@ -0,0 +1,31 @@ + + Copyright (C) 2019 Felix Matouschek + 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. +*/ + +class Sendercanonical extends BaseModel +{ +} diff --git a/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sendercanonical.xml b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sendercanonical.xml new file mode 100644 index 000000000..46b342438 --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/models/OPNsense/Postfix/Sendercanonical.xml @@ -0,0 +1,21 @@ + + //OPNsense/postfix/sendercanonical + Postfix sender_canonical rewrite configuration + 1.0.0 + + + + + 1 + Y + + + Y + + + Y + + + + + diff --git a/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/sendercanonical.volt b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/sendercanonical.volt new file mode 100644 index 000000000..5324769fb --- /dev/null +++ b/mail/postfix/src/opnsense/mvc/app/views/OPNsense/Postfix/sendercanonical.volt @@ -0,0 +1,87 @@ +{# + +OPNsense® is Copyright © 2014 – 2017 by Deciso B.V. +Copyright (C) 2018 Michael Muenz +Copyright (C) 2019 Felix Matouschek +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._('Rewrite From') }}{{ lang._('Rewrite To') }}{{ lang._('ID') }}{{ lang._('Commands') }}
+ + +
+
+
+ +

+
+
+
+ +{{ partial("layout_partials/base_dialog",['fields':formDialogEditPostfixSendercanonical,'id':'dialogEditPostfixSendercanonical','label':lang._('Edit sender_canonical rewriting')])}} diff --git a/mail/postfix/src/opnsense/scripts/OPNsense/Postfix/setup.sh b/mail/postfix/src/opnsense/scripts/OPNsense/Postfix/setup.sh index bd75813f3..3bafa9cc9 100755 --- a/mail/postfix/src/opnsense/scripts/OPNsense/Postfix/setup.sh +++ b/mail/postfix/src/opnsense/scripts/OPNsense/Postfix/setup.sh @@ -34,6 +34,7 @@ postmap /usr/local/etc/postfix/sender_access postmap /usr/local/etc/postfix/senderbcc postmap /usr/local/etc/postfix/recipientbcc postmap /usr/local/etc/postfix/smtp_auth +postmap /usr/local/etc/postfix/sendercanonical # Check for aliases if [ -f /usr/local/etc/postfix/aliases ]; then diff --git a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/+TARGETS b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/+TARGETS index dc76ac076..9d7dca3cd 100644 --- a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/+TARGETS +++ b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/+TARGETS @@ -8,3 +8,4 @@ sender_access:/usr/local/etc/postfix/sender_access senderbcc:/usr/local/etc/postfix/senderbcc recipientbcc:/usr/local/etc/postfix/recipientbcc smtp_auth:/usr/local/etc/postfix/smtp_auth +sendercanonical:/usr/local/etc/postfix/sendercanonical 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 120fb9e7e..a80bd07e9 100644 --- a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/main.cf +++ b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/main.cf @@ -34,6 +34,7 @@ transport_maps = hash:/usr/local/etc/postfix/transport virtual_alias_maps = hash:/usr/local/etc/postfix/virtual sender_bcc_maps = hash:/usr/local/etc/postfix/senderbcc recipient_bcc_maps = hash:/usr/local/etc/postfix/recipientbcc +sender_canonical_maps = regexp:/usr/local/etc/postfix/sendercanonical ########################## # END SYSTEM DEFAULTS ########################## diff --git a/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/sendercanonical b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/sendercanonical new file mode 100644 index 000000000..f3eea6ba6 --- /dev/null +++ b/mail/postfix/src/opnsense/service/templates/OPNsense/Postfix/sendercanonical @@ -0,0 +1,9 @@ +{% if helpers.exists('OPNsense.postfix.general.enabled') and OPNsense.postfix.general.enabled == '1' %} +{% if helpers.exists('OPNsense.postfix.sendercanonical.sendercanonicals.sendercanonical') %} +{% for sendercanonical in helpers.toList('OPNsense.postfix.sendercanonical.sendercanonicals.sendercanonical') %} +{% if sendercanonical.enabled == '1' %} +{{ sendercanonical.from }} {{ sendercanonical.to }} +{% endif %} +{% endfor %} +{% endif %} +{% endif %}