hive-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Damien Carol (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HIVE-6648) Permissions are not inherited correctly when tables have multiple partition columns
Date Thu, 10 Apr 2014 15:52:16 GMT

     [ https://issues.apache.org/jira/browse/HIVE-6648?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Damien Carol updated HIVE-6648:
-------------------------------

    Description: 
{{Warehouse.mkdirs()}} always looks at the immediate parent of the path that it creates when
determining what permissions to inherit. However, it may have created that parent directory
as well, in which case it will have the default permissions and will not have inherited them.

This is a problem when performing an {{INSERT}} into a table with more than one partition
column. E.g., in an empty table:

{code}INSERT INTO TABLE tbl PARTITION(p1=1, p2=2) ... {code}

A new subdirectory /p1=1/p2=2  will be created, and with permission inheritance (per HIVE-2504)
enabled, the intention is presumably for both new directories to inherit the root table dir's
permissions. However, {{mkdirs()}} will only set the permission of the leaf directory (i.e.
/p2=2/), and then only to the permissions of /p1=1/, which was just created.

{code}
public boolean mkdirs(Path f) throws MetaException {
    FileSystem fs = null;
    try {
      fs = getFs(f);
      LOG.debug("Creating directory if it doesn't exist: " + f);
      //Check if the directory already exists. We want to change the permission
      //to that of the parent directory only for newly created directories.
      if (this.inheritPerms) {
        try {
          return fs.getFileStatus(f).isDir();
        } catch (FileNotFoundException ignore) {
        }
      }
      boolean success = fs.mkdirs(f);
      if (this.inheritPerms && success) {
        // Set the permission of parent directory.
        // HNR: This is the bug - getParent() may refer to a just-created directory.
        fs.setPermission(f, fs.getFileStatus(f.getParent()).getPermission());
      }
      return success;
    } catch (IOException e) {
      closeFs(fs);
      MetaStoreUtils.logAndThrowMetaException(e);
    }
    return false;
  }
{code}

  was:
{{Warehouse.mkdirs()}} always looks at the immediate parent of the path that it creates when
determining what permissions to inherit. However, it may have created that parent directory
as well, in which case it will have the default permissions and will not have inherited them.

This is a problem when performing an {{INSERT}} into a table with more than one partition
column. E.g., in an empty table:

{{INSERT INTO TABLE tbl PARTITION(p1=1, p2=2) ... }}

A new subdirectory /p1=1/p2=2  will be created, and with permission inheritance (per HIVE-2504)
enabled, the intention is presumably for both new directories to inherit the root table dir's
permissions. However, {{mkdirs()}} will only set the permission of the leaf directory (i.e.
/p2=2/), and then only to the permissions of /p1=1/, which was just created.

{code}
public boolean mkdirs(Path f) throws MetaException {
    FileSystem fs = null;
    try {
      fs = getFs(f);
      LOG.debug("Creating directory if it doesn't exist: " + f);
      //Check if the directory already exists. We want to change the permission
      //to that of the parent directory only for newly created directories.
      if (this.inheritPerms) {
        try {
          return fs.getFileStatus(f).isDir();
        } catch (FileNotFoundException ignore) {
        }
      }
      boolean success = fs.mkdirs(f);
      if (this.inheritPerms && success) {
        // Set the permission of parent directory.
        // HNR: This is the bug - getParent() may refer to a just-created directory.
        fs.setPermission(f, fs.getFileStatus(f.getParent()).getPermission());
      }
      return success;
    } catch (IOException e) {
      closeFs(fs);
      MetaStoreUtils.logAndThrowMetaException(e);
    }
    return false;
  }
{code}


> Permissions are not inherited correctly when tables have multiple partition columns
> -----------------------------------------------------------------------------------
>
>                 Key: HIVE-6648
>                 URL: https://issues.apache.org/jira/browse/HIVE-6648
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 0.12.0, 0.13.0
>            Reporter: Henry Robinson
>            Assignee: Szehon Ho
>             Fix For: 0.14.0
>
>         Attachments: HIVE-6648.patch
>
>
> {{Warehouse.mkdirs()}} always looks at the immediate parent of the path that it creates
when determining what permissions to inherit. However, it may have created that parent directory
as well, in which case it will have the default permissions and will not have inherited them.
> This is a problem when performing an {{INSERT}} into a table with more than one partition
column. E.g., in an empty table:
> {code}INSERT INTO TABLE tbl PARTITION(p1=1, p2=2) ... {code}
> A new subdirectory /p1=1/p2=2  will be created, and with permission inheritance (per
HIVE-2504) enabled, the intention is presumably for both new directories to inherit the root
table dir's permissions. However, {{mkdirs()}} will only set the permission of the leaf directory
(i.e. /p2=2/), and then only to the permissions of /p1=1/, which was just created.
> {code}
> public boolean mkdirs(Path f) throws MetaException {
>     FileSystem fs = null;
>     try {
>       fs = getFs(f);
>       LOG.debug("Creating directory if it doesn't exist: " + f);
>       //Check if the directory already exists. We want to change the permission
>       //to that of the parent directory only for newly created directories.
>       if (this.inheritPerms) {
>         try {
>           return fs.getFileStatus(f).isDir();
>         } catch (FileNotFoundException ignore) {
>         }
>       }
>       boolean success = fs.mkdirs(f);
>       if (this.inheritPerms && success) {
>         // Set the permission of parent directory.
>         // HNR: This is the bug - getParent() may refer to a just-created directory.
>         fs.setPermission(f, fs.getFileStatus(f.getParent()).getPermission());
>       }
>       return success;
>     } catch (IOException e) {
>       closeFs(fs);
>       MetaStoreUtils.logAndThrowMetaException(e);
>     }
>     return false;
>   }
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message