diff --git a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/SQLAuthorizationUtils.java b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/SQLAuthorizationUtils.java index 94e059b..34a8e00 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/SQLAuthorizationUtils.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/plugin/sqlstd/SQLAuthorizationUtils.java @@ -396,26 +396,17 @@ public static RequiredPrivileges getPrivilegesFromFS(Path filePath, HiveConf con // recurse=false to check its parent - this is likely a case of // needing to create a dir that does not exist yet. - if ((fileMatches != null ) && (fileMatches.length > 1)){ - LOG.debug("Checking fs privileges for multiple files that matched {}", - filePath.toString()); + if ((fileMatches != null ) && (fileMatches.length > 0)){ + LOG.debug("Checking fs privileges for {} filestatus(es) that matched {}", + fileMatches.length, filePath.toString()); addPrivilegesFromFS(userName, availPrivs, fs, fileMatches, true); } else { - FileStatus fileStatus = FileUtils.getFileStatusOrNull(fs, filePath); - boolean pickParent = (fileStatus == null); // did we find the file/dir itself? - if (pickParent){ - fileStatus = FileUtils.getPathOrParentThatExists(fs, filePath.getParent()); - } + // We found 0 entries that matched the path, let's look to the first parent that exists + FileStatus fileStatus = FileUtils.getPathOrParentThatExists(fs, filePath.getParent()); Path path = fileStatus.getPath(); - if (pickParent){ - LOG.debug("Checking fs privileges for parent path {} for nonexistent {}", - path.toString(), filePath.toString()); - addPrivilegesFromFS(userName, availPrivs, fs, fileStatus, false); - } else { - LOG.debug("Checking fs privileges for path itself {}, originally specified as {}", - path.toString(), filePath.toString()); - addPrivilegesFromFS(userName, availPrivs, fs, fileStatus, true); - } + LOG.debug("Checking fs privileges for parent path {} for nonexistent {}", + path.toString(), filePath.toString()); + addPrivilegesFromFS(userName, availPrivs, fs, fileStatus, false); } } catch (Exception e) { String msg = "Error getting permissions for " + filePath + ": " + e.getMessage();