Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,31 +88,6 @@ public static List<OzoneAcl> filterAclList(String identityName,
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@ public boolean checkAccess(OzoneObj ozObject, RequestContext context)
return true;
}

boolean hasAccess = OzoneAclUtil.checkAclRight(
boolean hasAccess = OzoneAclUtil.checkAclRights(
keyInfo.getAcls(), context);
if (LOG.isDebugEnabled()) {
LOG.debug("user:{} has access rights for key:{} :{} ",
Expand Down Expand Up @@ -1819,7 +1819,7 @@ private boolean checkChildrenAcls(OzoneObj ozObject, RequestContext context)
// 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);
Expand All @@ -1835,7 +1835,7 @@ private boolean checkChildrenAcls(OzoneObj ozObject, RequestContext context)
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);
Expand Down