mirror of
https://github.com/samba-team/samba.git
synced 2025-08-03 04:22:09 +03:00
s4 dns: Fix return code for deleted records
This fixes bug #9225. We already had a test for this scenario, but the test wasn't correct. This patch fixes the test, and also fixes the bug. Signed-off-by: Kai Blin <kai@samba.org> Autobuild-User(master): Kai Blin <kai@samba.org> Autobuild-Date(master): Sun Sep 30 13:09:14 CEST 2012 on sn-devel-104
This commit is contained in:
@ -201,7 +201,7 @@ WERROR dns_lookup_records(struct dns_server *dns,
|
|||||||
if (el == NULL) {
|
if (el == NULL) {
|
||||||
*records = NULL;
|
*records = NULL;
|
||||||
*rec_count = 0;
|
*rec_count = 0;
|
||||||
return WERR_OK;
|
return DNS_ERR(NAME_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
recs = talloc_zero_array(mem_ctx, struct dnsp_DnssrvRpcRecord, el->num_values);
|
recs = talloc_zero_array(mem_ctx, struct dnsp_DnssrvRpcRecord, el->num_values);
|
||||||
|
@ -434,6 +434,10 @@ class TestDNSUpdates(DNSTest):
|
|||||||
|
|
||||||
def test_delete_record(self):
|
def test_delete_record(self):
|
||||||
"Test if deleting records works"
|
"Test if deleting records works"
|
||||||
|
|
||||||
|
NAME = "deleterec.%s" % self.get_dns_domain()
|
||||||
|
|
||||||
|
# First, create a record to make sure we have a record to delete.
|
||||||
p = self.make_name_packet(dns.DNS_OPCODE_UPDATE)
|
p = self.make_name_packet(dns.DNS_OPCODE_UPDATE)
|
||||||
updates = []
|
updates = []
|
||||||
|
|
||||||
@ -445,7 +449,43 @@ class TestDNSUpdates(DNSTest):
|
|||||||
|
|
||||||
updates = []
|
updates = []
|
||||||
r = dns.res_rec()
|
r = dns.res_rec()
|
||||||
r.name = "textrec.%s" % self.get_dns_domain()
|
r.name = NAME
|
||||||
|
r.rr_type = dns.DNS_QTYPE_TXT
|
||||||
|
r.rr_class = dns.DNS_QCLASS_IN
|
||||||
|
r.ttl = 900
|
||||||
|
r.length = 0xffff
|
||||||
|
r.rdata = dns.txt_record()
|
||||||
|
r.rdata.txt = '"This is a test"'
|
||||||
|
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_type = dns.DNS_QTYPE_TXT
|
||||||
r.rr_class = dns.DNS_QCLASS_NONE
|
r.rr_class = dns.DNS_QCLASS_NONE
|
||||||
r.ttl = 0
|
r.ttl = 0
|
||||||
@ -459,11 +499,11 @@ class TestDNSUpdates(DNSTest):
|
|||||||
response = self.dns_transaction_udp(p)
|
response = self.dns_transaction_udp(p)
|
||||||
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK)
|
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK)
|
||||||
|
|
||||||
|
# And finally check it's gone
|
||||||
p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
|
p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
|
||||||
questions = []
|
questions = []
|
||||||
|
|
||||||
name = "textrec.%s" % self.get_dns_domain()
|
q = self.make_name_question(NAME, dns.DNS_QTYPE_TXT, dns.DNS_QCLASS_IN)
|
||||||
q = self.make_name_question(name, dns.DNS_QTYPE_TXT, dns.DNS_QCLASS_IN)
|
|
||||||
questions.append(q)
|
questions.append(q)
|
||||||
|
|
||||||
self.finish_name_packet(p, questions)
|
self.finish_name_packet(p, questions)
|
||||||
|
Reference in New Issue
Block a user