From 728774e216b4b549c2c0e0275197a0c5979f4004 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Mon, 30 Jan 2023 19:51:47 +0000 Subject: [PATCH] Allow setting Postfix transport_file_type: regex without setting something for postmap_command:. Fixes #1058 * Allow setting Postfix transport_file_type: regex without setting something for postmap_command:. --- src/mailman/docs/NEWS.rst | 2 ++ src/mailman/mta/postfix.py | 3 ++- src/mailman/mta/tests/data/postfix.cfg | 2 ++ src/mailman/mta/tests/test_postfix.py | 37 ++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/mailman/mta/tests/data/postfix.cfg create mode 100644 src/mailman/mta/tests/test_postfix.py diff --git a/src/mailman/docs/NEWS.rst b/src/mailman/docs/NEWS.rst index ac218c093..ebad13ec3 100644 --- a/src/mailman/docs/NEWS.rst +++ b/src/mailman/docs/NEWS.rst @@ -26,6 +26,8 @@ Bugs fixed (Closes #1053) * The master process now robustly detects when runner processes terminate and restarts them (Closes #898). +* Setting Postfix transport_file_type: regex without setting something for + postmap_command: no longer throws an exception. (Closes #1058) .. _news-3.3.8: diff --git a/src/mailman/mta/postfix.py b/src/mailman/mta/postfix.py index 6e400451c..fc4df5f55 100644 --- a/src/mailman/mta/postfix.py +++ b/src/mailman/mta/postfix.py @@ -84,9 +84,10 @@ class LMTP: def __init__(self): # Locate and read the Postfix specific configuration file. mta_config = external_configuration(config.mta.configuration) - self.postmap_command = mta_config.get('postfix', 'postmap_command') self.transport_file_type = mta_config.get( 'postfix', 'transport_file_type') + if self.transport_file_type == 'hash': + self.postmap_command = mta_config.get('postfix', 'postmap_command') def create(self, mlist): """See `IMailTransportAgentLifecycle`.""" diff --git a/src/mailman/mta/tests/data/postfix.cfg b/src/mailman/mta/tests/data/postfix.cfg new file mode 100644 index 000000000..35f8e24e0 --- /dev/null +++ b/src/mailman/mta/tests/data/postfix.cfg @@ -0,0 +1,2 @@ +[postfix] +transport_file_type: regex diff --git a/src/mailman/mta/tests/test_postfix.py b/src/mailman/mta/tests/test_postfix.py new file mode 100644 index 000000000..2ea72ce7e --- /dev/null +++ b/src/mailman/mta/tests/test_postfix.py @@ -0,0 +1,37 @@ +# Copyright (C) 2014-2023 by the Free Software Foundation, Inc. +# +# This file is part of GNU Mailman. +# +# GNU Mailman is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) +# any later version. +# +# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along with +# GNU Mailman. If not, see . + +"""Test Postfix config.""" + +import unittest + +from mailman.config import config +from mailman.mta.postfix import LMTP +from mailman.testing.layers import ConfigLayer + + +class TestPostfixConfig(unittest.TestCase): + layer = ConfigLayer + + def test_regex_config(self): + config.push('regex_config', """\ +[mta] +configuration: python:mailman.mta.tests.data.postfix +""") + lmtp = LMTP() + self.assertEqual('regex', lmtp.transport_file_type) + config.pop('regex_config') -- 2.11.4.GIT