diff --git a/fail2ban/helpers.py b/fail2ban/helpers.py index 2407df1f..726631a6 100644 --- a/fail2ban/helpers.py +++ b/fail2ban/helpers.py @@ -240,6 +240,7 @@ def substituteRecursiveTags(inptags, conditional='', # init: ignore = set(ignore) done = set() + calmap = hasattr(tags, "getRawItem") # repeat substitution while embedded-recursive (repFlag is True) while True: repFlag = False @@ -247,6 +248,8 @@ def substituteRecursiveTags(inptags, conditional='', for tag in tags.iterkeys(): # ignore escaped or already done (or in ignore list): if tag in ignore or tag in done: continue + # ignore replacing callable items from calling map - should be converted on demand only (by get): + if calmap and callable(tags.getRawItem(tag)): continue value = orgval = str(tags[tag]) # search and replace all tags within value, that can be interpolated using other tags: m = tre_search(value) diff --git a/fail2ban/server/action.py b/fail2ban/server/action.py index e7a98dbb..06a499df 100644 --- a/fail2ban/server/action.py +++ b/fail2ban/server/action.py @@ -98,6 +98,13 @@ class CallingMap(MutableMapping, object): except: return dict(self.data, **self.storage) + def getRawItem(self, key): + try: + value = self.storage[key] + except KeyError: + value = self.data[key] + return value + def __getitem__(self, key): try: value = self.storage[key]