]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1996. [bug] nsupdate: if a zone has been specified it should
authorMark Andrews <marka@isc.org>
Thu, 2 Mar 2006 01:57:20 +0000 (01:57 +0000)
committerMark Andrews <marka@isc.org>
Thu, 2 Mar 2006 01:57:20 +0000 (01:57 +0000)
                        appear in the output of 'show'. [RT #15797]

CHANGES
bin/nsupdate/nsupdate.c
lib/dns/include/dns/message.h
lib/dns/message.c
lib/dns/win32/libdns.def

diff --git a/CHANGES b/CHANGES
index bd3663d551e2fdbd3a98795fe6fb74ff60c0e8d1..9614aa698e44bcac0909e6a1d461dda68584d592 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+1996.  [bug]           nsupdate: if a zone has been specified it should
+                       appear in the output of 'show'. [RT #15797]
+
 1995.  [bug]           'host' was reporting multiple "is an alias" messages.
                        [RT #15702]
 
index 568dc724085ef2e68814734b899941831bef496c..f55bc6fc1a2a79b7d842065b4d4566c6d8a5dd7f 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: nsupdate.c,v 1.142 2006/01/27 02:35:14 marka Exp $ */
+/* $Id: nsupdate.c,v 1.143 2006/03/02 01:57:20 marka Exp $ */
 
 /*! \file */
 
@@ -1421,6 +1421,41 @@ evaluate_update(char *cmdline) {
        return (update_addordelete(cmdline, isdelete));
 }
 
+static void
+setzone(dns_name_t *zonename) {
+       isc_result_t result;
+       dns_name_t *name = NULL;
+       dns_rdataset_t *rdataset = NULL;
+
+       result = dns_message_firstname(updatemsg, DNS_SECTION_ZONE);
+       if (result == ISC_R_SUCCESS) {
+               dns_message_currentname(updatemsg, DNS_SECTION_ZONE, &name);
+               dns_message_removename(updatemsg, name, DNS_SECTION_ZONE);
+               for (rdataset = ISC_LIST_HEAD(name->list);
+                    rdataset != NULL;
+                    rdataset = ISC_LIST_HEAD(name->list)) {
+                       ISC_LIST_UNLINK(name->list, rdataset, link);
+                       dns_rdataset_disassociate(rdataset);
+                       dns_message_puttemprdataset(updatemsg, &rdataset);
+               }
+               dns_message_puttempname(updatemsg, &name);
+       }
+
+       if (zonename != NULL) {
+               result = dns_message_gettempname(updatemsg, &name);
+               check_result(result, "dns_message_gettempname");
+               dns_name_init(name, NULL);
+               dns_name_clone(zonename, name);
+               result = dns_message_gettemprdataset(updatemsg, &rdataset);
+               check_result(result, "dns_message_gettemprdataset");
+               dns_rdataset_makequestion(rdataset, getzoneclass(),
+                                         dns_rdatatype_soa);
+               ISC_LIST_INIT(name->list);
+               ISC_LIST_APPEND(name->list, rdataset, link);
+               dns_message_addname(updatemsg, name, DNS_SECTION_ZONE);
+       }
+}
+
 static void
 show_message(dns_message_t *msg) {
        isc_result_t result;
@@ -1428,6 +1463,9 @@ show_message(dns_message_t *msg) {
        int bufsz;
 
        ddebug("show_message()");
+
+       setzone(userzone);
+
        bufsz = INITTEXT;
        do { 
                if (bufsz > MAXTEXT) {
@@ -1653,22 +1691,11 @@ send_update(dns_name_t *zonename, isc_sockaddr_t *master,
 {
        isc_result_t result;
        dns_request_t *request = NULL;
-       dns_name_t *name = NULL;
-       dns_rdataset_t *rdataset = NULL;
        unsigned int options = 0;
 
        ddebug("send_update()");
 
-       result = dns_message_gettempname(updatemsg, &name);
-       check_result(result, "dns_message_gettempname");
-       dns_name_init(name, NULL);
-       dns_name_clone(zonename, name);
-       result = dns_message_gettemprdataset(updatemsg, &rdataset);
-       check_result(result, "dns_message_gettemprdataset");
-       dns_rdataset_makequestion(rdataset, getzoneclass(), dns_rdatatype_soa);
-       ISC_LIST_INIT(name->list);
-       ISC_LIST_APPEND(name->list, rdataset, link);
-       dns_message_addname(updatemsg, name, DNS_SECTION_ZONE);
+       setzone(zonename);
 
        if (usevc)
                options |= DNS_REQUESTOPT_TCP;
index 953b14e6137c66c250e9b0de35b4bca3d6eab853..2467ecdd64ac0edb0c23ffcc7b1ada0ebb21c183 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: message.h,v 1.119 2006/02/28 02:39:51 marka Exp $ */
+/* $Id: message.h,v 1.120 2006/03/02 01:57:20 marka Exp $ */
 
 #ifndef DNS_MESSAGE_H
 #define DNS_MESSAGE_H 1
@@ -769,6 +769,25 @@ dns_message_addname(dns_message_t *msg, dns_name_t *name,
  *\li  'section' be a named section.
  */
 
+void
+dns_message_removename(dns_message_t *msg, dns_name_t *name,
+                       dns_section_t section);
+/*%<
+ * Remove a existing name from a given section.
+ *
+ * It is the caller's responsibility to ensure the name is part of the
+ * given section.
+ *
+ * Requires:
+ *
+ *\li  'msg' be valid, and be a renderable message.
+ *
+ *\li  'name' be a valid absolute name.
+ *
+ *\li  'section' be a named section.
+ */
+
+
 /*
  * LOANOUT FUNCTIONS
  *
index e518b35e7040303b653b7872d1bab44b1a8053bc..27f2109f26e3a34e44e45784dbbfd9a37800f857 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: message.c,v 1.231 2006/02/28 02:39:51 marka Exp $ */
+/* $Id: message.c,v 1.232 2006/03/02 01:57:20 marka Exp $ */
 
 /*! \file */
 
@@ -2284,6 +2284,18 @@ dns_message_addname(dns_message_t *msg, dns_name_t *name,
        ISC_LIST_APPEND(msg->sections[section], name, link);
 }
 
+void
+dns_message_removename(dns_message_t *msg, dns_name_t *name,
+                      dns_section_t section)
+{
+       REQUIRE(msg != NULL);
+       REQUIRE(msg->from_to_wire == DNS_MESSAGE_INTENTRENDER);
+       REQUIRE(name != NULL);
+       REQUIRE(VALID_NAMED_SECTION(section));
+
+       ISC_LIST_UNLINK(msg->sections[section], name, link);
+}
+
 isc_result_t
 dns_message_gettempname(dns_message_t *msg, dns_name_t **item) {
        REQUIRE(DNS_MESSAGE_VALID(msg));
index 2a85e2070718d541f2714d179be863987db0cd65..193d5543fda91e5ec36ee0158e4f0c4ca89750af 100644 (file)
@@ -276,6 +276,7 @@ dns_message_puttemprdata
 dns_message_puttemprdatalist
 dns_message_puttemprdataset
 dns_message_rechecksig
+dns_message_removename
 dns_message_renderbegin
 dns_message_renderchangebuffer
 dns_message_renderend