]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add -class option to rndc nta
authorEvan Hunt <each@isc.org>
Tue, 4 Sep 2018 06:55:29 +0000 (23:55 -0700)
committerEvan Hunt <each@isc.org>
Mon, 10 Sep 2018 20:18:35 +0000 (13:18 -0700)
(cherry picked from commit cc0abf62a1bb9c17dad4ace517ed654fd0b6d51e)

bin/named/server.c
bin/rndc/rndc.docbook
bin/tests/system/rndc/clean.sh
bin/tests/system/rndc/tests.sh

index 907d2851cc81cf9da70732eec42ca10efda56062..7f87ccf042b33386030fbca556cdbd0d4fee6b7e 100644 (file)
@@ -13667,6 +13667,7 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
        dns_name_t *ntaname;
        dns_ttl_t ntattl;
        bool ttlset = false, excl = false;
+       dns_rdataclass_t rdclass = dns_rdataclass_in;
 
        UNUSED(force);
 
@@ -13674,18 +13675,20 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
 
        /* Skip the command name. */
        ptr = next_token(lex, text);
-       if (ptr == NULL)
+       if (ptr == NULL) {
                return (ISC_R_UNEXPECTEDEND);
+       }
 
        for (;;) {
                /* Check for options */
                ptr = next_token(lex, text);
-               if (ptr == NULL)
+               if (ptr == NULL) {
                        return (ISC_R_UNEXPECTEDEND);
+               }
 
-               if (argcheck(ptr, "dump"))
+               if (argcheck(ptr, "dump")) {
                        dump = true;
-               else if (argcheck(ptr, "remove")) {
+               else if (argcheck(ptr, "remove")) {
                        ntattl = 0;
                        ttlset = true;
                } else if (argcheck(ptr, "force")) {
@@ -13715,8 +13718,22 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
 
                        ttlset = true;
                        continue;
-               } else
+               } else if (argcheck(ptr, "class")) {
+                       isc_textregion_t tr;
+
+                       ptr = next_token(lex, text);
+                       if (ptr == NULL) {
+                               msg = "No class specified";
+                               CHECK(ISC_R_UNEXPECTEDEND);
+                       }
+
+                       tr.base = ptr;
+                       tr.length = strlen(ptr);
+                       CHECK(dns_rdataclass_fromtext(&rdclass, &tr));
+                       continue;
+               } else {
                        nametext = ptr;
+               }
 
                break;
        }
@@ -13729,11 +13746,13 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
                     view != NULL;
                     view = ISC_LIST_NEXT(view, link))
                {
-                       if (ntatable != NULL)
+                       if (ntatable != NULL) {
                                dns_ntatable_detach(&ntatable);
+                       }
                        result = dns_view_getntatable(view, &ntatable);
-                       if (result == ISC_R_NOTFOUND)
+                       if (result == ISC_R_NOTFOUND) {
                                continue;
+                       }
                        CHECK(dns_ntatable_totext(ntatable, text));
                }
                CHECK(putnull(text));
@@ -13750,17 +13769,19 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
        }
 
        /* Get the NTA name. */
-       if (nametext == NULL)
+       if (nametext == NULL) {
                nametext = next_token(lex, text);
-       if (nametext == NULL)
+       }
+       if (nametext == NULL) {
                return (ISC_R_UNEXPECTEDEND);
+       }
 
        /* Copy nametext as it'll be overwritten by next_token() */
        strlcpy(namebuf, nametext, DNS_NAME_FORMATSIZE);
 
-       if (strcmp(namebuf, ".") == 0)
+       if (strcmp(namebuf, ".") == 0) {
                ntaname = dns_rootname;
-       else {
+       else {
                isc_buffer_t b;
                isc_buffer_init(&b, namebuf, strlen(namebuf));
                isc_buffer_add(&b, strlen(namebuf));
@@ -13785,6 +13806,10 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
                        continue;
                }
 
+               if (view->rdclass != rdclass && rdclass != dns_rdataclass_any) {
+                       continue;
+               }
+
                if (view->nta_lifetime == 0) {
                        continue;
                }
@@ -13870,10 +13895,12 @@ ns_server_nta(ns_server_t *server, isc_lex_t *lex, bool readonly,
                (void) putstr(text, msg);
                (void) putnull(text);
        }
-       if (excl)
+       if (excl) {
                isc_task_endexclusive(server->task);
-       if (ntatable != NULL)
+       }
+       if (ntatable != NULL) {
                dns_ntatable_detach(&ntatable);
+       }
        return (result);
 }
 
index 4bf3b13505722dfdfd91969982820c909e0fe73f..fb72bd1885d8076c587bcc26df176c2a5da78d40 100644 (file)
 
       <varlistentry>
        <term><userinput>nta
-       <optional>( -d | -f | -r | -l <replaceable>duration</replaceable>)</optional>
+           <optional>( -class <replaceable>class</replaceable> | -dump | -force | -remove | -lifetime <replaceable>duration</replaceable>)</optional>
        <replaceable>domain</replaceable>
        <optional><replaceable>view</replaceable></optional>
        </userinput></term>
            is equivalent to <option>-remove</option>.
          </para>
          <para>
-           If <option>-dump</option> is used, any other arguments
+           If the <option>-dump</option> is used, any other arguments
            are ignored, and a list of existing NTAs is printed
            (note that this may include NTAs that are expired but
            have not yet been cleaned up).
            lifetime, regardless of whether data could be
            validated if the NTA were not present.
          </para>
+         <para>
+           The view class can be specified with <option>-class</option>.
+           The default is class <userinput>IN</userinput>, which is
+           the only class for which DNSSEC is currently supported.
+         </para>
          <para>
            All of these options can be shortened, i.e., to
            <option>-l</option>, <option>-r</option>, <option>-d</option>,
-           and <option>-f</option>.
+           <option>-f</option>, and <option>-c</option>.
          </para>
        </listitem>
       </varlistentry>
index 884280ea96dda63163622495e6b074c042debabf..634248dea91a739f813934ab98f37bdf50c66e2f 100644 (file)
@@ -12,7 +12,7 @@
 rm -f dig.out.*.test*
 rm -f ns*/named.lock
 rm -f ns*/named.memstats
-rm -f ns*/named.run
+rm -f ns*/named.run ns*/named.run.prev
 rm -f ns2/named.stats
 rm -f ns2/nil.db ns2/other.db ns2/static.db ns2/*.jnl
 rm -f ns2/session.key
index a5225a50242a9461726bd0ee3b495bb2b5a13b07..647730e0be24f062bee290d7eabdfd4f879290c4 100644 (file)
@@ -477,6 +477,22 @@ grep "NTA lifetime cannot exceed one week" rndc.out.4.test$n > /dev/null || ret=
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
 
+n=`expr $n + 1`
+echo_i "testing rndc nta -class option ($n)"
+ret=0
+nextpart ns4/named.run > /dev/null
+$RNDCCMD4 nta -c in nta1.example > rndc.out.1.test$n 2>&1
+nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
+$RNDCCMD4 nta -c any nta1.example > rndc.out.2.test$n 2>&1
+nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null || ret=1
+$RNDCCMD4 nta -c ch nta1.example > rndc.out.3.test$n 2>&1
+nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
+$RNDCCMD4 nta -c fake nta1.example > rndc.out.4.test$n 2>&1
+nextpart ns4/named.run | grep "added NTA 'nta1.example'" > /dev/null && ret=1
+grep 'unknown class' rndc.out.4.test$n > /dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+
 for i in 512 1024 2048 4096 8192 16384 32768 65536 131072 262144 524288
 do
        n=`expr $n + 1`