]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
nameserver: correct owner of answered CNAME from wildcard expansion
authorDaniel Salzman <daniel.salzman@nic.cz>
Fri, 21 May 2021 11:23:28 +0000 (13:23 +0200)
committerLibor Peltan <libor.peltan@nic.cz>
Tue, 25 May 2021 15:21:03 +0000 (17:21 +0200)
fixes #715

src/knot/nameserver/process_query.c
tests-extra/data/flags.zone
tests-extra/tests/basic/query/test.py

index 03a8152b56d85dcba0085078b62b0f4bdd2df862..87da3b2884679b26c7d3bdc1ecc076feb388357e 100644 (file)
@@ -883,8 +883,8 @@ int process_query_put_rr(knot_pkt_t *pkt, knotd_qdata_t *qdata,
        /* Wildcard expansion applies only for answers. */
        bool expand = false;
        if (pkt->current == KNOT_ANSWER) {
-               /* Expand if RR is wildcard & we didn't query for wildcard. */
-               expand = (knot_dname_is_wildcard(rr->owner) && !knot_dname_is_wildcard(qdata->name));
+               /* Expand if RR is wildcard. TRICK: if the asterix node is queried directly, we behave like if wildcard would be expanded. It's the same. */
+               expand = knot_dname_is_wildcard(rr->owner);
        }
 
        int ret = KNOT_EOK;
index a243803189b414cedd469fc03fc5e3c5ead82a43..92b69700072b3d90d32895411696a3518e6b2c2a 100644 (file)
@@ -104,6 +104,10 @@ sub.*.wildcard     A       6.7.8.9
 ; Wildcard to CNAME
 *.wildcard-cname CNAME cname
 
+; CNAME to asterix-leading expansion
+wild-cname     CNAME   *.expanded.wildcard-cname2
+*.wildcard-cname2 CNAME        *.expanded.wildcard-cname
+
 ; Wildcard to delegation
 *.wildcard-deleg CNAME cname-ns
 
index 4543d7460161e8f71dec09b69ace6c70d9890f05..19f8c963126618ff76aafdd89ad9b99051e15873 100644 (file)
@@ -304,6 +304,14 @@ def query_test(knot, bind, dnssec):
     else:
         resp.cmp(bind, additional=True)
 
+    # Wildcard CNAME with asterisk query
+    resp = knot.dig("*.a.wildcard-cname.flags", "A", udp=True)
+    resp.cmp(bind)
+
+    # Double wildcard expansion
+    resp = knot.dig("wild-cname.flags", "TXT", udp=True)
+    resp.cmp(bind)
+
     # Wildcard leading out
     resp = knot.dig("a.wildcard-out.flags", "A", udp=True, dnssec=dnssec)
     resp.cmp(bind)