hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1622806 - in /hive/trunk: common/src/java/org/apache/hadoop/hive/common/ shims/0.20/src/main/java/org/apache/hadoop/hive/shims/ shims/0.20S/src/main/java/org/apache/hadoop/hive/shims/ shims/0.23/src/main/java/org/apache/hadoop/hive/shims/ ...
Date Fri, 05 Sep 2014 21:46:49 GMT
Author: brock
Date: Fri Sep  5 21:46:48 2014
New Revision: 1622806

URL: http://svn.apache.org/r1622806
Log:
HIVE-7927 - Checking sticky bit needs shim (Navis via Brock)

Modified:
    hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
    hive/trunk/shims/0.20/src/main/java/org/apache/hadoop/hive/shims/Hadoop20Shims.java
    hive/trunk/shims/0.20S/src/main/java/org/apache/hadoop/hive/shims/Hadoop20SShims.java
    hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java
    hive/trunk/shims/common/src/main/java/org/apache/hadoop/hive/shims/HadoopShims.java

Modified: hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
URL: http://svn.apache.org/viewvc/hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java?rev=1622806&r1=1622805&r2=1622806&view=diff
==============================================================================
--- hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java (original)
+++ hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java Fri Sep  5 21:46:48
2014
@@ -655,18 +655,28 @@ public final class FileUtils {
     }
 
     final FileSystem fs = path.getFileSystem(conf);
-    if (!fs.exists(path)) {
+    // check user has write permissions on the parent dir
+    FileStatus stat = null;
+    try {
+      stat = fs.getFileStatus(path);
+    } catch (FileNotFoundException e) {
+      // ignore
+    }
+    if (stat == null) {
       // no file/dir to be deleted
       return;
     }
-    Path parPath = path.getParent();
-    // check user has write permissions on the parent dir
-    FileStatus stat = fs.getFileStatus(path);
     FileUtils.checkFileAccessWithImpersonation(fs, stat, FsAction.WRITE, user);
 
+    HadoopShims shims = ShimLoader.getHadoopShims();
+    if (!shims.supportStickyBit()) {
+      // not supports sticky bit
+      return;
+    }
+
     // check if sticky bit is set on the parent dir
-    FileStatus parStatus = fs.getFileStatus(parPath);
-    if (!parStatus.getPermission().getStickyBit()) {
+    FileStatus parStatus = fs.getFileStatus(path.getParent());
+    if (!shims.hasStickyBit(parStatus.getPermission())) {
       // no sticky bit, so write permission on parent dir is sufficient
       // no further checks needed
       return;

Modified: hive/trunk/shims/0.20/src/main/java/org/apache/hadoop/hive/shims/Hadoop20Shims.java
URL: http://svn.apache.org/viewvc/hive/trunk/shims/0.20/src/main/java/org/apache/hadoop/hive/shims/Hadoop20Shims.java?rev=1622806&r1=1622805&r2=1622806&view=diff
==============================================================================
--- hive/trunk/shims/0.20/src/main/java/org/apache/hadoop/hive/shims/Hadoop20Shims.java (original)
+++ hive/trunk/shims/0.20/src/main/java/org/apache/hadoop/hive/shims/Hadoop20Shims.java Fri
Sep  5 21:46:48 2014
@@ -55,6 +55,7 @@ import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.fs.ProxyFileSystem;
 import org.apache.hadoop.fs.Trash;
 import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.hive.io.HiveIOExceptionHandlerUtil;
 import org.apache.hadoop.io.LongWritable;
@@ -895,4 +896,14 @@ public class Hadoop20Shims implements Ha
     // No password API, just retrieve value from conf
     return conf.get(name);
   }
+
+  @Override
+  public boolean supportStickyBit() {
+    return false;
+  }
+
+  @Override
+  public boolean hasStickyBit(FsPermission permission) {
+    return false;   // not supported
+  }
 }

Modified: hive/trunk/shims/0.20S/src/main/java/org/apache/hadoop/hive/shims/Hadoop20SShims.java
URL: http://svn.apache.org/viewvc/hive/trunk/shims/0.20S/src/main/java/org/apache/hadoop/hive/shims/Hadoop20SShims.java?rev=1622806&r1=1622805&r2=1622806&view=diff
==============================================================================
--- hive/trunk/shims/0.20S/src/main/java/org/apache/hadoop/hive/shims/Hadoop20SShims.java
(original)
+++ hive/trunk/shims/0.20S/src/main/java/org/apache/hadoop/hive/shims/Hadoop20SShims.java
Fri Sep  5 21:46:48 2014
@@ -40,6 +40,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.fs.ProxyFileSystem;
 import org.apache.hadoop.fs.Trash;
+import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.hdfs.MiniDFSCluster;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.mapred.ClusterStatus;
@@ -513,4 +514,14 @@ public class Hadoop20SShims extends Hado
     // No password API, just retrieve value from conf
     return conf.get(name);
   }
+
+  @Override
+  public boolean supportStickyBit() {
+    return false;
+  }
+
+  @Override
+  public boolean hasStickyBit(FsPermission permission) {
+    return false;   // not supported
+  }
 }

Modified: hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java
URL: http://svn.apache.org/viewvc/hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java?rev=1622806&r1=1622805&r2=1622806&view=diff
==============================================================================
--- hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java (original)
+++ hive/trunk/shims/0.23/src/main/java/org/apache/hadoop/hive/shims/Hadoop23Shims.java Fri
Sep  5 21:46:48 2014
@@ -19,21 +19,17 @@ package org.apache.hadoop.hive.shims;
 
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.security.AccessControlException;
-import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Comparator;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.commons.lang.ArrayUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.BlockLocation;
@@ -817,4 +813,14 @@ public class Hadoop23Shims extends Hadoo
       }
     }
   }
+
+  @Override
+  public boolean supportStickyBit() {
+    return true;
+  }
+
+  @Override
+  public boolean hasStickyBit(FsPermission permission) {
+    return permission.getStickyBit();
+  }
 }

Modified: hive/trunk/shims/common/src/main/java/org/apache/hadoop/hive/shims/HadoopShims.java
URL: http://svn.apache.org/viewvc/hive/trunk/shims/common/src/main/java/org/apache/hadoop/hive/shims/HadoopShims.java?rev=1622806&r1=1622805&r2=1622806&view=diff
==============================================================================
--- hive/trunk/shims/common/src/main/java/org/apache/hadoop/hive/shims/HadoopShims.java (original)
+++ hive/trunk/shims/common/src/main/java/org/apache/hadoop/hive/shims/HadoopShims.java Fri
Sep  5 21:46:48 2014
@@ -44,6 +44,7 @@ import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.PathFilter;
 import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.fs.permission.FsPermission;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.mapred.ClusterStatus;
 import org.apache.hadoop.mapred.InputSplit;
@@ -694,4 +695,16 @@ public interface HadoopShims {
    */
   public String getPassword(Configuration conf, String name) throws IOException;
 
+  /**
+   * check whether current hadoop supports sticky bit
+   * @return
+   */
+  boolean supportStickyBit();
+
+  /**
+   * Check stick bit in the permission
+   * @param permission
+   * @return sticky bit
+   */
+  boolean hasStickyBit(FsPermission permission);
 }



Mime
View raw message