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