Bladeren bron

commit cff4ddd772af65522337ba3380d2e75b7b5d61e0
Author: Konstantin Boudnik <cos@yahoo-inc.com>
Date: Tue May 4 18:47:13 2010 -0700

HADOOP-6332 from https://issues.apache.org/jira/secure/attachment/12443668/6332-phase2.fix1.patch
on top of https://issues.apache.org/jira/secure/attachment/12443539/6332-phase2.patch
fixing the issue with FileSystem access from Herriot via RPC


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

Owen O'Malley 14 jaren geleden
bovenliggende
commit
d06d47e2f5
1 gewijzigde bestanden met toevoegingen van 20 en 9 verwijderingen
  1. 20 9
      src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj

+ 20 - 9
src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj

@@ -20,6 +20,7 @@ package org.apache.hadoop.test.system;
 
 import java.io.File;
 import java.io.IOException;
+import java.security.PrivilegedExceptionAction;
 import java.util.HashMap;
 import java.util.List;
 import java.util.ArrayList;
@@ -28,6 +29,7 @@ import java.util.Properties;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.io.Writable;
+import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.hadoop.util.Shell.ShellCommandExecutor;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
@@ -157,18 +159,27 @@ public aspect DaemonProtocolAspect {
         fileStatus.getPath());
   }
 
-  private FileSystem DaemonProtocol.getFS(Path path, boolean local) 
-    throws IOException {
-    FileSystem fs = null;
-    if (local) {
-      fs = FileSystem.getLocal(getDaemonConf());
-    } else {
-      fs = path.getFileSystem(getDaemonConf());
+  private FileSystem DaemonProtocol.getFS(final Path path, final boolean local)
+      throws IOException {
+    FileSystem ret = null;
+    try {
+      ret = UserGroupInformation.getLoginUser().doAs (
+          new PrivilegedExceptionAction<FileSystem>() {
+            public FileSystem run() throws IOException {
+              FileSystem fs = null;
+              if (local) {
+                fs = FileSystem.getLocal(getDaemonConf());
+              } else {
+                fs = path.getFileSystem(getDaemonConf());
+              }
+              return fs;
+            }
+          });
+    } catch (InterruptedException ie) {
     }
-    return fs;
+    return ret;
   }
   
-  
   @SuppressWarnings("unchecked")
   public ControlAction[] DaemonProtocol.getActions(Writable key) 
     throws IOException {