diff --git a/fail2ban/server/action.py b/fail2ban/server/action.py index 77b97fcd..94beb784 100644 --- a/fail2ban/server/action.py +++ b/fail2ban/server/action.py @@ -379,11 +379,11 @@ class CommandAction(ActionBase): #logSys.log(5, 'found: %s' % found_tag) if found_tag == tag or found_tag in done: # recursive definitions are bad - #logSys.log(5, 'recursion fail') + #logSys.log(5, 'recursion fail tag: %s value: %s' % (tag, value) ) return False else: if tags.has_key(found_tag): - value = value[0:m.start()] + tags[found_tag] + value[m.end():] + value = value.replace('<%s>' % found_tag , tags[found_tag]) #logSys.log(5, 'value now: %s' % value) done.append(found_tag) m = t.search(value, m.start()) diff --git a/fail2ban/tests/actiontestcase.py b/fail2ban/tests/actiontestcase.py index 897813b2..35de36dd 100644 --- a/fail2ban/tests/actiontestcase.py +++ b/fail2ban/tests/actiontestcase.py @@ -60,6 +60,12 @@ class CommandActionTest(LogCaptureTestCase): self.assertEqual(CommandAction.substituteRecursiveTags({'A': ''}), {'A': ''}) self.assertEqual(CommandAction.substituteRecursiveTags({'A': ' ','X':'fun'}), {'A': ' fun', 'X':'fun'}) self.assertEqual(CommandAction.substituteRecursiveTags({'A': ' ', 'B': 'cool'}), {'A': ' cool', 'B': 'cool'}) + # Multiple stuff on same line is ok + self.assertEqual(CommandAction.substituteRecursiveTags({'failregex': 'to= fromip= evilperson=', 'honeypot': 'pokie', 'ignoreregex': ''}), + { 'failregex': "to=pokie fromip= evilperson=pokie", + 'honeypot': 'pokie', + 'ignoreregex': '', + }) # rest is just cool self.assertEqual(CommandAction.substituteRecursiveTags(aInfo), { 'HOST': "192.0.2.0",