[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Mon Jun 3 06:17:05 MDT 2013


The branch, v4-0-test has been updated
       via  6736784 dns: Delete dnsNode objects when they are empty
       via  1a1e445 dns: Fix allocation of txt_record in txt record tests
       via  a2814d3 dns: more debug debug options in the tests
       via  5a2d041 winbind4: Fix bug 9832 -- talloc use after free
      from  d4cd828 waf: build PIEs if supported by the compiler

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v4-0-test


- Log -----------------------------------------------------------------
commit 673678474791d2f71ba7d8d0f73e20b2a974ae9a
Author: Kai Blin <kai at samba.org>
Date:   Sat Jun 1 10:24:11 2013 +0200

    dns: Delete dnsNode objects when they are empty
    
    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 at samba.org>
    
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    (cherry picked from commit 8b24c43b382740106474e26dec59e1419ba77306)
    
    The last 3 patches address bug #9559 - Only initial signed DNS update for a host
    works.
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Mon Jun  3 14:16:16 CEST 2013 on sn-devel-104

commit 1a1e4452ff5811bbeb6212967707874f4b98f960
Author: Kai Blin <kai at samba.org>
Date:   Thu May 16 12:13:22 2013 +0200

    dns: Fix allocation of txt_record in txt record tests
    
    Signed-off-by: Kai Blin <kai at samba.org>
    Reviewed-By: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Thu May 16 15:39:15 CEST 2013 on sn-devel-104
    (cherry picked from commit 46e98cf20b04f3668e96fb597a414d0b39d5b1ed)

commit a2814d30ea70d25d0ee98d36b1fc74b0e5e2b82b
Author: Kai Blin <kai at samba.org>
Date:   Mon Jan 14 00:56:48 2013 +0100

    dns: more debug debug options in the tests
    
    Signed-off-by: Kai Blin <kai at samba.org>
    Reviewed-By: Amitay Isaacs <amitay at gmail.com>
    (cherry picked from commit 223cf7fb3026daa1d383a2e5796cbfe8beecaac2)

commit 5a2d041ebc8b3f667b935a97bf921facb965d517
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 7 10:17:26 2013 +0200

    winbind4: Fix bug 9832 -- talloc use after free
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu May 16 13:37:41 CEST 2013 on sn-devel-104
    (cherry picked from commit 51533eedd7fa162bf8113f1f551064c01741e40e)

-----------------------------------------------------------------------

Summary of changes:
 python/samba/tests/dns.py      |  167 +++++++++++++++++++++++++++++++++++++---
 source4/dns_server/dns_utils.c |    8 ++-
 source4/winbind/wb_server.c    |    2 +-
 3 files changed, 163 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/dns.py b/python/samba/tests/dns.py
index a29025d..0ac9cf4 100644
--- a/python/samba/tests/dns.py
+++ b/python/samba/tests/dns.py
@@ -23,6 +23,9 @@ import samba.ndr as ndr
 import samba.dcerpc.dns as dns
 from samba.tests import TestCase
 
+FILTER=''.join([(len(repr(chr(x)))==3) and chr(x) or '.' for x in range(256)])
+
+
 class DNSTest(TestCase):
 
     def errstr(self, errcode):
@@ -82,36 +85,53 @@ class DNSTest(TestCase):
         "Helper to get dns domain"
         return os.getenv('REALM', 'example.com').lower()
 
-    def dns_transaction_udp(self, packet, host=os.getenv('SERVER_IP')):
+    def dns_transaction_udp(self, packet, host=os.getenv('SERVER_IP'), dump=False):
         "send a DNS query and read the reply"
         s = None
         try:
             send_packet = ndr.ndr_pack(packet)
+            if dump:
+                print self.hexdump(send_packet)
             s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, 0)
             s.connect((host, 53))
             s.send(send_packet, 0)
             recv_packet = s.recv(2048, 0)
+            if dump:
+                print self.hexdump(recv_packet)
             return ndr.ndr_unpack(dns.name_packet, recv_packet)
         finally:
             if s is not None:
                 s.close()
 
-    def dns_transaction_tcp(self, packet, host=os.getenv('SERVER_IP')):
+    def dns_transaction_tcp(self, packet, host=os.getenv('SERVER_IP'), dump=False):
         "send a DNS query and read the reply"
         s = None
         try:
             send_packet = ndr.ndr_pack(packet)
+            if dump:
+                print self.hexdump(send_packet)
             s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
             s.connect((host, 53))
             tcp_packet = struct.pack('!H', len(send_packet))
             tcp_packet += send_packet
             s.send(tcp_packet, 0)
             recv_packet = s.recv(0xffff + 2, 0)
+            if dump:
+                print self.hexdump(recv_packet)
             return ndr.ndr_unpack(dns.name_packet, recv_packet[2:])
         finally:
                 if s is not None:
                     s.close()
 
+    def hexdump(self, src, length=8):
+        N=0; result=''
+        while src:
+           s,src = src[:length],src[length:]
+           hexa = ' '.join(["%02X"%ord(x) for x in s])
+           s = s.translate(FILTER)
+           result += "%04X   %-*s   %s\n" % (N, length*3, hexa, s)
+           N+=length
+        return result
 
 class TestSimpleQueries(DNSTest):
 
@@ -370,8 +390,9 @@ class TestDNSUpdates(DNSTest):
         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"'
+        rdata = dns.txt_record()
+        rdata.txt = '"This is a test"'
+        r.rdata = rdata
         updates.append(r)
         p.nscount = len(updates)
         p.nsrecs = updates
@@ -410,8 +431,9 @@ class TestDNSUpdates(DNSTest):
         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" "and this is a test, too"'
+        rdata = dns.txt_record()
+        rdata.txt = '"This is a test" "and this is a test, too"'
+        r.rdata = rdata
         updates.append(r)
         p.nscount = len(updates)
         p.nsrecs = updates
@@ -454,8 +476,9 @@ class TestDNSUpdates(DNSTest):
         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"'
+        rdata = dns.txt_record()
+        rdata.txt = '"This is a test"'
+        r.rdata = rdata
         updates.append(r)
         p.nscount = len(updates)
         p.nsrecs = updates
@@ -490,8 +513,9 @@ class TestDNSUpdates(DNSTest):
         r.rr_class = dns.DNS_QCLASS_NONE
         r.ttl = 0
         r.length = 0xffff
-        r.rdata = dns.txt_record()
-        r.rdata.txt = '"This is a test"'
+        rdata = dns.txt_record()
+        rdata.txt = '"This is a test"'
+        r.rdata = rdata
         updates.append(r)
         p.nscount = len(updates)
         p.nsrecs = updates
@@ -510,6 +534,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)
@@ -550,8 +691,10 @@ class TestDNSUpdates(DNSTest):
         response = self.dns_transaction_udp(p)
         self.assert_dns_rcode_equals(response, dns.DNS_RCODE_OK)
         self.assertEqual(response.ancount, 1)
-        self.assertEqual(response.answers[0].rdata.preference, 10)
-        self.assertEqual(response.answers[0].rdata.exchange, 'mail.%s' % self.get_dns_domain())
+        ans = response.answers[0]
+        self.assertEqual(ans.rr_type, dns.DNS_QTYPE_MX)
+        self.assertEqual(ans.rdata.preference, 10)
+        self.assertEqual(ans.rdata.exchange, 'mail.%s' % self.get_dns_domain())
 
 
 class TestComplexQueries(DNSTest):
diff --git a/source4/dns_server/dns_utils.c b/source4/dns_server/dns_utils.c
index cb2c6f4..b192730 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) {
diff --git a/source4/winbind/wb_server.c b/source4/winbind/wb_server.c
index bd2d361..3392353 100644
--- a/source4/winbind/wb_server.c
+++ b/source4/winbind/wb_server.c
@@ -56,7 +56,7 @@ static void wbsrv_call_loop(struct tevent_req *subreq)
 	if (!NT_STATUS_IS_OK(status)) {
 		const char *reason;
 
-		reason = talloc_asprintf(call, "wbsrv_call_loop: "
+		reason = talloc_asprintf(wbsrv_conn, "wbsrv_call_loop: "
 					 "tstream_read_pdu_blob_recv() - %s",
 					 nt_errstr(status));
 		if (!reason) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list