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