From e3c94f19dcc2fa9efff15b6e2669da6abbcf7a89 Mon Sep 17 00:00:00 2001 From: William Brown Date: Wed, 1 Jun 2016 12:53:12 +1000 Subject: [PATCH] Ticket 48434 - Fix for negative tz offsets Bug Description: In my infinite experience I only tested a positive timezone (AEST +10). When run in a location with a negative offset (IE -4), this would cause the log parser to crash. Fix Description: Fix the regex to accept a positive, negative tz https://fedorahosted.org/389/ticket/48434 Author: wibrown Review by: ??? --- lib389/dirsrv_log.py | 2 +- lib389/tests/dirsrv_log_test.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib389/dirsrv_log.py b/lib389/dirsrv_log.py index 83e6bc0..1032e4e 100644 --- a/lib389/dirsrv_log.py +++ b/lib389/dirsrv_log.py @@ -39,7 +39,7 @@ class DirsrvLog(object): def __init__(self, dirsrv): self.dirsrv = dirsrv self.log = self.dirsrv.log - self.prog_timestamp = re.compile('\[(?P\d*)\/(?P\w*)\/(?P\d*):(?P\d*):(?P\d*):(?P\d*)(.(?P\d*))+\s(?P\+\d*)') + self.prog_timestamp = re.compile('\[(?P\d*)\/(?P\w*)\/(?P\d*):(?P\d*):(?P\d*):(?P\d*)(.(?P\d*))+\s(?P[\+\-]\d*)') def _get_log_attr(self, attr): return self.dirsrv.getEntry(DN_CONFIG).__getattr__(attr) diff --git a/lib389/tests/dirsrv_log_test.py b/lib389/tests/dirsrv_log_test.py index dcb28f9..00c76c0 100644 --- a/lib389/tests/dirsrv_log_test.py +++ b/lib389/tests/dirsrv_log_test.py @@ -80,6 +80,10 @@ def test_access_log(topology): topology.standalone.ds_access_log.parse_line('[27/Apr/2016:12:49:49.736297002 +1000] conn=1 op=4 fd=64 closed - U1') == {'status': 'U1', 'fd': '64', 'action': 'DISCONNECT', 'timestamp': '[27/Apr/2016:12:49:49.736297002 +1000]', 'conn': '1', 'op': '4', 'datetime': datetime.datetime(2016, 4, 27, 12, 0, 0, 736297, tzinfo=tzoffset(None, 36000))} ) + assert( + topology.standalone.ds_access_log.parse_line('[27/Apr/2016:12:49:49.736297002 -1000] conn=1 op=4 fd=64 closed - U1') == + {'status': 'U1', 'fd': '64', 'action': 'DISCONNECT', 'timestamp': '[27/Apr/2016:12:49:49.736297002 -1000]', 'conn': '1', 'op': '4', 'datetime': datetime.datetime(2016, 4, 27, 12, 0, 0, 736297, tzinfo=tzoffset(None, -36000))} + ) def test_error_log(topology): """Check the parsing of the error log""" -- 2.5.5