mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
dns: always add authority records
Signed-off-by: Kai Blin <kai@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Kai Blin <kai@samba.org> Autobuild-Date(master): Thu Aug 6 14:06:52 CEST 2015 on sn-devel-104
This commit is contained in:
parent
d9a3f19749
commit
42f38fe8d9
@ -247,23 +247,23 @@ class TestSimpleQueries(DNSTest):
|
||||
response = self.dns_transaction_udp(p)
|
||||
self.assert_dns_rcode_equals(response, dns.DNS_RCODE_NOTIMP)
|
||||
|
||||
# Only returns an authority section entry in BIND and Win DNS
|
||||
# FIXME: Enable one Samba implements this feature
|
||||
# def test_soa_hostname_query(self):
|
||||
# "create a SOA query for a hostname"
|
||||
# p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
|
||||
# questions = []
|
||||
#
|
||||
# name = "%s.%s" % (os.getenv('SERVER'), self.get_dns_domain())
|
||||
# q = self.make_name_question(name, dns.DNS_QTYPE_SOA, 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.assert_dns_opcode_equals(response, dns.DNS_OPCODE_QUERY)
|
||||
# # We don't get SOA records for single hosts
|
||||
# self.assertEquals(response.ancount, 0)
|
||||
def test_soa_hostname_query(self):
|
||||
"create a SOA query for a hostname"
|
||||
p = self.make_name_packet(dns.DNS_OPCODE_QUERY)
|
||||
questions = []
|
||||
|
||||
name = "%s.%s" % (os.getenv('SERVER'), self.get_dns_domain())
|
||||
q = self.make_name_question(name, dns.DNS_QTYPE_SOA, 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.assert_dns_opcode_equals(response, dns.DNS_OPCODE_QUERY)
|
||||
# We don't get SOA records for single hosts
|
||||
self.assertEquals(response.ancount, 0)
|
||||
# But we do respond with an authority section
|
||||
self.assertEqual(response.nscount, 1)
|
||||
|
||||
def test_soa_domain_query(self):
|
||||
"create a SOA query for a domain"
|
||||
|
@ -314,12 +314,13 @@ static WERROR handle_question(struct dns_server *dns,
|
||||
struct ldb_dn *dn = NULL;
|
||||
|
||||
werror = dns_name2dn(dns, mem_ctx, question->name, &dn);
|
||||
W_ERROR_NOT_OK_RETURN(werror);
|
||||
if (!W_ERROR_IS_OK(werror)) {
|
||||
return werror;
|
||||
}
|
||||
|
||||
werror = dns_lookup_records(dns, mem_ctx, dn, &recs, &rec_count);
|
||||
if (!W_ERROR_IS_OK(werror)) {
|
||||
werror_return = werror;
|
||||
add_zone_authority_record(dns, mem_ctx, question, &ns, &ni);
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -369,7 +370,7 @@ static WERROR handle_question(struct dns_server *dns,
|
||||
/* and then call the lookup again */
|
||||
werror = handle_question(dns, mem_ctx, new_q, &ans, &ai, &ns, &ni);
|
||||
if (!W_ERROR_IS_OK(werror)) {
|
||||
return werror;
|
||||
goto done;
|
||||
}
|
||||
werror_return = WERR_OK;
|
||||
|
||||
@ -389,6 +390,9 @@ static WERROR handle_question(struct dns_server *dns,
|
||||
}
|
||||
|
||||
done:
|
||||
/* Always add an authority record to replies we should know about */
|
||||
add_zone_authority_record(dns, mem_ctx, question, &ns, &ni);
|
||||
|
||||
*ancount = ai;
|
||||
*answers = ans;
|
||||
*nscount = ni;
|
||||
@ -670,7 +674,9 @@ struct tevent_req *dns_server_process_query_send(
|
||||
&state->answers, &state->ancount,
|
||||
&state->nsrecs, &state->nscount);
|
||||
if (tevent_req_werror(req, err)) {
|
||||
return tevent_req_post(req, ev);
|
||||
if (!W_ERROR_EQUAL(err, DNS_ERR(NAME_ERROR))) {
|
||||
return tevent_req_post(req, ev);
|
||||
}
|
||||
}
|
||||
tevent_req_done(req);
|
||||
return tevent_req_post(req, ev);
|
||||
@ -724,10 +730,14 @@ WERROR dns_server_process_query_recv(
|
||||
{
|
||||
struct dns_server_process_query_state *state = tevent_req_data(
|
||||
req, struct dns_server_process_query_state);
|
||||
WERROR err;
|
||||
WERROR err = WERR_OK;
|
||||
|
||||
if (tevent_req_is_werror(req, &err)) {
|
||||
return err;
|
||||
|
||||
if ((!W_ERROR_EQUAL(err, DNS_ERR(NAME_ERROR))) &&
|
||||
(!W_ERROR_EQUAL(err, WERR_DNS_ERROR_NAME_DOES_NOT_EXIST))) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
*answers = talloc_move(mem_ctx, &state->answers);
|
||||
*ancount = state->ancount;
|
||||
@ -735,5 +745,5 @@ WERROR dns_server_process_query_recv(
|
||||
*nscount = state->nscount;
|
||||
*additional = talloc_move(mem_ctx, &state->additional);
|
||||
*arcount = state->arcount;
|
||||
return WERR_OK;
|
||||
return err;
|
||||
}
|
||||
|
@ -234,9 +234,13 @@ static WERROR dns_process_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
|
||||
if (tevent_req_is_werror(req, &ret)) {
|
||||
return ret;
|
||||
}
|
||||
if (state->dns_err != DNS_RCODE_OK) {
|
||||
if ((state->dns_err != DNS_RCODE_OK) &&
|
||||
(state->dns_err != DNS_RCODE_NXDOMAIN)) {
|
||||
goto drop;
|
||||
}
|
||||
if (state->dns_err != DNS_RCODE_OK) {
|
||||
state->out_packet.operation |= state->dns_err;
|
||||
}
|
||||
state->out_packet.operation |= state->state.flags;
|
||||
|
||||
if (state->state.sign) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user