scripts/gestion/tools/list_firewall.py
glondu 9e10f8584c port(TCP|UDP)(in|out) est dsormais une liste. Je ferai le changement de
syntaxe dans le schma au prochain dump/restauration de la base.

darcs-hash:20060327003949-68412-6475d4ba6f2cf144789a90915fd72e1df374910e.gz
2006-03-27 02:39:49 +02:00

38 lines
1.2 KiB
Python
Executable file

#! /usr/bin/env python
# -*- coding: iso-8859-15 -*-
import sys
sys.path.append('/usr/scripts/gestion')
from ldap_crans import crans_ldap, decode, AssociationCrans
db = crans_ldap()
machines = db.search('portTCPin=*')['machine'] + db.search('portTCPout=*')['machine'] + db.search('portUDPin=*')['machine'] + db.search('portUDPout=*')['machine']
done = []
txts = []
for m in machines :
# on vérifie qu'on l'a pas encore traité
if m.ip() in done :
continue
if m.proprietaire().__class__ == AssociationCrans :
continue
done.append(m.ip())
# texte pour la machine
txt = u''
txt += u'Propriétaire : %s\n' % m.proprietaire().Nom().encode('iso-8859-1')
txt += u'Machine : %s\n' % m.nom()
if m.portTCPin() :
txt += u'ports TCP in : %s\n' % ' '.join(m.portTCPin())
if m.portTCPout() :
txt += u'ports TCP out : %s\n' % ' '.join(m.portTCPout())
if m.portUDPin() :
txt += u'ports UDP in : %s\n' % ' '.join(m.portUDPin())
if m.portUDPout() :
txt += u'ports UDP out : %s\n' % ' '.join(m.portUDPout())
txts.append(txt.strip())
print '\n- - - - - - = = = = = = # # # # # # # # = = = = = = - - - - - -\n'.join(txts)