From: <los...@us...> - 2007-01-04 11:59:00
|
Revision: 509 http://svn.sourceforge.net/fail2ban/?rev=509&view=rev Author: lostcontrol Date: 2007-01-04 03:58:58 -0800 (Thu, 04 Jan 2007) Log Message: ----------- - Allow comma in action options. The value of the option must be escaped with " or '. Thanks to Yaroslav Halchenko Modified Paths: -------------- trunk/CHANGELOG trunk/TODO trunk/client/jailreader.py trunk/config/jail.conf Modified: trunk/CHANGELOG =================================================================== --- trunk/CHANGELOG 2007-01-03 18:18:31 UTC (rev 508) +++ trunk/CHANGELOG 2007-01-04 11:58:58 UTC (rev 509) @@ -18,6 +18,8 @@ - Several "failregex" and "ignoreregex" are now accepted. Creation of rules should be easier now. - Added license in COPYING. Thanks to Axel Thimm +- Allow comma in action options. The value of the option must + be escaped with " or '. Thanks to Yaroslav Halchenko ver. 0.7.5 (2006/12/07) - beta ---------- Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-01-03 18:18:31 UTC (rev 508) +++ trunk/TODO 2007-01-04 11:58:58 UTC (rev 509) @@ -13,6 +13,8 @@ # partially done * done +- Improve parsing of the action parameters in jailreader.py + - Better handling of the protocol in transmitter.py - Add gettext support (I18N) Modified: trunk/client/jailreader.py =================================================================== --- trunk/client/jailreader.py 2007-01-03 18:18:31 UTC (rev 508) +++ trunk/client/jailreader.py 2007-01-04 11:58:58 UTC (rev 509) @@ -134,7 +134,31 @@ m = JailReader.actionCRE.match(action) d = dict() if not m.group(2) == None: - for param in m.group(2).split(','): + # Huge bad hack :( This method really sucks. TODO Reimplement it. + actions = "" + escapeChar = None + allowComma = False + for c in m.group(2): + if c in ('"', "'") and not allowComma: + # Start + escapeChar = c + allowComma = True + elif c == escapeChar: + # End + escapeChar = None + allowComma = False + else: + if c == ',' and allowComma: + actions += "<COMMA>" + else: + actions += c + + # Split using , + actionsSplit = actions.split(',') + # Replace the tag <COMMA> with , + actionsSplit = [n.replace("<COMMA>", ',') for n in actionsSplit] + + for param in actionsSplit: p = param.split('=') try: d[p[0].strip()] = p[1].strip() Modified: trunk/config/jail.conf =================================================================== --- trunk/config/jail.conf 2007-01-03 18:18:31 UTC (rev 508) +++ trunk/config/jail.conf 2007-01-04 11:58:58 UTC (rev 509) @@ -141,13 +141,15 @@ logpath = /var/log/apache2/error_log # This jail uses ipfw, the standard firewall on FreeBSD. The "ignoreip" -# option is overridden in this jail. +# option is overridden in this jail. Moreover, the action "mail-whois" defines +# the variable "name" which contains a comma using "". The characters '' are +# valid too. [ssh-ipfw] enabled = false filter = sshd action = ipfw[localhost=192.168.0.1] - mail-whois[name=SSH, dest=you...@ma...] + mail-whois[name="SSH,IPFW", dest=you...@ma...] logpath = /var/log/auth.log ignoreip = 168.192.0.1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |