]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
report when NTAs added to multiple views
authorEvan Hunt <each@isc.org>
Wed, 15 Aug 2018 19:29:17 +0000 (12:29 -0700)
committerEvan Hunt <each@isc.org>
Mon, 10 Sep 2018 20:18:33 +0000 (13:18 -0700)
- the text returned by "rndc nta" when adding NTAs to multiple views
  was incorrectly terminated after the first line, so users only saw
  on NTA added unless they checked the logs.

(cherry picked from commit 83dc5a704a13f4b73cde99caa7b01f9702e84f5b)

bin/named/server.c
bin/tests/system/rndc/clean.sh
bin/tests/system/rndc/ns3/named.conf.in
bin/tests/system/rndc/tests.sh

index 9569ee9b5dd4ee0d4277a6b405a798f07dd12c5a..907d2851cc81cf9da70732eec42ca10efda56062 100644 (file)
@@ -917,7 +917,8 @@ configure_view_dnsseckeys(dns_view_t *view, const cfg_obj_t *vconfig,
 
        /* We don't need trust anchors for the _bind view */
        if (strcmp(view->name, "_bind") == 0 &&
-           view->rdclass == dns_rdataclass_chaos) {
+           view->rdclass == dns_rdataclass_chaos)
+       {
                return (ISC_R_SUCCESS);
        }
 
@@ -13778,18 +13779,23 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
             view != NULL;
             view = ISC_LIST_NEXT(view, link))
        {
-               if (viewname != NULL &&
-                   strcmp(view->name, viewname) != 0)
+               static bool first = true;
+
+               if (viewname != NULL && strcmp(view->name, viewname) != 0) {
                        continue;
+               }
 
-               if (view->nta_lifetime == 0)
+               if (view->nta_lifetime == 0) {
                        continue;
+               }
 
-               if (!ttlset)
+               if (!ttlset) {
                        ntattl = view->nta_lifetime;
+               }
 
-               if (ntatable != NULL)
+               if (ntatable != NULL) {
                        dns_ntatable_detach(&ntatable);
+               }
 
                result = dns_view_getntatable(view, &ntatable);
                if (result == ISC_R_NOTFOUND) {
@@ -13812,6 +13818,11 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
                        isc_time_set(&t, when, 0);
                        isc_time_formattimestamp(&t, tbuf, sizeof(tbuf));
 
+                       if (!first) {
+                               CHECK(putstr(text, "\n"));
+                       }
+                       first = false;
+
                        CHECK(putstr(text, "Negative trust anchor added: "));
                        CHECK(putstr(text, namebuf));
                        CHECK(putstr(text, "/"));
@@ -13826,6 +13837,11 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
                } else {
                        CHECK(dns_ntatable_delete(ntatable, ntaname));
 
+                       if (!first) {
+                               CHECK(putstr(text, "\n"));
+                       }
+                       first = false;
+
                        CHECK(putstr(text, "Negative trust anchor removed: "));
                        CHECK(putstr(text, namebuf));
                        CHECK(putstr(text, "/"));
@@ -13845,11 +13861,10 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
                                      "for view '%s': %s",
                                      view->name, isc_result_totext(result));
                }
-
-               CHECK(putnull(text));
-
        }
 
+       CHECK(putnull(text));
+
  cleanup:
        if (msg != NULL) {
                (void) putstr(text, msg);
index df8aa77210fc6546474750073439e1b6c4c3d7e8..884280ea96dda63163622495e6b074c042debabf 100644 (file)
@@ -24,3 +24,4 @@ rm -f ns*/named.conf
 rm -f nsupdate.out.*.test*
 rm -f python.out.*.test*
 rm -f rndc.out.*.test*
+rm -f ns*/*.nta
index e8dbfc4aeb9656d4401ea2bbaf8ce517ff092ce3..dd3529559e02729cdb96ed59232a336c82f3393b 100644 (file)
@@ -14,7 +14,6 @@ options {
        pid-file "named.pid";
        listen-on { 10.53.0.3; };
        listen-on-v6 { none; };
-       recursion no;
 };
 
 key rndc_key {
@@ -31,8 +30,17 @@ controls {
        inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
 };
 
+view all {
+       match-clients { any; };
+
+       recursion no;
+
+       zone "." {
+               type hint;
+               file "../../common/root.hint";
+       };
+};
 
-zone "." {
-       type hint;
-       file "../../common/root.hint";
+view none {
+       match-clients { none; };
 };
index d364e6fea070e9e46635ec9e9b627426e853f6a6..a5225a50242a9461726bd0ee3b495bb2b5a13b07 100644 (file)
@@ -631,5 +631,14 @@ grep "rndc: '' failed: failure" rndc.out.1.test$n > /dev/null
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo_i "check rndc nta reports adding to multiple views ($n)"
+ret=0
+$RNDCCMD 10.53.0.3 nta test.com > rndc.out.test$n 2>&1 || ret=1
+lines=`cat rndc.out.test$n | wc -l`
+[ ${lines:-0} -eq 2 ] || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1