correction :

pb1 : si on voulait dconnecter juste une machine alors que d'habitude dans
ldap c'est l'adhrent qui est blacklist, la santion n'tait pas prise en
compte

pb2 : si quelqu'on est bloq et bl_upload, il n'tait pas dans les fichiers
de squid, donc lors de sa reco de bloq il ne serait pas bloqu par squid

je crois que c'est tout...

darcs-hash:20060316195304-4ec08-97ea41461c9dc8ed410df999f8c4ea628bc9f04a.gz
This commit is contained in:
chove 2006-03-16 20:53:04 +01:00
parent ef9ac67522
commit 18635b6af6

View file

@ -12,6 +12,7 @@ from config import bl_carte_et_actif
class squid(gen_config) : class squid(gen_config) :
db = crans_ldap() db = crans_ldap()
actif = True # la sanction est elle active ?
restart_cmd = '/etc/init.d/squid reload' restart_cmd = '/etc/init.d/squid reload'
def __str__(self) : def __str__(self) :
@ -22,90 +23,77 @@ class squid(gen_config) :
def _mklist(self) : def _mklist(self) :
fic = self._open_conf(self.FICHIER) fic = self._open_conf(self.FICHIER)
# recherche_bl :
# 1 : search sur champ blacklist et clubs compris if not self.actif:
# 2 : search sur champ ablacklist et clubs compris return
# 3 : search sur champ mblacklist et clubs compris
# 0 : search plus général et clubs exclus # recherche dans la base LDAP
if self.recherche_bl==1: if '=' in self.chaine:
liste = self.db.search("paiement=ok&blacklist=*%s*"%self.chaine) # chaine de tri spéciale
liste = self.db.search("paiement=ok&%s"%self.chaine)
l_proprio = liste["adherent"] + liste["club"] l_proprio = liste["adherent"] + liste["club"]
elif self.recherche_bl==2: l_machine = liste["machine"]
else:
# recherche dans les adhérents blacklistés
liste = self.db.search("paiement=ok&ablacklist=*%s*"%self.chaine) liste = self.db.search("paiement=ok&ablacklist=*%s*"%self.chaine)
l_proprio = liste["adherent"] + liste["club"] l_proprio = liste["adherent"] + liste["club"]
elif self.recherche_bl==3: l_proprio = [ x for x in l_proprio if self.chaine in x.blacklist_actif() ]
# recherche dans les machines blacklistés
liste = self.db.search("paiement=ok&mblacklist=*%s*"%self.chaine) liste = self.db.search("paiement=ok&mblacklist=*%s*"%self.chaine)
l_proprio = liste["adherent"]+liste["club"] l_machine = liste["machine"]
else: l_machine = [ m for m in l_machine if self.chaine in proprio.blacklist_actif() ]
l_proprio = self.db.search('paiement=ok&' + self.chaine)["adherent"]
self.anim.iter=len(l_proprio) # on ajoute les machines des proprios aux autres machines
for proprio in l_proprio : for proprio in l_proprio :
l_machine += proprio.machines()
# on colle toutes les machines dans le fichier
self.anim.iter=len(l_machine)
for m in l_machine:
self.anim.cycle() self.anim.cycle()
if self.recherche_bl==0 or self.chaine in proprio.blacklist_actif():
# Pas la peine de renvoyer les machines complètement bloqués
for m in proprio.machines():
if not 'bloq' in m.blacklist_actif():
fic.write( m.Nom() + '\n' ) fic.write( m.Nom() + '\n' )
fic.close() fic.close()
class squid_upload(squid) : class squid_upload(squid) :
""" Genère le fichier blacklist-upload pour squid """ """ Genère le fichier blacklist-upload pour squid """
FICHIER = "/etc/squid/blacklist_upload" FICHIER = "/etc/squid/blacklist_upload"
chaine = "upload" chaine = "upload"
recherche_bl = 1
class squid_p2p(squid) : class squid_p2p(squid) :
""" Genère le fichier blacklist-p2p pour squid """ """ Genère le fichier blacklist-p2p pour squid """
FICHIER = "/etc/squid/blacklist_p2p" FICHIER = "/etc/squid/blacklist_p2p"
chaine = "p2p" chaine = "p2p"
recherche_bl = 2 # Sanction sur l'adhérent uniquement
class squid_autodisc_upload(squid) : class squid_autodisc_upload(squid) :
""" Genère le fichier blacklist-autodiscupload pour squid """ """ Genère le fichier blacklist-autodiscupload pour squid """
FICHIER = "/etc/squid/blacklist_autodisc_upload" FICHIER = "/etc/squid/blacklist_autodisc_upload"
chaine = "autodisc_upload" chaine = "autodisc_upload"
recherche_bl = 2
class squid_autodisc_p2p(squid) : class squid_autodisc_p2p(squid) :
""" Genère le fichier blacklist-autodisc-p2p pour squid """ """ Genère le fichier blacklist-autodisc-p2p pour squid """
FICHIER = "/etc/squid/blacklist_autodisc_p2p" FICHIER = "/etc/squid/blacklist_autodisc_p2p"
chaine = "autodisc_p2p" chaine = "autodisc_p2p"
recherche_bl = 2 # Sanction sur l'adhérent uniquement
class squid_virus(squid) : class squid_virus(squid) :
""" Genère le fichier blacklist-virus pour squid """ """ Genère le fichier blacklist-virus pour squid """
FICHIER = "/etc/squid/blacklist_virus" FICHIER = "/etc/squid/blacklist_virus"
chaine = "virus" chaine = "virus"
recherche_bl = 3 # Sanction sur une machine uniquement
class squid_warez(squid) : class squid_warez(squid) :
""" Genère le fichier blacklist-warez pour squid """ """ Genère le fichier blacklist-warez pour squid """
FICHIER = "/etc/squid/blacklist_warez" FICHIER = "/etc/squid/blacklist_warez"
chaine = "warez" chaine = "warez"
recherche_bl = 2 # Sanction sur l'adhérent uniquement
class squid_carte(squid) : class squid_carte(squid) :
""" Genère le fichier blacklist-carte pour squid """ """ Genère le fichier blacklist-carte pour squid """
actif = bl_carte_et_actif
if not actif : restart_cmd = ''
FICHIER = "/etc/squid/blacklist_carte_et" FICHIER = "/etc/squid/blacklist_carte_et"
chaine = "carteEtudiant!=%i"%ann_scol chaine = "carteEtudiant!=%i"%ann_scol
recherche_bl = 0
if not bl_carte_et_actif :
# Inutile de relancer squid si la blacklist n'est pas activée
restart_cmd = ''
def _gen(self) :
# Liste vide si la blacklist n'est pas activée
if not bl_carte_et_actif :
fic = self._open_conf(self.FICHIER)
# on vide la blackliste
fic.close()
return
self._mklist()
class squid_chbre(squid) : class squid_chbre(squid) :
""" Genère le fichier blacklist-chbre pour squid """ """ Genère le fichier blacklist-chbre pour squid """
FICHIER = "/etc/squid/blacklist_chbre" FICHIER = "/etc/squid/blacklist_chbre"
chaine = "chbre=????" chaine = "chbre=????"
recherche_bl = 0