2015-01-14 11:38:32 +00:00
|
|
|
diff -up bind-9.10.1b1/bin/dig/dig.docbook.libidn bind-9.10.1b1/bin/dig/dig.docbook
|
|
|
|
--- bind-9.10.1b1/bin/dig/dig.docbook.libidn 2014-06-23 06:47:35.000000000 +0200
|
|
|
|
+++ bind-9.10.1b1/bin/dig/dig.docbook 2014-07-29 15:30:42.808679630 +0200
|
|
|
|
@@ -1012,8 +1012,8 @@ dig +qr www.isc.org any -x 127.0.0.1 isc
|
2014-05-26 13:42:49 +00:00
|
|
|
<command>dig</command> appropriately converts character encoding of
|
|
|
|
domain name before sending a request to DNS server or displaying a
|
|
|
|
reply from the server.
|
|
|
|
- If you'd like to turn off the IDN support for some reason, defines
|
|
|
|
- the <envar>IDN_DISABLE</envar> environment variable.
|
|
|
|
+ If you'd like to turn off the IDN support for some reason, define
|
|
|
|
+ the <envar>CHARSET=ASCII</envar> environment variable.
|
|
|
|
The IDN support is disabled if the variable is set when
|
|
|
|
<command>dig</command> runs.
|
|
|
|
</para>
|
2015-01-14 11:38:32 +00:00
|
|
|
diff -up bind-9.10.1b1/bin/dig/dighost.c.libidn bind-9.10.1b1/bin/dig/dighost.c
|
|
|
|
--- bind-9.10.1b1/bin/dig/dighost.c.libidn 2014-06-23 06:47:35.000000000 +0200
|
|
|
|
+++ bind-9.10.1b1/bin/dig/dighost.c 2014-07-29 15:44:43.114012448 +0200
|
2007-07-30 13:34:39 +00:00
|
|
|
@@ -44,6 +44,11 @@
|
|
|
|
#include <idn/api.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef WITH_LIBIDN
|
|
|
|
+#include <stringprep.h>
|
|
|
|
+#include <idna.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#include <dns/byaddr.h>
|
|
|
|
#ifdef DIG_SIGCHASE
|
2013-07-15 11:58:12 +00:00
|
|
|
#include <dns/callbacks.h>
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -158,6 +163,14 @@ static void idn_check_result(idn_result
|
2007-07-30 13:34:39 +00:00
|
|
|
int idnoptions = 0;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
+#ifdef WITH_LIBIDN
|
2014-05-26 13:42:49 +00:00
|
|
|
+static isc_result_t libidn_locale_to_utf8 (const char* from, char *to);
|
2007-07-30 13:34:39 +00:00
|
|
|
+static isc_result_t libidn_utf8_to_ascii (const char* from, char *to);
|
|
|
|
+static isc_result_t output_filter (isc_buffer_t *buffer,
|
|
|
|
+ unsigned int used_org,
|
|
|
|
+ isc_boolean_t absolute);
|
|
|
|
+#endif
|
|
|
|
+
|
2014-01-06 13:09:43 +00:00
|
|
|
isc_socket_t *keep = NULL;
|
|
|
|
isc_sockaddr_t keepaddr;
|
|
|
|
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -1355,8 +1371,15 @@ setup_system(void) {
|
2007-07-30 13:34:39 +00:00
|
|
|
|
|
|
|
#ifdef WITH_IDN
|
|
|
|
initialize_idn();
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+#ifdef WITH_LIBIDN
|
|
|
|
+ result = dns_name_settotextfilter(output_filter);
|
|
|
|
+ check_result(result, "dns_name_settotextfilter");
|
|
|
|
+#ifdef HAVE_SETLOCALE
|
|
|
|
+ setlocale (LC_ALL, "");
|
|
|
|
+#endif
|
|
|
|
#endif
|
|
|
|
-
|
|
|
|
if (keyfile[0] != 0)
|
|
|
|
setup_file_key();
|
|
|
|
else if (keysecret[0] != 0)
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -2106,12 +2129,14 @@ setup_lookup(dig_lookup_t *lookup) {
|
2007-07-30 13:34:39 +00:00
|
|
|
idn_result_t mr;
|
|
|
|
char utf8_textname[MXNAME], utf8_origin[MXNAME], idn_textname[MXNAME];
|
|
|
|
#endif
|
|
|
|
+#ifdef WITH_LIBIDN
|
2014-05-26 13:42:49 +00:00
|
|
|
+ char utf8_str[MXNAME], utf8_name[MXNAME], ascii_name[MXNAME];
|
2007-07-30 13:34:39 +00:00
|
|
|
+#endif
|
|
|
|
|
2014-05-26 13:42:49 +00:00
|
|
|
-#ifdef WITH_IDN
|
|
|
|
+#if defined (WITH_IDN) || defined (WITH_LIBIDN)
|
2007-07-30 13:34:39 +00:00
|
|
|
result = dns_name_settotextfilter(output_filter);
|
|
|
|
check_result(result, "dns_name_settotextfilter");
|
|
|
|
#endif
|
|
|
|
-
|
|
|
|
REQUIRE(lookup != NULL);
|
|
|
|
INSIST(!free_now);
|
|
|
|
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -2148,6 +2173,14 @@ setup_lookup(dig_lookup_t *lookup) {
|
2007-07-30 13:34:39 +00:00
|
|
|
mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname,
|
|
|
|
utf8_textname, sizeof(utf8_textname));
|
|
|
|
idn_check_result(mr, "convert textname to UTF-8");
|
|
|
|
+#elif defined (WITH_LIBIDN)
|
2014-05-26 13:42:49 +00:00
|
|
|
+ result = libidn_locale_to_utf8 (lookup->textname, utf8_str);
|
|
|
|
+ check_result (result, "convert textname to UTF-8");
|
2007-07-30 13:34:39 +00:00
|
|
|
+ len = strlen (utf8_str);
|
2014-05-26 13:42:49 +00:00
|
|
|
+ if (len < MXNAME)
|
2007-07-30 13:34:39 +00:00
|
|
|
+ (void) strcpy (utf8_name, utf8_str);
|
2014-05-26 13:42:49 +00:00
|
|
|
+ else
|
2007-07-30 13:34:39 +00:00
|
|
|
+ fatal ("Too long name");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -2160,15 +2193,11 @@ setup_lookup(dig_lookup_t *lookup) {
|
2014-05-26 13:42:49 +00:00
|
|
|
if (lookup->new_search) {
|
|
|
|
#ifdef WITH_IDN
|
|
|
|
if ((count_dots(utf8_textname) >= ndots) || !usesearch) {
|
|
|
|
- lookup->origin = NULL; /* Force abs lookup */
|
|
|
|
- lookup->done_as_is = ISC_TRUE;
|
|
|
|
- lookup->need_search = usesearch;
|
|
|
|
- } else if (lookup->origin == NULL && usesearch) {
|
|
|
|
- lookup->origin = ISC_LIST_HEAD(search_list);
|
|
|
|
- lookup->need_search = ISC_FALSE;
|
|
|
|
- }
|
2007-07-30 13:34:39 +00:00
|
|
|
+#elif defined (WITH_LIBIDN)
|
|
|
|
+ if ((count_dots(utf8_name) >= ndots) || !usesearch) {
|
|
|
|
#else
|
|
|
|
if ((count_dots(lookup->textname) >= ndots) || !usesearch) {
|
2014-05-26 13:42:49 +00:00
|
|
|
+#endif
|
2007-07-30 13:34:39 +00:00
|
|
|
lookup->origin = NULL; /* Force abs lookup */
|
2014-05-26 13:42:49 +00:00
|
|
|
lookup->done_as_is = ISC_TRUE;
|
|
|
|
lookup->need_search = usesearch;
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -2176,7 +2205,6 @@ setup_lookup(dig_lookup_t *lookup) {
|
2014-05-26 13:42:49 +00:00
|
|
|
lookup->origin = ISC_LIST_HEAD(search_list);
|
|
|
|
lookup->need_search = ISC_FALSE;
|
|
|
|
}
|
|
|
|
-#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_IDN
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -2193,6 +2221,20 @@ setup_lookup(dig_lookup_t *lookup) {
|
2007-07-30 13:34:39 +00:00
|
|
|
IDN_IDNCONV | IDN_LENCHECK, utf8_textname,
|
|
|
|
idn_textname, sizeof(idn_textname));
|
|
|
|
idn_check_result(mr, "convert UTF-8 textname to IDN encoding");
|
|
|
|
+#elif defined (WITH_LIBIDN)
|
|
|
|
+ if (lookup->origin != NULL) {
|
2014-05-26 13:42:49 +00:00
|
|
|
+ result = libidn_locale_to_utf8 (lookup->origin->origin, utf8_str);
|
2007-07-30 13:34:39 +00:00
|
|
|
+ check_result (result, "convert origin to UTF-8");
|
2014-05-26 13:42:49 +00:00
|
|
|
+ if (len > 0 && utf8_name[len - 1] != '.') {
|
2007-07-30 13:34:39 +00:00
|
|
|
+ utf8_name[len++] = '.';
|
2014-05-26 13:42:49 +00:00
|
|
|
+ if (len + strlen (utf8_str) < MXNAME)
|
|
|
|
+ (void) strcpy (utf8_name + len, utf8_str);
|
|
|
|
+ else
|
|
|
|
+ fatal ("Too long name + origin");
|
2007-07-30 13:34:39 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ result = libidn_utf8_to_ascii (utf8_name, ascii_name);
|
|
|
|
#else
|
|
|
|
if (lookup->origin != NULL) {
|
|
|
|
debug("trying origin %s", lookup->origin->origin);
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -2248,6 +2290,13 @@ setup_lookup(dig_lookup_t *lookup) {
|
2009-09-16 11:09:13 +00:00
|
|
|
result = dns_name_fromtext(lookup->name, &b,
|
|
|
|
dns_rootname, 0,
|
2007-07-30 13:34:39 +00:00
|
|
|
&lookup->namebuf);
|
|
|
|
+#elif defined (WITH_LIBIDN)
|
|
|
|
+ len = strlen (ascii_name);
|
|
|
|
+ isc_buffer_init(&b, ascii_name, len);
|
|
|
|
+ isc_buffer_add(&b, len);
|
|
|
|
+ result = dns_name_fromtext(lookup->name, &b,
|
2009-09-16 11:09:13 +00:00
|
|
|
+ dns_rootname, 0,
|
2007-07-30 13:34:39 +00:00
|
|
|
+ &lookup->namebuf);
|
|
|
|
#else
|
|
|
|
len = strlen(lookup->textname);
|
|
|
|
isc_buffer_init(&b, lookup->textname, len);
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -4031,7 +4080,7 @@ destroy_libs(void) {
|
2007-07-30 13:34:39 +00:00
|
|
|
void * ptr;
|
|
|
|
dig_message_t *chase_msg;
|
|
|
|
#endif
|
|
|
|
-#ifdef WITH_IDN
|
|
|
|
+#if defined (WITH_IDN) || defined (WITH_LIBIDN)
|
|
|
|
isc_result_t result;
|
|
|
|
#endif
|
|
|
|
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -4072,6 +4121,10 @@ destroy_libs(void) {
|
2008-02-11 17:11:26 +00:00
|
|
|
result = dns_name_settotextfilter(NULL);
|
|
|
|
check_result(result, "dns_name_settotextfilter");
|
2007-07-30 13:34:39 +00:00
|
|
|
#endif
|
|
|
|
+#ifdef WITH_LIBIDN
|
|
|
|
+ result = dns_name_settotextfilter (NULL);
|
|
|
|
+ check_result(result, "clearing dns_name_settotextfilter");
|
|
|
|
+#endif
|
|
|
|
dns_name_destroy();
|
|
|
|
|
|
|
|
if (commctx != NULL) {
|
2015-01-14 11:38:32 +00:00
|
|
|
@@ -4251,6 +4304,97 @@ idn_check_result(idn_result_t r, const c
|
2007-07-30 13:34:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* WITH_IDN */
|
|
|
|
+#ifdef WITH_LIBIDN
|
|
|
|
+static isc_result_t
|
2014-05-26 13:42:49 +00:00
|
|
|
+libidn_locale_to_utf8 (const char *from, char *to) {
|
2007-07-30 13:34:39 +00:00
|
|
|
+ char *utf8_str;
|
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ debug ("libidn_locale_to_utf8");
|
2007-07-30 13:34:39 +00:00
|
|
|
+ utf8_str = stringprep_locale_to_utf8 (from);
|
2014-05-26 13:42:49 +00:00
|
|
|
+ if (utf8_str != NULL) {
|
|
|
|
+ (void) strcpy (to, utf8_str);
|
2007-07-30 13:34:39 +00:00
|
|
|
+ free (utf8_str);
|
2014-05-26 13:42:49 +00:00
|
|
|
+ return ISC_R_SUCCESS;
|
2007-07-30 13:34:39 +00:00
|
|
|
+ }
|
2014-05-26 13:42:49 +00:00
|
|
|
+
|
|
|
|
+ debug ("libidn_locale_to_utf8: failure");
|
|
|
|
+ return ISC_R_FAILURE;
|
2007-07-30 13:34:39 +00:00
|
|
|
+}
|
|
|
|
+static isc_result_t
|
|
|
|
+libidn_utf8_to_ascii (const char *from, char *to) {
|
|
|
|
+ char *ascii;
|
2014-05-26 13:42:49 +00:00
|
|
|
+ int iresult;
|
2007-07-30 13:34:39 +00:00
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ debug ("libidn_utf8_to_ascii");
|
|
|
|
+ iresult = idna_to_ascii_8z (from, &ascii, 0);
|
|
|
|
+ if (iresult != IDNA_SUCCESS) {
|
|
|
|
+ debug ("idna_to_ascii_8z: %s", idna_strerror (iresult));
|
|
|
|
+ return ISC_R_FAILURE;
|
|
|
|
+ }
|
2007-07-30 13:34:39 +00:00
|
|
|
+
|
|
|
|
+ (void) strcpy (to, ascii);
|
|
|
|
+ free (ascii);
|
2014-05-26 13:42:49 +00:00
|
|
|
+ return ISC_R_SUCCESS;
|
2007-07-30 13:34:39 +00:00
|
|
|
+}
|
2014-05-26 13:42:49 +00:00
|
|
|
+
|
2007-07-30 13:34:39 +00:00
|
|
|
+static isc_result_t
|
|
|
|
+output_filter (isc_buffer_t *buffer, unsigned int used_org,
|
|
|
|
+ isc_boolean_t absolute) {
|
2014-05-26 13:42:49 +00:00
|
|
|
+
|
2007-07-30 13:34:39 +00:00
|
|
|
+ char tmp1[MXNAME], *tmp2;
|
|
|
|
+ size_t fromlen, tolen;
|
|
|
|
+ isc_boolean_t end_with_dot;
|
2014-05-26 13:42:49 +00:00
|
|
|
+ int iresult;
|
2007-07-30 13:34:39 +00:00
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ debug ("output_filter");
|
|
|
|
+
|
|
|
|
+ fromlen = isc_buffer_usedlength (buffer) - used_org;
|
2007-07-30 13:34:39 +00:00
|
|
|
+ if (fromlen >= MXNAME)
|
2014-05-26 13:42:49 +00:00
|
|
|
+ return ISC_R_SUCCESS;
|
|
|
|
+ memcpy (tmp1, (char *) isc_buffer_base (buffer) + used_org, fromlen);
|
2007-07-30 13:34:39 +00:00
|
|
|
+ end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE;
|
|
|
|
+ if (absolute && !end_with_dot) {
|
|
|
|
+ fromlen++;
|
|
|
|
+ if (fromlen >= MXNAME)
|
2014-05-26 13:42:49 +00:00
|
|
|
+ return ISC_R_SUCCESS;
|
2007-07-30 13:34:39 +00:00
|
|
|
+ tmp1[fromlen - 1] = '.';
|
|
|
|
+ }
|
|
|
|
+ tmp1[fromlen] = '\0';
|
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ iresult = idna_to_unicode_8z8z (tmp1, &tmp2, 0);
|
|
|
|
+ if (iresult != IDNA_SUCCESS) {
|
|
|
|
+ debug ("output_filter: %s", idna_strerror (iresult));
|
|
|
|
+ return ISC_R_SUCCESS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ (void) strcpy (tmp1, tmp2);
|
|
|
|
+ free (tmp2);
|
|
|
|
+
|
|
|
|
+ tmp2 = stringprep_utf8_to_locale (tmp1);
|
|
|
|
+ if (tmp2 == NULL) {
|
|
|
|
+ debug ("output_filter: stringprep_utf8_to_locale failed");
|
|
|
|
+ return ISC_R_SUCCESS;
|
|
|
|
+ }
|
2007-07-30 13:34:39 +00:00
|
|
|
+
|
|
|
|
+ (void) strcpy (tmp1, tmp2);
|
|
|
|
+ free (tmp2);
|
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ tolen = strlen (tmp1);
|
2007-07-30 13:34:39 +00:00
|
|
|
+ if (absolute && !end_with_dot && tmp1[tolen - 1] == '.')
|
|
|
|
+ tolen--;
|
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ if (isc_buffer_length (buffer) < used_org + tolen)
|
|
|
|
+ return ISC_R_NOSPACE;
|
2007-07-30 13:34:39 +00:00
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ debug ("%s", tmp1);
|
2007-07-30 13:34:39 +00:00
|
|
|
+
|
2014-05-26 13:42:49 +00:00
|
|
|
+ isc_buffer_subtract (buffer, isc_buffer_usedlength (buffer) - used_org);
|
|
|
|
+ memcpy (isc_buffer_used (buffer), tmp1, tolen);
|
|
|
|
+ isc_buffer_add (buffer, tolen);
|
|
|
|
+
|
|
|
|
+ return ISC_R_SUCCESS;
|
2007-07-30 13:34:39 +00:00
|
|
|
+}
|
|
|
|
+#endif /* WITH_LIBIDN*/
|
|
|
|
|
|
|
|
#ifdef DIG_SIGCHASE
|
|
|
|
void
|
2015-01-14 11:38:32 +00:00
|
|
|
diff -up bind-9.10.1b1/bin/dig/Makefile.in.libidn bind-9.10.1b1/bin/dig/Makefile.in
|
|
|
|
--- bind-9.10.1b1/bin/dig/Makefile.in.libidn 2014-06-23 06:47:35.000000000 +0200
|
|
|
|
+++ bind-9.10.1b1/bin/dig/Makefile.in 2014-07-29 15:47:00.566230478 +0200
|
|
|
|
@@ -48,10 +48,10 @@ DEPLIBS = ${DNSDEPLIBS} ${BIND9DEPLIBS}
|
|
|
|
${ISCCFGDEPLIBS} ${LWRESDEPLIBS}
|
|
|
|
|
|
|
|
LIBS = ${LWRESLIBS} ${BIND9LIBS} ${ISCCFGLIBS} \
|
|
|
|
- ${ISCLIBS} @IDNLIBS@ @LIBS@
|
|
|
|
+ ${ISCLIBS} @IDNLIBS@ @LIBS@ -lidn
|
|
|
|
|
|
|
|
NOSYMLIBS = ${LWRESLIBS} ${BIND9LIBS} ${ISCCFGLIBS} \
|
|
|
|
- ${ISCNOSYMLIBS} @IDNLIBS@ @LIBS@
|
|
|
|
+ ${ISCNOSYMLIBS} @IDNLIBS@ @LIBS@ -lidn
|
|
|
|
|
|
|
|
SUBDIRS =
|
|
|
|
|
|
|
|
@@ -69,6 +69,8 @@ HTMLPAGES = dig.html host.html nslookup.
|
|
|
|
|
|
|
|
MANOBJS = ${MANPAGES} ${HTMLPAGES}
|
|
|
|
|
|
|
|
+EXT_CFLAGS = -DWITH_LIBIDN
|
|
|
|
+
|
|
|
|
@BIND9_MAKE_RULES@
|
|
|
|
|
|
|
|
dig@EXEEXT@: dig.@O@ dighost.@O@ ${UOBJS} ${DEPLIBS}
|