diff --git a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java index 0607913..79819b8 100644 --- a/common/src/java/org/apache/hadoop/hive/common/FileUtils.java +++ b/common/src/java/org/apache/hadoop/hive/common/FileUtils.java @@ -649,6 +649,11 @@ public static void checkDeletePermission(Path path, Configuration conf, String u // 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 diff --git a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java index 23ab8b6d..6cf8565 100644 --- a/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java +++ b/itests/hive-unit/src/test/java/org/apache/hadoop/hive/ql/security/TestStorageBasedMetastoreAuthorizationDrops.java @@ -96,6 +96,7 @@ protected void setUp() throws Exception { driver = new Driver(clientHiveConf); setupFakeUser(); + InjectableDummyAuthenticator.injectMode(false); } @@ -159,6 +160,38 @@ private void dropTableByOtherUser(String perm, int expectedRet) throws Exception 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 @@ private void setupFakeUser() { InjectableDummyAuthenticator.injectUserName(fakeUser); InjectableDummyAuthenticator.injectGroupNames(fakeGroupNames); - InjectableDummyAuthenticator.injectMode(true); } private String setupUser() {