return WERR_OK;
}
-
-static WERROR handle_question(struct dns_server *dns,
- TALLOC_CTX *mem_ctx,
- const struct dns_name_question *question,
- struct dns_res_rec **answers,
- struct dns_res_rec **nsrecs)
-{
- struct dns_res_rec *ans = *answers;
- struct dns_res_rec *ns = *nsrecs;
- WERROR werror, werror_return;
- unsigned int ri;
- struct dnsp_DnssrvRpcRecord *recs;
- uint16_t rec_count;
- struct ldb_dn *dn = NULL;
-
- werror = dns_name2dn(dns, mem_ctx, question->name, &dn);
- 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;
- goto done;
- }
-
- /* Set up for an NXDOMAIN reply if no match is found */
- werror_return = DNS_ERR(NAME_ERROR);
-
- for (ri = 0; ri < rec_count; ri++) {
- if ((recs[ri].wType == DNS_TYPE_CNAME) &&
- ((question->question_type == DNS_QTYPE_A) ||
- (question->question_type == DNS_QTYPE_AAAA))) {
- struct dns_name_question *new_q =
- talloc(mem_ctx, struct dns_name_question);
-
- if (new_q == NULL) {
- return WERR_NOMEM;
- }
-
- /* First put in the CNAME record */
- werror = add_response_rr(question->name, &recs[ri],
- &ans);
- if (!W_ERROR_IS_OK(werror)) {
- TALLOC_FREE(new_q);
- return werror;
- }
-
- /* And then look up the name it points at.. */
-
- /* First build up the new question */
- new_q->question_type = question->question_type;
- new_q->question_class = question->question_class;
- new_q->name = talloc_strdup(new_q, recs[ri].data.cname);
- if (new_q->name == NULL) {
- TALLOC_FREE(new_q);
- return WERR_NOMEM;
- }
- /* and then call the lookup again */
- werror = handle_question(dns, mem_ctx, new_q,
- &ans, &ns);
- if (!W_ERROR_IS_OK(werror)) {
- goto done;
- }
- werror_return = WERR_OK;
-
-
- continue;
- }
- if ((question->question_type != DNS_QTYPE_ALL) &&
- (recs[ri].wType != (enum dns_record_type) question->question_type)) {
- werror_return = WERR_OK;
- continue;
- }
- werror = add_response_rr(question->name, &recs[ri], &ans);
- if (!W_ERROR_IS_OK(werror)) {
- return werror;
- }
- werror_return = WERR_OK;
- }
-
-done:
- /* Always add an authority record to replies we should know about */
- add_zone_authority_record(dns, mem_ctx, question, &ns);
-
- *answers = ans;
- *nsrecs = ns;
-
- return werror_return;
-}
-
static struct tevent_req *handle_authoritative_send(
TALLOC_CTX *mem_ctx, struct tevent_context *ev,
struct dns_server *dns, const char *forwarder,