From 6326a143263fc460bbda871d6e74b1d7d2841ea1 Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Thu, 15 Jun 2017 17:44:59 +0200 Subject: [PATCH 1/2] Make IDN support conditional [zj: rename HAVE_IDN to ENABLE_IDN] --- configure.ac | 10 ++++++++++ src/basic/socket-util.c | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index a47492df3e..3e7af7694c 100644 --- a/configure.ac +++ b/configure.ac @@ -1049,6 +1049,15 @@ if test "$have_libidn2" != "yes"; then fi AM_CONDITIONAL(HAVE_LIBIDN, [test "$have_libidn" = "yes"]) +# ------------------------------------------------------------------------------ +have_idn=no +AC_ARG_ENABLE(idn, AS_HELP_STRING([--disable-idn], [disable IDN when printing host names])) +if test "x$enable_idn" != "xno"; then + have_idn=yes + AC_DEFINE(ENABLE_IDN, [1], [IDN is enabled]) +fi +AM_CONDITIONAL(ENABLE_IDN, [test "$have_idn" = "yes"]) + # ------------------------------------------------------------------------------ have_libiptc=no AC_ARG_ENABLE(libiptc, AS_HELP_STRING([--disable-libiptc], [disable optional LIBIPTC support])) @@ -1742,6 +1751,7 @@ AC_MSG_RESULT([ libcurl: ${have_libcurl} libidn2: ${have_libidn2} libidn: ${have_libidn} + IDN: ${have_idn} libiptc: ${have_libiptc} ELFUTILS: ${have_elfutils} binfmt: ${have_binfmt} diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index e5847dce00..49642c2347 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -48,6 +48,12 @@ #include "utf8.h" #include "util.h" +#ifdef ENABLE_IDN +# define IDN_FLAGS (NI_IDN|NI_IDN_USE_STD3_ASCII_RULES) +#else +# define IDN_FLAGS 0 +#endif + int socket_address_parse(SocketAddress *a, const char *s) { char *e, *n; unsigned u; @@ -723,8 +729,7 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret) assert(_ret); - r = getnameinfo(&sa->sa, salen, host, sizeof(host), NULL, 0, - NI_IDN|NI_IDN_USE_STD3_ASCII_RULES); + r = getnameinfo(&sa->sa, salen, host, sizeof(host), NULL, 0, IDN_FLAGS); if (r != 0) { int saved_errno = errno; From d1bf56759b1367c243c91a83857ea76f9ccc1faf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 16 Jun 2017 09:16:28 -0400 Subject: [PATCH 2/2] meson: add -Didn=yes|no option --- meson.build | 2 ++ meson_options.txt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/meson.build b/meson.build index f932d06a53..407d7ea08e 100644 --- a/meson.build +++ b/meson.build @@ -1009,6 +1009,7 @@ foreach pair : [['utmp', 'HAVE_UTMP'], ['ima', 'HAVE_IMA'], ['smack', 'HAVE_SMACK'], ['gshadow', 'ENABLE_GSHADOW'], + ['idn', 'ENABLE_IDN'], ] if get_option(pair[0]) @@ -2448,6 +2449,7 @@ foreach tuple : [ ['microhttpd'], ['gnutls'], ['libcurl'], + ['idn'], ['libidn2'], ['libidn'], ['libiptc'], diff --git a/meson_options.txt b/meson_options.txt index da4a932ff2..0de217744f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -197,6 +197,8 @@ option('libcryptsetup', type : 'combo', choices : ['auto', 'true', 'false'], description : 'libcryptsetup support') option('libcurl', type : 'combo', choices : ['auto', 'true', 'false'], description : 'libcurl support') +option('idn', type : 'boolean', + description : 'use IDN when printing host names') option('libidn2', type : 'combo', choices : ['auto', 'true', 'false'], description : 'libidn2 support') option('libidn', type : 'combo', choices : ['auto', 'true', 'false'],