From 7f00fcf5589fc0e27ddd1f78fbe9c223b26cd919 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 20 Nov 2014 11:31:29 +0100 Subject: [PATCH] addns: Remove support for dns_host_file. Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- lib/addns/dnsquery.c | 96 +++++++++++++++++++-------------- lib/addns/dnsquery.h | 7 --- lib/addns/wscript_build | 2 +- source3/libads/ldap.c | 10 ++-- source3/libsmb/dsgetdcname.c | 48 ++++++++++------- source3/libsmb/namequery.c | 21 ++++---- source3/utils/net_ads.c | 14 ++--- source3/utils/net_lookup.c | 16 +++--- source4/libcli/resolve/dns_ex.c | 2 +- 9 files changed, 122 insertions(+), 94 deletions(-) diff --git a/lib/addns/dnsquery.c b/lib/addns/dnsquery.c index 57ef8d92f4a..4e2aaf4f3be 100644 --- a/lib/addns/dnsquery.c +++ b/lib/addns/dnsquery.c @@ -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); } diff --git a/lib/addns/dnsquery.h b/lib/addns/dnsquery.h index 1491b699c25..213ed325a6e 100644 --- a/lib/addns/dnsquery.h +++ b/lib/addns/dnsquery.h @@ -25,40 +25,33 @@ /* The following definitions come from libads/dns.c */ NTSTATUS ads_dns_lookup_srv(TALLOC_CTX *ctx, - const char *dns_hosts_file, const char *name, struct dns_rr_srv **dclist, int *numdcs); 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 char *domain_guid, struct dns_rr_srv **dclist, diff --git a/lib/addns/wscript_build b/lib/addns/wscript_build index 5fac61c50fe..b1948ba35b1 100755 --- a/lib/addns/wscript_build +++ b/lib/addns/wscript_build @@ -2,6 +2,6 @@ bld.SAMBA_LIBRARY('addns', source='dnsquery.c dnsrecord.c dnsutils.c dnssock.c dnsgss.c dnsmarshall.c error.c', - public_deps='dnshostsfile samba-util gssapi ndr resolv', + public_deps='samba-util gssapi ndr resolv', private_library=True, vars=locals()) diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c index c774b445411..93d5c791bf0 100644 --- a/source3/libads/ldap.c +++ b/source3/libads/ldap.c @@ -539,7 +539,6 @@ 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(); @@ -549,7 +548,6 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads) sitename = sitename_fetch(frame, 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 @@ -558,9 +556,11 @@ ADS_STATUS ads_connect_gc(ADS_STRUCT *ads) if (sitename == NULL) done = true; - nt_status = ads_dns_query_gcs(frame, dns_hosts_file, - realm, sitename, - &gcs_list, &num_gcs); + nt_status = ads_dns_query_gcs(frame, + realm, + sitename, + &gcs_list, + &num_gcs); if (!NT_STATUS_IS_OK(nt_status)) { ads_status = ADS_ERROR_NT(nt_status); diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index 0d1570a9854..ac3bfd6c112 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -547,39 +547,49 @@ 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; char *guid_string; - dns_hosts_file = lp_parm_const_string(-1, "resolv", "host file", NULL); if (flags & DS_PDC_REQUIRED) { - status = ads_dns_query_pdc(mem_ctx, dns_hosts_file, - domain_name, &dcs, &numdcs); + status = ads_dns_query_pdc(mem_ctx, + domain_name, + &dcs, + &numdcs); } else if (flags & DS_GC_SERVER_REQUIRED) { - status = ads_dns_query_gcs(mem_ctx, dns_hosts_file, - domain_name, site_name, - &dcs, &numdcs); + status = ads_dns_query_gcs(mem_ctx, + domain_name, + site_name, + &dcs, + &numdcs); } else if (flags & DS_KDC_REQUIRED) { - status = ads_dns_query_kdcs(mem_ctx, dns_hosts_file, - domain_name, site_name, - &dcs, &numdcs); + status = ads_dns_query_kdcs(mem_ctx, + domain_name, + site_name, + &dcs, + &numdcs); } else if (flags & DS_DIRECTORY_SERVICE_REQUIRED) { - status = ads_dns_query_dcs(mem_ctx, dns_hosts_file, - domain_name, site_name, - &dcs, &numdcs); + status = ads_dns_query_dcs(mem_ctx, + domain_name, + site_name, + &dcs, + &numdcs); } else if (domain_guid) { guid_string = GUID_string(mem_ctx, domain_guid); if (!guid_string) { return NT_STATUS_NO_MEMORY; } - status = ads_dns_query_dcs_guid(mem_ctx, dns_hosts_file, - domain_name, guid_string, - &dcs, &numdcs); + status = ads_dns_query_dcs_guid(mem_ctx, + domain_name, + guid_string, + &dcs, + &numdcs); TALLOC_FREE(guid_string); } else { - status = ads_dns_query_dcs(mem_ctx, dns_hosts_file, - domain_name, site_name, - &dcs, &numdcs); + status = ads_dns_query_dcs(mem_ctx, + domain_name, + site_name, + &dcs, + &numdcs); } if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 654ca1d3499..3ee79b68a31 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -2424,7 +2424,6 @@ 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,28 +2436,32 @@ 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, dns_hosts_file, - name, &dcs, &numdcs); + status = ads_dns_query_pdc(ctx, + 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, dns_hosts_file, - name, sitename, &dcs, + status = ads_dns_query_dcs(ctx, + 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, dns_hosts_file, - name, sitename, &dcs, + status = ads_dns_query_kdcs(ctx, + name, + sitename, + &dcs, &numdcs); break; default: diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 7f3d74d7829..ba500b50b6c 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1143,7 +1143,6 @@ static NTSTATUS net_update_dns_internal(struct net_context *c, 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; @@ -1155,9 +1154,10 @@ static NTSTATUS net_update_dns_internal(struct net_context *c, } dnsdomain++; - 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); + status = ads_dns_lookup_ns(ctx, + 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 @@ -1195,8 +1195,10 @@ static NTSTATUS net_update_dns_internal(struct net_context *c, /* try again for NS servers */ - status = ads_dns_lookup_ns(ctx, dns_hosts_file, root_domain, - &nameservers, &ns_count); + status = ads_dns_lookup_ns(ctx, + root_domain, + &nameservers, + &ns_count); if ( !NT_STATUS_IS_OK(status) || (ns_count == 0)) { DEBUG(3,("net_update_dns_internal: Failed to find name server for the %s " diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index 9d61be2aa3c..0c019e6e4d4 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -106,7 +106,6 @@ 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,9 +122,11 @@ static int net_lookup_ldap(struct net_context *c, int argc, const char **argv) DEBUG(9, ("Lookup up ldap for domain %s\n", domain)); - 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); + status = ads_dns_query_dcs(ctx, + domain, + sitename, + &dcs, + &numdcs); if ( NT_STATUS_IS_OK(status) && numdcs ) { print_ldap_srvlist(dcs, numdcs); TALLOC_FREE( ctx ); @@ -159,8 +160,11 @@ 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, dns_hosts_file, domain, sitename, - &dcs, &numdcs); + status = ads_dns_query_dcs(ctx, + domain, + sitename, + &dcs, + &numdcs); if ( NT_STATUS_IS_OK(status) && numdcs ) { print_ldap_srvlist(dcs, numdcs); TALLOC_FREE( ctx ); diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c index 0935928dc2a..08b69327223 100644 --- a/source4/libcli/resolve/dns_ex.c +++ b/source4/libcli/resolve/dns_ex.c @@ -278,7 +278,7 @@ static struct dns_records_container get_srv_records(TALLOC_CTX *mem_ctx, memset(&ret, 0, sizeof(struct dns_records_container)); /* this is the blocking call we are going to lots of trouble to avoid them in the parent */ - status = ads_dns_lookup_srv(mem_ctx, NULL, name, &dclist, &count); + status = ads_dns_lookup_srv(mem_ctx, name, &dclist, &count); if (!NT_STATUS_IS_OK(status)) { return ret; } -- 2.34.1