Browse Source

commit cc1043c5914bea27225cfdf14ac0384cc851fc8f
Author: Jitendra Nath Pandey <jitendra@sufferhome-lm.(none)>
Date: Tue Mar 16 15:46:02 2010 -0700

HDFS-1039 from https://issues.apache.org/jira/secure/attachment/12438896/HDFS-1039-y20.2.patch

+++ b/YAHOO-CHANGES.txt
+ HDFS-1039. Service should be set in the token in JspHelper.getUGI.
+ (jitendra)
+


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077321 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley 14 years ago
parent
commit
959570bc2c

+ 5 - 2
src/hdfs/org/apache/hadoop/hdfs/server/namenode/JspHelper.java

@@ -48,6 +48,7 @@ import org.apache.hadoop.hdfs.server.datanode.DataNode;
 import org.apache.hadoop.hdfs.server.namenode.DatanodeDescriptor;
 import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
 import org.apache.hadoop.http.HtmlQuoting;
+import org.apache.hadoop.io.Text;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.security.AccessControlException;
 import org.apache.hadoop.security.UserGroupInformation;
@@ -354,8 +355,8 @@ public class JspHelper {
       String[] parts = dir.split(Path.SEPARATOR);
       StringBuilder tempPath = new StringBuilder(dir.length());
       out.print("<a href=\"browseDirectory.jsp" + "?dir="+ Path.SEPARATOR
-          + "&namenodeInfoPort=" + namenodeInfoPort
-          + "\">" + Path.SEPARATOR + "</a>");
+          + "&namenodeInfoPort=" + namenodeInfoPort + SET_DELEGATION
+          + tokenString + "\">" + Path.SEPARATOR + "</a>");
       tempPath.append(Path.SEPARATOR);
       for (int i = 0; i < parts.length-1; i++) {
         if (!parts[i].equals("")) {
@@ -435,6 +436,8 @@ public class JspHelper {
         Token<DelegationTokenIdentifier> token = 
           new Token<DelegationTokenIdentifier>();
         token.decodeFromUrlString(tokenString);
+        token.setService(new Text(nameNodeAddr.getAddress().getHostAddress() + ":"
+            + nameNodeAddr.getPort()));
         if (user == null) {
           //this really doesn't break any security since we use the 
           //delegation token for authentication in

+ 2 - 1
src/webapps/datanode/browseDirectory.jsp

@@ -138,7 +138,8 @@
           }
           String datanodeUrl = req.getRequestURL()+"?dir="+
               URLEncoder.encode(files[i].getFullName(target).toString(), "UTF-8") + 
-              "&namenodeInfoPort=" + namenodeInfoPort;
+              "&namenodeInfoPort=" + namenodeInfoPort + JspHelper.SET_DELEGATION + 
+              tokenString;
           cols[0] = "<a href=\""+datanodeUrl+"\">"+localname+"</a>";
           cols[5] = FsShell.dateForm.format(new Date((files[i].getModificationTime())));
           cols[6] = files[i].getPermission().toString();