mirror of https://github.com/fail2ban/fail2ban
BF: allow newlines in action specifications (e.g. when multiple entries for logpath)
This one should address a crash in #231 but not clear if that would be the right approach anyways since sendmail-whois-lines would not function properly anyways_bf/multiline_action_options
parent
725d666ee6
commit
a169ed93f8
|
@ -35,7 +35,8 @@ logSys = logging.getLogger("fail2ban.client.config")
|
||||||
|
|
||||||
class JailReader(ConfigReader):
|
class JailReader(ConfigReader):
|
||||||
|
|
||||||
actionCRE = re.compile("^((?:\w|-|_|\.)+)(?:\[(.*)\])?$")
|
actionCRE = re.compile("^((?:\w|-|_|\.)+)(?:\[(.*)\])?$",
|
||||||
|
flags=re.MULTILINE|re.DOTALL)
|
||||||
|
|
||||||
def __init__(self, name, force_enable=False, **kwargs):
|
def __init__(self, name, force_enable=False, **kwargs):
|
||||||
ConfigReader.__init__(self, **kwargs)
|
ConfigReader.__init__(self, **kwargs)
|
||||||
|
|
|
@ -110,6 +110,12 @@ class JailReaderTest(unittest.TestCase):
|
||||||
result = JailReader.splitAction(action)
|
result = JailReader.splitAction(action)
|
||||||
self.assertEquals(expected, result)
|
self.assertEquals(expected, result)
|
||||||
|
|
||||||
|
def testSplitActionMultiline(self):
|
||||||
|
action = "mail-whois-lines[logpath=/a/b\n/c/d]"
|
||||||
|
expected = ['mail-whois-lines', {'logpath': '/a/b\n/c/d'}]
|
||||||
|
result = JailReader.splitAction(action)
|
||||||
|
self.assertEquals(expected, result)
|
||||||
|
|
||||||
class JailsReaderTest(unittest.TestCase):
|
class JailsReaderTest(unittest.TestCase):
|
||||||
|
|
||||||
def testProvidingBadBasedir(self):
|
def testProvidingBadBasedir(self):
|
||||||
|
|
Loading…
Reference in New Issue