X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=ud-generate;h=792383e870750ef58c8b244f366ce38e17c36c61;hb=2525bf73603cb6487cfcea096e2dc347ad360394;hp=a145b68d3623a6ef42c68a1eb5600781da5191e6;hpb=ee3eb0677056b25df70d8fe93a74cb2e6c0e38f5;p=mirror%2Fuserdir-ldap.git diff --git a/ud-generate b/ud-generate index a145b68..792383e 100755 --- a/ud-generate +++ b/ud-generate @@ -2,7 +2,7 @@ # -*- mode: python -*- # Generates passwd, shadow and group files from the ldap directory. -import string, re, time, ldap, getopt, sys, os, posix, pwd; +import string, re, time, ldap, getopt, sys, os, pwd; from userdir_ldap import *; PasswdAttrs = None; @@ -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]: @@ -272,7 +274,7 @@ def GenMarkers(l,File): 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: @@ -305,12 +307,23 @@ def GenDNS(l,File): F.write("; %s\n"%(EmailAddress(x))); for z in x[1]["dnszoneentry"]: Split = string.split(string.lower(z)); - for y in range(0,len(Split)): - if Split[y] == "$": - Split[y] = "\n\t"; - - Line = string.join(Split," ") + "\n"; - F.write(Line); + 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; @@ -323,7 +336,7 @@ def GenDNS(l,File): # Connect to the ldap server l = ldap.open(LDAPServer); -F = open(PassDir+"/pass-"+pwd.getpwuid(posix.getuid())[0],"r"); +F = open(PassDir+"/pass-"+pwd.getpwuid(os.getuid())[0],"r"); Pass = string.split(string.strip(F.readline())," "); F.close(); l.simple_bind_s("uid="+Pass[0]+","+BaseDn,Pass[1]); @@ -345,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","dnszoneentry","cn","sn"]); + "allowedhosts","sshrsaauthkey","dnszoneentry","cn","sn",\ + "keyfingerprint"]); # Open the control file if len(sys.argv) == 1: