From e87420b85606fa78cb95e5bf5dece740c64a0a5f Mon Sep 17 00:00:00 2001 From: bernat Date: Thu, 15 Sep 2005 11:41:52 +0200 Subject: [PATCH] Plus d'erreur sur Nectaris. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Possibilite de voir si un client est correctement authentifié en wifi. Ex : whos host=var darcs-hash:20050915094152-d1718-d35cc3f526eb9b74fbdaa2974870cad1380d0ffc.gz --- gestion/set_droits.sh | 2 ++ gestion/whos.py | 33 ++++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/gestion/set_droits.sh b/gestion/set_droits.sh index 15b489ef..c8c05c27 100755 --- a/gestion/set_droits.sh +++ b/gestion/set_droits.sh @@ -13,6 +13,8 @@ set_dr () { chmod 775 $1 elif [[ $1 = "$BASE/clef-wifi" ]]; then chmod 600 $1 + elif [[ $1 = "$BASE/clef-encap" ]]; then + chmod 600 $1 elif [[ $1 = "$BASE/secrets.py" ]] || [[ $1 = "$BASE/secrets.pyc" ]]; then chmod 640 $1 else diff --git a/gestion/whos.py b/gestion/whos.py index 4393d4e4..cef0e6b6 100755 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -50,7 +50,7 @@ base = None from ldap_crans import is_actif , crans_ldap, ann_scol, crans, hostname from affich_tools import * import user_tests -import popen2 +import popen2, commands limit_aff_details = 1 limit_aff_historique = 4 @@ -394,6 +394,20 @@ def adher_details(adher) : f += u'aucune' return f + +clients_ipsec = None +def ipsec_ok(machine) : + """Indique si une machine est correctement authentifiée""" + prefix="" + if hostname != "nectaris": + if not os.path.isfile("/usr/scripts/gestion/clef-encap"): + return None + prefix = "ssh -i /usr/scripts/gestion/clef-encap " + clients = globals()['clients_ipsec'] + if clients == None: + clients = commands.getoutput("%snetstat -r -f encap | awk '($1 == \"0/0\") {print $3}'" % prefix).split("\n") + globals()['clients_ipsec'] = clients + return machine.nom() in clients def machine_details(machine) : """ @@ -460,6 +474,7 @@ def machine_details(machine) : for (client, rssi) in clients: # On va chercher le nom correspondant à l'adresse MAC res = base.search("mac=%s" % client)['machine'] + authentification="" if not res: client_nom = '????' coul_rssi = 'rouge' @@ -473,8 +488,16 @@ def machine_details(machine) : coul_rssi = 'jaune' else: coul_rssi = 'rouge' - f += u' %s (%s) (RSSI: %s)\n' % (client, client_nom, - coul("%d" % rssi, coul_rssi)) + # On va regarder si le client est authentifié + auth_ok = ipsec_ok(x) + if auth_ok != None: + if auth_ok: + authentification = " ; IPSec: %s" % OK + else: + authentification = " ; IPSec: %s" % OK + f += u' %s (%s) (RSSI: %s%s)\n' % (client, client_nom, + coul("%d" % rssi, coul_rssi), + authentification) else: f += coul(u'borne éteinte','rouge') f += '\n' @@ -966,13 +989,13 @@ if __name__ == '__main__' : try : __recherche() except KeyboardInterrupt : - print u"Recherche interrompue par l'utilisateur." + print "Recherche interrompue par l'utilisateur." sys.exit(255) except SystemExit, c : # Fin sys.exit(c) except : - print u"""Une erreur fatale s'est produite durant l'exécution. + print """Une erreur fatale s'est produite durant l'exécution. Pour l'amélioration de ce programme merci de prévenir nounou en spécifiant la marche à suivre pour reproduire cette erreur.""" if debug :