hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From omal...@apache.org
Subject svn commit: r1077717 - in /hadoop/common/branches/branch-0.20-security-patches/src: mapred/org/apache/hadoop/mapred/CleanupQueue.java test/org/apache/hadoop/mapred/UtilsForTests.java
Date Fri, 04 Mar 2011 04:47:41 GMT
Author: omalley
Date: Fri Mar  4 04:47:40 2011
New Revision: 1077717

URL: http://svn.apache.org/viewvc?rev=1077717&view=rev
Log:
commit 54da3daaee69eae19dc09af62bb7cd1f32f78f12
Author: Devaraj Das <ddas@yahoo-inc.com>
Date:   Mon Sep 20 14:25:31 2010 -0700

    Fixes delete in the CleanupQueue to do the delete as the login user

Modified:
    hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CleanupQueue.java
    hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/UtilsForTests.java

Modified: hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CleanupQueue.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CleanupQueue.java?rev=1077717&r1=1077716&r2=1077717&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CleanupQueue.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/mapred/org/apache/hadoop/mapred/CleanupQueue.java
Fri Mar  4 04:47:40 2011
@@ -19,6 +19,7 @@
 package org.apache.hadoop.mapred;
 
 import java.io.IOException;
+import java.security.PrivilegedExceptionAction;
 import java.util.concurrent.LinkedBlockingQueue;
 
 import org.apache.commons.logging.Log;
@@ -26,6 +27,7 @@ import org.apache.commons.logging.LogFac
 
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.security.UserGroupInformation;
 
 class CleanupQueue {
 
@@ -66,10 +68,17 @@ class CleanupQueue {
 
     /**
      * Deletes the path (and its subdirectories recursively)
+     * @throws IOException, InterruptedException 
      */
-    protected void deletePath() throws IOException {
+    protected void deletePath() throws IOException, InterruptedException {
       final Path p = getPathForCleanup();
-      p.getFileSystem(conf).delete(p, true);
+      UserGroupInformation.getLoginUser().doAs(
+          new PrivilegedExceptionAction<Object>() {
+            public Object run() throws IOException {
+             p.getFileSystem(conf).delete(p, true);
+             return null;
+            }
+          });
     }
 
     @Override

Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/UtilsForTests.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/UtilsForTests.java?rev=1077717&r1=1077716&r2=1077717&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/UtilsForTests.java
(original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/org/apache/hadoop/mapred/UtilsForTests.java
Fri Mar  4 04:47:40 2011
@@ -451,20 +451,27 @@ public class UtilsForTests {
     public void addToQueue(PathDeletionContext... contexts) {
       // delete paths in-line
       for (PathDeletionContext context : contexts) {
+        Exception exc = null;
         try {
           if (!deletePath(context)) {
             LOG.warn("Stale path " + context.fullPath);
             stalePaths.add(context.fullPath);
           }
         } catch (IOException e) {
+          exc = e;
+        } catch (InterruptedException ie) {
+          exc = ie;
+        }
+        if (exc != null) {
           LOG.warn("Caught exception while deleting path "
               + context.fullPath);
-          LOG.info(StringUtils.stringifyException(e));
+          LOG.info(StringUtils.stringifyException(exc));
           stalePaths.add(context.fullPath);
         }
       }
     }
-    static boolean deletePath(PathDeletionContext context) throws IOException {
+    static boolean deletePath(PathDeletionContext context) 
+    throws IOException, InterruptedException {
       if (LOG.isDebugEnabled()) {
         LOG.debug("Trying to delete " + context.fullPath);
       }



Mime
View raw message