Commit a3944387 authored by Valentin Samir's avatar Valentin Samir
Browse files

[firewall4] search by unicode string

parent 606c680c
......@@ -86,7 +86,7 @@ class firewall_base(object) :
if self._machines:
self._blacklisted_machines = [ machine for machine in self._machines if machine.blacklist_actif() ]
return self._blacklisted_machines
blacklisted = [ machine for machine in conn.search("blacklist=*",sizelimit=4096) if machine.blacklist_actif() ]
blacklisted = [ machine for machine in conn.search(u"blacklist=*",sizelimit=4096) if machine.blacklist_actif() ]
self._blacklisted_machines = set()
for item in blacklisted:
if isinstance(item, lc_ldap.objets.proprio):
......@@ -328,7 +328,7 @@ class firewall_base(object) :
def blacklist_hard_maj(self, ip_list):
"""Met à jour les blacklists hard, est appelée par :py:func:`blacklist_maj`"""
for ip in ip_list:
machine = conn.search("ipHostNumber=%s" % ip)
machine = conn.search(u"ipHostNumber=%s" % ip)
# Est-ce qu'il y a des blacklists hard parmis les blacklists de la machine
if machine and set([bl.value['type'] for bl in machine[0].blacklist_actif() ]).intersection(blacklist_sanctions):
try: self.ipset['blacklist']['hard'].add(ip)
......@@ -412,7 +412,7 @@ class firewall_base(object) :
self.add(table, chain, '-m set --match-set %s src,src -j RETURN' % self.ipset['mac_ip'][key])
# Proxy ARP de Komaz et Titanic pour OVH
ip_ovh = conn.search("host=ovh.adm.crans.org")[0]['ipHostNumber'][0]
ip_ovh = conn.search(u"host=ovh.adm.crans.org")[0]['ipHostNumber'][0]
self.add(table, chain, '-m mac -s %s --mac-source %s -j RETURN' % (ip_ovh, mac_komaz))
self.add(table, chain, '-m mac -s %s --mac-source %s -j RETURN' % (ip_ovh, mac_titanic))
......@@ -426,7 +426,7 @@ class firewall_base(object) :
def mac_ip_maj(self, ip_list):
"""Met à jour la correspondance mac-ip"""
for ip in ip_list:
machine = conn.search("ipHostNumber=%s" % ip)
machine = conn.search(u"ipHostNumber=%s" % ip)
if machine:
try: self.test_mac_ip_dispatch(lambda set, data: self.ipset['mac_ip'][set].delete(data.split(',',1)[0]), {'ipHostNumber' : [ip], 'macAddress':[''] })
except IpsetError: pass
......@@ -720,7 +720,7 @@ class firewall_komaz(firewall_base_routeur):
def blacklist_soft_maj(self, ip_list):
for ip in ip_list:
machine = conn.search("ipHostNumber=%s" % ip)
machine = conn.search(u"ipHostNumber=%s" % ip)
# Est-ce qu'il y a des blacklists soft parmis les blacklists de la machine
if machine and set([bl.value['type'] for bl in machine[0].blacklist_actif() ]).intersection(blacklist_sanctions_soft):
try: self.ipset['blacklist']['soft'].add(ip)
......@@ -775,7 +775,7 @@ class firewall_komaz(firewall_base_routeur):
def blacklist_upload_maj(self, ip_list):
for ip in ip_list:
machine = conn.search("ipHostNumber=%s" % ip)
machine = conn.search(u"ipHostNumber=%s" % ip)
# Est-ce qu'il y a des blacklists pour upload parmis les blacklists de la machine
if machine and set([bl.value['type'] for bl in machine[0].blacklist_actif() ]).intersection(blacklist_bridage_upload):
try: self.ipset['blacklist']['upload'].add(ip)
......@@ -1057,7 +1057,7 @@ class firewall_zamok(firewall_base):
try: self.add(table, chain, '-m owner --uid-owner %d -j ACCEPT' % pwd.getpwnam(user)[2])
except KeyError: print "Utilisateur %s inconnu" % user
for nounou in conn.search("droits=%s" % lc_ldap.attributs.nounou):
for nounou in conn.search(u"droits=%s" % lc_ldap.attributs.nounou):
self.add(table, chain, '-m owner --uid-owner %s -j RETURN' % nounou['uidNumber'][0])
# Rien d'autre ne passe
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment