From 9311f2abcf62cc5966f62169e62fa6e2cda5ac3b Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Tue, 18 Mar 2014 22:50:19 +0100 Subject: [PATCH] =?UTF-8?q?[lc=5Fldap]=20Usage=20de=20conn.get=5Flocal=5Fm?= =?UTF-8?q?achines=20g=C3=A9n=C3=A9ralis=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gestion/gen_confs/populate_sshFingerprint.py | 14 +------------- utils/ldapcertfs.py | 2 +- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/gestion/gen_confs/populate_sshFingerprint.py b/gestion/gen_confs/populate_sshFingerprint.py index b3fb7042..aa808e8c 100755 --- a/gestion/gen_confs/populate_sshFingerprint.py +++ b/gestion/gen_confs/populate_sshFingerprint.py @@ -20,14 +20,6 @@ conn = lc_ldap.shortcuts.lc_ldap_admin(user=u'sshfingerprint') ssh_algo = config.sshfp_algo.keys() -def ip4_addresses(): - ip_list = [] - for interface in interfaces(): - if interface!='lo' and AF_INET in ifaddresses(interface).keys(): - for link in ifaddresses(interface)[AF_INET]: - ip_list.append(link['addr']) - return ip_list - def ssh_keyscan(host,algo): p=subprocess.Popen(["/usr/bin/ssh-keyscan", "-t", "%s" % algo,"%s" % host],stdout=subprocess.PIPE,stderr=subprocess.PIPE) ret=p.communicate()[0].split() @@ -57,11 +49,7 @@ def ssh_keygen(algo,size): print("Nouvelle clef %s générée" % key_path) def get_machines(): - filter="" - for ip in set(ip4_addresses()): - filter+=u'(ipHostNumber=%s)' % ip - filter = u"(|%s)" % filter - return conn.search(filter, mode='rw') + return conn.get_local_machines(mode='rw') def check_keys_age(key_path,algo): age=time.time()-os.path.getmtime(key_path) diff --git a/utils/ldapcertfs.py b/utils/ldapcertfs.py index a6fa2bc0..df86a20f 100755 --- a/utils/ldapcertfs.py +++ b/utils/ldapcertfs.py @@ -150,7 +150,7 @@ class LdapCertFS(fuse.Fuse): elif self.ldap_filter: machines = conn.search("(&(%s)(mid=*))" % self.ldap_filter, sizelimit=8000) else: - machines = get_machines() + machines = conn.get_local_machines() for machine in machines: if not machine.certificats():