From: Christian Schmidt Date: Sat, 29 Aug 2009 08:46:19 +0000 (+0200) Subject: Fixed ids-block deamon, still not blocking but working X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4da665d998ab3abc38353b439794b221f4a6317f;p=ipfire-3.x.git Fixed ids-block deamon, still not blocking but working --- diff --git a/config/syslog-ng/ids-block b/config/syslog-ng/ids-block index a186175d8..e00ea749e 100644 --- a/config/syslog-ng/ids-block +++ b/config/syslog-ng/ids-block @@ -28,24 +28,35 @@ from IPy import IP #os.system('modprobe ipt_recent ip_list_tot=1000') def main(): - for data in sys.stdin.readlines(): + while 1: + data = sys.stdin.readline() + # need to extract the ip adress from the whole log line to get + # this working as expected,IPy just only returns a valid address + if not data: break try: - ip = IP(sys.data) + ip = IP(data) + except AttributeError: + #f = open("/tmp/testfile","w") + #f.write("Wrong value given") + #f.close() + sys.stderr.write("Wrong attribute given.\n") + break except KeyError: - #sys.stderr.write("Not enough parameters given.\n") - #sys.exit(1) - next() + sys.stderr.write("Not enough parameters given.\n") + break except ValueError: sys.stderr.write("Given value is not a valid ip address.\n") - sys.exit(1) - + #f = open("/tmp/testfile","w") + #f.write("This does not match - %s\n" % data ) + #f.close() + break try: + #f = open("/tmp/testfile", "w") f = open("/proc/net/ipt_recent/BLOCK", "w") f.write("%s\n" % ip) f.close() except: sys.stderr.write("Cannot write ip \"%s\" to file.\n" % ip) - sys.exit(1) - + break main() -sys.exit(0) \ No newline at end of file +sys.exit(0)