Commit e7137c1e authored by Ad Schellevis's avatar Ad Schellevis

dhcpd.leases using wrong timezone, closes https://github.com/opnsense/core/issues/1521

parent 184c79b1
...@@ -24,16 +24,16 @@ ...@@ -24,16 +24,16 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
""" """
import os import os
import time import calendar
import datetime import datetime
class DHCPDLease(object): class DHCPDLease(object):
watch_file = '/var/dhcpd/var/db/dhcpd.leases' def __init__(self, watch_file='/var/dhcpd/var/db/dhcpd.leases'):
def __init__(self):
""" init watcher """ init watcher
:param watch_file: filename to watch
:return: watcher object :return: watcher object
""" """
self.watch_file = watch_file
self._section_data = [] self._section_data = []
self._fhandle = None self._fhandle = None
self._last_pos = None self._last_pos = None
...@@ -67,7 +67,7 @@ class DHCPDLease(object): ...@@ -67,7 +67,7 @@ class DHCPDLease(object):
if field_name in ('starts', 'ends', 'tstp', 'tsfp', 'atsfp', 'cltt') and len(parts) >= 3: if field_name in ('starts', 'ends', 'tstp', 'tsfp', 'atsfp', 'cltt') and len(parts) >= 3:
dt = '%s %s'%(parts[2], parts[3]) dt = '%s %s'%(parts[2], parts[3])
try: try:
field_value = time.mktime(datetime.datetime.strptime(dt, "%Y/%m/%d %H:%M:%S;").timetuple()) field_value = calendar.timegm(datetime.datetime.strptime(dt, "%Y/%m/%d %H:%M:%S;").timetuple())
except ValueError: except ValueError:
field_value = None field_value = None
elif field_name == 'hardware' and len(parts) >= 3: elif field_name == 'hardware' and len(parts) >= 3:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment