57726f
From ec50eff97c259b5bfbfa4e050d69fe7b39b0f15a Mon Sep 17 00:00:00 2001
57726f
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
57726f
Date: Tue, 25 Sep 2018 18:08:46 +0200
57726f
Subject: [PATCH] Disable IDN from environment as documented
57726f
57726f
Manual page of host contained instructions to disable IDN processing
57726f
when it was built with libidn2. When refactoring IDN support however,
57726f
support for disabling IDN in host and nslookup was lost. Use also
57726f
environment variable and document it for nslookup, host and dig.
57726f
57726f
Support variable CHARSET=ASCII to disable IDN, supported in downstream
57726f
RH patch since RHEL 5.
57726f
---
57726f
 bin/dig/dig.docbook      |  4 +++-
57726f
 bin/dig/dighost.c        |  5 +++++
57726f
 bin/dig/host.docbook     |  2 +-
57726f
 bin/dig/nslookup.docbook | 15 +++++++++++++++
57726f
 4 files changed, 24 insertions(+), 2 deletions(-)
57726f
57726f
diff --git a/bin/dig/dig.docbook b/bin/dig/dig.docbook
57726f
index 5d19301..933af79 100644
57726f
--- a/bin/dig/dig.docbook
57726f
+++ b/bin/dig/dig.docbook
57726f
@@ -1312,7 +1312,9 @@ dig +qr www.isc.org any -x 127.0.0.1 isc.org ns +noqr
57726f
       reply from the server.
57726f
       If you'd like to turn off the IDN support for some reason, use
57726f
       parameters <parameter>+noidnin</parameter> and
57726f
-      <parameter>+noidnout</parameter>.
57726f
+      <parameter>+noidnout</parameter> or define
57726f
+      the <envar>IDN_DISABLE</envar> environment variable.
57726f
+
57726f
     </para>
57726f
   </refsection>
57726f
 
57726f
diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c
57726f
index 5eabc1f..73aaab8 100644
57726f
--- a/bin/dig/dighost.c
57726f
+++ b/bin/dig/dighost.c
57726f
@@ -826,6 +826,11 @@ make_empty_lookup(void) {
57726f
 	looknew->badcookie = true;
57726f
 #ifdef WITH_IDN_SUPPORT
57726f
 	looknew->idnin = isatty(1)?(getenv("IDN_DISABLE") == NULL):false;
57726f
+	if (looknew->idnin) {
57726f
+		const char *charset = getenv("CHARSET");
57726f
+		if (charset && !strcmp(charset, "ASCII"))
57726f
+			looknew->idnin = false;
57726f
+	}
57726f
 #else
57726f
 	looknew->idnin = false;
57726f
 #endif
57726f
diff --git a/bin/dig/host.docbook b/bin/dig/host.docbook
57726f
index da0f8fb..9689b5a 100644
57726f
--- a/bin/dig/host.docbook
57726f
+++ b/bin/dig/host.docbook
57726f
@@ -379,7 +379,7 @@
57726f
       <command>host</command> appropriately converts character encoding of
57726f
       domain name before sending a request to DNS server or displaying a
57726f
       reply from the server.
57726f
-      If you'd like to turn off the IDN support for some reason, defines
57726f
+      If you'd like to turn off the IDN support for some reason, define
57726f
       the <envar>IDN_DISABLE</envar> environment variable.
57726f
       The IDN support is disabled if the variable is set when
57726f
       <command>host</command> runs.
57726f
diff --git a/bin/dig/nslookup.docbook b/bin/dig/nslookup.docbook
57726f
index d46fc2d..6d7d181 100644
57726f
--- a/bin/dig/nslookup.docbook
57726f
+++ b/bin/dig/nslookup.docbook
57726f
@@ -495,6 +495,21 @@ nslookup -query=hinfo  -timeout=10
57726f
     </para>
57726f
   </refsection>
57726f
 
57726f
+  <refsection><info><title>IDN SUPPORT</title></info>
57726f
+
57726f
+    <para>
57726f
+      If <command>nslookup</command> has been built with IDN (internationalized
57726f
+      domain name) support, it can accept and display non-ASCII domain names.
57726f
+      <command>nslookup</command> appropriately converts character encoding of
57726f
+      domain name before sending a request to DNS server or displaying a
57726f
+      reply from the server.
57726f
+      If you'd like to turn off the IDN support for some reason, define
57726f
+      the <envar>IDN_DISABLE</envar> environment variable.
57726f
+      The IDN support is disabled if the variable is set when
57726f
+      <command>nslookup</command> runs.
57726f
+    </para>
57726f
+  </refsection>
57726f
+
57726f
   <refsection><info><title>FILES</title></info>
57726f
 
57726f
     <para><filename>/etc/resolv.conf</filename>
57726f
-- 
57726f
2.20.1
57726f