Skip to content

Commit

Permalink
HDDS-11732. Fix ACL check on bucket resolution while reading from sna…
Browse files Browse the repository at this point in the history
…pshot (apache#7446)

Change-Id: I192219d1840ea9ddb06c2c177207cf870a7be8eb
  • Loading branch information
swamirishi authored Nov 17, 2024
1 parent dbda703 commit 036e727
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ public ReferenceCounted<IOmMetadataReader> getActiveFsMetadataOrSnapshot(
// Updating the volumeName & bucketName in case the bucket is a linked bucket. We need to do this before a
// permission check, since linked bucket permissions and source bucket permissions could be different.
ResolvedBucket resolvedBucket = ozoneManager.resolveBucketLink(Pair.of(volumeName,
bucketName), false);
bucketName), false, false);
volumeName = resolvedBucket.realVolume();
bucketName = resolvedBucket.realBucket();
return (ReferenceCounted<IOmMetadataReader>) (ReferenceCounted<?>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4402,10 +4402,16 @@ public ResolvedBucket resolveBucketLink(Pair<String, String> requested,
}

public ResolvedBucket resolveBucketLink(Pair<String, String> requested,
boolean allowDanglingBuckets)
boolean allowDanglingBuckets) throws IOException {
return resolveBucketLink(requested, allowDanglingBuckets, isAclEnabled);
}

public ResolvedBucket resolveBucketLink(Pair<String, String> requested,
boolean allowDanglingBuckets,
boolean aclEnabled)
throws IOException {
OmBucketInfo resolved;
if (isAclEnabled) {
if (aclEnabled) {
UserGroupInformation ugi = getRemoteUser();
if (getS3Auth() != null) {
ugi = UserGroupInformation.createRemoteUser(
Expand All @@ -4416,15 +4422,26 @@ public ResolvedBucket resolveBucketLink(Pair<String, String> requested,
ugi,
remoteIp != null ? remoteIp : omRpcAddress.getAddress(),
remoteIp != null ? remoteIp.getHostName() :
omRpcAddress.getHostName(), allowDanglingBuckets);
omRpcAddress.getHostName(), allowDanglingBuckets, aclEnabled);
} else {
resolved = resolveBucketLink(requested, new HashSet<>(),
null, null, null, allowDanglingBuckets);
null, null, null, allowDanglingBuckets, aclEnabled);
}
return new ResolvedBucket(requested.getLeft(), requested.getRight(),
resolved);
}

private OmBucketInfo resolveBucketLink(
Pair<String, String> volumeAndBucket,
Set<Pair<String, String>> visited,
UserGroupInformation userGroupInformation,
InetAddress remoteAddress,
String hostName,
boolean allowDanglingBuckets) throws IOException {
return resolveBucketLink(volumeAndBucket, visited, userGroupInformation, remoteAddress, hostName,
allowDanglingBuckets, isAclEnabled);
}

/**
* Resolves bucket symlinks. Read permission is required for following links.
*
Expand All @@ -4442,7 +4459,8 @@ private OmBucketInfo resolveBucketLink(
UserGroupInformation userGroupInformation,
InetAddress remoteAddress,
String hostName,
boolean allowDanglingBuckets) throws IOException {
boolean allowDanglingBuckets,
boolean aclEnabled) throws IOException {

String volumeName = volumeAndBucket.getLeft();
String bucketName = volumeAndBucket.getRight();
Expand All @@ -4465,7 +4483,7 @@ private OmBucketInfo resolveBucketLink(
DETECTED_LOOP_IN_BUCKET_LINKS);
}

if (isAclEnabled) {
if (aclEnabled) {
final ACLType type = ACLType.READ;
checkAcls(ResourceType.BUCKET, StoreType.OZONE, type,
volumeName, bucketName, null, userGroupInformation,
Expand All @@ -4476,7 +4494,7 @@ private OmBucketInfo resolveBucketLink(
return resolveBucketLink(
Pair.of(info.getSourceVolume(), info.getSourceBucket()),
visited, userGroupInformation, remoteAddress, hostName,
allowDanglingBuckets);
allowDanglingBuckets, aclEnabled);
}

@VisibleForTesting
Expand Down

0 comments on commit 036e727

Please sign in to comment.