You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by xy...@apache.org on 2021/06/11 00:03:59 UTC

[ozone] branch master updated: HDDS-5307. Remove checkAclRight method, duplicates checkAclRights (#2323)

This is an automated email from the ASF dual-hosted git repository.

xyao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new f7ac8c1  HDDS-5307. Remove checkAclRight method, duplicates checkAclRights (#2323)
f7ac8c1 is described below

commit f7ac8c16919ec357626601442dec4525b238e09d
Author: pakapoj-tul <71...@users.noreply.github.com>
AuthorDate: Fri Jun 11 07:03:32 2021 +0700

    HDDS-5307. Remove checkAclRight method, duplicates checkAclRights (#2323)
---
 .../hadoop/ozone/om/helpers/OzoneAclUtil.java      | 25 ----------------------
 .../org/apache/hadoop/ozone/om/KeyManagerImpl.java |  6 +++---
 2 files changed, 3 insertions(+), 28 deletions(-)

diff --git a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclUtil.java b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclUtil.java
index 9901ae7..0ca1e36 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclUtil.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OzoneAclUtil.java
@@ -88,31 +88,6 @@ public final class OzoneAclUtil {
     return retList;
   }
 
-  /**
-   * Check if acl right requested for given RequestContext exist
-   * in provided acl list.
-   * Acl validation rules:
-   * 1. If user/group has ALL bit set than all user should have all rights.
-   * 2. If user/group has NONE bit set than user/group will not have any right.
-   * 3. For all other individual rights individual bits should be set.
-   *
-   * @param acls
-   * @param context
-   * @return return true if acl list contains right requsted in context.
-   * */
-  public static boolean checkAclRight(List<OzoneAcl> acls,
-      RequestContext context) throws OMException {
-    String[] userGroups = context.getClientUgi().getGroupNames();
-    String userName = context.getClientUgi().getUserName();
-    ACLType aclToCheck = context.getAclRights();
-    for (OzoneAcl a : acls) {
-      if(checkAccessInAcl(a, userGroups, userName, aclToCheck)) {
-        return true;
-      }
-    }
-    return false;
-  }
-
   private static boolean checkAccessInAcl(OzoneAcl a, String[] groups,
       String username, ACLType aclToCheck) {
     BitSet rights = a.getAclBitSet();
diff --git a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
index 2ed54f2..0097051 100644
--- a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
+++ b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
@@ -1782,7 +1782,7 @@ public class KeyManagerImpl implements KeyManager {
         return true;
       }
 
-      boolean hasAccess = OzoneAclUtil.checkAclRight(
+      boolean hasAccess = OzoneAclUtil.checkAclRights(
           keyInfo.getAcls(), context);
       if (LOG.isDebugEnabled()) {
         LOG.debug("user:{} has access rights for key:{} :{} ",
@@ -1819,7 +1819,7 @@ public class KeyManagerImpl implements KeyManager {
     // Using stack to check acls for subpaths
     Stack<OzoneFileStatus> directories = new Stack<>();
     // check whether given file/dir  has access
-    boolean hasAccess = OzoneAclUtil.checkAclRight(keyInfo.getAcls(), context);
+    boolean hasAccess = OzoneAclUtil.checkAclRights(keyInfo.getAcls(), context);
     if (LOG.isDebugEnabled()) {
       LOG.debug("user:{} has access rights for key:{} :{} ",
           context.getClientUgi(), ozObject.getKeyName(), hasAccess);
@@ -1835,7 +1835,7 @@ public class KeyManagerImpl implements KeyManager {
       while (hasAccess && children.hasNext()) {
         ozoneFileStatus = children.next();
         keyInfo = ozoneFileStatus.getKeyInfo();
-        hasAccess = OzoneAclUtil.checkAclRight(keyInfo.getAcls(), context);
+        hasAccess = OzoneAclUtil.checkAclRights(keyInfo.getAcls(), context);
         if (LOG.isDebugEnabled()) {
           LOG.debug("user:{} has access rights for key:{} :{} ",
               context.getClientUgi(), keyInfo.getKeyName(), hasAccess);

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org