summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/libads/dns.c41
-rw-r--r--source3/libads/dns.h6
-rw-r--r--source3/libads/ldap.c5
-rw-r--r--source3/libsmb/dsgetdcname.c23
-rw-r--r--source3/libsmb/namequery.c11
-rw-r--r--source3/utils/net_ads.c8
-rw-r--r--source3/utils/net_lookup.c8
7 files changed, 69 insertions, 33 deletions
diff --git a/source3/libads/dns.c b/source3/libads/dns.c
index ae9c914e22..f62837e0fe 100644
--- a/source3/libads/dns.c
+++ b/source3/libads/dns.c
@@ -389,6 +389,7 @@ static NTSTATUS dns_send_req( TALLOC_CTX *ctx, const char *name, int q_type,
*********************************************************************/
static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx,
+ const char *dns_hosts_file,
const char *name,
struct dns_rr_srv **dclist,
int *numdcs)
@@ -401,13 +402,11 @@ static NTSTATUS ads_dns_lookup_srv( TALLOC_CTX *ctx,
int rrnum;
int idx = 0;
NTSTATUS status;
- const char *dns_hosts_file;
if ( !ctx || !name || !dclist ) {
return NT_STATUS_INVALID_PARAMETER;
}
- dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
if (dns_hosts_file) {
return resolve_dns_hosts_file_as_dns_rr(dns_hosts_file,
name, true, ctx,
@@ -586,6 +585,7 @@ static 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)
@@ -598,13 +598,11 @@ NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
int rrnum;
int idx = 0;
NTSTATUS status;
- const char *dns_hosts_file;
if ( !ctx || !dnsdomain || !nslist ) {
return NT_STATUS_INVALID_PARAMETER;
}
- dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
if (dns_hosts_file) {
DEBUG(1, ("NO 'NS' lookup available when using resolv:host file"));
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
@@ -748,6 +746,7 @@ 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 +766,7 @@ static NTSTATUS ads_dns_query_internal(TALLOC_CTX *ctx,
if (!name) {
return NT_STATUS_NO_MEMORY;
}
- return ads_dns_lookup_srv( ctx, name, dclist, numdcs );
+ return ads_dns_lookup_srv(ctx, dns_hosts_file, name, dclist, numdcs);
}
/********************************************************************
@@ -775,6 +774,7 @@ 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,
@@ -782,8 +782,8 @@ NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
{
NTSTATUS status;
- status = ads_dns_query_internal(ctx, "_ldap", "dc", realm, sitename,
- dclist, numdcs);
+ status = ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", "dc",
+ realm, sitename, dclist, numdcs);
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_REFUSED)) {
@@ -794,7 +794,8 @@ 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, "_ldap", "dc", realm,
+ status = ads_dns_query_internal(ctx, dns_hosts_file,
+ "_ldap", "dc", realm,
NULL, dclist, numdcs);
}
return status;
@@ -805,6 +806,7 @@ 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,
@@ -812,8 +814,8 @@ NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
{
NTSTATUS status;
- status = ads_dns_query_internal(ctx, "_ldap", "gc", realm, sitename,
- dclist, numdcs);
+ status = ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", "gc",
+ realm, sitename, dclist, numdcs);
if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_REFUSED)) {
@@ -824,7 +826,8 @@ 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, "_ldap", "gc", realm,
+ status = ads_dns_query_internal(ctx, dns_hosts_file,
+ "_ldap", "gc", realm,
NULL, dclist, numdcs);
}
return status;
@@ -837,6 +840,7 @@ 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,
@@ -844,7 +848,7 @@ NTSTATUS ads_dns_query_kdcs(TALLOC_CTX *ctx,
{
NTSTATUS status;
- status = ads_dns_query_internal(ctx, "_kerberos", "dc",
+ status = ads_dns_query_internal(ctx, dns_hosts_file, "_kerberos", "dc",
dns_forest_name, sitename, dclist,
numdcs);
@@ -857,7 +861,8 @@ 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, "_kerberos", "dc",
+ status = ads_dns_query_internal(ctx, dns_hosts_file,
+ "_kerberos", "dc",
dns_forest_name, NULL,
dclist, numdcs);
}
@@ -869,12 +874,13 @@ 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, "_ldap", "pdc", dns_domain_name,
- NULL, dclist, numdcs);
+ return ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", "pdc",
+ dns_domain_name, NULL, dclist, numdcs);
}
/********************************************************************
@@ -882,6 +888,7 @@ 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 struct GUID *domain_guid,
struct dns_rr_srv **dclist,
@@ -904,6 +911,6 @@ NTSTATUS ads_dns_query_dcs_guid(TALLOC_CTX *ctx,
}
TALLOC_FREE(guid_string);
- return ads_dns_query_internal(ctx, "_ldap", domains, dns_forest_name,
- NULL, dclist, numdcs);
+ return ads_dns_query_internal(ctx, dns_hosts_file, "_ldap", domains,
+ dns_forest_name, NULL, dclist, numdcs);
}
diff --git a/source3/libads/dns.h b/source3/libads/dns.h
index f53153ba26..d57239d20c 100644
--- a/source3/libads/dns.h
+++ b/source3/libads/dns.h
@@ -25,29 +25,35 @@
/* The following definitions come from libads/dns.c */
NTSTATUS ads_dns_lookup_ns(TALLOC_CTX *ctx,
+ const char *dns_hosts_file,
const char *dnsdomain,
struct dns_rr_ns **nslist,
int *numns);
NTSTATUS ads_dns_query_dcs(TALLOC_CTX *ctx,
+ const char *dns_hosts_file,
const char *realm,
const char *sitename,
struct dns_rr_srv **dclist,
int *numdcs );
NTSTATUS ads_dns_query_gcs(TALLOC_CTX *ctx,
+ const char *dns_hosts_file,
const char *realm,
const char *sitename,
struct dns_rr_srv **dclist,
int *numdcs );
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,
int *numdcs );
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 );
NTSTATUS ads_dns_query_dcs_guid(TALLOC_CTX *ctx,
+ const char *dns_hosts_file,
const char *dns_forest_name,
const struct GUID *domain_guid,
struct dns_rr_srv **dclist,
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index 70dad2f496..23b655f401 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -553,6 +553,7 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads)
int i;
bool done = false;
char *sitename = NULL;
+ const char *dns_hosts_file;
if (!realm)
realm = lp_realm();
@@ -562,6 +563,7 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads)
sitename = sitename_fetch(realm);
}
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
do {
/* We try once with a sitename and once without
(unless we don't have a sitename and then we're
@@ -570,7 +572,8 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads)
if (sitename == NULL)
done = true;
- nt_status = ads_dns_query_gcs(frame, realm, sitename,
+ nt_status = ads_dns_query_gcs(frame, dns_hosts_file,
+ realm, sitename,
&gcs_list, &num_gcs);
SAFE_FREE(sitename);
diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c
index 05be272450..a690ab49c1 100644
--- a/source3/libsmb/dsgetdcname.c
+++ b/source3/libsmb/dsgetdcname.c
@@ -546,24 +546,31 @@ static NTSTATUS discover_dc_dns(TALLOC_CTX *mem_ctx,
int numaddrs = 0;
struct ip_service_name *dclist = NULL;
int count = 0;
+ const char *dns_hosts_file;
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
if (flags & DS_PDC_REQUIRED) {
- status = ads_dns_query_pdc(mem_ctx, domain_name,
- &dcs, &numdcs);
+ status = ads_dns_query_pdc(mem_ctx, dns_hosts_file,
+ domain_name, &dcs, &numdcs);
} else if (flags & DS_GC_SERVER_REQUIRED) {
- status = ads_dns_query_gcs(mem_ctx, domain_name, site_name,
+ status = ads_dns_query_gcs(mem_ctx, dns_hosts_file,
+ domain_name, site_name,
&dcs, &numdcs);
} else if (flags & DS_KDC_REQUIRED) {
- status = ads_dns_query_kdcs(mem_ctx, domain_name, site_name,
+ status = ads_dns_query_kdcs(mem_ctx, dns_hosts_file,
+ domain_name, site_name,
&dcs, &numdcs);
} else if (flags & DS_DIRECTORY_SERVICE_REQUIRED) {
- status = ads_dns_query_dcs(mem_ctx, domain_name, site_name,
+ status = ads_dns_query_dcs(mem_ctx, dns_hosts_file,
+ domain_name, site_name,
&dcs, &numdcs);
} else if (domain_guid) {
- status = ads_dns_query_dcs_guid(mem_ctx, domain_name,
- domain_guid, &dcs, &numdcs);
+ status = ads_dns_query_dcs_guid(mem_ctx, dns_hosts_file,
+ domain_name, domain_guid,
+ &dcs, &numdcs);
} else {
- status = ads_dns_query_dcs(mem_ctx, domain_name, site_name,
+ status = ads_dns_query_dcs(mem_ctx, dns_hosts_file,
+ domain_name, site_name,
&dcs, &numdcs);
}
diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c
index 8934d85243..417464c17e 100644
--- a/source3/libsmb/namequery.c
+++ b/source3/libsmb/namequery.c
@@ -2424,6 +2424,7 @@ static NTSTATUS resolve_ads(const char *name,
struct dns_rr_srv *dcs = NULL;
int numdcs = 0;
int numaddrs = 0;
+ const char *dns_hosts_file;
if ((name_type != 0x1c) && (name_type != KDC_NAME_TYPE) &&
(name_type != 0x1b)) {
@@ -2437,23 +2438,27 @@ static NTSTATUS resolve_ads(const char *name,
/* The DNS code needs fixing to find IPv6 addresses... JRA. */
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
switch (name_type) {
case 0x1b:
DEBUG(5,("resolve_ads: Attempting to resolve "
"PDC for %s using DNS\n", name));
- status = ads_dns_query_pdc(ctx, name, &dcs, &numdcs);
+ status = ads_dns_query_pdc(ctx, dns_hosts_file,
+ name, &dcs, &numdcs);
break;
case 0x1c:
DEBUG(5,("resolve_ads: Attempting to resolve "
"DCs for %s using DNS\n", name));
- status = ads_dns_query_dcs(ctx, name, sitename, &dcs,
+ status = ads_dns_query_dcs(ctx, dns_hosts_file,
+ name, sitename, &dcs,
&numdcs);
break;
case KDC_NAME_TYPE:
DEBUG(5,("resolve_ads: Attempting to resolve "
"KDCs for %s using DNS\n", name));
- status = ads_dns_query_kdcs(ctx, name, sitename, &dcs,
+ status = ads_dns_query_kdcs(ctx, dns_hosts_file,
+ name, sitename, &dcs,
&numdcs);
break;
default:
diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c
index 0ccb328527..22f235f059 100644
--- a/source3/utils/net_ads.c
+++ b/source3/utils/net_ads.c
@@ -1137,6 +1137,7 @@ static NTSTATUS net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads,
NTSTATUS status = NT_STATUS_UNSUCCESSFUL;
DNS_ERROR dns_err;
fstring dns_server;
+ const char *dns_hosts_file;
const char *dnsdomain = NULL;
char *root_domain = NULL;
@@ -1148,7 +1149,9 @@ static NTSTATUS net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads,
}
dnsdomain++;
- status = ads_dns_lookup_ns( ctx, dnsdomain, &nameservers, &ns_count );
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
+ status = ads_dns_lookup_ns(ctx, dns_hosts_file,
+ dnsdomain, &nameservers, &ns_count);
if ( !NT_STATUS_IS_OK(status) || (ns_count == 0)) {
/* Child domains often do not have NS records. Look
for the NS record for the forest root domain
@@ -1186,7 +1189,8 @@ static NTSTATUS net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads,
/* try again for NS servers */
- status = ads_dns_lookup_ns( ctx, root_domain, &nameservers, &ns_count );
+ status = ads_dns_lookup_ns(ctx, dns_hosts_file, root_domain,
+ &nameservers, &ns_count);
if ( !NT_STATUS_IS_OK(status) || (ns_count == 0)) {
DEBUG(3,("net_ads_join: Failed to find name server for the %s "
diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c
index 7b2a214575..7f204745b1 100644
--- a/source3/utils/net_lookup.c
+++ b/source3/utils/net_lookup.c
@@ -106,6 +106,7 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
NTSTATUS status;
int ret;
char h_name[MAX_DNS_NAME_LENGTH];
+ const char *dns_hosts_file;
if (argc > 0)
domain = argv[0];
@@ -123,7 +124,9 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
DEBUG(9, ("Lookup up ldap for domain %s\n", domain));
- status = ads_dns_query_dcs( ctx, domain, sitename, &dcs, &numdcs );
+ dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL);
+ status = ads_dns_query_dcs(ctx, dns_hosts_file, domain, sitename,
+ &dcs, &numdcs);
if ( NT_STATUS_IS_OK(status) && numdcs ) {
print_ldap_srvlist(dcs, numdcs);
TALLOC_FREE( ctx );
@@ -161,7 +164,8 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv)
DEBUG(9, ("Looking up ldap for domain %s\n", domain));
- status = ads_dns_query_dcs( ctx, domain, sitename, &dcs, &numdcs );
+ status = ads_dns_query_dcs(ctx, dns_hosts_file, domain, sitename,
+ &dcs, &numdcs);
if ( NT_STATUS_IS_OK(status) && numdcs ) {
print_ldap_srvlist(dcs, numdcs);
TALLOC_FREE( ctx );