Problem with BlockHosts 2.1.0 & Python 2.4.4

Hi,

I'm not able to run BlockHost 2.1.0 with Python 2.4.4 (on Gentoo). BlockHost 2.0.6 works okay. I have updated the configuration file to 2.1.0.

I get the following error message:

blockhosts 2.1.0 started: 2007-10-29 06:38:48 EET
... load blockfile: /etc/hosts.allow
... found both markers, count blocked: 1, watched: 1
... loading log file /var/log/sshdlog, offset: 2944
... discarding all host entries older than 2007-08-30 07:38:48 EEST
Traceback (most recent call last):
File "./blockhosts.py", line 1875, in ?
main()
File "./blockhosts.py", line 1848, in main
[
File "./blockhosts.py", line 1391, in update_hosts_lists
filter(config, self._blocked_ips, self._watched_hosts)
File "./blockhosts.py", line 1608, in add_blocked_blacklist
test = re.compile("^" + ip + "$")
File "/usr/lib/python2.4/sre.py", line 180, in compile
return _compile(pattern, flags)
File "/usr/lib/python2.4/sre.py", line 227, in _compile
raise error, v # invalid expression
sre_constants.error: multiple repeat

Obviously there's something wrong with the regexps, but I'm really no expert on Python or regexps. Any ideas?

debug help?

If possible, can you edit the blockhosts.py and run it with --verbose option, and post the value for the "ip" variable?

Around line 1598, just below this pre-existing line in function add_blocked_blacklist:

            ip = ip.strip()

Add this line:

            Log.Info(" ... add_blocked_blacklist: testing ip: '%s'" % ip)

Then run it with --verbose, and the log will show "testing ip" line with the string used for ip.

This seems to work fine with python 2.5, but can't conclusively say that there isn't some problem in the way the ip string is handled in blockhosts.py at this time. More testing needed.

Hi, Thanks for your help,

Hi,

Thanks for your help, but apparently I had made a typo in the configuration file. I rewrote the config file and unpacked the script again, and now it seems to work.

possible cause

Looking at the code - one possible cause is if the "BLACKLIST" configuration is defined in /etc/blockhosts.cg or if the --blacklist argument is used - and if it contains a incorrect regexp (like an unadorned *), that could cause this error to be reported.