From e579798fdcf402e77ef883a9ad06eab91efea0f6 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Fri, 21 Feb 2014 18:05:02 +0100 Subject: [PATCH] =?UTF-8?q?[gen=5Fconfs/bind]=20Dans=20la=20m=C3=A9thode?= =?UTF-8?q?=20add=5Fsshfp=5Frecord,=20on=20rattrape=20les=20exceptions=20d?= =?UTF-8?q?u=20=C3=A0=20des=20sshFingerprint=20mal=20form=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gestion/gen_confs/bind.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/gestion/gen_confs/bind.py b/gestion/gen_confs/bind.py index 4335ba72..e929abd2 100755 --- a/gestion/gen_confs/bind.py +++ b/gestion/gen_confs/bind.py @@ -254,17 +254,22 @@ class Zone(ZoneBase): def add_sshfp_record(self, nom, machine): for sshkey in machine.get('sshFingerprint', []): - algo_txt, key = str(sshkey).split()[:2] - algo=config.sshfs_ralgo[algo_txt][1] - for hash in config.sshfp_hash.keys(): - self.add(SSHFP(nom, hash, algo, key)) - if self.ipv4 and self.ipv6: - if nom == '@': - self.add(SSHFP("v4", hash, algo, key)) - self.add(SSHFP("v6", hash, algo, key)) - else: - self.add(SSHFP("%s.v4" % nom, hash, algo, key)) - self.add(SSHFP("%s.v6" % nom, hash, algo, key)) + try: + algo_txt, key = str(sshkey).split()[:2] + algo=config.sshfs_ralgo[algo_txt][1] + for hash in config.sshfp_hash.keys(): + self.add(SSHFP(nom, hash, algo, key)) + if self.ipv4 and self.ipv6: + if nom == '@': + self.add(SSHFP("v4", hash, algo, key)) + self.add(SSHFP("v6", hash, algo, key)) + else: + self.add(SSHFP("%s.v4" % nom, hash, algo, key)) + self.add(SSHFP("%s.v6" % nom, hash, algo, key)) + # KeyError is l'algo dans ldap n'est pas connu + # TypeError si la clef n'est pas bien en base64 + except (KeyError, TypeError): + pass def add_machine(self, machine): for host in machine['host']: