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