diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 3b1adcf51da..5cb490eca61 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -81,6 +81,9 @@ Release 0.23.1 - Unreleased HADOOP-7939. Improve Hadoop subcomponent integration in Hadoop 0.23. (rvs via tucu) + HADOOP-7988. Upper case in hostname part of the principals doesn't work with + kerberos. (jitendra) + OPTIMIZATIONS BUG FIXES 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 a72b1f272ca..abf9f3aa80a 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 @@ -236,7 +236,7 @@ public class SecurityUtil { if (fqdn == null || fqdn.equals("") || fqdn.equals("0.0.0.0")) { fqdn = getLocalHostName(); } - return components[0] + "/" + fqdn + "@" + components[2]; + return components[0] + "/" + fqdn.toLowerCase() + "@" + components[2]; } static String getLocalHostName() throws UnknownHostException { diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java index 84f585b5999..57a1e116de7 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/security/TestSecurityUtil.java @@ -89,6 +89,16 @@ public class TestSecurityUtil { Mockito.verify(notUsed, Mockito.never()).getCanonicalHostName(); } + @Test + public void testPrincipalsWithLowerCaseHosts() throws IOException { + String service = "xyz/"; + String realm = "@REALM"; + String principalInConf = service + SecurityUtil.HOSTNAME_PATTERN + realm; + String hostname = "FooHost"; + String principal = service + hostname.toLowerCase() + realm; + verify(principalInConf, hostname, principal); + } + @Test public void testLocalHostNameForNullOrWild() throws Exception { String local = SecurityUtil.getLocalHostName();