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
|
# Author: Yaroslav Halchenko
|
||||||
# Modified: Cyril Jaquier
|
# Modified: Cyril Jaquier
|
||||||
|
|
||||||
__author__ = 'Yaroslav Halhenko'
|
__author__ = 'Yaroslav Halhenko, Serg G. Brester (aka sebres)'
|
||||||
__copyright__ = 'Copyright (c) 2007 Yaroslav Halchenko'
|
__copyright__ = 'Copyright (c) 2007 Yaroslav Halchenko, 2015 Serg G. Brester (aka sebres)'
|
||||||
__license__ = 'GPL'
|
__license__ = 'GPL'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -150,7 +150,7 @@ after = 1.conf
|
||||||
if seclwr == 'known':
|
if seclwr == 'known':
|
||||||
# try get raw value from known options:
|
# try get raw value from known options:
|
||||||
try:
|
try:
|
||||||
v = self._sections['KNOWN'][opt]
|
v = self._sections['KNOWN/'+section][opt]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# fallback to default:
|
# fallback to default:
|
||||||
try:
|
try:
|
||||||
|
@ -297,7 +297,6 @@ after = 1.conf
|
||||||
# merge defaults and all sections to self:
|
# merge defaults and all sections to self:
|
||||||
alld.update(cfg.get_defaults())
|
alld.update(cfg.get_defaults())
|
||||||
for n, s in cfg.get_sections().iteritems():
|
for n, s in cfg.get_sections().iteritems():
|
||||||
curalls = alls
|
|
||||||
# conditional sections
|
# conditional sections
|
||||||
cond = SafeConfigParserWithIncludes.CONDITIONAL_RE.match(n)
|
cond = SafeConfigParserWithIncludes.CONDITIONAL_RE.match(n)
|
||||||
if cond:
|
if cond:
|
||||||
|
@ -313,7 +312,7 @@ after = 1.conf
|
||||||
s2 = alls.get(n)
|
s2 = alls.get(n)
|
||||||
if isinstance(s2, dict):
|
if isinstance(s2, dict):
|
||||||
# save previous known values, for possible using in local interpolations later:
|
# save previous known values, for possible using in local interpolations later:
|
||||||
self.merge_section('KNOWN', s2, '')
|
self.merge_section('KNOWN/'+n, s2, '')
|
||||||
# merge section
|
# merge section
|
||||||
s2.update(s)
|
s2.update(s)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
# Author: Cyril Jaquier
|
# Author: Cyril Jaquier
|
||||||
# Modified by: Yaroslav Halchenko (SafeConfigParserWithIncludes)
|
# Modified by: Yaroslav Halchenko (SafeConfigParserWithIncludes)
|
||||||
|
|
||||||
__author__ = "Cyril Jaquier"
|
__author__ = "Cyril Jaquier, Yaroslav Halchenko, Serg G. Brester (aka sebres)"
|
||||||
__copyright__ = "Copyright (c) 2004 Cyril Jaquier"
|
__copyright__ = "Copyright (c) 2004 Cyril Jaquier, 2007 Yaroslav Halchenko, 2015 Serg G. Brester (aka sebres)"
|
||||||
__license__ = "GPL"
|
__license__ = "GPL"
|
||||||
|
|
||||||
import glob
|
import glob
|
||||||
|
@ -110,7 +110,7 @@ class ConfigReader():
|
||||||
|
|
||||||
def sections(self):
|
def sections(self):
|
||||||
try:
|
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:
|
except AttributeError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue