-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2012-12-09 08:37, Michael B. Trausch wrote:
Hi Mike,
> I am trying to get mail working for a subdomain that is being
> managed by Samba 4. I added an MX record, but the problem here is
> that the Samba 4 DNS server isn't replying with the record:
>
> =====================================================================
>
>
[mbt@aloe ~]$ dig -t MX nautest.naunetcorp.com @s4.nautest.naunetcorp.com
>
> ; <<>> DiG 9.9.2-P1-RedHat-9.9.2-5.P1.fc18 <<>> -t MX
> nautest.naunetcorp.com @s4.nautest.naunetcorp.com ;; global
> options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status:
> NOTIMP, id: 5782
^^^^^^
This one is the important bit. MX queries return NOTIMP. I'm a bit
surprised about that because I was sure I had seen code in the dns
update logc handling this. But apparently I forgot to add code to the
query logic to actually return MX records. Sorry.
> ;; flags: qr rd ad; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL:
> 1 ;; WARNING: recursion requested but not available
This is just caused by our error handling code not bothering to set
the 'recursion available' bit on error replies.
> The query should return the name and priority of the MX server that
> I have defined. The MX shows up in the "samba-tool dns query"
> output, so it's just the DNS server that isn't responding
> correctly.
>
> Is this a bug, or is this the result of something I've done wrong?
This clearly is a bug in the DNS server. Attached is a patch that
should fix MX queries for both the 4.0 release branch and master.
I'm afraid we just missed the window for the 4.0.0 release, but I've
opened bug #9485 in Samba Bugzilla to track this bug and get it in for
the next bugfix release.
Thanks for the catch and sorry for any inconvenience.
Kai
- --
Kai Blin
Worldforge developer http://www.worldforge.org/
Wine developer http://wiki.winehq.org/KaiBlin
Samba team member http://www.samba.org/samba/team/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/
iEYEARECAAYFAlDE7Q0ACgkQEKXX/bF2FpR9pgCfeV1AFdWyF2zHGCZXvy4LcgJ6
SYYAn04b4BCtCCc6oE/+zxA+fxu2S/49
=rGcM
-----END PGP SIGNATURE-----
>From e6b772c3215c3cf677e0268c7283f5b0e6e75abf Mon Sep 17 00:00:00 2001
From: Kai Blin <[email protected]>
Date: Mon, 10 Dec 2012 05:50:05 +1000
Subject: [PATCH] dns: Add support for MX queries
Due to an oversight, the internal DNS server supports MX record updates,
but not MX record queries. Add support for MX queries and tests.
This should fix bug #9485
Signed-off-by: Kai Blin <[email protected]>
---
source4/dns_server/dns_query.c | 8 +++++
source4/scripting/python/samba/tests/dns.py | 42 +++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/source4/dns_server/dns_query.c b/source4/dns_server/dns_query.c
index 54e0c7f..75f0e9f 100644
--- a/source4/dns_server/dns_query.c
+++ b/source4/dns_server/dns_query.c
@@ -89,6 +89,14 @@ 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_MX:
+ ans[ai].rdata.mx_record.preference = rec->data.mx.wPriority;
+ ans[ai].rdata.mx_record.exchange = talloc_strdup(
+ ans, rec->data.mx.nameTarget);
+ if (ans[ai].rdata.mx_record.exchange == NULL) {
+ return WERR_NOMEM;
+ }
+ break;
case DNS_QTYPE_TXT:
tmp = talloc_asprintf(ans, "\"%s\"", rec->data.txt.str[0]);
W_ERROR_HAVE_NO_MEMORY(tmp);
diff --git a/source4/scripting/python/samba/tests/dns.py b/source4/scripting/python/samba/tests/dns.py
index 49d699e..d01c8ff 100644
--- a/source4/scripting/python/samba/tests/dns.py
+++ b/source4/scripting/python/samba/tests/dns.py
@@ -510,6 +510,48 @@ class TestDNSUpdates(DNSTest):
response = self.dns_transaction_udp(p)
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_NXDOMAIN)
+ def test_update_add_mx_record(self):
+ "test adding MX 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 = "%s" % self.get_dns_domain()
+ r.rr_type = dns.DNS_QTYPE_MX
+ r.rr_class = dns.DNS_QCLASS_IN
+ r.ttl = 900
+ r.length = 0xffff
+ r.rdata = dns.mx_record()
+ r.rdata.preference = 10
+ r.rdata.exchange = 'mail.%s' % self.get_dns_domain()
+ 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 = "%s" % self.get_dns_domain()
+ q = self.make_name_question(name, dns.DNS_QTYPE_MX, 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.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())
+
class TestComplexQueries(DNSTest):
--
1.7.1
--
To unsubscribe from this list go to the following URL and read the
instructions: https://lists.samba.org/mailman/options/samba