s4 dns: TKEY record needs to remember incoming algorithm
[mdw/samba.git] / source4 / dns_server / dns_query.c
index 00feec0a83d3d6d175d0e2f11b7efe05707ce8cc..3c919ee0a973c6fe63487ec120941c184028132b 100644 (file)
@@ -322,6 +322,7 @@ static WERROR handle_question(struct dns_server *dns,
 
 static NTSTATUS create_tkey(struct dns_server *dns,
                            const char* name,
+                           const char* algorithm,
                            struct dns_server_tkey **tkey)
 {
        NTSTATUS status;
@@ -338,6 +339,11 @@ static NTSTATUS create_tkey(struct dns_server *dns,
                return NT_STATUS_NO_MEMORY;
        }
 
+       k->algorithm = talloc_strdup(k, algorithm);
+       if (k->algorithm == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
        status = samba_server_gensec_start(k,
                                           dns->task->event_ctx,
                                           dns->task->msg_ctx,
@@ -442,7 +448,8 @@ static WERROR handle_tkey(struct dns_server *dns,
        ret_tkey->rr_class = DNS_QCLASS_ANY;
        ret_tkey->length = UINT16_MAX;
 
-       ret_tkey->rdata.tkey_record.algorithm = talloc_strdup(ret_tkey, ret_tkey->name);
+       ret_tkey->rdata.tkey_record.algorithm = talloc_strdup(ret_tkey,
+                       in_tkey->rdata.tkey_record.algorithm);
        if (ret_tkey->rdata.tkey_record.algorithm  == NULL) {
                return WERR_NOMEM;
        }
@@ -473,6 +480,7 @@ static WERROR handle_tkey(struct dns_server *dns,
 
                if (tkey == NULL) {
                        status  = create_tkey(dns, in->questions[0].name,
+                                             in_tkey->rdata.tkey_record.algorithm,
                                              &tkey);
                        if (!NT_STATUS_IS_OK(status)) {
                                ret_tkey->rdata.tkey_record.error = DNS_RCODE_BADKEY;