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