From: Mark Andrews Date: Fri, 28 Oct 2016 01:05:19 +0000 (+1100) Subject: 4496. [func] dig: add +idnout to control whether labels are X-Git-Tag: v9.12.0a1~706 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=42470b0b87da24b18e0ff6ce78f3143e89df6d31;p=thirdparty%2Fbind9.git 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] --- diff --git a/CHANGES b/CHANGES index 58ec0d2e95a..c031529e4ad 100644 --- 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 . [RT #43429] diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 55b5a87aefe..906f006ddbf 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -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: /* diff --git a/bin/dig/dig.docbook b/bin/dig/dig.docbook index 2a711a8fefd..c36310cc7ce 100644 --- a/bin/dig/dig.docbook +++ b/bin/dig/dig.docbook @@ -758,6 +758,17 @@ + + + + + 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. + + + + diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 5384358bf19..1304d2e20bb 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -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 diff --git a/bin/dig/include/dig/dig.h b/bin/dig/include/dig/dig.h index 23d63b259ad..e1f80a8fbf4 100644 --- a/bin/dig/include/dig/dig.h +++ b/bin/dig/include/dig/dig.h @@ -137,6 +137,7 @@ struct dig_lookup { use_usec, nocrypto, ttlunits, + idnout, qr; #ifdef DIG_SIGCHASE isc_boolean_t sigchase; diff --git a/bin/tests/system/Makefile.in b/bin/tests/system/Makefile.in index 6a7cac6392a..40e85f08e4b 100644 --- a/bin/tests/system/Makefile.in +++ b/bin/tests/system/Makefile.in @@ -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 diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index 1346c5a08d6..3820cfbf63f 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -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 diff --git a/bin/tests/system/digdelv/ns2/example.db b/bin/tests/system/digdelv/ns2/example.db index a8a94a5a83b..117776e9c5e 100644 --- a/bin/tests/system/digdelv/ns2/example.db +++ b/bin/tests/system/digdelv/ns2/example.db @@ -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 diff --git a/bin/tests/system/digdelv/tests.sh b/bin/tests/system/digdelv/tests.sh index 2cd845a217c..de5c6c049b3 100644 --- a/bin/tests/system/digdelv/tests.sh +++ b/bin/tests/system/digdelv/tests.sh @@ -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 index 00000000000..05cc3d83d2f --- /dev/null +++ b/bin/tests/system/feature-test.c @@ -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 + +#include +#include +#include +#include + +#include +#include + +#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 \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); +} diff --git a/lib/dns/name.c b/lib/dns/name.c index eb3190b74e6..5eecca5dabd 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -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;