From f27eae9cfeb5b6c3c38ead6a7a0b1dd36bba691d Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Thu, 2 Mar 2006 01:57:20 +0000 Subject: [PATCH] 1996. [bug] nsupdate: if a zone has been specified it should appear in the output of 'show'. [RT #15797] --- CHANGES | 3 ++ bin/nsupdate/nsupdate.c | 53 ++++++++++++++++++++++++++--------- lib/dns/include/dns/message.h | 21 +++++++++++++- lib/dns/message.c | 14 ++++++++- lib/dns/win32/libdns.def | 1 + 5 files changed, 77 insertions(+), 15 deletions(-) diff --git a/CHANGES b/CHANGES index bd3663d551..9614aa698e 100644 --- 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] diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 568dc72408..f55bc6fc1a 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -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; diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 953b14e613..2467ecdd64 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -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 * diff --git a/lib/dns/message.c b/lib/dns/message.c index e518b35e70..27f2109f26 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -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)); diff --git a/lib/dns/win32/libdns.def b/lib/dns/win32/libdns.def index 2a85e20707..193d5543fd 100644 --- a/lib/dns/win32/libdns.def +++ b/lib/dns/win32/libdns.def @@ -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