10d019
From ec50eff97c259b5bfbfa4e050d69fe7b39b0f15a 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 +++-
10d019
 bin/dig/dighost.c        |  5 +++++
2e2c49
 bin/dig/host.docbook     |  2 +-
2e2c49
 bin/dig/nslookup.docbook | 15 +++++++++++++++
10d019
 4 files changed, 24 insertions(+), 2 deletions(-)
2e2c49
2e2c49
diff --git a/bin/dig/dig.docbook b/bin/dig/dig.docbook
10d019
index 5d19301..933af79 100644
2e2c49
--- a/bin/dig/dig.docbook
2e2c49
+++ b/bin/dig/dig.docbook
10d019
@@ -1312,7 +1312,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
10d019
index 5eabc1f..73aaab8 100644
2e2c49
--- a/bin/dig/dighost.c
2e2c49
+++ b/bin/dig/dighost.c
10d019
@@ -826,6 +826,11 @@ make_empty_lookup(void) {
10d019
 	looknew->badcookie = true;
2e2c49
 #ifdef WITH_IDN_SUPPORT
10d019
 	looknew->idnin = isatty(1)?(getenv("IDN_DISABLE") == NULL):false;
2e2c49
+	if (looknew->idnin) {
2e2c49
+		const char *charset = getenv("CHARSET");
2e2c49
+		if (charset && !strcmp(charset, "ASCII"))
10d019
+			looknew->idnin = false;
2e2c49
+	}
2e2c49
 #else
10d019
 	looknew->idnin = false;
2e2c49
 #endif
2e2c49
diff --git a/bin/dig/host.docbook b/bin/dig/host.docbook
10d019
index da0f8fb..9689b5a 100644
2e2c49
--- a/bin/dig/host.docbook
2e2c49
+++ b/bin/dig/host.docbook
10d019
@@ -379,7 +379,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
10d019
index d46fc2d..6d7d181 100644
2e2c49
--- a/bin/dig/nslookup.docbook
2e2c49
+++ b/bin/dig/nslookup.docbook
10d019
@@ -495,6 +495,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
-- 
10d019
2.20.1
2e2c49