Import initial !

darcs-hash:20040831131446-d1718-0734aa73d3b8481b3b4b861e447e85128e488e8a.gz
This commit is contained in:
bernat 2004-08-31 15:14:46 +02:00
parent c9083dfd86
commit 6626a44f15
20 changed files with 6494 additions and 0 deletions

90
gestion/gen_confs/squid.py Executable file
View file

@ -0,0 +1,90 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
""" Génération de la configuration pour squid """
from gen_confs import gen_config
from time import localtime
class bl_carte_etudiant(gen_config) :
""" Génère le fichier de blackliste pour carte d'étudiant pour squid"""
BL_CARTE = '/tmp/bl_carte_et'
restart_cmd = '/etc/init.d/squid reload'
def __str__(self) :
return "blackliste cartes d'étudiant"
def _gen(self) :
fd=self._open_conf(self.BL_CARTE)
if localtime()[1] == 9:
# On est en septembre, on autorise ceux qui ont payé l'an dernier et cette année
base = self.base.search('carteEtudiant!=%s&(paiement=%d|paiement=%d)' % (self.ann_scol,
int(self.ann_scol),
int(self.ann_scol) - 1))
else:
base = self.base.search('paiement=%s' % self.ann_scol)
for adh in ( [ self.crans ] + base['adherent'] + base['club'] ):
for machine in adh.machines() :
self.anim.cycle()
if 'bloq' in machine.blacklist_actif() : continue
if machine.proprietaire().idn != 'aid' : continue
fd.write(machine.nom() + '\n')
fd.close()
class bl_upload_squid(gen_config) :
""" Génère le fichier de blackliste d'upload pour squid"""
# Fichier
BL_UPLOAD = '/tmp/bl_upload_squid'
restart_cmd = '/etc/init.d/squid reload'
def __str__(self) :
return "blackliste upload squid"
def _gen(self) :
upload = self._open_conf( self.BL_UPLOAD )
if localtime()[1] == 9:
# On est en septembre, on autorise ceux qui ont payé l'an dernier et cette année
base = self.base.search('(paiement=%d|paiement=%d)' % (int(self.ann_scol),
int(self.ann_scol) - 1))
else:
base = self.base.search('paiement=%s' % self.ann_scol)
for adh in ( [ self.crans ] + base['adherent'] + base['club'] ):
for machine in adh.machines() :
self.anim.cycle()
bl = machine.blacklist_actif()
if 'bl_upload' in bl and not 'bloq' in bl :
upload.write( machine.nom() + '\n' )
upload.close()
class bl_virus(gen_config) :
""" Génère le fichier de blackliste virus pour squid"""
# Fichiers
BL_VIRUS = '/tmp/bl_virus'
def __str__(self) :
return "blackliste virus"
restart_cmd = '/etc/init.d/squid reload'
description = u'Bloquage accès http vers l\'extérieur, page expliquative'
def _gen(self) :
virus = self._open_conf( self.BL_VIRUS )
if localtime()[1] == 9:
# On est en septembre, on autorise ceux qui ont payé l'an dernier et cette année
base = self.base.search('(paiement=%d|paiement=%d)' % (int(self.ann_scol),
int(self.ann_scol) - 1))
else:
base = self.base.search('paiement=%s' % self.ann_scol)
for machine in base['machine'] :
self.anim.cycle()
bl = machine.blacklist_actif()
if 'bl_virus' in bl and not 'bloq' in bl :
virus.write( machine.nom() + '\n')
virus.close()