[lc_ldap] Usage de conn.get_local_machines généralisé
This commit is contained in:
parent
266cf73a0a
commit
9311f2abcf
2 changed files with 2 additions and 14 deletions
|
@ -20,14 +20,6 @@ conn = lc_ldap.shortcuts.lc_ldap_admin(user=u'sshfingerprint')
|
||||||
|
|
||||||
ssh_algo = config.sshfp_algo.keys()
|
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):
|
def ssh_keyscan(host,algo):
|
||||||
p=subprocess.Popen(["/usr/bin/ssh-keyscan", "-t", "%s" % algo,"%s" % host],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
p=subprocess.Popen(["/usr/bin/ssh-keyscan", "-t", "%s" % algo,"%s" % host],stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
ret=p.communicate()[0].split()
|
ret=p.communicate()[0].split()
|
||||||
|
@ -57,11 +49,7 @@ def ssh_keygen(algo,size):
|
||||||
print("Nouvelle clef %s générée" % key_path)
|
print("Nouvelle clef %s générée" % key_path)
|
||||||
|
|
||||||
def get_machines():
|
def get_machines():
|
||||||
filter=""
|
return conn.get_local_machines(mode='rw')
|
||||||
for ip in set(ip4_addresses()):
|
|
||||||
filter+=u'(ipHostNumber=%s)' % ip
|
|
||||||
filter = u"(|%s)" % filter
|
|
||||||
return conn.search(filter, mode='rw')
|
|
||||||
|
|
||||||
def check_keys_age(key_path,algo):
|
def check_keys_age(key_path,algo):
|
||||||
age=time.time()-os.path.getmtime(key_path)
|
age=time.time()-os.path.getmtime(key_path)
|
||||||
|
|
|
@ -150,7 +150,7 @@ class LdapCertFS(fuse.Fuse):
|
||||||
elif self.ldap_filter:
|
elif self.ldap_filter:
|
||||||
machines = conn.search("(&(%s)(mid=*))" % self.ldap_filter, sizelimit=8000)
|
machines = conn.search("(&(%s)(mid=*))" % self.ldap_filter, sizelimit=8000)
|
||||||
else:
|
else:
|
||||||
machines = get_machines()
|
machines = conn.get_local_machines()
|
||||||
|
|
||||||
for machine in machines:
|
for machine in machines:
|
||||||
if not machine.certificats():
|
if not machine.certificats():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue