You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by th...@apache.org on 2014/09/05 21:25:47 UTC

svn commit: r1622767 - in /hive/trunk: common/src/java/org/apache/hadoop/hive/common/FileUtils.java itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java

Author: thejas
Date: Fri Sep  5 19:25:46 2014
New Revision: 1622767

URL: http://svn.apache.org/r1622767
Log:
HIVE-7987 : Storage based authorization  - NPE for drop view (Thejas Nair, reviewed by Jason Dere)

Modified:
    hive/trunk/common/src/java/org/apache/hadoop/hive/common/FileUtils.java
    hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.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=1622767&r1=1622766&r2=1622767&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 19:25:46 2014
@@ -649,6 +649,11 @@ public final class FileUtils {
     //   if a user is a super user. Also super users running hive queries is not a common
     //   use case. super users can also do a chown to be able to drop the file
 
+    if(path == null) {
+      // no file/dir to be deleted
+      return;
+    }
+
     final FileSystem fs = path.getFileSystem(conf);
     if (!fs.exists(path)) {
       // no file/dir to be deleted

Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java
URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java?rev=1622767&r1=1622766&r2=1622767&view=diff
==============================================================================
--- hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java (original)
+++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java Fri Sep  5 19:25:46 2014
@@ -96,6 +96,7 @@ public class TestStorageBasedMetastoreAu
     driver = new Driver(clientHiveConf);
 
     setupFakeUser();
+    InjectableDummyAuthenticator.injectMode(false);
   }
 
 
@@ -159,6 +160,38 @@ public class TestStorageBasedMetastoreAu
     assertEquals(expectedRet, resp.getResponseCode());
   }
 
+  /**
+   * Drop view should not be blocked by SBA. View will not have any location to drop.
+   * @throws Exception
+   */
+  public void testDropView() throws Exception {
+    String dbName = getTestDbName();
+    String tblName = getTestTableName();
+    String viewName = "view" + tblName;
+    setPermissions(clientHiveConf.getVar(ConfVars.METASTOREWAREHOUSE), "-rwxrwxrwx");
+
+    CommandProcessorResponse resp = driver.run("create database " + dbName);
+    assertEquals(0, resp.getResponseCode());
+    Database db = msc.getDatabase(dbName);
+    validateCreateDb(db, dbName);
+
+    setPermissions(db.getLocationUri(), "-rwxrwxrwt");
+
+    String dbDotTable = dbName + "." + tblName;
+    resp = driver.run("create table " + dbDotTable + "(i int)");
+    assertEquals(0, resp.getResponseCode());
+
+    String dbDotView = dbName + "." + viewName;
+    resp = driver.run("create view " + dbDotView + " as select * from " +  dbDotTable);
+    assertEquals(0, resp.getResponseCode());
+
+    resp = driver.run("drop view " + dbDotView);
+    assertEquals(0, resp.getResponseCode());
+
+    resp = driver.run("drop table " + dbDotTable);
+    assertEquals(0, resp.getResponseCode());
+  }
+
 
   public void testDropPartition() throws Exception {
     dropPartitionByOtherUser("-rwxrwxrwx", 0);
@@ -202,7 +235,6 @@ public class TestStorageBasedMetastoreAu
 
     InjectableDummyAuthenticator.injectUserName(fakeUser);
     InjectableDummyAuthenticator.injectGroupNames(fakeGroupNames);
-    InjectableDummyAuthenticator.injectMode(true);
   }
 
   private String setupUser() {