Browse Source

Merged r1236963 from branch-1 for HADOOP-7988.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0@1236966 13f79535-47bb-0310-9956-ffa450edef68
Jitendra Nath Pandey 13 years ago
parent
commit
b8b220c2b0

+ 3 - 0
CHANGES.txt

@@ -10,6 +10,9 @@ Release 1.0.1 - unreleased
 
 
     HADOOP-7987. Support setting the run-as user in unsecure mode. (jitendra)
     HADOOP-7987. Support setting the run-as user in unsecure mode. (jitendra)
 
 
+    HADOOP-7988. Upper case in hostname part of the principals doesn't work with 
+    kerberos. (jitendra)
+
   BUG FIXES
   BUG FIXES
 
 
     HADOOP-7964. Deadlock in NetUtils and SecurityUtil class initialization.
     HADOOP-7964. Deadlock in NetUtils and SecurityUtil class initialization.

+ 1 - 1
src/core/org/apache/hadoop/security/SecurityUtil.java

@@ -210,7 +210,7 @@ public class SecurityUtil {
     if (fqdn == null || fqdn.equals("") || fqdn.equals("0.0.0.0")) {
     if (fqdn == null || fqdn.equals("") || fqdn.equals("0.0.0.0")) {
       fqdn = getLocalHostName();
       fqdn = getLocalHostName();
     }
     }
-    return components[0] + "/" + fqdn + "@" + components[2];
+    return components[0] + "/" + fqdn.toLowerCase() + "@" + components[2];
   }
   }
   
   
   static String getLocalHostName() throws UnknownHostException {
   static String getLocalHostName() throws UnknownHostException {

+ 10 - 0
src/test/org/apache/hadoop/security/TestSecurityUtil.java

@@ -83,6 +83,16 @@ public class TestSecurityUtil {
     Mockito.verify(notUsed, Mockito.never()).getCanonicalHostName();
     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
   @Test
   public void testLocalHostNameForNullOrWild() throws Exception {
   public void testLocalHostNameForNullOrWild() throws Exception {
     String local = SecurityUtil.getLocalHostName();
     String local = SecurityUtil.getLocalHostName();