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

60
gestion/gen_confs/firewall.py Executable file
View file

@ -0,0 +1,60 @@
#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
""" Génération de la configuration pour le firewall
Copyright (C) Frédéric Pauget
Licence : GPLv2
"""
from gen_confs import gen_config
from time import localtime
class firewall(gen_config) :
""" Génère le fichier de paires MAC-IP """
# Fichier
MACIP = '/CRANS/generated/ether/pairesMAC-IP.txt'
restart_cmd = '/etc/init.d/firewall macip'
def __str__(self) :
return "firewall"
def _gen(self) :
macip= self._open_conf(self.MACIP)
self.anim.iter=len(self.machines)
for machine in self.machines :
self.anim.cycle()
macip.write( "%s %s\n" % ( machine.mac(), machine.ip() ) )
macip.close()
class bl_upload_fw(gen_config) :
""" Génère le fichier de blackliste d'upload pour le firewall"""
# Fichier
BL_UPLOAD = '/tmp/bl_upload_fw'
restart_cmd = '/etc/init.d/firewall blacklist'
def __str__(self) :
return "blackliste upload firewall"
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( '%s:smtp,smtps,pop3,pop3s,imap,imaps,http\n' % machine.nom() )
upload.close()