From: Peter Palfrader Date: Wed, 14 May 2008 15:37:21 +0000 (+0200) Subject: Add IPv6-Adresses (and IPv4 in v6 notation - ::ffff:192.0.2.1) to ssh_known_hosts... X-Git-Tag: userdir-ldap-0.3.22~2 X-Git-Url: https://git.adam-barratt.org.uk/?a=commitdiff_plain;h=746a7e9fd846ce621ac16c781937d37bebc712ea;hp=bb945fb1a5ba9ddeee3fc90a477cfc49e9b53ce5;p=mirror%2Fuserdir-ldap.git Add IPv6-Adresses (and IPv4 in v6 notation - ::ffff:192.0.2.1) to ssh_known_hosts. [aba] --- diff --git a/debian/changelog b/debian/changelog index 38afa81..d937a98 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,10 @@ userdir-ldap (0.3.21+X) Xunstable; urgency=low * Add VoIP fiels to the LDAP shema and teach ud-info and ud-mailgate about it. [zobel] + * Add IPv6-Adresses (and IPv4 in v6 notation - ::ffff:192.0.2.1) to + ssh_known_hosts. [aba] - -- Peter Palfrader Wed, 14 May 2008 17:31:22 +0200 + -- Peter Palfrader Wed, 14 May 2008 17:33:47 +0200 userdir-ldap (0.3.21) unstable; urgency=low diff --git a/ud-generate b/ud-generate index b5594fe..d2f00ab 100755 --- a/ud-generate +++ b/ud-generate @@ -718,12 +718,23 @@ def GenSSHKnown(l,File): x[1].has_key("sshRSAHostKey") == 0: continue; Host = GetAttr(x,"hostname"); + HostNames = [ Host ] SHost = Host.find(".") + if SHost != None: HostNames += [Host[0:SHost]] + + IPAdressesT = None + IPAdresses = [] + # get IP adresses back as "proto adress" to distinguish between v4 and v6 + try: + IPAdressesT = set([ (a[0],a[4][0]) for a in socket.getaddrinfo(Host, None)]) + except: + if code[0] != -2: raise + for addr in IPAdressesT: + if addr[0] == socket.AF_INET: IPAdresses += [addr[1], "::ffff:"+addr[1]] + else: IPAdresses += [addr[1]] + for I in x[1]["sshRSAHostKey"]: - if SHost == None: - Line = "%s,%s %s" %(Host,socket.gethostbyname(Host),I); - else: - Line = "%s,%s,%s %s" %(Host,Host[0:SHost],socket.gethostbyname(Host),I); + Line = "%s,%s %s" %(",".join(HostNames + IPAdresses), I); Line = Sanitize(Line) + "\n"; F.write(Line); # Oops, something unspeakable happened.