|
|
a2a915 |
From fb4271f5881a83c2cfb639587597b9a80c536a6d Mon Sep 17 00:00:00 2001
|
|
|
a2a915 |
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
|
|
|
a2a915 |
Date: Tue, 29 Jan 2019 20:59:57 +0100
|
|
|
a2a915 |
Subject: [PATCH] Replace libidn2 support with libidn
|
|
|
a2a915 |
|
|
|
a2a915 |
They should be more or less compatible. Try to maintain original
|
|
|
a2a915 |
behaviour of old 9.11 libidn patch, ignore any in output filter.
|
|
|
a2a915 |
---
|
|
|
a2a915 |
bin/dig/Makefile.in | 6 ++---
|
|
|
a2a915 |
bin/dig/dighost.c | 64 ++++++++++++++++++++++++++++++---------------
|
|
|
a2a915 |
config.h.in | 4 +--
|
|
|
a2a915 |
configure.in | 56 +++++++++++++++++++--------------------
|
|
|
a2a915 |
4 files changed, 76 insertions(+), 54 deletions(-)
|
|
|
a2a915 |
|
|
|
a2a915 |
diff --git a/bin/dig/Makefile.in b/bin/dig/Makefile.in
|
|
|
a2a915 |
index 3edd951..75441b0 100644
|
|
|
a2a915 |
--- a/bin/dig/Makefile.in
|
|
|
a2a915 |
+++ b/bin/dig/Makefile.in
|
|
|
a2a915 |
@@ -19,7 +19,7 @@ READLINE_LIB = @READLINE_LIB@
|
|
|
a2a915 |
|
|
|
a2a915 |
CINCLUDES = -I${srcdir}/include ${DNS_INCLUDES} \
|
|
|
a2a915 |
${BIND9_INCLUDES} ${ISC_INCLUDES} \
|
|
|
a2a915 |
- ${LWRES_INCLUDES} ${ISCCFG_INCLUDES} @LIBIDN2_CFLAGS@ @DST_OPENSSL_INC@
|
|
|
a2a915 |
+ ${LWRES_INCLUDES} ${ISCCFG_INCLUDES} @LIBIDN_CFLAGS@ @DST_OPENSSL_INC@
|
|
|
a2a915 |
|
|
|
a2a915 |
CDEFINES = -DVERSION=\"${VERSION}\" @CRYPTO@
|
|
|
a2a915 |
CWARNINGS =
|
|
|
a2a915 |
@@ -41,10 +41,10 @@ DEPLIBS = ${DNSDEPLIBS} ${BIND9DEPLIBS} ${ISCDEPLIBS} \
|
|
|
a2a915 |
${ISCCFGDEPLIBS} ${LWRESDEPLIBS}
|
|
|
a2a915 |
|
|
|
a2a915 |
LIBS = ${LWRESLIBS} ${BIND9LIBS} ${ISCCFGLIBS} \
|
|
|
a2a915 |
- ${ISCLIBS} @IDNKIT_LIBS@ @LIBIDN2_LIBS@ @LIBS@
|
|
|
a2a915 |
+ ${ISCLIBS} @IDNKIT_LIBS@ @LIBIDN_LIBS@ @LIBS@
|
|
|
a2a915 |
|
|
|
a2a915 |
NOSYMLIBS = ${LWRESLIBS} ${BIND9LIBS} ${ISCCFGLIBS} \
|
|
|
a2a915 |
- ${ISCNOSYMLIBS} @IDNKIT_LIBS@ @LIBIDN2_LIBS@ @LIBS@
|
|
|
a2a915 |
+ ${ISCNOSYMLIBS} @IDNKIT_LIBS@ @LIBIDN_LIBS@ @LIBS@
|
|
|
a2a915 |
|
|
|
a2a915 |
SUBDIRS =
|
|
|
a2a915 |
|
|
|
a2a915 |
diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c
|
|
|
a2a915 |
index ffc16c4..a345a21 100644
|
|
|
a2a915 |
--- a/bin/dig/dighost.c
|
|
|
a2a915 |
+++ b/bin/dig/dighost.c
|
|
|
a2a915 |
@@ -38,8 +38,9 @@
|
|
|
a2a915 |
#include <idn/api.h>
|
|
|
a2a915 |
#endif
|
|
|
a2a915 |
|
|
|
a2a915 |
-#ifdef WITH_LIBIDN2
|
|
|
a2a915 |
-#include <idn2.h>
|
|
|
a2a915 |
+#ifdef WITH_LIBIDN
|
|
|
a2a915 |
+#include <stringprep.h>
|
|
|
a2a915 |
+#include <idna.h>
|
|
|
a2a915 |
#endif
|
|
|
a2a915 |
#endif /* WITH_IDN_SUPPORT */
|
|
|
a2a915 |
|
|
|
a2a915 |
@@ -4761,7 +4762,7 @@ idn_ace_to_locale(const char *from, char *to, size_t tolen) {
|
|
|
a2a915 |
}
|
|
|
a2a915 |
#endif /* WITH_IDNKIT */
|
|
|
a2a915 |
|
|
|
a2a915 |
-#ifdef WITH_LIBIDN2
|
|
|
a2a915 |
+#ifdef WITH_LIBIDN
|
|
|
a2a915 |
static void
|
|
|
a2a915 |
idn_initialize(void) {
|
|
|
a2a915 |
}
|
|
|
a2a915 |
@@ -4769,16 +4770,25 @@ idn_initialize(void) {
|
|
|
a2a915 |
static isc_result_t
|
|
|
a2a915 |
idn_locale_to_ace(const char *from, char *to, size_t tolen) {
|
|
|
a2a915 |
int res;
|
|
|
a2a915 |
+ char *utf8_str;
|
|
|
a2a915 |
char *tmp_str = NULL;
|
|
|
a2a915 |
|
|
|
a2a915 |
- res = idn2_to_ascii_lz(from, &tmp_str, IDN2_NONTRANSITIONAL|IDN2_NFC_INPUT);
|
|
|
a2a915 |
- if (res == IDN2_DISALLOWED) {
|
|
|
a2a915 |
- res = idn2_to_ascii_lz(from, &tmp_str, IDN2_TRANSITIONAL|IDN2_NFC_INPUT);
|
|
|
a2a915 |
+ debug ("libidn_locale_to_utf8");
|
|
|
a2a915 |
+ utf8_str = stringprep_locale_to_utf8 (from);
|
|
|
a2a915 |
+ if (utf8_str == NULL) {
|
|
|
a2a915 |
+ debug ("libidn stringprep_locale_to_utf8 failure");
|
|
|
a2a915 |
+ return ISC_R_FAILURE;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
|
|
|
a2a915 |
- if (res == IDN2_OK) {
|
|
|
a2a915 |
+ int iresult;
|
|
|
a2a915 |
+
|
|
|
a2a915 |
+ debug ("libidn_utf8_to_ascii");
|
|
|
a2a915 |
+ res = idna_to_ascii_8z (utf8_str, &tmp_str, 0);
|
|
|
a2a915 |
+ free (utf8_str);
|
|
|
a2a915 |
+
|
|
|
a2a915 |
+ if (res == IDNA_SUCCESS) {
|
|
|
a2a915 |
/*
|
|
|
a2a915 |
- * idn2_to_ascii_lz() normalizes all strings to lowerl case,
|
|
|
a2a915 |
+ * idna_to_ascii_8z() normalizes all strings to lowerl case,
|
|
|
a2a915 |
* but we generally don't want to lowercase all input strings;
|
|
|
a2a915 |
* make sure to return the original case if the two strings
|
|
|
a2a915 |
* differ only in case
|
|
|
a2a915 |
@@ -4786,26 +4796,26 @@ idn_locale_to_ace(const char *from, char *to, size_t tolen) {
|
|
|
a2a915 |
if (!strcasecmp(from, tmp_str)) {
|
|
|
a2a915 |
if (strlen(from) >= tolen) {
|
|
|
a2a915 |
debug("from string is too long");
|
|
|
a2a915 |
- idn2_free(tmp_str);
|
|
|
a2a915 |
+ free(tmp_str);
|
|
|
a2a915 |
return ISC_R_NOSPACE;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
- idn2_free(tmp_str);
|
|
|
a2a915 |
+ free(tmp_str);
|
|
|
a2a915 |
(void) strlcpy(to, from, tolen);
|
|
|
a2a915 |
return ISC_R_SUCCESS;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
/* check the length */
|
|
|
a2a915 |
if (strlen(tmp_str) >= tolen) {
|
|
|
a2a915 |
debug("ACE string is too long");
|
|
|
a2a915 |
- idn2_free(tmp_str);
|
|
|
a2a915 |
+ free(tmp_str);
|
|
|
a2a915 |
return ISC_R_NOSPACE;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
|
|
|
a2a915 |
(void) strlcpy(to, tmp_str, tolen);
|
|
|
a2a915 |
- idn2_free(tmp_str);
|
|
|
a2a915 |
+ free(tmp_str);
|
|
|
a2a915 |
return ISC_R_SUCCESS;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
|
|
|
a2a915 |
- fatal("'%s' is not a legal IDN name (%s), use +noidnin", from, idn2_strerror(res));
|
|
|
a2a915 |
+ fatal("'%s' is not a legal IDN name (%s), use +noidnin", from, idna_strerror (res));
|
|
|
a2a915 |
return ISC_R_FAILURE;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
|
|
|
a2a915 |
@@ -4813,29 +4823,41 @@ idn_locale_to_ace(const char *from, char *to, size_t tolen) {
|
|
|
a2a915 |
static isc_result_t
|
|
|
a2a915 |
idn_ace_to_locale(const char *from, char *to, size_t tolen) {
|
|
|
a2a915 |
int res;
|
|
|
a2a915 |
+ char *tmp2 = NULL;
|
|
|
a2a915 |
char *tmp_str = NULL;
|
|
|
a2a915 |
|
|
|
a2a915 |
- res = idn2_to_unicode_8zlz(from, &tmp_str,
|
|
|
a2a915 |
- IDN2_NONTRANSITIONAL|IDN2_NFC_INPUT);
|
|
|
a2a915 |
+ res = idna_to_unicode_8z8z (from, &tmp2, 0);
|
|
|
a2a915 |
+ if (res != IDNA_SUCCESS) {
|
|
|
a2a915 |
+ debug ("output_filter: %s", idna_strerror (res));
|
|
|
a2a915 |
+ return ISC_R_SUCCESS;
|
|
|
a2a915 |
+ }
|
|
|
a2a915 |
+
|
|
|
a2a915 |
+ tmp_str = stringprep_utf8_to_locale (tmp2);
|
|
|
a2a915 |
+ if (tmp_str == NULL) {
|
|
|
a2a915 |
+ debug ("output_filter: stringprep_utf8_to_locale failed");
|
|
|
a2a915 |
+ res = idna_to_ascii_8z(tmp2, &tmp_str, 0);
|
|
|
a2a915 |
+ }
|
|
|
a2a915 |
+
|
|
|
a2a915 |
+ free(tmp2);
|
|
|
a2a915 |
|
|
|
a2a915 |
- if (res == IDN2_OK) {
|
|
|
a2a915 |
+ if (res == IDNA_SUCCESS) {
|
|
|
a2a915 |
/* check the length */
|
|
|
a2a915 |
if (strlen(tmp_str) >= tolen) {
|
|
|
a2a915 |
debug("encoded ASC string is too long");
|
|
|
a2a915 |
- idn2_free(tmp_str);
|
|
|
a2a915 |
+ free(tmp_str);
|
|
|
a2a915 |
return ISC_R_FAILURE;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
|
|
|
a2a915 |
(void) strlcpy(to, tmp_str, tolen);
|
|
|
a2a915 |
- idn2_free(tmp_str);
|
|
|
a2a915 |
+ free(tmp_str);
|
|
|
a2a915 |
return ISC_R_SUCCESS;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
-
|
|
|
a2a915 |
- fatal("'%s' is not a legal IDN name (%s), use +noidnout", from, idn2_strerror(res));
|
|
|
a2a915 |
+ // fatal("'%s' is not a legal IDN name (%s), use +noidnout", from, idna_strerror(res));
|
|
|
a2a915 |
+ free(tmp_str);
|
|
|
a2a915 |
return ISC_R_FAILURE;
|
|
|
a2a915 |
}
|
|
|
a2a915 |
#endif /* WITH_IDN_OUT_SUPPORT */
|
|
|
a2a915 |
-#endif /* WITH_LIBIDN2 */
|
|
|
a2a915 |
+#endif /* WITH_LIBIDN */
|
|
|
a2a915 |
#endif /* WITH_IDN_SUPPORT */
|
|
|
a2a915 |
|
|
|
a2a915 |
#ifdef DIG_SIGCHASE
|
|
|
a2a915 |
diff --git a/config.h.in b/config.h.in
|
|
|
a2a915 |
index 1dc65cf..9eb8a16 100644
|
|
|
a2a915 |
--- a/config.h.in
|
|
|
a2a915 |
+++ b/config.h.in
|
|
|
a2a915 |
@@ -615,8 +615,8 @@ int sigwait(const unsigned int *set, int *sig);
|
|
|
a2a915 |
/* define if IDN input support is to be included. */
|
|
|
a2a915 |
#undef WITH_IDN_SUPPORT
|
|
|
a2a915 |
|
|
|
a2a915 |
-/* define if libidn2 support is to be included. */
|
|
|
a2a915 |
-#undef WITH_LIBIDN2
|
|
|
a2a915 |
+/* define if libidn support is to be included. */
|
|
|
a2a915 |
+#undef WITH_LIBIDN
|
|
|
a2a915 |
|
|
|
a2a915 |
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
|
|
a2a915 |
significant byte first (like Motorola and SPARC, unlike Intel). */
|
|
|
a2a915 |
diff --git a/configure.in b/configure.in
|
|
|
a2a915 |
index 9a1d16d..1397c50 100644
|
|
|
a2a915 |
--- a/configure.in
|
|
|
a2a915 |
+++ b/configure.in
|
|
|
a2a915 |
@@ -4864,36 +4864,36 @@ fi
|
|
|
a2a915 |
AC_SUBST(IDNKIT_LIBS)
|
|
|
a2a915 |
|
|
|
a2a915 |
#
|
|
|
a2a915 |
-# IDN support using libidn2
|
|
|
a2a915 |
+# IDN support using libidn
|
|
|
a2a915 |
#
|
|
|
a2a915 |
|
|
|
a2a915 |
-LIBIDN2_CFLAGS=
|
|
|
a2a915 |
-LIBIDN2_LDFLAGS=
|
|
|
a2a915 |
-LIBIDN2_LIBS=
|
|
|
a2a915 |
-AC_ARG_WITH(libidn2,
|
|
|
a2a915 |
- AS_HELP_STRING([--with-libidn2[=PATH]], [enable IDN support using GNU libidn2 [yes|no|path]]),
|
|
|
a2a915 |
- use_libidn2="$withval", use_libidn2="no")
|
|
|
a2a915 |
-AS_CASE([$use_libidn2],
|
|
|
a2a915 |
+LIBIDN_CFLAGS=
|
|
|
a2a915 |
+LIBIDN_LDFLAGS=
|
|
|
a2a915 |
+LIBIDN_LIBS=
|
|
|
a2a915 |
+AC_ARG_WITH(libidn,
|
|
|
a2a915 |
+ AS_HELP_STRING([--with-libidn[=PATH]], [enable IDN support using GNU libidn [yes|no|path]]),
|
|
|
a2a915 |
+ use_libidn="$withval", use_libidn="no")
|
|
|
a2a915 |
+AS_CASE([$use_libidn],
|
|
|
a2a915 |
[no],[:],
|
|
|
a2a915 |
[yes],[:],
|
|
|
a2a915 |
[*],[
|
|
|
a2a915 |
- LIBIDN2_CFLAGS="-I$use_libidn2/include"
|
|
|
a2a915 |
- LIBIDN2_LDFLAGS="-L$use_libidn2/lib"
|
|
|
a2a915 |
+ LIBIDN_CFLAGS="-I$use_libidn/include"
|
|
|
a2a915 |
+ LIBIDN_LDFLAGS="-L$use_libidn/lib"
|
|
|
a2a915 |
])
|
|
|
a2a915 |
|
|
|
a2a915 |
-AS_IF([test "$use_libidn2" != "no"],
|
|
|
a2a915 |
+AS_IF([test "$use_libidn" != "no"],
|
|
|
a2a915 |
[save_CFLAGS="$CFLAGS"
|
|
|
a2a915 |
save_LIBS="$LIBS"
|
|
|
a2a915 |
save_LDFLAGS="$LDFLAGS"
|
|
|
a2a915 |
- CFLAGS="$LIBIDN2_CFLAGS $CFLAGS"
|
|
|
a2a915 |
- LDFLAGS="$LIBIDN2_LDFLAGS $LDFLAGS"
|
|
|
a2a915 |
- AC_SEARCH_LIBS([idn2_to_ascii_8z], [idn2],
|
|
|
a2a915 |
+ CFLAGS="$LIBIDN_CFLAGS $CFLAGS"
|
|
|
a2a915 |
+ LDFLAGS="$LIBIDN_LDFLAGS $LDFLAGS"
|
|
|
a2a915 |
+ AC_SEARCH_LIBS([idna_to_ascii_8z], [idn],
|
|
|
a2a915 |
[AC_DEFINE(WITH_IDN_SUPPORT, 1, [define if IDN input support is to be included.])
|
|
|
a2a915 |
- AC_DEFINE(WITH_LIBIDN2, 1, [define if libidn2 support is to be included.])
|
|
|
a2a915 |
- LIBIDN2_LIBS="$LIBIDN2_LDFLAGS -lidn2"],
|
|
|
a2a915 |
- [AC_MSG_ERROR([libidn2 requested, but not found])])
|
|
|
a2a915 |
- AC_TRY_LINK([#include <idn2.h>],
|
|
|
a2a915 |
- [idn2_to_unicode_8zlz(".", NULL, IDN2_NONTRANSITIONAL|IDN2_NFC_INPUT);],
|
|
|
a2a915 |
+ AC_DEFINE(WITH_LIBIDN, 1, [define if libidn support is to be included.])
|
|
|
a2a915 |
+ LIBIDN_LIBS="$LIBIDN_LDFLAGS -lidn"],
|
|
|
a2a915 |
+ [AC_MSG_ERROR([libidn requested, but not found])])
|
|
|
a2a915 |
+ AC_TRY_LINK([#include <idna.h>],
|
|
|
a2a915 |
+ [idna_to_unicode_8zlz(".", NULL, 0);],
|
|
|
a2a915 |
[AC_MSG_RESULT(yes)
|
|
|
a2a915 |
AC_DEFINE(WITH_IDN_OUT_SUPPORT, 1, [define if IDN output support is to be included.])],
|
|
|
a2a915 |
[AC_MSG_RESULT([no])])
|
|
|
a2a915 |
@@ -4901,21 +4901,21 @@ AS_IF([test "$use_libidn2" != "no"],
|
|
|
a2a915 |
LIBS="$save_LIBS"
|
|
|
a2a915 |
LDFLAGS="$save_LDFLAGS"
|
|
|
a2a915 |
])
|
|
|
a2a915 |
-AC_SUBST([LIBIDN2_CFLAGS])
|
|
|
a2a915 |
-AC_SUBST([LIBIDN2_LIBS])
|
|
|
a2a915 |
+AC_SUBST([LIBIDN_CFLAGS])
|
|
|
a2a915 |
+AC_SUBST([LIBIDN_LIBS])
|
|
|
a2a915 |
|
|
|
a2a915 |
#
|
|
|
a2a915 |
# IDN support in general
|
|
|
a2a915 |
#
|
|
|
a2a915 |
|
|
|
a2a915 |
-# check if idnkit and libidn2 are not used at the same time
|
|
|
a2a915 |
-if test "$use_idnkit" != no && test "$use_libidn2" != no; then
|
|
|
a2a915 |
- AC_MSG_ERROR([idnkit and libidn2 cannot be used at the same time.])
|
|
|
a2a915 |
+# check if idnkit and libidn are not used at the same time
|
|
|
a2a915 |
+if test "$use_idnkit" != no && test "$use_libidn" != no; then
|
|
|
a2a915 |
+ AC_MSG_ERROR([idnkit and libidn cannot be used at the same time.])
|
|
|
a2a915 |
fi
|
|
|
a2a915 |
# the IDN support is on
|
|
|
a2a915 |
-if test "$use_idnkit" != no || test "$use_libidn2" != no; then
|
|
|
a2a915 |
+if test "$use_idnkit" != no || test "$use_libidn" != no; then
|
|
|
a2a915 |
AC_DEFINE(WITH_IDN_SUPPORT, 1, [define if IDN input support is to be included.])
|
|
|
a2a915 |
- if test "$use_libidn2" = no || test "$use_libidn2_out" != no; then
|
|
|
a2a915 |
+ if test "$use_libidn" = no || test "$use_libidn_out" != no; then
|
|
|
a2a915 |
AC_DEFINE(WITH_IDN_OUT_SUPPORT, 1, [define if IDN output support is to be included.])
|
|
|
a2a915 |
fi
|
|
|
a2a915 |
fi
|
|
|
a2a915 |
@@ -5618,7 +5618,7 @@ report() {
|
|
|
a2a915 |
test "X$JSONSTATS" = "X" || echo " JSON statistics (--with-libjson)"
|
|
|
a2a915 |
test "X$ZLIB" = "X" || echo " HTTP zlib compression (--with-zlib)"
|
|
|
a2a915 |
test "X$NZD_TOOLS" = "X" || echo " LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
|
|
|
a2a915 |
- test "no" = "$use_libidn2" || echo " IDN support (--with-libidn2)"
|
|
|
a2a915 |
+ test "no" = "$use_libidn" || echo " IDN support (--with-libidn)"
|
|
|
a2a915 |
fi
|
|
|
a2a915 |
|
|
|
a2a915 |
if test "no" != "$use_pkcs11"; then
|
|
|
a2a915 |
@@ -5716,7 +5716,7 @@ report() {
|
|
|
a2a915 |
test "X$JSONSTATS" = "X" && echo " JSON statistics (--with-libjson)"
|
|
|
a2a915 |
test "X$ZLIB" = "X" && echo " HTTP zlib compression (--with-zlib)"
|
|
|
a2a915 |
test "X$NZD_TOOLS" = "X" && echo " LMDB database to store configuration for 'addzone' zones (--with-lmdb)"
|
|
|
a2a915 |
- test "no" = "$use_libidn2" && echo " IDN support (--with-libidn2)"
|
|
|
a2a915 |
+ test "no" = "$use_libidn" && echo " IDN support (--with-libidn)"
|
|
|
a2a915 |
|
|
|
a2a915 |
echo "-------------------------------------------------------------------------------"
|
|
|
a2a915 |
echo "Configured paths:"
|
|
|
a2a915 |
--
|
|
|
a2a915 |
2.20.1
|
|
|
a2a915 |
|