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