From d4c921c22abd9cb80fb7351a0e1d292286705171 Mon Sep 17 00:00:00 2001 From: sebres Date: Wed, 15 Jan 2020 13:22:55 +0100 Subject: [PATCH] amend to 31b8d91ba2211595182d8d3fe6d89034b562aef0: tag `` is normally dynamic tag (ticket related), so better to replace it this way (may avoid confusing if tag is used directly during restore sane env process for both families); conditional replacement is not affected here --- fail2ban/server/action.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fail2ban/server/action.py b/fail2ban/server/action.py index e748fa77..2a5bb704 100644 --- a/fail2ban/server/action.py +++ b/fail2ban/server/action.py @@ -392,10 +392,13 @@ class CommandAction(ActionBase): def _getOperation(self, tag, family): # replace operation tag (interpolate all values), be sure family is enclosed as conditional value # (as lambda in addrepl so only if not overwritten in action): - return self.replaceTag(tag, self._properties, + cmd = self.replaceTag(tag, self._properties, conditional=('family='+family if family else ''), - addrepl=(lambda tag:family if tag == 'family' else None), cache=self.__substCache) + if '<' not in cmd or not family: return cmd + # replace family as dynamic tags, important - don't cache, no recursion and auto-escape here: + cmd = self.replaceDynamicTags(cmd, {'family':family}) + return cmd def _operationExecuted(self, tag, family, *args): """ Get, set or delete command of operation considering family.