From 83786855db3344ed3285a60e1d44c2c8cc4c55c6 Mon Sep 17 00:00:00 2001 From: sabban Date: Wed, 27 Oct 2004 23:56:30 +0200 Subject: [PATCH] a a l'air de fonctionner comme a. Reste tester la blacklist. On attend Fred pour a. darcs-hash:20041027215630-1d643-bf07c0d8a288582f01951d9556cbfe205d8bc57f.gz --- gestion/classe_firewall.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/gestion/classe_firewall.py b/gestion/classe_firewall.py index 8b3d36ee..1e8d6697 100755 --- a/gestion/classe_firewall.py +++ b/gestion/classe_firewall.py @@ -100,7 +100,9 @@ class firewall: """ Détruit une entrée dans le firewall Note: Il faut *os.systemer lourdement* cette fonction. - """ + Ce serait pas mal de factoriser par ici, mais de toute façon la + méthode ne me plaît pas du tout. + """ try: os.system("iptables -L -n > /tmp/firewall") except: @@ -110,14 +112,30 @@ class firewall: count=0 for line in fileinput.input('/tmp/firewall'): count=count+1 - if "Chain" in line: + if "Chain" in line: tmp=line.split(' ') chaine=tmp[1] count=0 - if ip in line: - os.system("iptables -L") - test("iptables -D %s %i"%(chaine,count)) + if ip in line: count=count-1 + test("iptables -D %s %i"%(chaine,count)) + os.system("rm -f /tmp/firewall") + try: + os.system("iptables -t nat -L -n > /tmp/firewall") + except: + print "Impossible de créer le fichier d'états /tmp/firewall" + exit() + chaines=[] + count=0 + for line in fileinput.input('/tmp/firewall'): + count=count+1 + if "Chain" in line: + tmp=line.split(' ') + chaine=tmp[1] + count=0 + if ip in line: + count=count-1 + test("iptables -t nat -D %s %i"%(chaine,count)) os.system("rm -f /tmp/firewall") def paire_macip(self,ip,mac):