Don't let Python abort unconditionally if a host wasn't found.
[mirror/userdir-ldap.git] / ud-generate
index 4a0fd51..ba282b9 100755 (executable)
@@ -408,6 +408,10 @@ def GenDNS(l,File,HomePrefix):
    for x in PasswdAttrs:
       if x[1].has_key("dnsZoneEntry") == 0:
          continue;
+
+      # If the account has no PGP key, do not write it
+      if x[1].has_key("keyFingerPrint") == 0:
+         continue;
       try:
          F.write("; %s\n"%(EmailAddress(x)));
          for z in x[1]["dnsZoneEntry"]:
@@ -459,6 +463,10 @@ def GenBSMTP(l,File,HomePrefix):
    for x in PasswdAttrs:
       if x[1].has_key("dnsZoneEntry") == 0:
          continue;
+
+      # If the account has no PGP key, do not write it
+      if x[1].has_key("keyFingerPrint") == 0:
+         continue;
       try:
          for z in x[1]["dnsZoneEntry"]:
             Split = string.split(string.lower(z));
@@ -536,8 +544,11 @@ def GenHosts(l,File):
       if x[1].has_key("hostname") == 0:
          continue;
       Host = GetAttr(x,"hostname");
-      Addr = socket.gethostbyname(Host);
-      F.write(Addr + "\n");
+      try:
+        Addr = socket.gethostbyname(Host);
+        F.write(Addr + "\n");
+      except:
+        pass
   # Oops, something unspeakable happened.
   except:
    Die(File,F,None);