X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=549c7440ed20fa79bdbd09f2f2cfc5eeb8f40991;hb=c4154ed547a3875a82f554922544f6d05f80787f;hp=5523ce02880df9d81dc750f935fc9927bf41e38e;hpb=a965ddb65d40f3a1e5ef26657f46b04509d07dc8;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index 5523ce0..549c744 100755 --- a/ud-generate +++ b/ud-generate @@ -753,21 +753,26 @@ def GenDNS(File): try: F = open(File + ".tmp", "w") - global HostAttrs - - for x in HostAttrs: - if x[1].has_key("hostname") == 0 or \ - x[1].has_key("architecture") == 0 or\ - x[1].has_key("sshRSAHostKey") == 0: - continue - - if IsDebianHost.match(GetAttr(x, "hostname")) is not None: - continue - - DNSInfo = ExtractDNSInfo(x) - for Line in DNSInfo: - Line = Sanitize(Line) + "\n" - F.write(Line) +# global HostAttrs +# +# for x in HostAttrs: +# if x[1].has_key("hostname") == 0 or \ +# x[1].has_key("architecture") == 0 or\ +# x[1].has_key("sshRSAHostKey") == 0: +# continue +# +# if IsDebianHost.match(GetAttr(x, "hostname")) is not None: +# continue +# +# DNSInfo = ExtractDNSInfo(x) +# start = True +# for Line in DNSInfo: +# if start == True: +# Line = "%s.\t%s" % (GetAttr(x, "hostname"), Line) +# start = False +# else: +# Line = "\t\t\t%s" % (Line) +# F.write(Line + "\n") # Fetch all the users global PasswdAttrs @@ -819,6 +824,14 @@ def GenDNS(File): def ExtractDNSInfo(x): DNSInfo = [] + + if x[1].has_key("ipHostNumber"): + for I in x[1]["ipHostNumber"]: + if IsV6Addr.match(I) != None: + DNSInfo.append("IN\tAAAA\t%s" % (I)) + else: + DNSInfo.append("IN\tA\t%s" % (I)) + Host = GetAttr(x, "hostname") Arch = GetAttr(x, "architecture") Algorithm = None @@ -832,23 +845,16 @@ def ExtractDNSInfo(x): if Algorithm == None: continue Fingerprint = sha.new(base64.decodestring(Split[1])).hexdigest() - DNSInfo.append("%s. IN SSHFP %u 1 %s" % (Host, Algorithm, Fingerprint)) + DNSInfo.append("IN\tSSHFP\t%u 1 %s" % (Algorithm, Fingerprint)) Mach = "" if x[1].has_key("machine"): Mach = " " + GetAttr(x, "machine") - DNSInfo.append("%s. IN HINFO \"%s%s\" \"%s\"" % (Host, Arch, Mach, "Debian GNU/Linux")) - - if x[1].has_key("ipHostNumber"): - for I in x[1]["ipHostNumber"]: - if IsV6Addr.match(I) != None: - DNSInfo.append("%s. IN AAAA %s" % (Host, I)) - else: - DNSInfo.append("%s. IN A %s" % (Host, I)) + DNSInfo.append("IN\tHINFO\t\"%s%s\" \"%s\"" % (Arch, Mach, "Debian GNU/Linux")) if x[1].has_key("mXRecord"): for I in x[1]["mXRecord"]: - DNSInfo.append("%s. IN MX %s" % (Host, I)) + DNSInfo.append("IN\tMX\t%s" % (I)) return DNSInfo @@ -871,9 +877,15 @@ def GenZoneRecords(File): continue DNSInfo = ExtractDNSInfo(x) + start = True for Line in DNSInfo: - Line = Sanitize(Line) + "\n" - F.write(Line) + if start == True: + Line = "%s.\t%s" % (GetAttr(x, "hostname"), Line) + start = False + else: + Line = "\t\t\t%s" % (Line) + + F.write(Line + "\n") # Oops, something unspeakable happened. except: @@ -974,7 +986,10 @@ def GenSSHKnown(File, mode=None): for I in x[1]["sshRSAHostKey"]: if mode and mode == 'authorized_keys': - Line = 'command="rsync --server --sender -pr . /var/cache/userdir-ldap/hosts/%s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,from="%s" %s' % (Host, ",".join(HostToIP(x)), I) + hosts = HostToIP(x) + if 'sshdistAuthKeysHost' in x[1]: + hosts += x[1]['sshdistAuthKeysHost'] + Line = 'command="rsync --server --sender -pr . /var/cache/userdir-ldap/hosts/%s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,from="%s" %s' % (Host, ",".join(hosts), I) #Line = 'command="rsync --server --sender -pr . /var/cache/userdir-ldap/hosts/%s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding %s' % (Host,I) else: Line = "%s %s" %(",".join(HostNames + HostToIP(x, False)), I) @@ -1003,6 +1018,9 @@ def GenHosts(File): if IsDebianHost.match(GetAttr(x, "hostname")) is None: continue + if not 'ipHostNumber' in x[1]: + continue + addrs = x[1]["ipHostNumber"] for addr in addrs: if addr not in seen: @@ -1034,6 +1052,8 @@ Attrs = l.search_s(BaseDn, ldap.SCOPE_ONELEVEL, "gid=*",\ # Generate the SubGroupMap and GroupIDMap for x in Attrs: + if x[1].has_key("accountStatus") and x[1]['accountStatus'] == "disabled": + continue if x[1].has_key("gidNumber") == 0: continue GroupIDMap[x[1]["gid"][0]] = int(x[1]["gidNumber"][0]) @@ -1055,6 +1075,8 @@ PasswdAttrs = l.search_s(BaseDn, ldap.SCOPE_ONELEVEL, "uid=*",\ if PasswdAttrs is None: raise UDEmptyList, "No Users" +PasswdAttrs.sort(lambda x, y: cmp((GetAttr(x, "uid")).lower(), (GetAttr(y, "uid")).lower())) + # Fetch all the hosts HostAttrs = l.search_s(HostBaseDn, ldap.SCOPE_ONELEVEL, "objectClass=debianServer",\ ["hostname", "sshRSAHostKey", "purpose", "allowedGroups", "exportOptions",\