From fe958d000979cd0979c8bc91e05809863d3be5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Sat, 12 Jan 2013 17:01:40 +0100 Subject: [PATCH] =?UTF-8?q?[ldap=5Fcrans/whos]=20Deux=20corrections=20conc?= =?UTF-8?q?ernant=20ssh,=20et=20ajout=20des=20champs=20=C3=A0=20whos,=20av?= =?UTF-8?q?ec=20option=20-s=20pour=20afficher=20les=20fpr=20ssh.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ignore-this: c7d7960aad0da2f4a510b09d97eeeec7 <> sshFingerprint n'était pas un historique de type diff <> gpgexists au milieu de sshFingerprint() <> on rajoute une espace après le cinquième bloc GPG + Affichage des fpr GPG dans whos + Affichage des fpr SSH dans whos avec option -s ou --ssh + ? darcs-hash:20130112160140-b6762-824baacdb54a9dbd358d8762bda30d5511616674.gz --- gestion/ldap_crans.py | 10 ++++++---- gestion/whos.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/gestion/ldap_crans.py b/gestion/ldap_crans.py index 1cb5e473..e95c9dd5 100644 --- a/gestion/ldap_crans.py +++ b/gestion/ldap_crans.py @@ -236,7 +236,7 @@ def format_mac(mac): def format_gpg_fingerprint(fpr): """ Formatage de fingerpring GPG pour les avoir de la forme - XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX + XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX """ # longueur + fpr sans espaces @@ -257,6 +257,8 @@ def format_gpg_fingerprint(fpr): if i != 10: formattedfpr += " " + if i == 4: + formattedfpr += " " return formattedfpr @@ -480,7 +482,7 @@ class CransLdap: aid $ chbre $ mail $ mailAlias $ canonicalAlias $ mid $ macAddress $ host $ hostAlias $ ipHostNumber $ - gpgFingerprint + gpgFingerprint $ sshFingerprint Retourne le dn du lock """ @@ -1205,7 +1207,7 @@ class BaseClasseCrans(CransLdap): for champ in ['droits', 'controle', 'paiement', 'carteEtudiant', 'mailAlias', 'hostAlias', 'exempt', 'nvram', 'portTCPin', 'portTCPout', 'portUDPin', 'portUDPout', - 'homepageAlias', 'imprimeurClub', 'gpgFingerprint']: + 'homepageAlias', 'imprimeurClub', 'gpgFingerprint', 'sshFingerprint']: if champ in self.modifs: if champ == 'controle': # Ce n'est pas pareil que self._init_data.get('controle', ['']) @@ -3024,7 +3026,7 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3) else: index = -1 - #if gpgexists(new): + #if sshexists(new): # raise ValueError(u"FPR existant ou correspondand à un compte.") if index != -1: diff --git a/gestion/whos.py b/gestion/whos.py index b1885a7a..1bcb8bdd 100644 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -37,6 +37,7 @@ le mode d'affichage condensé au lieu du mode détaillé (défaut %(limit_aff_de d'historique affichées (défaut %(limit_aff_historique)i) -d ou --limit-blacklist= : limitation du nombre de lignes d'historique des déconnexions affichées (défaut %(limit_aff_blacklist)i) + -s ou --ssh : affiche les fingerpring ssh des machines """ try: @@ -63,6 +64,7 @@ limit_aff_machines = 15 limit_aff_historique = 4 limit_aff_blacklist = 4 aff_ipsec = 0 +aff_ssh = 0 ################################################################################ ### Fonctions utiles @@ -434,6 +436,8 @@ def adher_details(adher) : f += GL f += RMH f += u'\n' + if len(adher.gpgFingerprint()) > 0: + f += u"\n".join([coul(u'Fingerprint GPG : ', 'gras') + u"%s" % (i) for i in adher.gpgFingerprint()])+"\n" try: forward = file("/home/%s/.forward" % adher.compte()).readlines() if len(forward) > 1: @@ -600,6 +604,9 @@ def machine_details(machine) : f+= coul(u'IP : ','gras') + "%s\t\t" %machine.ip() f+= coul(u'MAC : ','gras') + "%s\n" %machine.mac() + if len(machine.sshFingerprint()) > 0 and aff_ssh: + f += u"\n".join([coul(u'Fingerprint SSH : ', 'gras') + u"%s" % (i) for i in machine.sshFingerprint()])+"\n" + # Propriétaire f+= coul(u'Propriétaire : ','gras') try : @@ -1093,7 +1100,7 @@ def __recherche() : """ Recherche et affichage des résultats à partir des options founies (sys.argv) """ - global aff_ipsec, limit_aff_details, limit_aff_historique, limit_aff_blacklist, debug + global aff_ipsec, aff_ssh, limit_aff_details, limit_aff_historique, limit_aff_blacklist, debug # Récupération des options if len(sys.argv) == 1 : @@ -1101,7 +1108,7 @@ def __recherche() : __usage_brief() try : - options, arg = getopt.getopt(sys.argv[1:], 'hamctbil:L:d:', [ 'debug', 'help', 'adherent', 'machine', 'club' , 'tech', 'bornes', 'limit=', 'limit-historique=', 'limit-blacklist=', 'ipsec', 'crans' ]) + options, arg = getopt.getopt(sys.argv[1:], 'hamcstbil:L:d:', [ 'debug', 'help', 'adherent', 'machine', 'club' , 'tech', 'bornes', 'limit=', 'limit-historique=', 'limit-blacklist=', 'ipsec', 'crans', 'ssh' ]) except getopt.error, msg : __usage_brief(unicode(msg)) @@ -1164,6 +1171,8 @@ def __recherche() : elif opt in [ '-i', '--ipsec' ] : # Affichage des clefs ipsec aff_ipsec = 1 + elif opt in [ '-s', '--ssh' ]: + aff_ssh = 1 if only_adh + only_mac + only_club + only_bornes > 1 : __usage_brief(u'Options utilisées incompatibles')