sentry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sra...@apache.org
Subject incubator-sentry git commit: SENTRY-922: INSERT OVERWRITE DIRECTORY permission not working correctly (Yibing Shi, Reviewed by: Sravya Tirukkovalur)
Date Fri, 11 Mar 2016 01:18:51 GMT
Repository: incubator-sentry
Updated Branches:
  refs/heads/master baad976f0 -> 0619d8a1a


SENTRY-922: INSERT OVERWRITE DIRECTORY permission not working correctly (Yibing Shi, Reviewed
by: Sravya Tirukkovalur)

Change-Id: I9bc565506e544ee747a7ce5f7cc9b84a56786ec2


Project: http://git-wip-us.apache.org/repos/asf/incubator-sentry/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-sentry/commit/0619d8a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-sentry/tree/0619d8a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-sentry/diff/0619d8a1

Branch: refs/heads/master
Commit: 0619d8a1a0860674bae2fcc035148ce3d23d009f
Parents: baad976
Author: Sravya Tirukkovalur <sravya@cloudera.com>
Authored: Thu Mar 10 17:18:03 2016 -0800
Committer: Sravya Tirukkovalur <sravya@cloudera.com>
Committed: Thu Mar 10 17:18:03 2016 -0800

----------------------------------------------------------------------
 .../apache/sentry/binding/hive/HiveAuthzBindingHook.java    | 7 +++++++
 .../test/java/org/apache/sentry/binding/hive/TestURI.java   | 9 +++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/0619d8a1/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
index dd33d2d..c425e06 100644
--- a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
+++ b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/hive/HiveAuthzBindingHook.java
@@ -30,6 +30,8 @@ import java.util.Set;
 import java.util.Arrays;
 
 import com.google.common.base.Preconditions;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.hive.common.JavaUtils;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
@@ -368,6 +370,11 @@ public class HiveAuthzBindingHook extends AbstractSemanticAnalyzerHook
{
     try {
       HiveConf conf = SessionState.get().getConf();
       String warehouseDir = conf.getVar(ConfVars.METASTOREWAREHOUSE);
+      Path warehousePath = new Path(warehouseDir);
+      if (warehousePath.isAbsoluteAndSchemeAuthorityNull()) {
+        FileSystem fs = FileSystem.get(conf);
+        warehouseDir = fs.makeQualified(warehousePath).toUri().toString();
+      }
       return new AccessURI(PathUtils.parseURI(warehouseDir, uri, isLocal));
     } catch (Exception e) {
       throw new SemanticException("Error parsing URI " + uri + ": " +

http://git-wip-us.apache.org/repos/asf/incubator-sentry/blob/0619d8a1/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
----------------------------------------------------------------------
diff --git a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
index cdd4e0b..8b716c3 100644
--- a/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
+++ b/sentry-binding/sentry-binding-hive/src/test/java/org/apache/sentry/binding/hive/TestURI.java
@@ -19,6 +19,7 @@ package org.apache.sentry.binding.hive;
 import java.io.File;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.hive.conf.HiveConf;
 import org.apache.hadoop.hive.conf.HiveConf.ConfVars;
 import org.apache.hadoop.hive.ql.parse.SemanticException;
@@ -72,6 +73,14 @@ public class TestURI {
         HiveAuthzBindingHook.parseURI("hdfs:///some/path").getName());
   }
 
+  @Test
+  public void testWarehouseDirWithoutPrefix() throws SemanticException {
+    conf.set(CommonConfigurationKeys.FS_DEFAULT_NAME_KEY, "hdfs://localhost:8020");
+    conf.set(ConfVars.METASTOREWAREHOUSE.varname, "/path/to/warehouse");
+    Assert.assertEquals("hdfs://localhost:8020/some/path",
+        HiveAuthzBindingHook.parseURI("/some/path").getName());
+  }
+
   @AfterClass
   public static void clear() {
     if(baseDir != null) {


Mime
View raw message