X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=e27b6fab9e0dc80c78077a95e35e448f112528dd;hb=a86d975ac15e074f142c75ba5c74596be92e740d;hp=d52b80103ee0a2be970d1dccdc979984d2869ea2;hpb=57d51d7e5cc0a79bb97a55d9eaa0263a4cfc2005;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index d52b801..e27b6fa 100755 --- a/ud-generate +++ b/ud-generate @@ -202,6 +202,8 @@ def GenGroup(l,File): # Output the group file. Counter = 0; for x in GroupMap.keys(): + if GroupIDMap.has_key(x) == 0: + continue; Line = "%s:x:%u:" % (x,GroupIDMap[x]); Comma = ''; for I in GroupMap[x]: @@ -267,12 +269,12 @@ def GenMarkers(l,File): if PasswdAttrs == None: raise "No Users"; - # Write out the email address for each user + # Write out the position for each user for x in PasswdAttrs: if x[1].has_key("latitude") == 0 or x[1].has_key("longitude") == 0: continue; try: - Line = "%8s %8s \"\""%(DecDegree(x,"latitude",1),DecDegree(x,"longitude",1)); + Line = "%8s %8s \"\""%(DecDegree(GetAttr(x,"latitude"),1),DecDegree(GetAttr(x,"longitude"),1)); Line = Sanitize(Line) + "\n"; F.write(Line); except: @@ -284,6 +286,54 @@ def GenMarkers(l,File): raise; Done(File,F,Fdb); +# Generate the DNS Zone file +def GenDNS(l,File): + F = None; + Fdb = None; + try: + F = open(File + ".tmp","w"); + Fdb = None; + + # Fetch all the users + global PasswdAttrs; + if PasswdAttrs == None: + raise "No Users"; + + # Write out the zone file entry for each user + for x in PasswdAttrs: + if x[1].has_key("dnszoneentry") == 0: + continue; + try: + F.write("; %s\n"%(EmailAddress(x))); + for z in x[1]["dnszoneentry"]: + Split = string.split(string.lower(z)); + if string.lower(Split[1]) == 'in': + for y in range(0,len(Split)): + if Split[y] == "$": + Split[y] = "\n\t"; + Line = string.join(Split," ") + "\n"; + F.write(Line); + + # Write some identication information + if string.lower(Split[2]) != "cname": + Line = "%s IN TXT \"%s\"\n"%(Split[0],EmailAddress(x)); + for y in x[1]["keyfingerprint"]: + Line = Line + "%s IN TXT \"PGP %s\"\n"%(Split[0],FormatPGPKey(y)); + F.write(Line); + else: + Line = "; Err %s"%(str(Split)); + F.write(Line); + + F.write("\n"); + except: + pass; + + # Oops, something unspeakable happened. + except: + Die(F,Fdb); + raise; + Done(File,F,Fdb); + # Connect to the ldap server l = ldap.open(LDAPServer); F = open(PassDir+"/pass-"+pwd.getpwuid(posix.getuid())[0],"r"); @@ -308,7 +358,8 @@ PasswdAttrs = l.search_s(BaseDn,ldap.SCOPE_ONELEVEL,"uid=*",\ "gecos","loginshell","userpassword","shadowlastchange",\ "shadowmin","shadowmax","shadowwarning","shadowinactive", "shadowexpire","emailforward","latitude","longitude",\ - "allowedhosts","sshrsaauthkey"]); + "allowedhosts","sshrsaauthkey","dnszoneentry","cn","sn",\ + "keyfingerprint"]); # Open the control file if len(sys.argv) == 1: @@ -332,7 +383,11 @@ while(1): # Get the group list and convert any named groups to numerics GroupList = {}; + ExtraList = {}; for I in Split[2:]: + if I[0] == '[': + ExtraList[I] = None; + continue; GroupList[I] = None; if GroupIDMap.has_key(I): GroupList[str(GroupIDMap[I])] = None; @@ -348,3 +403,6 @@ while(1): GenForward(l,OutDir+"forward-alias"); GenMarkers(l,OutDir+"markers"); + if ExtraList.has_key("[DNS]"): + GenDNS(l,OutDir+"dns-zone"); +