Repository: sentry
Updated Branches:
  refs/heads/master 3dbfe8811 -> caa630c97


SENTRY-1345: ACLS on table folder disappear after insert for unpartitioned 
tables (Sravya Tirukkovalur, Reviewed by: Hao Hao and Anne Yu)

Change-Id: I716000e5e49714169e87c8d3ffcef9ae3da8a796


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

Branch: refs/heads/master
Commit: caa630c97438c29c8d43e345431bddd4ed3cf9ef
Parents: 3dbfe88
Author: hahao <[email protected]>
Authored: Tue Jun 21 13:23:50 2016 -0700
Committer: hahao <[email protected]>
Committed: Tue Jun 21 13:23:50 2016 -0700

----------------------------------------------------------------------
 .../SentryMetastorePostEventListener.java       |  6 ++--
 .../tests/e2e/hdfs/TestHDFSIntegration.java     | 29 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sentry/blob/caa630c9/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
----------------------------------------------------------------------
diff --git 
a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
 
b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
index d12ac15..8d8f5ce 100644
--- 
a/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
+++ 
b/sentry-binding/sentry-binding-hive/src/main/java/org/apache/sentry/binding/metastore/SentryMetastorePostEventListener.java
@@ -391,8 +391,10 @@ public class SentryMetastorePostEventListener extends 
MetaStoreEventListener {
     }
     // The HDFS plugin needs to know if it's a path change (set location)
     for (SentryMetastoreListenerPlugin plugin : sentryPlugins) {
-      plugin.renameAuthzObject(oldDbName + "." + oldTabName, oldPath,
-          newDbName + "." + newTabName, newPath);
+      if(!oldPath.equals(newPath)) {
+        plugin.renameAuthzObject(oldDbName + "." + oldTabName, oldPath,
+                newDbName + "." + newTabName, newPath);
+      }
     }
   }
 

http://git-wip-us.apache.org/repos/asf/sentry/blob/caa630c9/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
----------------------------------------------------------------------
diff --git 
a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
 
b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
index 1606b6d..898552e 100644
--- 
a/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
+++ 
b/sentry-tests/sentry-tests-hive/src/test/java/org/apache/sentry/tests/e2e/hdfs/TestHDFSIntegration.java
@@ -539,6 +539,35 @@ public class TestHDFSIntegration {
   }
 
   @Test
+  public void testNoPartitionInsert() throws Throwable {
+    tmpHDFSDir = new Path("/tmp/external");
+    dbNames = new String[]{"db1"};
+    roles = new String[]{"admin_role", "tab_role"};
+    admin = "hive";
+
+    Connection conn;
+    Statement stmt;
+    conn = hiveServer2.createConnection("hive", "hive");
+    stmt = conn.createStatement();
+    stmt.execute("create role admin_role");
+    stmt.execute("grant role admin_role to group hive");
+    stmt.execute("grant all on server server1 to role admin_role");
+
+    //Create table and grant select to user flume
+    stmt.execute("create database db1");
+    stmt.execute("use db1");
+    stmt.execute("create table t1 (s string)");
+    stmt.execute("create role tab_role");
+    stmt.execute("grant select on table t1 to role tab_role");
+    stmt.execute("grant role tab_role to group flume");
+
+    verifyOnAllSubDirs("/user/hive/warehouse/db1.db/t1", 
FsAction.READ_EXECUTE, "flume", true);
+    stmt.execute("INSERT INTO TABLE t1 VALUES (1)");
+    verifyOnAllSubDirs("/user/hive/warehouse/db1.db/t1", 
FsAction.READ_EXECUTE, "flume", true);
+
+  }
+
+  @Test
   public void testEnd2End() throws Throwable {
     tmpHDFSDir = new Path("/tmp/external");
     dbNames = new String[]{"db1"};

Reply via email to