Fixed zone generation
[mirror/userdir-ldap.git] / ud-generate
index d556f8b..b20e6bb 100755 (executable)
@@ -10,6 +10,8 @@ GroupIDMap = {};
 Allowed = None;
 CurrentHost = "";
 
+EmailCheck = re.compile("^([^ <>@]+@[^ ,<>@]+)?$");
+
 def Sanitize(Str):
   return string.translate(Str,string.maketrans("\n\r\t","$$$"));
 
@@ -254,6 +256,9 @@ def GenForward(l,File):
       if len(GetAttr(x,"emailforward")) > 200:
          continue;
 
+      # Check the forwarding address
+      if EmailCheck.match(GetAttr(x,"emailforward")) == None:
+         continue;
       Line = "%s: %s" % (GetAttr(x,"uid"),GetAttr(x,"emailforward"));
       Line = Sanitize(Line) + "\n";
       F.write(Line);
@@ -286,6 +291,10 @@ def GenAllForward(l,File):
       if len(Forward) > 200:
          continue;
 
+      # Check the forwarding address
+      if EmailCheck.match(Forward) == None:
+         continue;
+        
       User = GetAttr(x,"uid");
       Fdb.write("+%d,%d:%s->%s\n"%(len(User),len(Forward),User,Forward));
    Fdb.write("\n");
@@ -398,7 +407,7 @@ def GenDNS(l,File):
                F.write(Line);
               
               # Write some identication information
-               if string.lower(Split[2]) != "cname":
+               if string.lower(Split[2]) == "a":
                  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));