Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to specify multiple same actions within a jail with different names #37

Closed
yarikoptic opened this issue Feb 28, 2012 · 6 comments
Milestone

Comments

@yarikoptic
Copy link
Member

e.g.


[asterisk]

enabled  = true
filter   = asterisk
action   = iptables-multiport[name=asterisk-udp, port="5060,5061", protocol=udp]
           iptables-multiport[name=asterisk-tcp, port="5060,5061", protocol=tcp]
           sendmail-whois[name=Asterisk, dest=you@example.com, sender=fail2ban@example.com]
logpath  = /var/log/asterisk/messages
maxretry = 10

would result only in asterisk-tcp chain setup -- it is due to actions taking the 'name' of the jail. Simple patch


diff --git a/client/jailreader.py b/client/jailreader.py
index f66dc01..247216f 100644
--- a/client/jailreader.py
+++ b/client/jailreader.py
@@ -87,7 +87,9 @@ class JailReader(ConfigReader):
                        for act in self.__opts["action"].split('\n'):
                                try:
                                        splitAct = JailReader.splitAction(act)
-                                   action = ActionReader(splitAct, self.__name)
+                                 # YOH: action takes name specified in options if available
+                                 action = ActionReader(splitAct,
+                                                                           splitAct[1].get('name', self.__name))
                                        ret = action.read()
                                        if ret:
                                                action.getOptions(self.__opts)

is insufficient since it brakes logic somewhere in jails.py (I believe) which relies on action name to correspond to jail name. So more TODO (may be action name could be jail_name:action_name_option)?

@generalfault
Copy link

Wanted to give a +1 to this... it's rather important if you have a central syslog server that distrubutes bans across a cluster... here is a typical jail section:

[ssh-iptables]
enabled  = true
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
           rban[rhost=server4.cluster.com, ruleset=rban-ssh]
           rban[rhost=server5.cluster.com, ruleset=rban-ssh]
           rban[rhost=server7.cluster.com, ruleset=rban-ssh]
           rban[rhost=server8.cluster.com, ruleset=rban-ssh]
           rban[rhost=server9.cluster.com, ruleset=rban-ssh]
logpath  = /var/log/secure
maxretry = 5

as is is now, we have to copy the rban action to rban1, rban2, rban3.... etc

@combro2k
Copy link

+1 I want to use multiple sendmail-whois-lines to send a mail to blocklist.de and myself.
Now it only matches the last one there 👎

@kwirk
Copy link
Contributor

kwirk commented Apr 25, 2013

Had a look at this as I recently tweaked this area of the code for the filter [Init] sections, therefore was sort of familiar with this code.

kwirk/fail2ban@fail2ban:0.9...kwirk:multiaction

@yarikoptic
Copy link
Member Author

that it's awesome @kwirk
I think this one is worth for master (I could cheery pick if necessary)
please send pr for consistency :-)

@kwirk
Copy link
Contributor

kwirk commented Apr 25, 2013

@yarikoptic Will do. My battery is about to die on my laptop, so wont be today...

yarikoptic added a commit that referenced this issue Apr 30, 2013
Allow creation of multiple of the same action for a filter -- use actname option. Close #37
@yarikoptic
Copy link
Member Author

So we resolved this with PR #189

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants