mirror of https://github.com/fail2ban/fail2ban
closes gh-2395: safe conversion of `SYSLOG_PID` or `_PID` (if journal entry contains a string instead of numeric)
parent
7a7a905ab2
commit
7a463eb3f7
|
@ -204,7 +204,14 @@ class FilterSystemd(JournalFilter): # pragma: systemd no cover
|
|||
if not v:
|
||||
v = logentry.get('_PID')
|
||||
if v:
|
||||
logelements[-1] += ("[%i]" % v)
|
||||
try: # [integer] (if already numeric):
|
||||
v = "[%i]" % v
|
||||
except TypeError:
|
||||
try: # as [integer] (try to convert to int):
|
||||
v = "[%i]" % int(v, 0)
|
||||
except (TypeError, ValueError): # fallback - [string] as it is
|
||||
v = "[%s]" % v
|
||||
logelements[-1] += v
|
||||
logelements[-1] += ":"
|
||||
if logelements[-1] == "kernel:":
|
||||
if '_SOURCE_MONOTONIC_TIMESTAMP' in logentry:
|
||||
|
|
Loading…
Reference in New Issue