[ 
https://issues.apache.org/jira/browse/HIVE-24330?focusedWorklogId=508995&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-508995
 ]

ASF GitHub Bot logged work on HIVE-24330:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Nov/20 06:32
            Start Date: 09/Nov/20 06:32
    Worklog Time Spent: 10m 
      Work Description: aasha commented on a change in pull request #1630:
URL: https://github.com/apache/hive/pull/1630#discussion_r519577185



##########
File path: 
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
##########
@@ -606,6 +614,45 @@ public Void execute() throws IOException {
     }
   }
 
+  /*
+   * Provide members of warehouse group access to the cmRoot location.
+   * To do this, assign cmRoot to group of warehouse if possible. If not, set 
acl for wh-group.
+   * If warehouse directory cannot be determined then give rwx permissions to 
default group of cmroot.
+   */
+  private static void setCmRootPermissions(Path cmroot) throws IOException{
+    FileSystem cmFs = cmroot.getFileSystem(conf);
+    cmFs.setPermission(cmroot, new FsPermission("770"));
+    try {
+      FileStatus warehouseStatus = cmFs.getFileStatus(new 
Path(MetastoreConf.get(conf, ConfVars.WAREHOUSE.getVarname())));
+      String warehouseOwner = warehouseStatus.getOwner();
+      String warehouseGroup = warehouseStatus.getGroup();
+      if (warehouseOwner.equals(cmFs.getFileStatus(cmroot).getOwner())) {
+        FsAction whOwnerAction = 
warehouseStatus.getPermission().getUserAction();
+        FsAction whGroupAction = 
warehouseStatus.getPermission().getGroupAction();
+        FsAction whOtherAction = 
warehouseStatus.getPermission().getOtherAction();
+        if(!warehouseGroup.equals(cmFs.getFileStatus(cmroot).getGroup())) {
+          //change group to wh-group.
+          //since cmRoot owner is already part of wh-group, this can be done.
+          cmFs.setOwner(cmroot, null, warehouseGroup);
+          cmFs.setPermission(cmroot, new FsPermission(whOwnerAction, 
whGroupAction, whOtherAction));
+        }
+      } else {
+        LOG.warn("Metastore-user is not same as owner of warehouse.");
+        if(!warehouseGroup.equals(cmFs.getFileStatus(cmroot).getGroup())) {
+          List<AclEntry> aclList = Lists.newArrayList(
+                  new 
AclEntry.Builder().setScope(ACCESS).setType(USER).setPermission(FsAction.ALL).build(),
+                  new 
AclEntry.Builder().setScope(ACCESS).setType(GROUP).setPermission(FsAction.ALL).build(),
+                  new 
AclEntry.Builder().setScope(ACCESS).setType(OTHER).setPermission(FsAction.NONE).build());
+          aclList.add(new 
AclEntry.Builder().setScope(ACCESS).setType(GROUP).setName(warehouseGroup).
+                  
setPermission(warehouseStatus.getPermission().getGroupAction()).build());
+          cmFs.setAcl(cmroot, aclList);

Review comment:
       If group is same and owner is different for cm and warehouse nothing 
needs to be done?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 508995)
    Time Spent: 40m  (was: 0.5h)

> Automate setting permissions on cmRoot directories.
> ---------------------------------------------------
>
>                 Key: HIVE-24330
>                 URL: https://issues.apache.org/jira/browse/HIVE-24330
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Arko Sharma
>            Assignee: Arko Sharma
>            Priority: Major
>              Labels: pull-request-available
>         Attachments: HIVE-24330.01.patch, HIVE-24330.02.patch, 
> HIVE-24330.03.patch, HIVE-24330.04.patch, HIVE-24330.05.patch, 
> HIVE-24330.06.patch
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to