talloc: use the system pytalloc-util for python3 as well
[sfrench/samba-autobuild/.git] / lib / addns / dnsquery.c
index 4b45722471838d719f84840a4fc1eea1822070d8..4e2aaf4f3be5f1b1bc7bdc17015e1abfc4e5977a 100644 (file)
@@ -316,7 +316,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
              NT_STATUS_EQUAL(last_dns_status,NT_STATUS_CONNECTION_REFUSED)) &&
             (last_dns_check+DNS_FAILED_WAITTIME) > now )
        {
-               DEBUG(10,("last_dns_check: Returning cached status (%s)\n",
+               DEBUG(10,("dns_send_req: last dns check returning cached status (%s)\n",
                          nt_errstr(last_dns_status) ));
                return last_dns_status;
        }
@@ -331,7 +331,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
                if (buf_len) {
                        if ((buffer = talloc_array(ctx, uint8_t, buf_len))
                                        == NULL ) {
-                               DEBUG(0,("ads_dns_lookup_srv: "
+                               DEBUG(0,("dns_send_req: "
                                        "talloc() failed!\n"));
                                last_dns_status = NT_STATUS_NO_MEMORY;
                                last_dns_check = time_mono(NULL);
@@ -341,7 +341,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
 
                if ((resp_len = res_query(name, C_IN, q_type, buffer, buf_len))
                                < 0 ) {
-                       DEBUG(3,("ads_dns_lookup_srv: "
+                       DEBUG(3,("dns_send_req: "
                                "Failed to resolve %s (%s)\n",
                                name, strerror(errno)));
                        TALLOC_FREE( buffer );
@@ -390,7 +390,6 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
 *********************************************************************/
 
 NTSTATUS ads_dns_lookup_srv(TALLOC_CTX *ctx,
-                               const char *dns_hosts_file,
                                const char *name,
                                struct dns_rr_srv **dclist,
                                int *numdcs)
@@ -408,12 +407,6 @@ NTSTATUS ads_dns_lookup_srv(TALLOC_CTX *ctx,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (dns_hosts_file) {
-               return resolve_dns_hosts_file_as_dns_rr(dns_hosts_file,
-                                                       name, true, ctx,
-                                                       dclist, numdcs);
-       }
-
        /* Send the request.  May have to loop several times in case
           of large replies */
 
@@ -586,7 +579,6 @@ NTSTATUS ads_dns_lookup_srv(TALLOC_CTX *ctx,
 *********************************************************************/
 
 NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
-                               const char *dns_hosts_file,
                                const char *dnsdomain,
                                struct dns_rr_ns **nslist,
                                int *numns)
@@ -604,11 +596,6 @@ NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (dns_hosts_file) {
-               DEBUG(1, ("NO 'NS' lookup available when using resolv:host file"));
-               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-       }
-
        /* Send the request.  May have to loop several times in case
           of large replies */
 
@@ -747,7 +734,6 @@ NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
 ********************************************************************/
 
 static NTSTATUS ads_dns_query_internal(TALLOC_CTX *ctx,
-                                      const char *dns_hosts_file,
                                       const char *servicename,
                                       const char *dc_pdc_gc_domains,
                                       const char *realm,
@@ -767,7 +753,7 @@ static NTSTATUS ads_dns_query_internal(TALLOC_CTX *ctx,
        if (!name) {
                return NT_STATUS_NO_MEMORY;
        }
-       return ads_dns_lookup_srv(ctx, dns_hosts_file, name, dclist, numdcs);
+       return ads_dns_lookup_srv(ctx, name, dclist, numdcs);
 }
 
 /********************************************************************
@@ -775,7 +761,6 @@ static NTSTATUS ads_dns_query_internal(TALLOC_CTX *ctx,
 ********************************************************************/
 
 NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
-                          const char *dns_hosts_file,
                           const char *realm,
                           const char *sitename,
                           struct dns_rr_srv **dclist,
@@ -783,8 +768,13 @@ NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
 {
        NTSTATUS status;
 
-       status = ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", "dc",
-                                       realm, sitename, dclist, numdcs);
+       status = ads_dns_query_internal(ctx,
+                                       "_ldap",
+                                       "dc",
+                                       realm,
+                                       sitename,
+                                       dclist,
+                                       numdcs);
 
        if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
            NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_REFUSED)) {
@@ -795,9 +785,13 @@ NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
            ((!NT_STATUS_IS_OK(status)) ||
             (NT_STATUS_IS_OK(status) && (numdcs == 0)))) {
                /* Sitename DNS query may have failed. Try without. */
-               status = ads_dns_query_internal(ctx, dns_hosts_file,
-                                               "_ldap", "dc", realm,
-                                               NULL, dclist, numdcs);
+               status = ads_dns_query_internal(ctx,
+                                               "_ldap",
+                                               "dc",
+                                               realm,
+                                               NULL,
+                                               dclist,
+                                               numdcs);
        }
        return status;
 }
@@ -807,7 +801,6 @@ NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
 ********************************************************************/
 
 NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
-                          const char *dns_hosts_file,
                           const char *realm,
                           const char *sitename,
                           struct dns_rr_srv **dclist,
@@ -815,8 +808,13 @@ NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
 {
        NTSTATUS status;
 
-       status = ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", "gc",
-                                       realm, sitename, dclist, numdcs);
+       status = ads_dns_query_internal(ctx,
+                                       "_ldap",
+                                       "gc",
+                                       realm,
+                                       sitename,
+                                       dclist,
+                                       numdcs);
 
        if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
            NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_REFUSED)) {
@@ -827,9 +825,13 @@ NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
            ((!NT_STATUS_IS_OK(status)) ||
             (NT_STATUS_IS_OK(status) && (numdcs == 0)))) {
                /* Sitename DNS query may have failed. Try without. */
-               status = ads_dns_query_internal(ctx, dns_hosts_file,
-                                               "_ldap", "gc", realm,
-                                               NULL, dclist, numdcs);
+               status = ads_dns_query_internal(ctx,
+                                               "_ldap",
+                                               "gc",
+                                               realm,
+                                               NULL,
+                                               dclist,
+                                               numdcs);
        }
        return status;
 }
@@ -841,7 +843,6 @@ NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
 ********************************************************************/
 
 NTSTATUS ads_dns_query_kdcs(TALLOC_CTX *ctx,
-                           const char *dns_hosts_file,
                            const char *dns_forest_name,
                            const char *sitename,
                            struct dns_rr_srv **dclist,
@@ -849,8 +850,12 @@ NTSTATUS ads_dns_query_kdcs(TALLOC_CTX *ctx,
 {
        NTSTATUS status;
 
-       status = ads_dns_query_internal(ctx, dns_hosts_file, "_kerberos", "dc",
-                                       dns_forest_name, sitename, dclist,
+       status = ads_dns_query_internal(ctx,
+                                       "_kerberos",
+                                       "dc",
+                                       dns_forest_name,
+                                       sitename,
+                                       dclist,
                                        numdcs);
 
        if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
@@ -862,10 +867,13 @@ NTSTATUS ads_dns_query_kdcs(TALLOC_CTX *ctx,
            ((!NT_STATUS_IS_OK(status)) ||
             (NT_STATUS_IS_OK(status) && (numdcs == 0)))) {
                /* Sitename DNS query may have failed. Try without. */
-               status = ads_dns_query_internal(ctx, dns_hosts_file,
-                                               "_kerberos", "dc",
-                                               dns_forest_name, NULL,
-                                               dclist, numdcs);
+               status = ads_dns_query_internal(ctx,
+                                               "_kerberos",
+                                               "dc",
+                                               dns_forest_name,
+                                               NULL,
+                                               dclist,
+                                               numdcs);
        }
        return status;
 }
@@ -875,13 +883,17 @@ NTSTATUS ads_dns_query_kdcs(TALLOC_CTX *ctx,
 ********************************************************************/
 
 NTSTATUS ads_dns_query_pdc(TALLOC_CTX *ctx,
-                          const char *dns_hosts_file,
                           const char *dns_domain_name,
                           struct dns_rr_srv **dclist,
                           int *numdcs )
 {
-       return ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", "pdc",
-                                     dns_domain_name, NULL, dclist, numdcs);
+       return ads_dns_query_internal(ctx,
+                                     "_ldap",
+                                     "pdc",
+                                     dns_domain_name,
+                                     NULL,
+                                     dclist,
+                                     numdcs);
 }
 
 /********************************************************************
@@ -889,7 +901,6 @@ NTSTATUS ads_dns_query_pdc(TALLOC_CTX *ctx,
 ********************************************************************/
 
 NTSTATUS ads_dns_query_dcs_guid(TALLOC_CTX *ctx,
-                               const char *dns_hosts_file,
                                const char *dns_forest_name,
                                const char *domain_guid,
                                struct dns_rr_srv **dclist,
@@ -905,6 +916,11 @@ NTSTATUS ads_dns_query_dcs_guid(TALLOC_CTX *ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
-       return ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", domains,
-                                     dns_forest_name, NULL, dclist, numdcs);
+       return ads_dns_query_internal(ctx,
+                                     "_ldap",
+                                     domains,
+                                     dns_forest_name,
+                                     NULL,
+                                     dclist,
+                                     numdcs);
 }