]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Handle placeholder KEYDATA record
authorMark Andrews <marka@isc.org>
Tue, 15 Jun 2021 01:50:52 +0000 (11:50 +1000)
committerMark Andrews <marka@isc.org>
Thu, 1 Jul 2021 05:01:05 +0000 (15:01 +1000)
A placeholder keydata record can appear in a zone file.  Allow them
to be read back in.

(cherry picked from commit c6fa8a1d4526a768a93a4f14dff69e6d3751329a)

bin/tests/system/journal/clean.sh
bin/tests/system/journal/ns2/managed-keys.bind.in [new file with mode: 0644]
bin/tests/system/journal/ns2/managed-keys.bind.jnl.in [new file with mode: 0644]
bin/tests/system/journal/ns2/named.conf.in [new file with mode: 0644]
bin/tests/system/journal/setup.sh
bin/tests/system/journal/tests.sh
lib/dns/rdata/generic/keydata_65533.c

index dc275f439178744a1a8a36d530d4f404e0cead8d..45b6657dfacac73925cb70a38cdd6a699b301461 100644 (file)
@@ -14,4 +14,5 @@ rm -f */named.run
 rm -f dig.out*
 rm -f journalprint.out.*
 rm -f ns1/managed-keys.bind
+rm -f ns2/managed-keys.bind
 rm -f tmp.jnl
diff --git a/bin/tests/system/journal/ns2/managed-keys.bind.in b/bin/tests/system/journal/ns2/managed-keys.bind.in
new file mode 100644 (file)
index 0000000..2139706
--- /dev/null
@@ -0,0 +1,14 @@
+$ORIGIN .
+$TTL 0 ; 0 seconds
+@                      IN SOA  . . (
+                               29         ; serial
+                               0          ; refresh (0 seconds)
+                               0          ; retry (0 seconds)
+                               0          ; expire (0 seconds)
+                               0          ; minimum (0 seconds)
+                               )
+                       KEYDATA 20210611104535 19700101000000 19700101000000 0 0 0 (
+
+                               ) ; ZSK; alg = 0; key id = 0
+                               ; next refresh: Fri, 11 Jun 2021 10:45:35 GMT
+                               ; no trust
diff --git a/bin/tests/system/journal/ns2/managed-keys.bind.jnl.in b/bin/tests/system/journal/ns2/managed-keys.bind.jnl.in
new file mode 100644 (file)
index 0000000..01c1d47
Binary files /dev/null and b/bin/tests/system/journal/ns2/managed-keys.bind.jnl.in differ
diff --git a/bin/tests/system/journal/ns2/named.conf.in b/bin/tests/system/journal/ns2/named.conf.in
new file mode 100644 (file)
index 0000000..17d1f12
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+options {
+       query-source address 10.53.0.2;
+       notify-source 10.53.0.2;
+       transfer-source 10.53.0.2;
+       port @PORT@;
+       session-keyfile "session.key";
+       pid-file "named.pid";
+       listen-on { 10.53.0.2; };
+       listen-on-v6 { none; };
+       dnssec-validation yes;
+       minimal-responses no;
+       recursion no;
+       notify yes;
+};
+
+key rndc_key {
+       secret "1234abcd8765";
+       algorithm hmac-sha256;
+};
+
+controls {
+       inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
+};
index 4a5253900c94d9ac709f83ac20744dbc86530c49..62387d2e0dfb66370dd6713e365fd712ceffccdc 100644 (file)
@@ -43,3 +43,7 @@ cp ns1/maxjournal2.jnl.saved ns1/maxjournal2.db.jnl
 
 cp ns1/managed-keys.bind.in ns1/managed-keys.bind
 $PERL ../fromhex.pl < ns1/managed-keys.bind.jnl.in > ns1/managed-keys.bind.jnl
+
+copy_setports ns2/named.conf.in ns2/named.conf
+cp ns2/managed-keys.bind.in ns2/managed-keys.bind
+cp ns2/managed-keys.bind.jnl.in ns2/managed-keys.bind.jnl
index 3c20925dbc33fbb4cd4ce67442a163737a0ffd0e..c5fbd4b6c6c0ab52f682ea4a858f1b51c9c220ba 100644 (file)
@@ -243,5 +243,11 @@ done
 [ $ret -eq 0 ] || echo_i "failed"
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo_i "check that journal is applied to zone with keydata placeholder record"
+ret=0
+grep 'managed-keys-zone: journal rollforward completed successfully: up to date' ns2/named.run > /dev/null 2>&1 || ret=1
+[ $ret -eq 0 ] || echo_i "failed"
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1
index 27eb20c02646ab71bfb531c0581c98407d1d8a5c..6c78c98a1f2493243e4bffaa99cdcf46e3b82b66 100644 (file)
@@ -71,6 +71,11 @@ fromtext_keydata(ARGS_FROMTEXT) {
        RETTOK(dns_secalg_fromtext(&alg, &token.value.as_textregion));
        RETERR(mem_tobuffer(target, &alg, 1));
 
+       /* Do we have a placeholder KEYDATA record? */
+       if (flags == 0 && proto == 0 && alg == 0) {
+               return (ISC_R_SUCCESS);
+       }
+
        /* No Key? */
        if ((flags & 0xc000) == 0xc000) {
                return (ISC_R_SUCCESS);
@@ -84,7 +89,7 @@ totext_keydata(ARGS_TOTEXT) {
        isc_region_t sr;
        char buf[sizeof("64000")];
        unsigned int flags;
-       unsigned char algorithm;
+       unsigned char proto, algorithm;
        unsigned long refresh, add, deltime;
        char algbuf[DNS_NAME_FORMATSIZE];
        const char *keyinfo;
@@ -132,7 +137,8 @@ totext_keydata(ARGS_TOTEXT) {
        }
 
        /* protocol */
-       snprintf(buf, sizeof(buf), "%u", sr.base[0]);
+       proto = sr.base[0];
+       snprintf(buf, sizeof(buf), "%u", proto);
        isc_region_consume(&sr, 1);
        RETERR(str_totext(buf, target));
        RETERR(str_totext(" ", target));
@@ -143,6 +149,14 @@ totext_keydata(ARGS_TOTEXT) {
        isc_region_consume(&sr, 1);
        RETERR(str_totext(buf, target));
 
+       /* Do we have a placeholder KEYDATA record? */
+       if (flags == 0 && proto == 0 && algorithm == 0) {
+               if ((tctx->flags & DNS_STYLEFLAG_RRCOMMENT) != 0) {
+                       RETERR(str_totext(" ; placeholder", target));
+               }
+               return (ISC_R_SUCCESS);
+       }
+
        /* No Key? */
        if ((flags & 0xc000) == 0xc000) {
                return (ISC_R_SUCCESS);