[PATCH 1/4] dns: Log the DNS error on DNS update failure.

James Peach jpeach at apple.com
Fri May 30 17:43:01 GMT 2008


---
  source/libaddns/dnserr.h   |    2 ++
  source/libaddns/dnsutils.c |   36 ++++++++++++++++++++++++++++++++++++
  source/utils/net_ads.c     |    4 +++-
  3 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/source/libaddns/dnserr.h b/source/libaddns/dnserr.h
index 9e049ac..8859420 100644
--- a/source/libaddns/dnserr.h
+++ b/source/libaddns/dnserr.h
@@ -83,5 +83,7 @@ typedef uint32 DNS_ERROR;
   */
  #define ERROR_UNSUCCESSFUL 999

+const char * dns_errstr(DNS_ERROR err);
+
  #endif	/* _DNSERR_H */

diff --git a/source/libaddns/dnsutils.c b/source/libaddns/dnsutils.c
index 4f6593e..8201ce4 100644
--- a/source/libaddns/dnsutils.c
+++ b/source/libaddns/dnsutils.c
@@ -3,6 +3,7 @@

    Copyright (C) 2006 Krishna Ganugapati <krishnag at centeris.com>
    Copyright (C) 2006 Gerald Carter <jerry at samba.org>
+  Copyright (C) 2008 James Peach <jpeach at samba.org>

       ** NOTE! The following LGPL license applies to the libaddns
       ** library. This does NOT imply that all of Samba is released
@@ -147,3 +148,38 @@ char *dns_generate_keyname( TALLOC_CTX *mem_ctx )

  	return result;
  }
+
+/*********************************************************************
+*********************************************************************/
+
+const char * dns_errstr(DNS_ERROR err)
+{
+	if (ERR_DNS_EQUAL(err, ERROR_DNS_SUCCESS)) {
+		return "success";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_RECORD_NOT_FOUND)) {
+		return "DNS record not found";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_BAD_RESPONSE)) {
+		return "bad DNS response";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_INVALID_PARAMETER)) {
+		return "invalid DNS parameter";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_NO_MEMORY)) {
+		return "out of memory";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_INVALID_NAME_SERVER)) {
+		return "invalild name server";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_CONNECTION_FAILED)) {
+		return "connection failed";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_GSS_ERROR)) {
+		return "GSS error";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_INVALID_NAME)) {
+		return "invalid DNS name";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_INVALID_MESSAGE)) {
+		return "invalid DNS message";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_SOCKET_ERROR)) {
+		return "socket error";
+	} else if (ERR_DNS_EQUAL(err, ERROR_DNS_UPDATE_FAILED)) {
+		return "DNS update failed";
+	} else {
+		return "invalid DNS error code";
+	}
+
+}
diff --git a/source/utils/net_ads.c b/source/utils/net_ads.c
index 8053b24..96fa6ba 100644
--- a/source/utils/net_ads.c
+++ b/source/utils/net_ads.c
@@ -1018,7 +1018,7 @@ static NTSTATUS  
net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads,
  		status = ads_dns_lookup_ns( ctx, 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 "
+			DEBUG(3,("net_update_dns_internal: Failed to find name server for  
the %s "
  			 "realm\n", ads->config.realm));
  			goto done;
  		}
@@ -1034,6 +1034,8 @@ static NTSTATUS  
net_update_dns_internal(TALLOC_CTX *ctx, ADS_STRUCT *ads,

  	dns_err = DoDNSUpdate(dns_server, dnsdomain, machine_name, addrs,  
num_addrs);
  	if (!ERR_DNS_IS_OK(dns_err)) {
+		DEBUG(3,("net_update_dns_internal: DNS update failed: %s",
+			    dns_errstr(dns_err)));
  		status = NT_STATUS_UNSUCCESSFUL;
  	}

-- 
1.5.5.1




More information about the samba-technical mailing list