From 3f9adb57db2c47ef19297279475a9b9f01e37fbd Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 26 Mar 2024 14:24:10 +0100 Subject: [PATCH] Fixing lib/pp_admintools/handler/pflogparse.py. --- lib/pp_admintools/handler/pflogparse.py | 5 ++--- test/test_25_postfix_logparser.py | 9 ++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/pp_admintools/handler/pflogparse.py b/lib/pp_admintools/handler/pflogparse.py index aa03a88..6206b9a 100644 --- a/lib/pp_admintools/handler/pflogparse.py +++ b/lib/pp_admintools/handler/pflogparse.py @@ -27,7 +27,7 @@ LOG = logging.getLogger(__name__) _ = XLATOR.gettext ngettext = XLATOR.ngettext -__version__ = '0.3.0' +__version__ = '0.3.1' # ============================================================================= @@ -131,7 +131,6 @@ class PostfixLogfileParser(HandlingObject): if command == 'postfix/smtpd' and pid: self.eval_smtpd_line(entry) - return if postfix_id: if command == 'postfix/smtpd' and pid: @@ -148,7 +147,7 @@ class PostfixLogfileParser(HandlingObject): m = self.re_from_addr.match(message) if m and postfix_id in self.chain and self.chain[postfix_id]: - self.logchain[postfix_id].from_address = m[1] + self.chain[postfix_id].from_address = m[1] # ------------------------------------------------------------------------- def eval_smtpd_line(self, entry): diff --git a/test/test_25_postfix_logparser.py b/test/test_25_postfix_logparser.py index 27fbc73..2f3dafd 100755 --- a/test/test_25_postfix_logparser.py +++ b/test/test_25_postfix_logparser.py @@ -92,7 +92,14 @@ class TestPostfixLogparser(PpAdminToolsTestcase): LOG.debug('PostfixLogfileParser %r: {!r}'.format(parser)) - with self.logfile.open('rt') as fh: + maillog = self.logfile + if 'MAILLOG' in os.environ: + env_maillog = Path(os.environ['MAILLOG']) + if env_maillog.exists() and env_maillog.is_file() and os.access(env_maillog, os.R_OK): + maillog = env_maillog + + LOG.debug('Parsing maillog {!r} ...'.format(str(maillog))) + with maillog.open('rt') as fh: parser.parse(fh) LOG.debug('PostfixLogfileParser %s:\n{}'.format(parser)) -- 2.39.5