1 IDN patch for bind-9.2.2
2 ========================
5 This is a patch file for ISC BIND 9.2.2 to make it work with
6 internationalized domain names. With this patch you'll get IDN-aware
9 To apply this patch, you should go to the top directory of the BIND
10 distribution (where you see `README' file), then invoke `patch'
13 % patch -p0 < this-file
15 Then follow the instructions described in `README.idnkit' to compile
20 diff -c /dev/null mdn/othersrc/bind9/README.idnkit:1.3
21 *** README.idnkit Tue Mar 11 08:55:20 2003
22 --- README.idnkit Mon Mar 10 09:47:41 2003
29 + Japan Network Information Center (JPNIC)
32 + * What is this patch for?
34 + This patch adds internationalized domain name (IDN) support to BIND-9.
35 + You'll get internationalized version of dig/host/nslookup commands.
37 + + internationalized dig/host/nslookup
38 + dig/host/nslookup accepts non-ASCII domain names in the local
39 + codeset (such as Shift JIS, Big5 or ISO8859-1) determined by
40 + the locale information. The domain names are normalized and
41 + converted to the encoding on the DNS protocol, and sent to DNS
42 + servers. The replies are converted back to the local codeset
46 + * Compilation & installation
50 + You have to build and install idnkit before building this patched version
53 + 1. Running configure script
55 + Run `configure' in the top directory. See `README' for the
56 + configuration options.
58 + This patch adds the following 4 options to `configure'. You should
59 + at least specify `--with-idn' option to enable IDN support.
61 + --with-idn[=IDN_PREFIX]
62 + To enable IDN support, you have to specify `--with-idn' option.
63 + The argument IDN_PREFIX is the install prefix of idnkit. If
64 + IDN_PREFIX is omitted, PREFIX (derived from `--prefix=PREFIX')
67 + --with-libiconv[=LIBICONV_PREFIX]
68 + Specify this option if idnkit you have installed links GNU
69 + libiconv. The argument LIBICONV_PREFIX is install prefix of
70 + GNU libiconv. If the argument is omitted, PREFIX (derived
71 + from `--prefix=PREFIX') is assumed.
73 + `--with-libiconv' is shorthand option for GNU libiconv.
75 + --with-libiconv=/usr/local
77 + This is equivalent to:
79 + --with-iconv='-L/usr/local/lib -R/usr/local/lib -liconv'
81 + `--with-libiconv' assumes that your C compiler has `-R'
82 + option, and that the option adds the specified run-time path
83 + to an exacutable binary. If `-R' option of your compiler has
84 + different meaning, or your compiler lacks the option, you
85 + should use `--with-iconv' option instead. Binary command
86 + without run-time path information might be unexecutable.
87 + In that case, you would see an error message like:
89 + error in loading shared libraries: libiconv.so.2: cannot
90 + open shared object file
92 + If both `--with-libiconv' and `--with-iconv' options are
93 + specified, `--with-iconv' is prior to `--with-libiconv'.
95 + --with-iconv=ICONV_LIBSPEC
96 + If your libc doens't provide iconv(), you need to specify the
97 + library containing iconv() with this option. `ICONV_LIBSPEC'
98 + is the argument(s) to `cc' or `ld' to link the library, for
99 + example, `--with-iconv="-L/usr/local/lib -liconv"'.
100 + You don't need to specify the header file directory for "iconv.h"
101 + to the compiler, as it isn't included directly by bind-9 with
104 + --with-idnlib=IDN_LIBSPEC
105 + With this option, you can explicitly specify the argument(s)
106 + to `cc' or `ld' to link the idnkit's library, `libidnkit'. If
107 + this option is not specified, `-L${PREFIX}/lib -lidnkit' is
108 + assumed, where ${PREFIX} is the installation prefix specified
109 + with `--with-idn' option above. You may need to use this
110 + option to specify extra argments, for example,
111 + `--with-idnlib="-L/usr/local/lib -R/usr/local/lib -lidnkit"'.
113 + Please consult `README' for other configuration options.
115 + Note that if you want to specify some extra header file directories,
116 + you should use the environment variable STD_CINCLUDES instead of
117 + CFLAGS, as described in README.
119 + 2. Compilation and installation
121 + After running "configure", just do
126 + for compiling and installing.
129 + * Contact information
131 + Please see http//www.nic.ad.jp/en/idn/ for the latest news
132 + about idnkit and this patch.
134 + Bug reports and comments on this kit should be sent to
135 + mdnkit-bugs@nic.ad.jp and idn-cmt@nic.ad.jp, respectively.
138 + ; Id: bind-9.2.2-patch,v 1.1 2003/06/04 00:27:32 marka Exp
140 diff -c mdn/othersrc/bind9/config.h.in:1.1.1.6 mdn/othersrc/bind9/config.h.in:1.12
141 *** config.h.in Tue Nov 27 16:55:45 2001
142 --- config.h.in Tue Mar 19 16:45:35 2002
146 /* define if you have strerror in the C library. */
149 + /* Define if you have the setlocale function. */
150 + #undef HAVE_SETLOCALE
152 /* Define if you have the <dlfcn.h> header file. */
158 /* Define if you have the <linux/capability.h> header file. */
159 #undef HAVE_LINUX_CAPABILITY_H
161 + /* Define if you have the <locale.h> header file. */
162 + #undef HAVE_LOCALE_H
164 /* Define if you have the <sys/prctl.h> header file. */
165 #undef HAVE_SYS_PRCTL_H
171 /* Define if you have the socket library (-lsocket). */
172 #undef HAVE_LIBSOCKET
174 + /* define if idnkit support is to be included. */
178 diff -c mdn/othersrc/bind9/configure:1.1.1.10 mdn/othersrc/bind9/configure:1.16
179 *** configure Wed Mar 5 17:14:55 2003
180 --- configure Thu Mar 6 20:10:05 2003
184 --with-gnu-ld assume the C compiler uses GNU ld default=no
185 --with-pic try to use only PIC/non-PIC objects default=use both
186 --with-kame=PATH use Kame IPv6 default path /usr/local/v6
187 + --with-idn=MPREFIX enable IDN support using idnkit default PREFIX
188 + --with-libiconv=IPREFIX GNU libiconv are in IPREFIX default PREFIX
189 + --with-iconv=LIBSPEC specify iconv library default -liconv
190 + --with-idnlib=ARG specify libidnkit
192 Some influential environment variables:
193 CC C compiler command
198 # Find out which ABI we are using.
199 ! echo '#line 7374 "configure"' > conftest.$ac_ext
200 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
201 (eval $ac_compile) 2>&5
206 # Find out which ABI we are using.
207 ! echo '#line 7378 "configure"' > conftest.$ac_ext
208 if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
209 (eval $ac_compile) 2>&5
213 save_CFLAGS="$CFLAGS"
214 CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
216 ! if { (eval echo configure:7917: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
217 # The compiler can only warn and ignore the option if not recognized
218 # So say no if there are warnings
219 if test -s out/conftest.err; then
221 save_CFLAGS="$CFLAGS"
222 CFLAGS="$CFLAGS -o out/conftest2.$ac_objext"
224 ! if { (eval echo configure:7921: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then
225 # The compiler can only warn and ignore the option if not recognized
226 # So say no if there are warnings
227 if test -s out/conftest.err; then
230 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
231 lt_status=$lt_dlunknown
232 cat > conftest.$ac_ext <<EOF
233 ! #line 9602 "configure"
234 #include "confdefs.h"
238 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
239 lt_status=$lt_dlunknown
240 cat > conftest.$ac_ext <<EOF
241 ! #line 9606 "configure"
242 #include "confdefs.h"
247 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
248 lt_status=$lt_dlunknown
249 cat > conftest.$ac_ext <<EOF
250 ! #line 9700 "configure"
251 #include "confdefs.h"
255 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
256 lt_status=$lt_dlunknown
257 cat > conftest.$ac_ext <<EOF
258 ! #line 9704 "configure"
259 #include "confdefs.h"
271 + # Check whether --with-idn or --without-idn was given.
272 + if test "${with_idn+set}" = set; then
273 + withval="$with_idn"
280 + if test X$prefix = XNONE ; then
281 + idn_path=/usr/local
289 + idn_path="$use_idn"
296 + # Check whether --with-libiconv or --without-libiconv was given.
297 + if test "${with_libiconv+set}" = set; then
298 + withval="$with_libiconv"
299 + use_libiconv="$withval"
303 + case "$use_libiconv" in
305 + if test X$prefix = XNONE ; then
306 + iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
308 + iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
315 + iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
320 + # Check whether --with-iconv or --without-iconv was given.
321 + if test "${with_iconv+set}" = set; then
322 + withval="$with_iconv"
323 + iconvlib="$withval"
325 + case "$iconvlib" in
335 + # Check whether --with-idnlib or --without-idnlib was given.
336 + if test "${with_idnlib+set}" = set; then
337 + withval="$with_idnlib"
342 + if test "$idnlib" = yes; then
343 + { { echo "$as_me:$LINENO: error: You must specify ARG for --with-idnlib." >&5
344 + echo "$as_me: error: You must specify ARG for --with-idnlib." >&2;}
345 + { (exit 1); exit 1; }; }
349 + if test "$use_idn" != no; then
351 + cat >>confdefs.h <<\_ACEOF
355 + STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
356 + if test "$idnlib" != no; then
357 + IDNLIBS="$idnlib $iconvlib"
359 + IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
365 + for ac_header in locale.h
367 + as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
368 + if eval "test \"\${$as_ac_Header+set}\" = set"; then
369 + echo "$as_me:$LINENO: checking for $ac_header" >&5
370 + echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
371 + if eval "test \"\${$as_ac_Header+set}\" = set"; then
372 + echo $ECHO_N "(cached) $ECHO_C" >&6
374 + echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
375 + echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
377 + # Is the header compilable?
378 + echo "$as_me:$LINENO: checking $ac_header usability" >&5
379 + echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
380 + cat >conftest.$ac_ext <<_ACEOF
381 + #line $LINENO "configure"
382 + #include "confdefs.h"
383 + $ac_includes_default
384 + #include <$ac_header>
386 + rm -f conftest.$ac_objext
387 + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
388 + (eval $ac_compile) 2>&5
390 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
391 + (exit $ac_status); } &&
392 + { ac_try='test -s conftest.$ac_objext'
393 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
394 + (eval $ac_try) 2>&5
396 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
397 + (exit $ac_status); }; }; then
398 + ac_header_compiler=yes
400 + echo "$as_me: failed program was:" >&5
401 + cat conftest.$ac_ext >&5
402 + ac_header_compiler=no
404 + rm -f conftest.$ac_objext conftest.$ac_ext
405 + echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
406 + echo "${ECHO_T}$ac_header_compiler" >&6
408 + # Is the header present?
409 + echo "$as_me:$LINENO: checking $ac_header presence" >&5
410 + echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
411 + cat >conftest.$ac_ext <<_ACEOF
412 + #line $LINENO "configure"
413 + #include "confdefs.h"
414 + #include <$ac_header>
416 + if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
417 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
419 + egrep -v '^ *\+' conftest.er1 >conftest.err
421 + cat conftest.err >&5
422 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
423 + (exit $ac_status); } >/dev/null; then
424 + if test -s conftest.err; then
425 + ac_cpp_err=$ac_c_preproc_warn_flag
432 + if test -z "$ac_cpp_err"; then
433 + ac_header_preproc=yes
435 + echo "$as_me: failed program was:" >&5
436 + cat conftest.$ac_ext >&5
437 + ac_header_preproc=no
439 + rm -f conftest.err conftest.$ac_ext
440 + echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
441 + echo "${ECHO_T}$ac_header_preproc" >&6
443 + # So? What about this header?
444 + case $ac_header_compiler:$ac_header_preproc in
446 + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
447 + echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
448 + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
449 + echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
451 + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
452 + echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
453 + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
454 + echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
455 + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
456 + echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};;
458 + echo "$as_me:$LINENO: checking for $ac_header" >&5
459 + echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
460 + if eval "test \"\${$as_ac_Header+set}\" = set"; then
461 + echo $ECHO_N "(cached) $ECHO_C" >&6
463 + eval "$as_ac_Header=$ac_header_preproc"
465 + echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
466 + echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
469 + if test `eval echo '${'$as_ac_Header'}'` = yes; then
470 + cat >>confdefs.h <<_ACEOF
471 + #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
479 + for ac_func in setlocale
481 + as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
482 + echo "$as_me:$LINENO: checking for $ac_func" >&5
483 + echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
484 + if eval "test \"\${$as_ac_var+set}\" = set"; then
485 + echo $ECHO_N "(cached) $ECHO_C" >&6
487 + cat >conftest.$ac_ext <<_ACEOF
488 + #line $LINENO "configure"
489 + #include "confdefs.h"
490 + /* From autoconf 2.57 */
491 + /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
492 + For example, HP-UX 11i <limits.h> declares gettimeofday. */
493 + #define $ac_func innocuous_$ac_func
495 + /* System header to define __stub macros and hopefully few prototypes,
496 + which can conflict with char $ac_func (); below.
497 + Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
498 + <limits.h> exists even on freestanding compilers. */
501 + # include <limits.h>
503 + # include <assert.h>
508 + /* Override any gcc2 internal prototype to avoid an error. */
513 + /* We use char because int might match the return type of a gcc2
514 + builtin and then its argument prototype would still apply. */
516 + /* The GNU C library defines this for functions which it implements
517 + to always fail with ENOSYS. Some functions are actually named
518 + something starting with __ and the normal name is an alias. */
519 + #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
522 + char (*f) () = $ac_func;
528 + #ifdef F77_DUMMY_MAIN
529 + # ifdef __cplusplus
532 + int F77_DUMMY_MAIN() { return 1; }
537 + return f != $ac_func;
542 + rm -f conftest.$ac_objext conftest$ac_exeext
543 + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
544 + (eval $ac_link) 2>&5
546 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
547 + (exit $ac_status); } &&
548 + { ac_try='test -s conftest$ac_exeext'
549 + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
550 + (eval $ac_try) 2>&5
552 + echo "$as_me:$LINENO: \$? = $ac_status" >&5
553 + (exit $ac_status); }; }; then
554 + eval "$as_ac_var=yes"
556 + echo "$as_me: failed program was:" >&5
557 + cat conftest.$ac_ext >&5
558 + eval "$as_ac_var=no"
560 + rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
562 + echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
563 + echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
564 + if test `eval echo '${'$as_ac_var'}'` = yes; then
565 + cat >>confdefs.h <<_ACEOF
566 + #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
580 s,@PRINTSTYLE@,$PRINTSTYLE,;t t
581 s,@XMLDCL@,$XMLDCL,;t t
582 s,@DOCBOOK2MANSPEC@,$DOCBOOK2MANSPEC,;t t
583 + s,@IDNLIBS@,$IDNLIBS,;t t
584 s,@BIND9_TOP_BUILDDIR@,$BIND9_TOP_BUILDDIR,;t t
585 s,@BIND9_ISC_BUILDINCLUDE@,$BIND9_ISC_BUILDINCLUDE,;t t
586 s,@BIND9_ISCCC_BUILDINCLUDE@,$BIND9_ISCCC_BUILDINCLUDE,;t t
588 diff -c mdn/othersrc/bind9/configure.in:1.1.1.10 mdn/othersrc/bind9/configure.in:1.16
589 *** configure.in Wed Mar 5 17:14:56 2003
590 --- configure.in Wed Mar 5 17:37:08 2003
594 NOM_PATH_FILE(DOCBOOK2MANSPEC, docbook2X/docbook2man-spec.pl, $sgmltrees)
600 + [ --with-idn[=MPREFIX] enable IDN support using idnkit [default PREFIX]],
601 + use_idn="$withval", use_idn="no")
604 + if test X$prefix = XNONE ; then
605 + idn_path=/usr/local
613 + idn_path="$use_idn"
619 + AC_ARG_WITH(libiconv,
620 + [ --with-libiconv[=IPREFIX] GNU libiconv are in IPREFIX [default PREFIX]],
621 + use_libiconv="$withval", use_libiconv="no")
622 + case "$use_libiconv" in
624 + if test X$prefix = XNONE ; then
625 + iconvlib="-L/usr/local/lib -R/usr/local/lib -liconv"
627 + iconvlib="-L$prefix/lib -R$prefix/lib -liconv"
634 + iconvlib="-L$use_libiconv/lib -R$use_libiconv/lib -liconv"
639 + [ --with-iconv[=LIBSPEC] specify iconv library [default -liconv]],
640 + iconvlib="$withval")
641 + case "$iconvlib" in
650 + AC_ARG_WITH(idnlib,
651 + [ --with-idnlib=ARG specify libidnkit],
652 + idnlib="$withval", idnlib="no")
653 + if test "$idnlib" = yes; then
654 + AC_MSG_ERROR([You must specify ARG for --with-idnlib.])
658 + if test "$use_idn" != no; then
659 + AC_DEFINE(WITH_IDN, 1, [define if idnkit support is to be included.])
660 + STD_CINCLUDES="$STD_CINCLUDES -I$idn_path/include"
661 + if test "$idnlib" != no; then
662 + IDNLIBS="$idnlib $iconvlib"
664 + IDNLIBS="-L$idn_path/lib -lidnkit $iconvlib"
669 + AC_CHECK_HEADERS(locale.h)
670 + AC_CHECK_FUNCS(setlocale)
675 AC_SUBST(BIND9_TOP_BUILDDIR)
676 Index: bin/dig/Makefile.in
677 diff -c mdn/othersrc/bind9/bin/dig/Makefile.in:1.1.1.6 mdn/othersrc/bind9/bin/dig/Makefile.in:1.3
678 *** bin/dig/Makefile.in Tue Nov 27 16:55:50 2001
679 --- bin/dig/Makefile.in Tue Mar 19 16:45:35 2002
683 DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS}
685 ! LIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@
691 DEPLIBS = ${DNSDEPLIBS} ${ISCDEPLIBS}
693 ! LIBS = ${DNSLIBS} ${ISCLIBS} @IDNLIBS@ @LIBS@
698 diff -c mdn/othersrc/bind9/bin/dig/dig.1:1.1.1.3 mdn/othersrc/bind9/bin/dig/dig.1:1.5
699 *** bin/dig/dig.1 Wed Mar 5 17:14:57 2003
700 --- bin/dig/dig.1 Wed Mar 5 17:42:53 2003
704 \fI+noqr\fR which means that \fBdig\fR
705 will not print the initial query when it looks up the NS records for
709 + If \fBdig\fR has been built with IDN (internationalized
710 + domain name) support, it can accept and display non-ASCII domain names.
711 + \fBdig\fR appropriately converts character encoding of
712 + domain name before sending a request to DNS server or displaying a
713 + reply from the server.
714 + If you'd like to turn off the IDN support for some reason, defines
715 + the \fBIDN_DISABLE\fR environment variable.
716 + The IDN support is disabled if the the variable is set when
720 \fI/etc/resolv.conf\fR
721 Index: bin/dig/dig.docbook
722 diff -c mdn/othersrc/bind9/bin/dig/dig.docbook:1.1.1.3 mdn/othersrc/bind9/bin/dig/dig.docbook:1.5
723 *** bin/dig/dig.docbook Wed Mar 5 17:14:57 2003
724 --- bin/dig/dig.docbook Wed Mar 5 17:42:53 2003
731 + <title>IDN SUPPORT</title>
733 + If <command>dig</command> has been built with IDN (internationalized
734 + domain name) support, it can accept and display non-ASCII domain names.
735 + <command>dig</command> appropriately converts character encoding of
736 + domain name before sending a request to DNS server or displaying a
737 + reply from the server.
738 + If you'd like to turn off the IDN support for some reason, defines
739 + the <envar>IDN_DISABLE</envar> environment variable.
740 + The IDN support is disabled if the the variable is set when
741 + <command>dig</command> runs.
748 <filename>/etc/resolv.conf</filename>
749 Index: bin/dig/dighost.c
750 diff -c mdn/othersrc/bind9/bin/dig/dighost.c:1.1.1.13 mdn/othersrc/bind9/bin/dig/dighost.c:1.33
751 *** bin/dig/dighost.c Wed Mar 5 17:14:57 2003
752 --- bin/dig/dighost.c Wed Mar 5 17:42:53 2003
759 + #ifdef HAVE_LOCALE_H
760 + #include <locale.h>
764 + #include <idn/result.h>
765 + #include <idn/log.h>
766 + #include <idn/resconf.h>
767 + #include <idn/api.h>
770 #include <dns/byaddr.h>
771 #include <dns/fixedname.h>
772 #include <dns/message.h>
776 isc_mutex_t lookup_lock;
777 dig_lookup_t *current_lookup = NULL;
780 + static void initialize_idn(void);
781 + static isc_result_t output_filter(isc_buffer_t *buffer,
782 + unsigned int used_org,
783 + isc_boolean_t absolute);
784 + static idn_result_t append_textname(char *name, const char *origin,
786 + static void idn_check_result(idn_result_t r, const char *msg);
788 + #define MAXDLEN 256
792 * Apply and clear locks at the event level in global task.
793 * Can I get rid of these using shutdown events? XXX
797 ISC_LIST_APPEND(server_list, srv, link);
806 else if (keysecret[0] != 0)
815 + char utf8_textname[MXNAME], utf8_origin[MXNAME], idn_textname[MXNAME];
819 + dns_name_settotextfilter(output_filter);
822 REQUIRE(lookup != NULL);
827 isc_buffer_init(&lookup->onamebuf, lookup->onamespace,
828 sizeof(lookup->onamespace));
832 + * We cannot convert `textname' and `origin' separately.
833 + * `textname' doesn't contain TLD, but local mapping needs
836 + mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP, lookup->textname,
837 + utf8_textname, sizeof(utf8_textname));
838 + idn_check_result(mr, "convert textname to UTF-8");
842 * If the name has too many dots, force the origin to be NULL
843 * (which produces an absolute lookup). Otherwise, take the origin
847 * is TRUE or we got a domain line in the resolv.conf file.
849 /* XXX New search here? */
851 + if ((count_dots(utf8_textname) >= ndots) || !usesearch)
852 + lookup->origin = NULL; /* Force abs lookup */
853 + else if (lookup->origin == NULL && lookup->new_search && usesearch) {
854 + lookup->origin = ISC_LIST_HEAD(search_list);
857 if ((count_dots(lookup->textname) >= ndots) || !usesearch)
858 lookup->origin = NULL; /* Force abs lookup */
859 else if (lookup->origin == NULL && lookup->new_search && usesearch) {
860 lookup->origin = ISC_LIST_HEAD(search_list);
865 if (lookup->origin != NULL) {
866 + mr = idn_encodename(IDN_LOCALCONV | IDN_DELIMMAP,
867 + lookup->origin->origin, utf8_origin,
868 + sizeof(utf8_origin));
869 + idn_check_result(mr, "convert origin to UTF-8");
870 + mr = append_textname(utf8_textname, utf8_origin,
871 + sizeof(utf8_textname));
872 + idn_check_result(mr, "append origin to textname");
874 + mr = idn_encodename(IDN_LOCALMAP | IDN_NAMEPREP | IDN_ASCCHECK |
875 + IDN_IDNCONV | IDN_LENCHECK, utf8_textname,
876 + idn_textname, sizeof(idn_textname));
877 + idn_check_result(mr, "convert UTF-8 textname to IDN encoding");
883 + if (lookup->origin != NULL) {
885 debug("trying origin %s", lookup->origin->origin);
886 result = dns_message_gettempname(lookup->sendmsg,
891 if (lookup->trace && lookup->trace_root)
892 dns_name_clone(dns_rootname, lookup->name);
895 + len = strlen(idn_textname);
896 + isc_buffer_init(&b, idn_textname, len);
897 + isc_buffer_add(&b, len);
898 + result = dns_name_fromtext(lookup->name, &b,
903 len = strlen(lookup->textname);
904 isc_buffer_init(&b, lookup->textname, len);
905 isc_buffer_add(&b, len);
914 if (result != ISC_R_SUCCESS) {
915 dns_message_puttempname(lookup->sendmsg,
920 isc_mem_destroy(&mctx);
925 + initialize_idn(void) {
928 + #ifdef HAVE_SETLOCALE
930 + (void)setlocale(LC_ALL, "");
932 + /* Create configuration context. */
933 + r = idn_nameinit(1);
934 + if (r != idn_success)
935 + fatal("idn api initialization failed: %s",
936 + idn_result_tostring(r));
938 + /* Set domain name -> text post-conversion filter. */
939 + dns_name_settotextfilter(output_filter);
942 + static isc_result_t
943 + output_filter(isc_buffer_t *buffer, unsigned int used_org,
944 + isc_boolean_t absolute)
946 + char tmp1[MAXDLEN], tmp2[MAXDLEN];
947 + size_t fromlen, tolen;
948 + isc_boolean_t end_with_dot;
951 + * Copy contents of 'buffer' to 'tmp1', supply trailing dot
952 + * if 'absolute' is true, and terminate with NUL.
954 + fromlen = isc_buffer_usedlength(buffer) - used_org;
955 + if (fromlen >= MAXDLEN)
956 + return (ISC_R_SUCCESS);
957 + memcpy(tmp1, (char *)isc_buffer_base(buffer) + used_org, fromlen);
958 + end_with_dot = (tmp1[fromlen - 1] == '.') ? ISC_TRUE : ISC_FALSE;
959 + if (absolute && !end_with_dot) {
961 + if (fromlen >= MAXDLEN)
962 + return (ISC_R_SUCCESS);
963 + tmp1[fromlen - 1] = '.';
965 + tmp1[fromlen] = '\0';
968 + * Convert contents of 'tmp1' to local encoding.
970 + if (idn_decodename(IDN_DECODE_APP, tmp1, tmp2, MAXDLEN) != idn_success)
971 + return (ISC_R_SUCCESS);
972 + strcpy(tmp1, tmp2);
975 + * Copy the converted contents in 'tmp1' back to 'buffer'.
976 + * If we have appended trailing dot, remove it.
978 + tolen = strlen(tmp1);
979 + if (absolute && !end_with_dot && tmp1[tolen - 1] == '.')
982 + if (isc_buffer_length(buffer) < used_org + tolen)
983 + return (ISC_R_NOSPACE);
985 + isc_buffer_subtract(buffer, isc_buffer_usedlength(buffer) - used_org);
986 + memcpy(isc_buffer_used(buffer), tmp1, tolen);
987 + isc_buffer_add(buffer, tolen);
989 + return (ISC_R_SUCCESS);
992 + static idn_result_t
993 + append_textname(char *name, const char *origin, size_t namesize) {
994 + size_t namelen = strlen(name);
995 + size_t originlen = strlen(origin);
997 + /* Already absolute? */
998 + if (namelen > 0 && name[namelen - 1] == '.')
999 + return idn_success;
1001 + /* Append dot and origin */
1003 + if (namelen + 1 + originlen >= namesize)
1004 + return idn_buffer_overflow;
1006 + name[namelen++] = '.';
1007 + (void)strcpy(name + namelen, origin);
1008 + return idn_success;
1012 + idn_check_result(idn_result_t r, const char *msg) {
1013 + if (r != idn_success) {
1015 + fatal("%s: %s", msg, idn_result_tostring(r));
1019 + #endif /* WITH_IDN */
1020 Index: bin/dig/host.1
1021 diff -c mdn/othersrc/bind9/bin/dig/host.1:1.1.1.2 mdn/othersrc/bind9/bin/dig/host.1:1.4
1022 *** bin/dig/host.1 Wed Mar 5 17:14:57 2003
1023 --- bin/dig/host.1 Wed Mar 5 17:42:53 2003
1027 effectively wait forever for a reply. The time to wait for a response
1028 will be set to the number of seconds given by the hardware's maximum
1029 value for an integer quantity.
1032 + If \fBhost\fR has been built with IDN (internationalized
1033 + domain name) support, it can accept and display non-ASCII domain names.
1034 + \fBhost\fR appropriately converts character encoding of
1035 + domain name before sending a request to DNS server or displaying a
1036 + reply from the server.
1037 + If you'd like to turn off the IDN support for some reason, defines
1038 + the \fBIDN_DISABLE\fR environment variable.
1039 + The IDN support is disabled if the the variable is set when
1043 \fI/etc/resolv.conf\fR
1044 Index: bin/dig/host.docbook
1045 diff -c mdn/othersrc/bind9/bin/dig/host.docbook:1.1.1.2 mdn/othersrc/bind9/bin/dig/host.docbook:1.4
1046 *** bin/dig/host.docbook Wed Mar 5 17:14:57 2003
1047 --- bin/dig/host.docbook Wed Mar 5 17:42:53 2003
1054 + <title>IDN SUPPORT</title>
1056 + If <command>host</command> has been built with IDN (internationalized
1057 + domain name) support, it can accept and display non-ASCII domain names.
1058 + <command>host</command> appropriately converts character encoding of
1059 + domain name before sending a request to DNS server or displaying a
1060 + reply from the server.
1061 + If you'd like to turn off the IDN support for some reason, defines
1062 + the <envar>IDN_DISABLE</envar> environment variable.
1063 + The IDN support is disabled if the the variable is set when
1064 + <command>host</command> runs.
1069 <title>FILES</title>
1071 <filename>/etc/resolv.conf</filename>
1072 Index: lib/dns/name.c
1073 diff -c mdn/othersrc/bind9/lib/dns/name.c:1.1.1.11 mdn/othersrc/bind9/lib/dns/name.c:1.15
1074 *** lib/dns/name.c Wed Mar 5 17:16:22 2003
1075 --- lib/dns/name.c Wed Mar 5 17:49:58 2003
1079 /* XXXDCL make const? */
1080 dns_name_t *dns_wildcardname = &wild;
1084 + * dns_name_t to text post-conversion procedure.
1086 + static dns_name_totextfilter_t totext_filter_proc = NULL;
1090 set_offsets(const dns_name_t *name, unsigned char *offsets,
1091 dns_name_t *set_name);
1095 unsigned int labels;
1096 isc_boolean_t saw_root = ISC_FALSE;
1099 + unsigned int oused = target->used;
1103 * This function assumes the name is in proper uncompressed
1108 isc_buffer_add(target, tlen - trem);
1111 + if (totext_filter_proc != NULL)
1112 + return ((*totext_filter_proc)(target, oused, saw_root));
1114 return (ISC_R_SUCCESS);
1120 return (ISC_R_SUCCESS);
1125 + dns_name_settotextfilter(dns_name_totextfilter_t proc) {
1126 + totext_filter_proc = proc;
1129 Index: lib/dns/include/dns/name.h
1130 diff -c mdn/othersrc/bind9/lib/dns/include/dns/name.h:1.1.1.7 mdn/othersrc/bind9/lib/dns/include/dns/name.h:1.10
1131 *** lib/dns/include/dns/name.h Wed May 22 17:15:29 2002
1132 --- lib/dns/include/dns/name.h Mon May 27 12:10:15 2002
1137 #define DNS_NAME_MAXWIRE 255
1141 + * Text output filter procedure.
1142 + * 'target' is the buffer to be converted. The region to be converted
1143 + * is from 'buffer'->base + 'used_org' to the end of the used region.
1145 + typedef isc_result_t (*dns_name_totextfilter_t)(isc_buffer_t *target,
1146 + unsigned int used_org,
1147 + isc_boolean_t absolute);
1162 + dns_name_settotextfilter(dns_name_totextfilter_t proc);
1164 + * Call 'proc' at the end of dns_name_totext.
1166 + #endif /* WITH_IDN */
1168 #define DNS_NAME_FORMATSIZE (DNS_NAME_MAXTEXT + 1)