From f2a4eeca185d40bc4f94522c82215349f1d95c73 Mon Sep 17 00:00:00 2001 From: =?utf8?q?G=C3=BCnther=20Deschner?= Date: Thu, 6 Jan 2011 16:23:54 +0100 Subject: [PATCH] s3-net: Fix bug #7690: retry DNS updates when connection to one nameserver has failed. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Initial patch from Patrik Martinsson . Guenther Autobuild-User: Günther Deschner Autobuild-Date: Thu Jan 6 17:29:11 CET 2011 on sn-devel-104 (cherry picked from commit fa1fd85eea549d2944974ddbc67e21ef9231c49b) --- source3/utils/net_ads.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 48df5647923..ac14184aa83 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -1132,7 +1132,7 @@ static NTSTATUS net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads, int num_addrs) { struct dns_rr_ns *nameservers = NULL; - int ns_count = 0; + int ns_count = 0, i; NTSTATUS status = NT_STATUS_UNSUCCESSFUL; DNS_ERROR dns_err; fstring dns_server; @@ -1197,16 +1197,31 @@ static NTSTATUS net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads, } - /* Now perform the dns update - we'll try non-secure and if we fail, - we'll follow it up with a secure update */ + for (i=0; i < ns_count; i++) { - fstrcpy( dns_server, nameservers[0].hostname ); + /* Now perform the dns update - we'll try non-secure and if we fail, + we'll follow it up with a secure update */ + + fstrcpy( dns_server, nameservers[i].hostname ); + + dns_err = DoDNSUpdate(dns_server, dnsdomain, machine_name, addrs, num_addrs); + if (ERR_DNS_IS_OK(dns_err)) { + status = NT_STATUS_OK; + goto done; + } + + if (ERR_DNS_EQUAL(dns_err, ERROR_DNS_INVALID_NAME_SERVER) || + ERR_DNS_EQUAL(dns_err, ERROR_DNS_CONNECTION_FAILED) || + ERR_DNS_EQUAL(dns_err, ERROR_DNS_SOCKET_ERROR)) { + DEBUG(1,("retrying DNS update with next nameserver after receiving %s\n", + dns_errstr(dns_err))); + continue; + } - dns_err = DoDNSUpdate(dns_server, dnsdomain, machine_name, addrs, num_addrs); - if (!ERR_DNS_IS_OK(dns_err)) { d_printf(_("DNS Update for %s failed: %s\n"), machine_name, dns_errstr(dns_err)); status = NT_STATUS_UNSUCCESSFUL; + goto done; } done: -- 2.11.4.GIT