Fix blackbox tests on IPv6-only hosts.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 20 Oct 2008 08:18:02 +0000 (10:18 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 20 Oct 2008 08:18:02 +0000 (10:18 +0200)
source4/scripting/python/samba/provision.py
source4/setup/provision.zone

index 4764d0c..823d5e6 100644 (file)
@@ -959,13 +959,16 @@ def provision(setup_dir, message, session_info,
     paths = provision_paths_from_lp(lp, names.dnsdomain)
 
     if hostip is None:
-        hostip = socket.getaddrinfo(names.hostname, None, socket.AF_INET, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0]
+        try:
+            hostip = socket.getaddrinfo(names.hostname, None, socket.AF_INET, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0]
+        except socket.gaierror, (socket.EAI_NODATA, msg):
+            hostip = None
 
     if hostip6 is None:
         try:
             hostip6 = socket.getaddrinfo(names.hostname, None, socket.AF_INET6, socket.AI_CANONNAME, socket.IPPROTO_IP)[0][-1][0]
-        except socket.gaierror: 
-            pass
+        except socket.gaierror, (socket.EAI_NODATA, msg)
+            hostip6 = None
 
     if serverrole is None:
         serverrole = lp.get("server role")
@@ -1426,12 +1429,20 @@ def create_zone_file(path, setup_path, dnsdomain, domaindn,
         hostip6_base_line = ""
         hostip6_host_line = ""
 
+    if hostip is not None:
+        hostip_base_line = "            IN A    " + hostip
+        hostip_host_line = hostname + "        IN A    " + hostip
+    else:
+        hostip_base_line = ""
+        hostip_host_line = ""
+
     setup_file(setup_path("provision.zone"), path, {
             "DNSPASS_B64": b64encode(dnspass),
             "HOSTNAME": hostname,
             "DNSDOMAIN": dnsdomain,
             "REALM": realm,
-            "HOSTIP": hostip,
+            "HOSTIP_BASE_LINE": hostip_base_line,
+            "HOSTIP_HOST_LINE": hostip_host_line,
             "DOMAINGUID": domainguid,
             "DATESTRING": time.strftime("%Y%m%d%H"),
             "DEFAULTSITE": DEFAULTSITE,
index 17ae3bb..e7d600d 100644 (file)
@@ -10,10 +10,10 @@ $TTL 1W
                                 1W )            ; minimum
                        IN NS   ${HOSTNAME}
 ${HOSTIP6_BASE_LINE}
-                       IN A    ${HOSTIP}
+${HOSTIP_BASE_LINE}
 ;
 ${HOSTIP6_HOST_LINE}
-${HOSTNAME}            IN A    ${HOSTIP}
+${HOSTIP_HOST_LINE}
 gc._msdcs              IN CNAME        ${HOSTNAME}
 ${HOSTGUID}._msdcs     IN CNAME        ${HOSTNAME}
 ;