Index: metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java (revision 1635297) +++ metastore/src/java/org/apache/hadoop/hive/metastore/Warehouse.java (revision ) @@ -54,6 +54,7 @@ import org.apache.hadoop.hive.metastore.api.Partition; import org.apache.hadoop.hive.metastore.api.StorageDescriptor; import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.hive.shims.HadoopShims; import org.apache.hadoop.hive.shims.ShimLoader; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.util.ReflectionUtils; @@ -249,8 +250,10 @@ return false; } final FileStatus stat; + final FileSystem fs; try { - stat = getFs(path).getFileStatus(path); + fs = getFs(path); + stat = fs.getFileStatus(path); } catch (FileNotFoundException fnfe){ // File named by path doesn't exist; nothing to validate. return true; @@ -259,30 +262,15 @@ // unauthorized accesses return false; } - final UserGroupInformation ugi; try { - ugi = ShimLoader.getHadoopShims().getUGIForConf(conf); - } catch (LoginException le) { - throw new IOException(le); - } - String user = ShimLoader.getHadoopShims().getShortUserName(ugi); - //check whether owner can delete - if (stat.getOwner().equals(user) && - stat.getPermission().getUserAction().implies(FsAction.WRITE)) { + ShimLoader.getHadoopShims().checkFileAccess(fs, stat, FsAction.WRITE); return true; + } catch (Exception e) { + if (LOG.isDebugEnabled()) { + LOG.debug("Exception when checking if path (" + path + ")", e); - } + } - //check whether group of the user can delete - if (stat.getPermission().getGroupAction().implies(FsAction.WRITE)) { - String[] groups = ugi.getGroupNames(); - if (ArrayUtils.contains(groups, stat.getGroup())) { - return true; - } - } - //check whether others can delete (uncommon case!!) - if (stat.getPermission().getOtherAction().implies(FsAction.WRITE)) { - return true; - } - return false; + return false; + } } /* // NOTE: This is for generating the internal path name for partitions. Users