lib: Add prctl_set_comment to utils.
[Samba/id10ts.git] / source4 / dns_server / dns_query.c
blob54e0c7f3b0c4119f12490edb56396af71063b92c
1 /*
2 Unix SMB/CIFS implementation.
4 DNS server handler for queries
6 Copyright (C) 2010 Kai Blin <kai@samba.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
23 #include "smbd/service_task.h"
24 #include "libcli/util/werror.h"
25 #include "librpc/ndr/libndr.h"
26 #include "librpc/gen_ndr/ndr_dns.h"
27 #include "librpc/gen_ndr/ndr_dnsp.h"
28 #include <ldb.h>
29 #include "param/param.h"
30 #include "dsdb/samdb/samdb.h"
31 #include "dsdb/common/util.h"
32 #include "dns_server/dns_server.h"
33 #include "libcli/dns/libdns.h"
34 #include "lib/util/util_net.h"
35 #include "lib/util/tevent_werror.h"
36 #include "auth/auth.h"
37 #include "auth/credentials/credentials.h"
38 #include "auth/gensec/gensec.h"
40 static WERROR create_response_rr(const struct dns_name_question *question,
41 const struct dnsp_DnssrvRpcRecord *rec,
42 struct dns_res_rec **answers, uint16_t *ancount)
44 struct dns_res_rec *ans = *answers;
45 uint16_t ai = *ancount;
46 char *tmp;
47 uint32_t i;
49 ZERO_STRUCT(ans[ai]);
51 switch (rec->wType) {
52 case DNS_QTYPE_CNAME:
53 ans[ai].rdata.cname_record = talloc_strdup(ans, rec->data.cname);
54 W_ERROR_HAVE_NO_MEMORY(ans[ai].rdata.cname_record);
55 break;
56 case DNS_QTYPE_A:
57 ans[ai].rdata.ipv4_record = talloc_strdup(ans, rec->data.ipv4);
58 W_ERROR_HAVE_NO_MEMORY(ans[ai].rdata.ipv4_record);
59 break;
60 case DNS_QTYPE_AAAA:
61 ans[ai].rdata.ipv6_record = talloc_strdup(ans, rec->data.ipv6);
62 W_ERROR_HAVE_NO_MEMORY(ans[ai].rdata.ipv6_record);
63 break;
64 case DNS_TYPE_NS:
65 ans[ai].rdata.ns_record = talloc_strdup(ans, rec->data.ns);
66 W_ERROR_HAVE_NO_MEMORY(ans[ai].rdata.ns_record);
67 break;
68 case DNS_QTYPE_SRV:
69 ans[ai].rdata.srv_record.priority = rec->data.srv.wPriority;
70 ans[ai].rdata.srv_record.weight = rec->data.srv.wWeight;
71 ans[ai].rdata.srv_record.port = rec->data.srv.wPort;
72 ans[ai].rdata.srv_record.target = talloc_strdup(
73 ans, rec->data.srv.nameTarget);
74 W_ERROR_HAVE_NO_MEMORY(ans[ai].rdata.srv_record.target);
75 break;
76 case DNS_QTYPE_SOA:
77 ans[ai].rdata.soa_record.mname = talloc_strdup(
78 ans, rec->data.soa.mname);
79 W_ERROR_HAVE_NO_MEMORY(ans[ai].rdata.soa_record.mname);
80 ans[ai].rdata.soa_record.rname = talloc_strdup(
81 ans, rec->data.soa.rname);
82 W_ERROR_HAVE_NO_MEMORY(ans[ai].rdata.soa_record.rname);
83 ans[ai].rdata.soa_record.serial = rec->data.soa.serial;
84 ans[ai].rdata.soa_record.refresh = rec->data.soa.refresh;
85 ans[ai].rdata.soa_record.retry = rec->data.soa.retry;
86 ans[ai].rdata.soa_record.expire = rec->data.soa.expire;
87 ans[ai].rdata.soa_record.minimum = rec->data.soa.minimum;
88 break;
89 case DNS_QTYPE_PTR:
90 ans[ai].rdata.ptr_record = talloc_strdup(ans, rec->data.ptr);
91 break;
92 case DNS_QTYPE_TXT:
93 tmp = talloc_asprintf(ans, "\"%s\"", rec->data.txt.str[0]);
94 W_ERROR_HAVE_NO_MEMORY(tmp);
95 for (i=1; i<rec->data.txt.count; i++) {
96 tmp = talloc_asprintf_append_buffer(
97 tmp, " \"%s\"", rec->data.txt.str[i]);
98 W_ERROR_HAVE_NO_MEMORY(tmp);
100 ans[ai].rdata.txt_record.txt = tmp;
101 break;
102 default:
103 DEBUG(0, ("Got unhandled type %u query.\n", rec->wType));
104 return DNS_ERR(NOT_IMPLEMENTED);
107 ans[ai].name = talloc_strdup(ans, question->name);
108 W_ERROR_HAVE_NO_MEMORY(ans[ai].name);
109 ans[ai].rr_type = rec->wType;
110 ans[ai].rr_class = DNS_QCLASS_IN;
111 ans[ai].ttl = rec->dwTtlSeconds;
112 ans[ai].length = UINT16_MAX;
113 ai++;
115 *answers = ans;
116 *ancount = ai;
118 return WERR_OK;
121 struct ask_forwarder_state {
122 struct tevent_context *ev;
123 uint16_t id;
124 struct dns_name_packet in_packet;
127 static void ask_forwarder_done(struct tevent_req *subreq);
129 static struct tevent_req *ask_forwarder_send(
130 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
131 const char *forwarder, struct dns_name_question *question)
133 struct tevent_req *req, *subreq;
134 struct ask_forwarder_state *state;
135 struct dns_name_packet out_packet = { 0, };
136 DATA_BLOB out_blob;
137 enum ndr_err_code ndr_err;
139 req = tevent_req_create(mem_ctx, &state, struct ask_forwarder_state);
140 if (req == NULL) {
141 return NULL;
143 state->ev = ev;
144 generate_random_buffer((uint8_t *)&state->id, sizeof(state->id));
146 if (!is_ipaddress(forwarder)) {
147 DEBUG(0, ("Invalid 'dns forwarder' setting '%s', needs to be "
148 "an IP address\n", forwarder));
149 tevent_req_werror(req, DNS_ERR(NAME_ERROR));
150 return tevent_req_post(req, ev);
153 out_packet.id = state->id;
154 out_packet.operation |= DNS_OPCODE_QUERY | DNS_FLAG_RECURSION_DESIRED;
155 out_packet.qdcount = 1;
156 out_packet.questions = question;
158 ndr_err = ndr_push_struct_blob(
159 &out_blob, state, &out_packet,
160 (ndr_push_flags_fn_t)ndr_push_dns_name_packet);
161 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
162 tevent_req_werror(req, DNS_ERR(SERVER_FAILURE));
163 return tevent_req_post(req, ev);
165 subreq = dns_udp_request_send(state, ev, forwarder, out_blob.data,
166 out_blob.length);
167 if (tevent_req_nomem(subreq, req)) {
168 return tevent_req_post(req, ev);
170 tevent_req_set_callback(subreq, ask_forwarder_done, req);
171 return req;
174 static void ask_forwarder_done(struct tevent_req *subreq)
176 struct tevent_req *req = tevent_req_callback_data(
177 subreq, struct tevent_req);
178 struct ask_forwarder_state *state = tevent_req_data(
179 req, struct ask_forwarder_state);
180 DATA_BLOB in_blob;
181 enum ndr_err_code ndr_err;
182 WERROR ret;
184 ret = dns_udp_request_recv(subreq, state,
185 &in_blob.data, &in_blob.length);
186 TALLOC_FREE(subreq);
187 if (tevent_req_werror(req, ret)) {
188 return;
191 ndr_err = ndr_pull_struct_blob(
192 &in_blob, state, &state->in_packet,
193 (ndr_pull_flags_fn_t)ndr_pull_dns_name_packet);
194 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
195 tevent_req_werror(req, DNS_ERR(SERVER_FAILURE));
196 return;
198 if (state->in_packet.id != state->id) {
199 tevent_req_werror(req, DNS_ERR(NAME_ERROR));
200 return;
202 tevent_req_done(req);
205 static WERROR ask_forwarder_recv(
206 struct tevent_req *req, TALLOC_CTX *mem_ctx,
207 struct dns_res_rec **answers, uint16_t *ancount,
208 struct dns_res_rec **nsrecs, uint16_t *nscount,
209 struct dns_res_rec **additional, uint16_t *arcount)
211 struct ask_forwarder_state *state = tevent_req_data(
212 req, struct ask_forwarder_state);
213 struct dns_name_packet *in_packet = &state->in_packet;
214 WERROR err;
216 if (tevent_req_is_werror(req, &err)) {
217 return err;
220 *ancount = in_packet->ancount;
221 *answers = talloc_move(mem_ctx, &in_packet->answers);
223 *nscount = in_packet->nscount;
224 *nsrecs = talloc_move(mem_ctx, &in_packet->nsrecs);
226 *arcount = in_packet->arcount;
227 *additional = talloc_move(mem_ctx, &in_packet->additional);
229 return WERR_OK;
232 static WERROR handle_question(struct dns_server *dns,
233 TALLOC_CTX *mem_ctx,
234 const struct dns_name_question *question,
235 struct dns_res_rec **answers, uint16_t *ancount)
237 struct dns_res_rec *ans = *answers;
238 WERROR werror;
239 unsigned int ri;
240 struct dnsp_DnssrvRpcRecord *recs;
241 uint16_t rec_count, ai = *ancount;
242 struct ldb_dn *dn = NULL;
244 werror = dns_name2dn(dns, mem_ctx, question->name, &dn);
245 W_ERROR_NOT_OK_RETURN(werror);
247 werror = dns_lookup_records(dns, mem_ctx, dn, &recs, &rec_count);
248 W_ERROR_NOT_OK_RETURN(werror);
250 ans = talloc_realloc(mem_ctx, ans, struct dns_res_rec, rec_count + ai);
251 if (ans == NULL) {
252 return WERR_NOMEM;
255 for (ri = 0; ri < rec_count; ri++) {
256 if ((recs[ri].wType == DNS_TYPE_CNAME) &&
257 ((question->question_type == DNS_QTYPE_A) ||
258 (question->question_type == DNS_QTYPE_AAAA))) {
259 struct dns_name_question *new_q =
260 talloc(mem_ctx, struct dns_name_question);
262 if (new_q == NULL) {
263 return WERR_NOMEM;
266 /* We reply with one more record, so grow the array */
267 ans = talloc_realloc(mem_ctx, ans, struct dns_res_rec,
268 rec_count + 1);
269 if (ans == NULL) {
270 TALLOC_FREE(new_q);
271 return WERR_NOMEM;
274 /* First put in the CNAME record */
275 werror = create_response_rr(question, &recs[ri], &ans, &ai);
276 if (!W_ERROR_IS_OK(werror)) {
277 return werror;
280 /* And then look up the name it points at.. */
282 /* First build up the new question */
283 new_q->question_type = question->question_type;
284 new_q->question_class = question->question_class;
285 if (new_q->question_type == DNS_QTYPE_A) {
286 new_q->name = talloc_strdup(new_q, recs[ri].data.ipv4);
287 } else if (new_q->question_type == DNS_QTYPE_AAAA) {
288 new_q->name = talloc_strdup(new_q, recs[ri].data.ipv6);
290 if (new_q->name == NULL) {
291 TALLOC_FREE(new_q);
292 return WERR_NOMEM;
294 /* and then call the lookup again */
295 werror = handle_question(dns, mem_ctx, new_q, &ans, &ai);
296 if (!W_ERROR_IS_OK(werror)) {
297 return werror;
301 continue;
303 if ((question->question_type != DNS_QTYPE_ALL) &&
304 (recs[ri].wType != question->question_type)) {
305 continue;
307 werror = create_response_rr(question, &recs[ri], &ans, &ai);
308 if (!W_ERROR_IS_OK(werror)) {
309 return werror;
313 if (ai == 0) {
314 return DNS_ERR(NAME_ERROR);
317 *ancount = ai;
318 *answers = ans;
320 return WERR_OK;
323 static NTSTATUS create_tkey(struct dns_server *dns,
324 const char* name,
325 const char* algorithm,
326 struct dns_server_tkey **tkey)
328 NTSTATUS status;
329 struct dns_server_tkey_store *store = dns->tkeys;
330 struct dns_server_tkey *k = talloc_zero(store, struct dns_server_tkey);
332 if (k == NULL) {
333 return NT_STATUS_NO_MEMORY;
336 k->name = talloc_strdup(k, name);
338 if (k->name == NULL) {
339 return NT_STATUS_NO_MEMORY;
342 k->algorithm = talloc_strdup(k, algorithm);
343 if (k->algorithm == NULL) {
344 return NT_STATUS_NO_MEMORY;
347 status = samba_server_gensec_start(k,
348 dns->task->event_ctx,
349 dns->task->msg_ctx,
350 dns->task->lp_ctx,
351 dns->server_credentials,
352 "dns",
353 &k->gensec);
354 if (!NT_STATUS_IS_OK(status)) {
355 DEBUG(1, ("Failed to start GENSEC server code: %s\n", nt_errstr(status)));
356 *tkey = NULL;
357 return status;
360 gensec_want_feature(k->gensec, GENSEC_FEATURE_SIGN);
362 status = gensec_start_mech_by_oid(k->gensec, GENSEC_OID_SPNEGO);
364 if (!NT_STATUS_IS_OK(status)) {
365 DEBUG(1, ("Failed to start GENSEC server code: %s\n",
366 nt_errstr(status)));
367 *tkey = NULL;
368 return status;
371 if (store->tkeys[store->next_idx] != NULL) {
372 TALLOC_FREE(store->tkeys[store->next_idx]);
375 store->tkeys[store->next_idx] = k;
376 (store->next_idx)++;
377 store->next_idx %= store->size;
379 *tkey = k;
380 return NT_STATUS_OK;
383 static NTSTATUS accept_gss_ticket(TALLOC_CTX *mem_ctx,
384 struct dns_server *dns,
385 struct dns_server_tkey *tkey,
386 const DATA_BLOB *key,
387 DATA_BLOB *reply,
388 uint16_t *dns_auth_error)
390 NTSTATUS status;
392 status = gensec_update(tkey->gensec, mem_ctx, dns->task->event_ctx,
393 *key, reply);
395 if (NT_STATUS_EQUAL(NT_STATUS_MORE_PROCESSING_REQUIRED, status)) {
396 *dns_auth_error = DNS_RCODE_OK;
397 return status;
400 if (NT_STATUS_IS_OK(status)) {
402 status = gensec_session_info(tkey->gensec, tkey, &tkey->session_info);
403 if (!NT_STATUS_IS_OK(status)) {
404 *dns_auth_error = DNS_RCODE_BADKEY;
405 return status;
407 *dns_auth_error = DNS_RCODE_OK;
410 return status;
413 static WERROR handle_tkey(struct dns_server *dns,
414 TALLOC_CTX *mem_ctx,
415 const struct dns_name_packet *in,
416 struct dns_request_state *state,
417 struct dns_res_rec **answers,
418 uint16_t *ancount)
420 struct dns_res_rec *in_tkey = NULL;
421 struct dns_res_rec *ret_tkey;
422 uint16_t i;
424 for (i = 0; i < in->arcount; i++) {
425 if (in->additional[i].rr_type == DNS_QTYPE_TKEY) {
426 in_tkey = &in->additional[i];
427 break;
431 /* If this is a TKEY query, it should have a TKEY RR.
432 * Behaviour is not really specified in RFC 2930 or RFC 3645, but
433 * FORMAT_ERROR seems to be what BIND uses .*/
434 if (in_tkey == NULL) {
435 return DNS_ERR(FORMAT_ERROR);
438 ret_tkey = talloc_zero(mem_ctx, struct dns_res_rec);
439 if (ret_tkey == NULL) {
440 return WERR_NOMEM;
443 ret_tkey->name = talloc_strdup(ret_tkey, in_tkey->name);
444 if (ret_tkey->name == NULL) {
445 return WERR_NOMEM;
448 ret_tkey->rr_type = DNS_QTYPE_TKEY;
449 ret_tkey->rr_class = DNS_QCLASS_ANY;
450 ret_tkey->length = UINT16_MAX;
452 ret_tkey->rdata.tkey_record.algorithm = talloc_strdup(ret_tkey,
453 in_tkey->rdata.tkey_record.algorithm);
454 if (ret_tkey->rdata.tkey_record.algorithm == NULL) {
455 return WERR_NOMEM;
458 ret_tkey->rdata.tkey_record.inception = in_tkey->rdata.tkey_record.inception;
459 ret_tkey->rdata.tkey_record.expiration = in_tkey->rdata.tkey_record.expiration;
460 ret_tkey->rdata.tkey_record.mode = in_tkey->rdata.tkey_record.mode;
462 switch (in_tkey->rdata.tkey_record.mode) {
463 case DNS_TKEY_MODE_DH:
464 /* FIXME: According to RFC 2930, we MUST support this, but we don't.
465 * Still, claim it's a bad key instead of a bad mode */
466 ret_tkey->rdata.tkey_record.error = DNS_RCODE_BADKEY;
467 break;
468 case DNS_TKEY_MODE_GSSAPI: {
469 NTSTATUS status;
470 struct dns_server_tkey *tkey;
471 DATA_BLOB key;
472 DATA_BLOB reply;
474 tkey = dns_find_tkey(dns->tkeys, in->questions[0].name);
475 if (tkey != NULL && tkey->complete) {
476 /* TODO: check if the key is still valid */
477 DEBUG(1, ("Rejecting tkey negotiation for already established key\n"));
478 ret_tkey->rdata.tkey_record.error = DNS_RCODE_BADNAME;
479 break;
482 if (tkey == NULL) {
483 status = create_tkey(dns, in->questions[0].name,
484 in_tkey->rdata.tkey_record.algorithm,
485 &tkey);
486 if (!NT_STATUS_IS_OK(status)) {
487 ret_tkey->rdata.tkey_record.error = DNS_RCODE_BADKEY;
488 return ntstatus_to_werror(status);
492 key.data = in_tkey->rdata.tkey_record.key_data;
493 key.length = in_tkey->rdata.tkey_record.key_size;
495 status = accept_gss_ticket(ret_tkey, dns, tkey, &key, &reply,
496 &ret_tkey->rdata.tkey_record.error);
497 if (NT_STATUS_EQUAL(status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
498 DEBUG(1, ("More processing required\n"));
499 ret_tkey->rdata.tkey_record.error = DNS_RCODE_BADKEY;
500 } else if (NT_STATUS_IS_OK(status)) {
501 DEBUG(1, ("Tkey handshake completed\n"));
502 ret_tkey->rdata.tkey_record.key_size = reply.length;
503 ret_tkey->rdata.tkey_record.key_data = talloc_memdup(ret_tkey,
504 reply.data,
505 reply.length);
506 state->sign = true;
507 state->key_name = talloc_strdup(mem_ctx, tkey->name);
508 if (state->key_name == NULL) {
509 return WERR_NOMEM;
511 } else {
512 DEBUG(1, ("GSS key negotiation returned %s\n", nt_errstr(status)));
513 ret_tkey->rdata.tkey_record.error = DNS_RCODE_BADKEY;
516 break;
518 case DNS_TKEY_MODE_DELETE:
519 /* TODO: implement me */
520 DEBUG(1, ("Should delete tkey here\n"));
521 ret_tkey->rdata.tkey_record.error = DNS_RCODE_OK;
522 break;
523 case DNS_TKEY_MODE_NULL:
524 case DNS_TKEY_MODE_SERVER:
525 case DNS_TKEY_MODE_CLIENT:
526 case DNS_TKEY_MODE_LAST:
527 /* We don't have to implement these, return a mode error */
528 ret_tkey->rdata.tkey_record.error = DNS_RCODE_BADMODE;
529 break;
530 default:
531 DEBUG(1, ("Unsupported TKEY mode %d\n",
532 in_tkey->rdata.tkey_record.mode));
535 *answers = ret_tkey;
536 *ancount = 1;
538 return WERR_OK;
541 struct dns_server_process_query_state {
542 struct dns_res_rec *answers;
543 uint16_t ancount;
544 struct dns_res_rec *nsrecs;
545 uint16_t nscount;
546 struct dns_res_rec *additional;
547 uint16_t arcount;
550 static void dns_server_process_query_got_response(struct tevent_req *subreq);
552 struct tevent_req *dns_server_process_query_send(
553 TALLOC_CTX *mem_ctx, struct tevent_context *ev,
554 struct dns_server *dns, struct dns_request_state *req_state,
555 const struct dns_name_packet *in)
557 struct tevent_req *req, *subreq;
558 struct dns_server_process_query_state *state;
560 req = tevent_req_create(mem_ctx, &state,
561 struct dns_server_process_query_state);
562 if (req == NULL) {
563 return NULL;
565 if (in->qdcount != 1) {
566 tevent_req_werror(req, DNS_ERR(FORMAT_ERROR));
567 return tevent_req_post(req, ev);
570 /* Windows returns NOT_IMPLEMENTED on this as well */
571 if (in->questions[0].question_class == DNS_QCLASS_NONE) {
572 tevent_req_werror(req, DNS_ERR(NOT_IMPLEMENTED));
573 return tevent_req_post(req, ev);
576 if (in->questions[0].question_type == DNS_QTYPE_TKEY) {
577 WERROR err;
579 err = handle_tkey(dns, state, in, req_state,
580 &state->answers, &state->ancount);
581 if (tevent_req_werror(req, err)) {
582 return tevent_req_post(req, ev);
584 tevent_req_done(req);
585 return tevent_req_post(req, ev);
588 if (dns_authorative_for_zone(dns, in->questions[0].name)) {
589 WERROR err;
591 req_state->flags |= DNS_FLAG_AUTHORITATIVE;
592 err = handle_question(dns, state, &in->questions[0],
593 &state->answers, &state->ancount);
594 if (tevent_req_werror(req, err)) {
595 return tevent_req_post(req, ev);
597 tevent_req_done(req);
598 return tevent_req_post(req, ev);
601 if ((req_state->flags & DNS_FLAG_RECURSION_DESIRED) &&
602 (req_state->flags & DNS_FLAG_RECURSION_AVAIL)) {
603 DEBUG(2, ("Not authoritative for '%s', forwarding\n",
604 in->questions[0].name));
606 subreq = ask_forwarder_send(
607 state, ev, lpcfg_dns_forwarder(dns->task->lp_ctx),
608 &in->questions[0]);
609 if (tevent_req_nomem(subreq, req)) {
610 return tevent_req_post(req, ev);
612 tevent_req_set_callback(
613 subreq, dns_server_process_query_got_response, req);
614 return req;
617 tevent_req_werror(req, DNS_ERR(NAME_ERROR));
618 return tevent_req_post(req, ev);
621 static void dns_server_process_query_got_response(struct tevent_req *subreq)
623 struct tevent_req *req = tevent_req_callback_data(
624 subreq, struct tevent_req);
625 struct dns_server_process_query_state *state = tevent_req_data(
626 req, struct dns_server_process_query_state);
627 WERROR err;
629 err = ask_forwarder_recv(subreq, state,
630 &state->answers, &state->ancount,
631 &state->nsrecs, &state->nscount,
632 &state->additional, &state->arcount);
633 TALLOC_FREE(subreq);
634 if (tevent_req_werror(req, err)) {
635 return;
637 tevent_req_done(req);
640 WERROR dns_server_process_query_recv(
641 struct tevent_req *req, TALLOC_CTX *mem_ctx,
642 struct dns_res_rec **answers, uint16_t *ancount,
643 struct dns_res_rec **nsrecs, uint16_t *nscount,
644 struct dns_res_rec **additional, uint16_t *arcount)
646 struct dns_server_process_query_state *state = tevent_req_data(
647 req, struct dns_server_process_query_state);
648 WERROR err;
650 if (tevent_req_is_werror(req, &err)) {
651 return err;
653 *answers = talloc_move(mem_ctx, &state->answers);
654 *ancount = state->ancount;
655 *nsrecs = talloc_move(mem_ctx, &state->nsrecs);
656 *nscount = state->nscount;
657 *additional = talloc_move(mem_ctx, &state->additional);
658 *arcount = state->arcount;
659 return WERR_OK;