The Samba-Bugzilla – Attachment 8936 Details for
Bug 9559
Only initial signed DNS update for a host works
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Correctly delete empty dnsNode objects
0001-dns-Delete-dnsNode-objects-when-they-are-empty.patch (text/plain), 5.44 KB, created by
Kai Blin
on 2013-06-01 09:44:12 UTC
(
hide
)
Description:
Correctly delete empty dnsNode objects
Filename:
MIME Type:
Creator:
Kai Blin
Created:
2013-06-01 09:44:12 UTC
Size:
5.44 KB
patch
obsolete
>From 9f0f90921e481c79d284a56e6bad27e23afc2a22 Mon Sep 17 00:00:00 2001 >From: Kai Blin <kai@samba.org> >Date: Sat, 1 Jun 2013 10:18:25 +0200 >Subject: [PATCH] dns: Delete dnsNode objects when they are empty >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >If an update leaves the dnsNode without any entries, the dnsNode object >should be deleted. Thanks to Günter Kukkukk for his excellent debugging >work on this one. > >This should fix bug #9559 > >Signed-off-by: Kai Blin <kai@samba.org> >--- > python/samba/tests/dns.py | 117 +++++++++++++++++++++++++++++++++++++++++ > source4/dns_server/dns_utils.c | 8 ++- > 2 files changed, 124 insertions(+), 1 deletion(-) > >diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py >index a29025d..629d3fe 100644 >--- a/python/samba/tests/dns.py >+++ b/python/samba/tests/dns.py >@@ -510,6 +510,123 @@ class TestDNSUpdates(DNSTest): > response = self.dns_transaction_udp(p) > self.assert_dns_rcode_equals(response, dns.DNS_RCODE_NXDOMAIN) > >+ def test_readd_record(self): >+ "Test if adding, deleting and then readding a records works" >+ >+ NAME = "readdrec.%s" % self.get_dns_domain() >+ >+ # Create the record >+ p = self.make_name_packet(dns.DNS_OPCODE_UPDATE) >+ updates = [] >+ >+ name = self.get_dns_domain() >+ >+ u = self.make_name_question(name, dns.DNS_QTYPE_SOA, dns.DNS_QCLASS_IN) >+ updates.append(u) >+ self.finish_name_packet(p, updates) >+ >+ updates = [] >+ r = dns.res_rec() >+ r.name = NAME >+ r.rr_type = dns.DNS_QTYPE_TXT >+ r.rr_class = dns.DNS_QCLASS_IN >+ r.ttl = 900 >+ r.length = 0xffff >+ rdata = dns.txt_record() >+ rdata.txt = '"This is a test"' >+ r.rdata = rdata >+ updates.append(r) >+ p.nscount = len(updates) >+ p.nsrecs = updates >+ >+ response = self.dns_transaction_udp(p) >+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK) >+ >+ # Now check the record is around >+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY) >+ questions = [] >+ q = self.make_name_question(NAME, dns.DNS_QTYPE_TXT, dns.DNS_QCLASS_IN) >+ questions.append(q) >+ >+ self.finish_name_packet(p, questions) >+ response = self.dns_transaction_udp(p) >+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK) >+ >+ # Now delete the record >+ p = self.make_name_packet(dns.DNS_OPCODE_UPDATE) >+ updates = [] >+ >+ name = self.get_dns_domain() >+ >+ u = self.make_name_question(name, dns.DNS_QTYPE_SOA, dns.DNS_QCLASS_IN) >+ updates.append(u) >+ self.finish_name_packet(p, updates) >+ >+ updates = [] >+ r = dns.res_rec() >+ r.name = NAME >+ r.rr_type = dns.DNS_QTYPE_TXT >+ r.rr_class = dns.DNS_QCLASS_NONE >+ r.ttl = 0 >+ r.length = 0xffff >+ rdata = dns.txt_record() >+ rdata.txt = '"This is a test"' >+ r.rdata = rdata >+ updates.append(r) >+ p.nscount = len(updates) >+ p.nsrecs = updates >+ >+ response = self.dns_transaction_udp(p) >+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK) >+ >+ # check it's gone >+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY) >+ questions = [] >+ >+ q = self.make_name_question(NAME, dns.DNS_QTYPE_TXT, dns.DNS_QCLASS_IN) >+ questions.append(q) >+ >+ self.finish_name_packet(p, questions) >+ response = self.dns_transaction_udp(p) >+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_NXDOMAIN) >+ >+ # recreate the record >+ p = self.make_name_packet(dns.DNS_OPCODE_UPDATE) >+ updates = [] >+ >+ name = self.get_dns_domain() >+ >+ u = self.make_name_question(name, dns.DNS_QTYPE_SOA, dns.DNS_QCLASS_IN) >+ updates.append(u) >+ self.finish_name_packet(p, updates) >+ >+ updates = [] >+ r = dns.res_rec() >+ r.name = NAME >+ r.rr_type = dns.DNS_QTYPE_TXT >+ r.rr_class = dns.DNS_QCLASS_IN >+ r.ttl = 900 >+ r.length = 0xffff >+ rdata = dns.txt_record() >+ rdata.txt = '"This is a test"' >+ r.rdata = rdata >+ updates.append(r) >+ p.nscount = len(updates) >+ p.nsrecs = updates >+ >+ response = self.dns_transaction_udp(p) >+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK) >+ >+ # Now check the record is around >+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY) >+ questions = [] >+ q = self.make_name_question(NAME, dns.DNS_QTYPE_TXT, dns.DNS_QCLASS_IN) >+ questions.append(q) >+ >+ self.finish_name_packet(p, questions) >+ response = self.dns_transaction_udp(p) >+ self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK) >+ > def test_update_add_mx_record(self): > "test adding MX records works" > p = self.make_name_packet(dns.DNS_OPCODE_UPDATE) >diff --git a/source4/dns_server/dns_utils.c b/source4/dns_server/dns_utils.c >index 74f7a29..eea3dfd 100644 >--- a/source4/dns_server/dns_utils.c >+++ b/source4/dns_server/dns_utils.c >@@ -271,7 +271,13 @@ WERROR dns_replace_records(struct dns_server *dns, > if (needs_add) { > return WERR_OK; > } >- /* TODO: Delete object? */ >+ /* No entries left, delete the dnsNode object */ >+ ret = ldb_delete(dns->samdb, msg->dn); >+ if (ret != LDB_SUCCESS) { >+ DEBUG(0, ("Deleting record failed; %d\n", ret)); >+ return DNS_ERR(SERVER_FAILURE); >+ } >+ return WERR_OK; > } > > if (needs_add) { >-- >1.8.1.2 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
abartlet
:
review-
Actions:
View
Attachments on
bug 9559
:
8416
|
8417
|
8418
|
8419
|
8420
|
8421
|
8422
|
8424
|
8936
|
8937