From 2c841e65648244d46f98e988cdb964f7d5681775 Mon Sep 17 00:00:00 2001 From: rohithsharmaks Date: Thu, 7 Jan 2016 10:42:48 +0530 Subject: [PATCH] HADOOP-12687. SecureUtil#QualifiedHostResolver#getByName should also try to resolve direct hostname (Sunil G via rohithsharmaks) (cherry picked from commit 2b252844e04eebd4f32815d4bd6f914c02994709) --- hadoop-common-project/hadoop-common/CHANGES.txt | 4 ++++ .../main/java/org/apache/hadoop/security/SecurityUtil.java | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 1d612862b07..44f561ab60b 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -19,6 +19,10 @@ Release 2.9.0 - UNRELEASED BUG FIXES + HADOOP-12687. SecureUtil#QualifiedHostResolver#getByName should also try to + resolve direct hostname, incase multiple loopback addresses are present in + /etc/hosts (Sunil G via rohithsharmaks) + Release 2.8.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java index 38096ab4715..714c923a627 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java @@ -580,7 +580,13 @@ public class SecurityUtil { addr = getByNameWithSearch(host); if (addr == null) { addr = getByExactName(host); + // If multiple loopback addresses are present, a direct lookup + // will be helpful + if (addr == null) { + addr = InetAddress.getByName(host); + } } + } } // unresolvable!