mirror of https://github.com/fail2ban/fail2ban
restrict saving of previous known values to section-related (don't overwrite with the values of other sections, especially like "INCLUDES", etc.)
parent
e20f6204d3
commit
462b534469
|
@ -20,8 +20,8 @@
|
|||
# Author: Yaroslav Halchenko
|
||||
# Modified: Cyril Jaquier
|
||||
|
||||
__author__ = 'Yaroslav Halhenko'
|
||||
__copyright__ = 'Copyright (c) 2007 Yaroslav Halchenko'
|
||||
__author__ = 'Yaroslav Halhenko, Serg G. Brester (aka sebres)'
|
||||
__copyright__ = 'Copyright (c) 2007 Yaroslav Halchenko, 2015 Serg G. Brester (aka sebres)'
|
||||
__license__ = 'GPL'
|
||||
|
||||
import os
|
||||
|
@ -150,7 +150,7 @@ after = 1.conf
|
|||
if seclwr == 'known':
|
||||
# try get raw value from known options:
|
||||
try:
|
||||
v = self._sections['KNOWN'][opt]
|
||||
v = self._sections['KNOWN/'+section][opt]
|
||||
except KeyError:
|
||||
# fallback to default:
|
||||
try:
|
||||
|
@ -297,7 +297,6 @@ after = 1.conf
|
|||
# merge defaults and all sections to self:
|
||||
alld.update(cfg.get_defaults())
|
||||
for n, s in cfg.get_sections().iteritems():
|
||||
curalls = alls
|
||||
# conditional sections
|
||||
cond = SafeConfigParserWithIncludes.CONDITIONAL_RE.match(n)
|
||||
if cond:
|
||||
|
@ -313,7 +312,7 @@ after = 1.conf
|
|||
s2 = alls.get(n)
|
||||
if isinstance(s2, dict):
|
||||
# save previous known values, for possible using in local interpolations later:
|
||||
self.merge_section('KNOWN', s2, '')
|
||||
self.merge_section('KNOWN/'+n, s2, '')
|
||||
# merge section
|
||||
s2.update(s)
|
||||
else:
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
# Author: Cyril Jaquier
|
||||
# Modified by: Yaroslav Halchenko (SafeConfigParserWithIncludes)
|
||||
|
||||
__author__ = "Cyril Jaquier"
|
||||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
||||
__author__ = "Cyril Jaquier, Yaroslav Halchenko, Serg G. Brester (aka sebres)"
|
||||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2007 Yaroslav Halchenko, 2015 Serg G. Brester (aka sebres)"
|
||||
__license__ = "GPL"
|
||||
|
||||
import glob
|
||||
|
@ -110,7 +110,7 @@ class ConfigReader():
|
|||
|
||||
def sections(self):
|
||||
try:
|
||||
return (n for n in self._cfg.sections() if n != 'KNOWN')
|
||||
return (n for n in self._cfg.sections() if not n.startswith('KNOWN/'))
|
||||
except AttributeError:
|
||||
return []
|
||||
|
||||
|
|
Loading…
Reference in New Issue