55 lines
1.4 KiB
Python
Executable file
55 lines
1.4 KiB
Python
Executable file
#! /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, '#' )
|
|
|
|
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()
|
|
|