]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[master] fix dig +norrcomments
authorEvan Hunt <each@isc.org>
Sat, 5 Dec 2015 00:16:59 +0000 (16:16 -0800)
committerEvan Hunt <each@isc.org>
Sat, 5 Dec 2015 00:16:59 +0000 (16:16 -0800)
4272. [bug] dig: the +norrcomments option didn't work with +multi.
[RT #41234]

CHANGES
bin/dig/dig.c
bin/tests/system/digdelv/ns2/example.db
bin/tests/system/digdelv/tests.sh

diff --git a/CHANGES b/CHANGES
index 7a2fb96666c864a5bb0272c5260b543063dda0e2..06cb373c731d5e603ed4b57b73853cb29d548390 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+4272.  [bug]           dig: the +norrcomments option didn't work with +multi.
+                       [RT #41234]
+
 4271.  [test]          Unit tests could deadlock in isc__taskmgr_pause().
                        [RT #41235]
 
index 52e5df009a8e162c2a202c3c2d4504b052e1ff8a..0ae86b60228bb5f10f802f866639bd8118ece211 100644 (file)
@@ -67,11 +67,14 @@ static char hexcookie[81];
 static isc_boolean_t short_form = ISC_FALSE, printcmd = ISC_TRUE,
        ip6_int = ISC_FALSE, plusquest = ISC_FALSE, pluscomm = ISC_FALSE,
        multiline = ISC_FALSE, nottl = ISC_FALSE, noclass = ISC_FALSE,
-       onesoa = ISC_FALSE, rrcomments = ISC_FALSE, use_usec = ISC_FALSE,
-       nocrypto = ISC_FALSE, ttlunits = ISC_FALSE, ipv4only = ISC_FALSE,
-       ipv6only = ISC_FALSE;
+       onesoa = ISC_FALSE, use_usec = ISC_FALSE,
+       nocrypto = ISC_FALSE, ttlunits = ISC_FALSE,
+       ipv4only = ISC_FALSE, ipv6only = ISC_FALSE;
 static isc_uint32_t splitwidth = 0xffffffff;
 
+/*% rrcomments are neither explicitly enabled nor disabled by default */
+static int rrcomments = 0;
+
 /*% opcode text */
 static const char * const opcodetext[] = {
        "QUERY",
@@ -325,7 +328,8 @@ say_message(dns_rdata_t *rdata, dig_query_t *query, isc_buffer_t *buf) {
                ADD_STRING(buf, " ");
        }
 
-       if (rrcomments)
+       /* Turn on rrcomments if explicitly enabled */
+       if (rrcomments > 0)
                styleflags |= DNS_STYLEFLAG_RRCOMMENT;
        if (nocrypto)
                styleflags |= DNS_STYLEFLAG_NOCRYPTO;
@@ -417,10 +421,11 @@ printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
                styleflags |= DNS_STYLEFLAG_NO_TTL;
        if (noclass)
                styleflags |= DNS_STYLEFLAG_NO_CLASS;
-       if (rrcomments)
-               styleflags |= DNS_STYLEFLAG_RRCOMMENT;
        if (nocrypto)
                styleflags |= DNS_STYLEFLAG_NOCRYPTO;
+       /* Turn on rrcomments if explicitly enabled */
+       if (rrcomments > 0)
+               styleflags |= DNS_STYLEFLAG_RRCOMMENT;
        if (multiline) {
                styleflags |= DNS_STYLEFLAG_OMIT_OWNER;
                styleflags |= DNS_STYLEFLAG_OMIT_CLASS;
@@ -429,7 +434,9 @@ printrdataset(dns_name_t *owner_name, dns_rdataset_t *rdataset,
                styleflags |= DNS_STYLEFLAG_TTL;
                styleflags |= DNS_STYLEFLAG_MULTILINE;
                styleflags |= DNS_STYLEFLAG_COMMENT;
-               styleflags |= DNS_STYLEFLAG_RRCOMMENT;
+               /* Turn on rrcomments if not explicitly disabled */
+               if (rrcomments >= 0)
+                       styleflags |= DNS_STYLEFLAG_RRCOMMENT;
        }
 
        if (multiline || (nottl && noclass))
@@ -470,7 +477,8 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
        styleflags |= DNS_STYLEFLAG_REL_OWNER;
        if (query->lookup->comments)
                styleflags |= DNS_STYLEFLAG_COMMENT;
-       if (rrcomments)
+       /* Turn on rrcomments if explicitly enabled */
+       if (rrcomments > 0)
                styleflags |= DNS_STYLEFLAG_RRCOMMENT;
        if (ttlunits)
                styleflags |= DNS_STYLEFLAG_TTL_UNITS;
@@ -487,7 +495,9 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
                styleflags |= DNS_STYLEFLAG_OMIT_TTL;
                styleflags |= DNS_STYLEFLAG_TTL;
                styleflags |= DNS_STYLEFLAG_MULTILINE;
-               styleflags |= DNS_STYLEFLAG_RRCOMMENT;
+               /* Turn on rrcomments unless explicitly disabled */
+               if (rrcomments >= 0)
+                       styleflags |= DNS_STYLEFLAG_RRCOMMENT;
        }
        if (multiline || (nottl && noclass))
                result = dns_master_stylecreate2(&style, styleflags,
@@ -806,7 +816,6 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
                        lookup->section_answer = state;
                        lookup->section_additional = state;
                        lookup->comments = state;
-                       rrcomments = state;
                        lookup->stats = state;
                        printcmd = state;
                        break;
@@ -1085,13 +1094,13 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
                                        lookup->identify = ISC_TRUE;
                                        lookup->stats = ISC_FALSE;
                                        lookup->comments = ISC_FALSE;
-                                       rrcomments = ISC_FALSE;
                                        lookup->section_additional = ISC_FALSE;
                                        lookup->section_authority = ISC_FALSE;
                                        lookup->section_question = ISC_FALSE;
                                        lookup->rdtype = dns_rdatatype_ns;
                                        lookup->rdtypeset = ISC_TRUE;
                                        short_form = ISC_TRUE;
+                                       rrcomments = 0;
                                }
                                break;
                        default:
@@ -1181,7 +1190,7 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
                        break;
                case 'r': /* rrcomments */
                        FULLCHECK("rrcomments");
-                       rrcomments = state;
+                       rrcomments = state ? 1 : -1;
                        break;
                default:
                        goto invalid_option;
@@ -1209,8 +1218,8 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
                                        lookup->section_authority = ISC_FALSE;
                                        lookup->section_question = ISC_FALSE;
                                        lookup->comments = ISC_FALSE;
-                                       rrcomments = ISC_FALSE;
                                        lookup->stats = ISC_FALSE;
+                                       rrcomments = -1;
                                }
                                break;
                        case 'w': /* showsearch */
@@ -1325,7 +1334,7 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
                                        lookup->recurse = ISC_FALSE;
                                        lookup->identify = ISC_TRUE;
                                        lookup->comments = ISC_FALSE;
-                                       rrcomments = ISC_FALSE;
+                                       rrcomments = 0;
                                        lookup->stats = ISC_FALSE;
                                        lookup->section_additional = ISC_FALSE;
                                        lookup->section_authority = ISC_TRUE;
index 03d57725ce121841135b6efd4558d29d13e75513..0a1aa5d61579bab9fa0d47b9ceacecc46dafef20 100644 (file)
@@ -37,3 +37,14 @@ c                    AAAA    fd92:7065:b8e:ffff::3
 foo                    TXT     "testing"
 foo                    A       10.0.1.0
 foo                    SSHFP   2 1 123456789abcdef67890123456789abcdef67890
+
+;;
+;; we are not testing DNSSEC behavior, so we don't care about the semantics
+;; of the following records.
+dnskey                  300     DNSKEY  256 3 1 (
+                                        AQPTpWyReB/e9Ii6mVGnakS8hX2zkh/iUYAg
+                                        +Ge4noWROpTWOIBvm76zeJPWs4Zfqa1IsswD
+                                        Ix5Mqeg0zwclz59uecKsKyx5w9IhtZ8plc4R
+                                        b9VIE5x7KNHAYTvTO5d4S8M=
+                                        )
+
index 9cb44965594f223c6f390ee4b34d53ba627e7bd1..175f216811a7f7af5b77c14c44fc5d39ed5e9278 100644 (file)
@@ -54,6 +54,38 @@ if [ -x ${DIG} ] ; then
   if [ $ret != 0 ]; then echo "I:failed"; fi
   status=`expr $status + $ret`
 
+  n=`expr $n + 1`
+  echo "I:checking dig +multi +norrcomments works for dnskey (when default is rrcomments)($n)"
+  ret=0
+  $DIG $DIGOPTS +tcp @10.53.0.3 +multi +norrcomments DNSKEY dnskey.example > dig.out.test$n || ret=1
+  grep -v "; ZSK; alg = RSAMD5 ; key id = 30795" < dig.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo "I:checking dig +multi +norrcomments works for soa (when default is rrcomments)($n)"
+  ret=0
+  $DIG $DIGOPTS +tcp @10.53.0.3 +multi +norrcomments SOA example > dig.out.test$n || ret=1
+  grep -v "; ZSK; alg = RSAMD5 ; key id = 30795" < dig.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo "I:checking dig +rrcomments works for DNSKEY($n)"
+  ret=0
+  $DIG $DIGOPTS +tcp @10.53.0.3 +rrcomments DNSKEY dnskey.example > dig.out.test$n || ret=1
+  grep "; ZSK; alg = RSAMD5 ; key id = 30795" < dig.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo "I:checking dig +short +rrcomments works for DNSKEY ($n)"
+  ret=0
+  $DIG $DIGOPTS +tcp @10.53.0.3 +short +rrcomments DNSKEY dnskey.example > dig.out.test$n || ret=1
+  grep "; ZSK; alg = RSAMD5 ; key id = 30795" < dig.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
 else
   echo "$DIG is needed, so skipping these dig tests"
 fi
@@ -115,6 +147,38 @@ if [ -x ${DELV} ] ; then
   if [ $ret != 0 ]; then echo "I:failed"; fi
   status=`expr $status + $ret`
 
+  n=`expr $n + 1`
+  echo "I:checking delv +multi +norrcomments works for dnskey (when default is rrcomments)($n)"
+  ret=0
+  $DELV $DELVOPTS +tcp @10.53.0.3 +multi +norrcomments DNSKEY dnskey.example > delv.out.test$n || ret=1
+  grep -v "; ZSK; alg = RSAMD5 ; key id = 30795" < delv.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo "I:checking delv +multi +norrcomments works for soa (when default is rrcomments)($n)"
+  ret=0
+  $DELV $DELVOPTS +tcp @10.53.0.3 +multi +norrcomments SOA example > delv.out.test$n || ret=1
+  grep -v "; ZSK; alg = RSAMD5 ; key id = 30795" < delv.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo "I:checking delv +rrcomments works for DNSKEY($n)"
+  ret=0
+  $DELV $DELVOPTS +tcp @10.53.0.3 +rrcomments DNSKEY dnskey.example > delv.out.test$n || ret=1
+  grep "; ZSK; alg = RSAMD5 ; key id = 30795" < delv.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
+  n=`expr $n + 1`
+  echo "I:checking delv +short +rrcomments works for DNSKEY ($n)"
+  ret=0
+  $DELV $DELVOPTS +tcp @10.53.0.3 +short +rrcomments DNSKEY dnskey.example > delv.out.test$n || ret=1
+  grep "; ZSK; alg = RSAMD5 ; key id = 30795" < delv.out.test$n > /dev/null || ret=1
+  if [ $ret != 0 ]; then echo "I:failed"; fi
+  status=`expr $status + $ret`
+
   exit $status
 else
   echo "$DELV is needed, so skipping these delv tests"