[SCM] Samba Shared Repository - branch master updated
Kai Blin
kai at samba.org
Sat Mar 10 18:28:03 MST 2012
The branch, master has been updated
via 26a0e7a s4 dns: Test deleting records and fix a small bu
via 1e6ef24 s4 dns: Be less chatty during tests
via a4bc7dc s4 dns: Clean up tests a bit
via 98ae359 s4 dns: Support TXT updates, add tests
via e6c6f49 s4 dns: Support TXT queries
via f9f1d98 s3 selftest: Allow DNS updates during testing
from ce4531e tdb_wrap: Move to specific directory.
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 26a0e7a3f5ba7f8d6af2d2b8d7a6acf1323e8c57
Author: Kai Blin <kai at samba.org>
Date: Sun Mar 11 00:25:57 2012 +0100
s4 dns: Test deleting records and fix a small bu
Autobuild-User: Kai Blin <kai at samba.org>
Autobuild-Date: Sun Mar 11 02:27:45 CET 2012 on sn-devel-104
commit 1e6ef242ec65e4f8e9c8ffa44a09581b28c2599a
Author: Kai Blin <kai at samba.org>
Date: Sun Mar 11 00:25:05 2012 +0100
s4 dns: Be less chatty during tests
commit a4bc7dc281237c88682de796691cb458e4802e02
Author: Kai Blin <kai at samba.org>
Date: Sat Mar 10 23:49:18 2012 +0100
s4 dns: Clean up tests a bit
commit 98ae3592ad058619b4953c08a0cb91e6fb44e573
Author: Kai Blin <kai at samba.org>
Date: Sat Mar 10 23:48:44 2012 +0100
s4 dns: Support TXT updates, add tests
commit e6c6f4959558d89f811c3da281b10e3525660179
Author: Kai Blin <kai at samba.org>
Date: Sat Mar 10 23:47:29 2012 +0100
s4 dns: Support TXT queries
commit f9f1d98e747e9126b9d301052f639bbc25db7a88
Author: Kai Blin <kai at samba.org>
Date: Sat Mar 10 23:43:44 2012 +0100
s3 selftest: Allow DNS updates during testing
-----------------------------------------------------------------------
Summary of changes:
selftest/target/Samba4.pm | 4 +-
source4/dns_server/dns_query.c | 11 +++
source4/dns_server/dns_update.c | 51 +++++++++---
source4/scripting/python/samba/tests/dns.py | 123 ++++++++++++++++++++++++++-
4 files changed, 174 insertions(+), 15 deletions(-)
Changeset truncated at 500 lines:
diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm
index 698cd12..d9385c8 100644
--- a/selftest/target/Samba4.pm
+++ b/selftest/target/Samba4.pm
@@ -1090,6 +1090,8 @@ sub provision_dc($$)
my ($self, $prefix) = @_;
print "PROVISIONING DC...";
+ my $extra_conf_options = "netbios aliases = localDC1-a
+allow dns updates = True";
my $ret = $self->provision($prefix,
"domain controller",
"localdc",
@@ -1097,7 +1099,7 @@ sub provision_dc($$)
"samba.example.com",
"2008",
"locDCpass1",
- undef, "netbios aliases = localDC1-a");
+ undef, $extra_conf_options);
return undef unless(defined $ret);
unless($self->add_wins_config("$prefix/private")) {
diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c
index 42aa11f..4277659 100644
--- a/source4/dns_server/dns_query.c
+++ b/source4/dns_server/dns_query.c
@@ -35,6 +35,8 @@ static WERROR create_response_rr(const struct dns_name_question *question,
{
struct dns_res_rec *ans = *answers;
uint16_t ai = *ancount;
+ char *tmp;
+ uint32_t i;
ZERO_STRUCT(ans[ai]);
@@ -69,7 +71,16 @@ static WERROR create_response_rr(const struct dns_name_question *question,
case DNS_QTYPE_PTR:
ans[ai].rdata.ptr_record = talloc_strdup(ans, rec->data.ptr);
break;
+ case DNS_QTYPE_TXT:
+ tmp = talloc_asprintf(ans, "\"%s\"", rec->data.txt.str[0]);
+ for (i=1; i<rec->data.txt.count; i++) {
+ tmp = talloc_asprintf_append(tmp, " \"%s\"",
+ rec->data.txt.str[i]);
+ }
+ ans[ai].rdata.txt_record.txt = tmp;
+ break;
default:
+ DEBUG(0, ("Got unhandled type %u query.\n", rec->wType));
return DNS_ERR(NOT_IMPLEMENTED);
}
diff --git a/source4/dns_server/dns_update.c b/source4/dns_server/dns_update.c
index 62cf9e5..3d7ecce 100644
--- a/source4/dns_server/dns_update.c
+++ b/source4/dns_server/dns_update.c
@@ -285,6 +285,10 @@ static WERROR dns_rr_to_dnsp(TALLOC_CTX *mem_ctx,
const struct dns_res_rec *rrec,
struct dnsp_DnssrvRpcRecord *r)
{
+ char *tmp;
+ char *txt_record_txt;
+ char *saveptr = NULL;
+
if (rrec->rr_type == DNS_QTYPE_ALL) {
return DNS_ERR(FORMAT_ERROR);
}
@@ -334,15 +338,30 @@ static WERROR dns_rr_to_dnsp(TALLOC_CTX *mem_ctx,
W_ERROR_HAVE_NO_MEMORY(r->data.mx.nameTarget);
break;
case DNS_QTYPE_TXT:
- /* FIXME: This converts the TXT rr data into a single string.
- * Since dns server does not reply to qtype TXT,
- * this is not yet relevant.
- */
- r->data.txt.count = 1;
- r->data.txt.str = talloc_array(mem_ctx, const char *, 1);
+ r->data.txt.count = 0;
+ r->data.txt.str = talloc_array(mem_ctx, const char *,
+ r->data.txt.count);
W_ERROR_HAVE_NO_MEMORY(r->data.txt.str);
- r->data.txt.str[0] = talloc_strdup(mem_ctx, rrec->rdata.txt_record.txt);
- W_ERROR_HAVE_NO_MEMORY(r->data.txt.str[0]);
+
+ txt_record_txt = talloc_strdup(r->data.txt.str,
+ rrec->rdata.txt_record.txt);
+ W_ERROR_HAVE_NO_MEMORY(txt_record_txt);
+
+ tmp = strtok_r(txt_record_txt, "\"", &saveptr);
+ while (tmp) {
+ if (strcmp(tmp, " ") == 0) {
+ tmp = strtok_r(NULL, "\"", &saveptr);
+ continue;
+ }
+ r->data.txt.str = talloc_realloc(mem_ctx, r->data.txt.str, const char *,
+ r->data.txt.count+1);
+ r->data.txt.str[r->data.txt.count] = talloc_strdup(r->data.txt.str, tmp);
+ W_ERROR_HAVE_NO_MEMORY(r->data.txt.str[r->data.txt.count]);
+
+ r->data.txt.count++;
+ tmp = strtok_r(NULL, "\"", &saveptr);
+ }
+
break;
default:
DEBUG(0, ("Got a qytpe of %d\n", rrec->rr_type));
@@ -367,8 +386,10 @@ static WERROR handle_one_update(struct dns_server *dns,
WERROR werror;
bool needs_add = false;
- DEBUG(1, ("Looking at record: \n"));
- NDR_PRINT_DEBUG(dns_res_rec, discard_const(update));
+ DEBUG(2, ("Looking at record: \n"));
+ if (DEBUGLVL(2)) {
+ NDR_PRINT_DEBUG(dns_res_rec, discard_const(update));
+ }
switch (update->rr_type) {
case DNS_QTYPE_A:
@@ -390,6 +411,8 @@ static WERROR handle_one_update(struct dns_server *dns,
case DNS_QTYPE_TXT:
break;
default:
+ DEBUG(0, ("Can't handle updates of type %u yet\n",
+ update->rr_type));
return DNS_ERR(NOT_IMPLEMENTED);
}
@@ -605,6 +628,10 @@ static WERROR handle_one_update(struct dns_server *dns,
ZERO_STRUCT(recs[i]);
}
}
+
+ werror = dns_replace_records(dns, mem_ctx, dn,
+ needs_add, recs, rcount);
+ W_ERROR_NOT_OK_RETURN(werror);
}
return WERR_OK;
@@ -679,7 +706,7 @@ WERROR dns_server_process_update(struct dns_server *dns,
return DNS_ERR(FORMAT_ERROR);
}
- DEBUG(0, ("Got a dns update request.\n"));
+ DEBUG(2, ("Got a dns update request.\n"));
for (z = dns->zones; z != NULL; z = z->next) {
bool match;
@@ -711,7 +738,7 @@ WERROR dns_server_process_update(struct dns_server *dns,
* key-based GSSAPI, key-based bind-style TSIG and "never" as
* smb.conf options. */
if (lpcfg_allow_dns_updates(dns->task->lp_ctx) != DNS_UPDATE_ON) {
- DEBUG(0, ("Update not allowed."));
+ DEBUG(0, ("Update not allowed.\n"));
return DNS_ERR(REFUSED);
}
diff --git a/source4/scripting/python/samba/tests/dns.py b/source4/scripting/python/samba/tests/dns.py
index 26f8089..ff973bd 100644
--- a/source4/scripting/python/samba/tests/dns.py
+++ b/source4/scripting/python/samba/tests/dns.py
@@ -18,7 +18,6 @@
#
import os
-import sys
import struct
import random
from samba import socket
@@ -324,7 +323,7 @@ class DNSTest(TestCase):
# self.assert_dns_rcode_equals(response, dns.DNS_RCODE_FORMERR)
def test_update_prereq_nonexisting_name(self):
- "test update with a non-null TTL"
+ "test update with a nonexisting name"
p = self.make_name_packet(dns.DNS_OPCODE_UPDATE)
updates = []
@@ -349,6 +348,126 @@ class DNSTest(TestCase):
response = self.dns_transaction_udp(p)
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_NXRRSET)
+ def test_update_add_txt_record(self):
+ "test adding records works"
+ 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 = "textrec.%s" % self.get_dns_domain()
+ 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)
+
+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
+ questions = []
+
+ name = "textrec.%s" % self.get_dns_domain()
+ 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)
+ self.assertEquals(response.ancount, 1)
+ self.assertEquals(response.answers[0].rdata.txt, '"This is a test"')
+
+ def test_update_add_two_txt_records(self):
+ "test adding two txt records works"
+ 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 = "textrec2.%s" % self.get_dns_domain()
+ 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" "and this is a test, too"'
+ 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)
+
+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
+ questions = []
+
+ name = "textrec2.%s" % self.get_dns_domain()
+ 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)
+ self.assertEquals(response.ancount, 1)
+ self.assertEquals(response.answers[0].rdata.txt, '"This is a test" "and this is a test, too"')
+
+
+ def test_delete_record(self):
+ "Test if deleting records works"
+ 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 = "textrec.%s" % self.get_dns_domain()
+ r.rr_type = dns.DNS_QTYPE_TXT
+ 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"'
+ 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)
+
+ p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
+ questions = []
+
+ name = "textrec.%s" % self.get_dns_domain()
+ 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)
+
+
if __name__ == "__main__":
import unittest
unittest.main()
--
Samba Shared Repository
More information about the samba-cvs
mailing list