]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4496. [func] dig: add +idnout to control whether labels are
authorMark Andrews <marka@isc.org>
Fri, 28 Oct 2016 01:05:19 +0000 (12:05 +1100)
committerMark Andrews <marka@isc.org>
Fri, 28 Oct 2016 01:05:19 +0000 (12:05 +1100)
                        display in punycode or not.  Requires idn support
                        to be enabled at compile time. [RT #43398]

CHANGES
bin/dig/dig.c
bin/dig/dig.docbook
bin/dig/dighost.c
bin/dig/include/dig/dig.h
bin/tests/system/Makefile.in
bin/tests/system/conf.sh.in
bin/tests/system/digdelv/ns2/example.db
bin/tests/system/digdelv/tests.sh
bin/tests/system/feature-test.c [new file with mode: 0644]
lib/dns/name.c

diff --git a/CHANGES b/CHANGES
index 58ec0d2e95a097500fb07fa60e83843ac8bef904..c031529e4ad42aed5b2d3cbfe4db902acedab9dc 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+4496.  [func]          dig: add +idnout to control whether labels are
+                       display in punycode or not.  Requires idn support
+                       to be enabled at compile time. [RT #43398]
+
 4495.  [bug]           A isc_mutex_init call was it being checked. [RT #43391]
 
 4494.  [bug]           Look for <editline/readline.h>. [RT #43429]
index 55b5a87aefee1643a6d29bac8032ddaa046066cb..906f006ddbf5175fe13d12b84187558999e9e6a6 100644 (file)
@@ -189,6 +189,7 @@ help(void) {
 "                 +[no]fail           (Don't try next server on SERVFAIL)\n"
 "                 +[no]header-only    (Send query without a question section)\n"
 "                 +[no]identify       (ID responders in short answers)\n"
+"                 +[no]idnout         (convert IDN response)\n"
 "                 +[no]ignore         (Don't revert to TCP for TC responses.)\n"
 "                 +[no]keepopen       (Keep the TCP socket open between queries)\n"
 "                 +[no]mapped         (Allow mapped IPv4 over IPv6)\n"
@@ -1057,8 +1058,22 @@ plus_option(const char *option, isc_boolean_t is_batchfile,
        case 'i':
                switch (cmd[1]) {
                case 'd': /* identify */
-                       FULLCHECK("identify");
-                       lookup->identify = state;
+                       switch (cmd[2]) {
+                       case 'e':
+                               FULLCHECK("identify");
+                               lookup->identify = state;
+                               break;
+                       case 'n':
+                               FULLCHECK("idnout");
+#ifndef WITH_IDN
+                               fprintf(stderr, ";; IDN support not enabled\n");
+#else
+                               lookup->idnout = state;
+#endif
+                               break;
+                       default:
+                               goto invalid_option;
+                       }
                        break;
                case 'g': /* ignore */
                default: /*
index 2a711a8fefd2ff3f6db698540d72cd17118ece10..c36310cc7ced37f9303f3e6f029d79119b07b7c2 100644 (file)
          </listitem>
        </varlistentry>
 
+       <varlistentry>
+         <term><option>+[no]idnout</option></term>
+         <listitem>
+           <para>
+             Convert [do not convert] puny code on output.
+             This requires IDN SUPPORT to have been enabled at
+             compile time.  The default is to convert output.
+           </para>
+         </listitem>
+       </varlistentry>
+
        <varlistentry>
          <term><option>+[no]ignore</option></term>
          <listitem>
index 5384358bf19d234436ad333d3267dd82dab86f68..1304d2e20bb2581af80400728b526331441b8510 100644 (file)
@@ -789,6 +789,11 @@ make_empty_lookup(void) {
        looknew->ttlunits = ISC_FALSE;
        looknew->ttlunits = ISC_FALSE;
        looknew->qr = ISC_FALSE;
+#ifdef WITH_IDN
+       looknew->idnout = ISC_TRUE;
+#else
+       looknew->idnout = ISC_FALSE;
+#endif
 #ifdef DIG_SIGCHASE
        looknew->sigchase = ISC_FALSE;
 #if DIG_SIGCHASE_TD
@@ -902,6 +907,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
        looknew->nocrypto = lookold->nocrypto;
        looknew->ttlunits = lookold->ttlunits;
        looknew->qr = lookold->qr;
+       looknew->idnout = lookold->idnout;
 #ifdef DIG_SIGCHASE
        looknew->sigchase = lookold->sigchase;
 #if DIG_SIGCHASE_TD
@@ -2246,7 +2252,8 @@ setup_lookup(dig_lookup_t *lookup) {
 #endif
 
 #ifdef WITH_IDN
-       result = dns_name_settotextfilter(output_filter);
+       result = dns_name_settotextfilter(lookup->idnout ?
+                                         output_filter : NULL);
        check_result(result, "dns_name_settotextfilter");
 #endif
 
index 23d63b259ad432b9d095749877132ba9a8a5440a..e1f80a8fbf468fbe62265900162aeb5c141ccbfd 100644 (file)
@@ -137,6 +137,7 @@ struct dig_lookup {
                use_usec,
                nocrypto,
                ttlunits,
+               idnout,
                qr;
 #ifdef DIG_SIGCHASE
 isc_boolean_t  sigchase;
index 6a7cac6392a2dc57b054b4936d0dd42a5945f87b..40e85f08e4b8803f4e508f7e7726cb77991f6f42 100644 (file)
@@ -8,14 +8,40 @@ srcdir =      @srcdir@
 VPATH =                @srcdir@
 top_srcdir =   @top_srcdir@
 
+VERSION=@BIND9_VERSION@
+
 @BIND9_MAKE_INCLUDES@
 
-SUBDIRS =      builtin dlzexternal dyndb filter-aaaa geoip lwresd pipelined \
-               resolver rndc rpz rsabigexponent statistics tkey tsiggss
-TARGETS =
+SUBDIRS =      builtin dlzexternal dyndb filter-aaaa geoip lwresd \
+               pipelined resolver rndc rpz rsabigexponent statistics tkey \
+               tsiggss
+
+CINCLUDES =    ${ISC_INCLUDES}
+
+CDEFINES =     @USE_GSSAPI@
+CWARNINGS =
+
+DNSLIBS =
+ISCLIBS =      .
+
+DNSDEPLIBS =
+ISCDEPLIBS =
+
+DEPLIBS =
+
+LIBS =         @LIBS@
+
+OBJS =         feature-test.@O@
+SRCS =         feature-test.c
+
+TARGETS =      feature-test@EXEEXT@
 
 @BIND9_MAKE_RULES@
 
+feature-test@EXEEXT@: feature-test.@O@
+       ${LIBTOOL_MODE_LINK} ${PURIFY} ${CC} ${CFLAGS} ${LDFLAGS} -o $@ feature-test.@O@ ${LIBS}
+
+
 # Running the scripts below is bypassed when a separate
 # build directory is used.
 
@@ -28,6 +54,8 @@ testclean clean distclean::
        if test -f ./cleanall.sh; then sh ./cleanall.sh; fi
        rm -f systests.output
        rm -f random.data
+       rm -f ${TARGETS}
+       rm -f ${OBJS}
 
 distclean::
        rm -f conf.sh
index 1346c5a08d64252f7b2fb5fa6745c84e56225331..3820cfbf63f5346e7353ffdb2f81f52682b36c73 100644 (file)
@@ -54,6 +54,7 @@ DNSTAPREAD=$TOP/bin/tools/dnstap-read
 MDIG=$TOP/bin/tools/mdig
 NZD2NZF=$TOP/bin/tools/named-nzd2nzf
 FSTRM_CAPTURE=@FSTRM_CAPTURE@
+FEATURETEST=$TOP/bin/tests/system/feature-test
 
 RANDFILE=$TOP/bin/tests/system/random.data
 
@@ -138,9 +139,45 @@ NZD=@NZD_TOOLS@
 
 . ${TOP}/version
 
-export NAMED LWRESD DIG NSUPDATE KEYGEN KEYFRLAB SIGNER KEYSIGNER KEYSETTOOL \
-       PERL SUBDIRS RNDC CHECKZONE PK11GEN PK11LIST PK11DEL TESTSOCK6 \
-       JOURNALPRINT ARPANAME RESOLVE RRCHECKER NSLOOKUP DESCRIPTION PYTHON \
-       MDIG FSTRM_CAPTURE NZD2NZF \
-       RANDFILE BIGKEY DLOPEN EDNSVERSION FILTERAAAA GENCHECK GETHOSTNAME \
-       KEYCREATE KEYDELETE LWTEST MAKEJOURNAL PIPEQUERIES RPZ XMLSTATS
+export ARPANAME
+export BIGKEY
+export CHECKZONE
+export DESCRIPTION
+export DIG
+export DLOPEN
+export EDNSVERSION
+export FEATURETEST
+export FILTERAAAA
+export FSTRM_CAPTURE
+export GENCHECK
+export GETHOSTNAME
+export JOURNALPRINT
+export KEYCREATE
+export KEYDELETE
+export KEYFRLAB
+export KEYGEN
+export KEYSETTOOL
+export KEYSIGNER
+export LWRESD
+export LWTEST
+export MAKEJOURNAL
+export MDIG
+export NAMED
+export NSLOOKUP
+export NSUPDATE
+export NZD2NZF
+export PERL
+export PIPEQUERIES
+export PK11DEL
+export PK11GEN
+export PK11LIST
+export PYTHON
+export RANDFILE
+export RESOLVE
+export RNDC
+export RPZ
+export RRCHECKER
+export SIGNER
+export SUBDIRS
+export TESTSOCK6
+export XMLSTATS
index a8a94a5a83b1d648a0ce6e0ec8d8be7778d0ea67..117776e9c5e39ab6d463380c94a6ea4e02735e79 100644 (file)
@@ -26,6 +26,8 @@ b                     AAAA    fd92:7065:b8e:ffff::2
 c                      A       10.0.0.3
 c                      AAAA    fd92:7065:b8e:ffff::3
 
+xn--caf-dma            A       10.1.2.3
+
 foo                    TXT     "testing"
 foo                    A       10.0.1.0
 foo                    SSHFP   2 1 123456789abcdef67890123456789abcdef67890
index 2cd845a217c94278f6f92ba1dfe6bc810311f436..de5c6c049b379a9d624636e330b397a41157bb99 100644 (file)
@@ -384,6 +384,23 @@ if [ -x ${DIG} ] ; then
   if [ $ret != 0 ]; then echo "I:failed"; fi
   status=`expr $status + $ret`
 
+  n=`expr $n + 1`
+  if $FEATURETEST --with-idn
+  then
+    echo "I:checking dig +idnout ($n)"
+    ret=0
+    $DIG $DIGOPTS @10.53.0.3 +noidnout xn--caf-dma.example. > dig.out.1.test$n 2>&1 || ret=1
+    $DIG $DIGOPTS @10.53.0.3 +idnout xn--caf-dma.example. > dig.out.2.test$n 2>&1 || ret=1
+    grep "^xn--caf-dma.example" dig.out.1.test$n > /dev/null || ret=1
+    grep "^xn--caf-dma.example" dig.out.2.test$n > /dev/null && ret=1
+    grep 10.1.2.3 dig.out.1.test$n > /dev/null || ret=1
+    grep 10.1.2.3 dig.out.2.test$n > /dev/null || ret=1
+    if [ $ret != 0 ]; then echo "I:failed"; fi
+    status=`expr $status + $ret`
+  else
+    echo "I:skipping 'dig +idnout' as IDN support is not enabled ($n)"
+  fi
+
 else
   echo "$DIG is needed, so skipping these dig tests"
 fi
diff --git a/bin/tests/system/feature-test.c b/bin/tests/system/feature-test.c
new file mode 100644 (file)
index 0000000..05cc3d8
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2016  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/.
+ */
+
+#include <config.h>
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <isc/print.h>
+#include <isc/util.h>
+
+#ifndef MAXHOSTNAMELEN
+#ifdef HOST_NAME_MAX
+#define MAXHOSTNAMELEN HOST_NAME_MAX
+#else
+#define MAXHOSTNAMELEN 256
+#endif
+#endif
+
+static void
+usage() {
+       fprintf(stderr, "usage: feature-test <arg>\n");
+       fprintf(stderr, "args:\n");
+       fprintf(stderr, "       --allow-filter-aaaa\n");
+       fprintf(stderr, "       --edns-version\n");
+       fprintf(stderr, "       --gethostname\n");
+       fprintf(stderr, "       --gssapi\n");
+       fprintf(stderr, "       --have-dlopen\n");
+       fprintf(stderr, "       --have-geoip\n");
+       fprintf(stderr, "       --have-libxml2\n");
+       fprintf(stderr, "       --rpz-nsip\n");
+       fprintf(stderr, "       --rpz-nsdname\n");
+       fprintf(stderr, "       --with-idn\n");
+}
+
+int
+main(int argc, char **argv) {
+       
+       if (argc != 2) {
+               usage();
+               return (1);
+       }
+
+       if (strcmp(argv[1], "--allow-filter-aaaa") == 0) {
+#ifdef ALLOW_FILTER_AAAA
+               return (0);
+#else
+               return (1);
+#endif
+       }
+
+       if (strcmp(argv[1], "--edns-version") == 0) {
+#ifdef DNS_EDNS_VERSION
+               printf("%d\n", DNS_EDNS_VERSION);
+#else
+               printf("0\n");
+#endif
+               return (0);
+       }
+
+       if (strcmp(argv[1], "--gethostname") == 0) {
+               char hostname[MAXHOSTNAMELEN];
+               int n;
+               n = gethostname(hostname, sizeof(hostname));
+               if (n == -1) {
+                       perror("gethostname");
+                       return(1);
+               }
+               fprintf(stdout, "%s\n", hostname);
+               return (0);
+       }
+
+       if (strcmp(argv[1], "--gssapi") == 0) {
+#if defined(GSSAPI)
+               return (0);
+#else
+               return (1);
+#endif
+       }
+
+       if (strcmp(argv[1], "--have-dlopen") == 0) {    
+#if defined(HAVE_DLOPEN) && defined(ISC_DLZ_DLOPEN)
+               return (0);
+#else
+               return (1);
+#endif
+       }
+
+       if (strcmp(argv[1], "--have-geoip") == 0) {     
+#ifdef HAVE_GEOIP
+               return (0);
+#else
+               return (1);
+#endif
+       }
+
+        if (strcmp(argv[1], "--have-libxml2") == 0) {
+#ifdef HAVE_LIBXML2
+               return (0);
+#else
+               return (1);
+#endif
+       }
+
+        if (strcmp(argv[1], "--rpz-nsip") == 0) {
+#ifdef ENABLE_RPZ_NSIP
+                return (0);
+#else
+                return (1);
+#endif
+        }
+
+        if (strcmp(argv[1], "--rpz-nsdname") == 0) {
+#ifdef ENABLE_RPZ_NSDNAME
+                return (0);
+#else
+                return (1);
+#endif
+        }
+
+       if (strcmp(argv[1], "--with-idn") == 0) {
+#ifdef WITH_IDN
+               return (0);
+#else
+               return (1);
+#endif
+       }
+
+       fprintf(stderr, "unknown arg: %s\n", argv[1]);
+       usage();
+       return (1);
+}
index eb3190b74e663dde16f2bb20e95b4158c8149889..5eecca5dabd5fbeb2004057538a56c0366bb73cf 100644 (file)
@@ -2375,7 +2375,8 @@ dns_name_settotextfilter(dns_name_totextfilter_t proc) {
                return (ISC_R_SUCCESS);
        }
        if (proc == NULL) {
-               isc_mem_put(thread_key_mctx, mem, sizeof(*mem));
+               if (mem != NULL)
+                       isc_mem_put(thread_key_mctx, mem, sizeof(*mem));
                res = isc_thread_key_setspecific(totext_filter_proc_key, NULL);
                if (res != 0)
                        result = ISC_R_UNEXPECTED;