GCS gateway to return error in getBucketPolicy, when no policy is set (#5117)

Return NoSuchBucketPolicy error when there is no policy set.
Fixes minio/mint#199
master
kannappanr 7 years ago committed by Dee Koder
parent bc8b936d4b
commit 95d97c2d6d
  1. 6
      cmd/gateway-gcs.go

@ -1060,7 +1060,6 @@ func (l *gcsGateway) GetBucketPolicies(bucket string) (policy.BucketAccessPolicy
if err != nil {
return policy.BucketAccessPolicy{}, gcsToObjectError(traceError(err), bucket)
}
policyInfo := policy.BucketAccessPolicy{Version: "2012-10-17"}
for _, r := range rules {
if r.Entity != storage.AllUsers || r.Role == storage.RoleOwner {
@ -1073,7 +1072,10 @@ func (l *gcsGateway) GetBucketPolicies(bucket string) (policy.BucketAccessPolicy
policyInfo.Statements = policy.SetPolicy(policyInfo.Statements, policy.BucketPolicyWriteOnly, bucket, "")
}
}
// Return NoSuchBucketPolicy error, when policy is not set
if len(policyInfo.Statements) == 0 {
return policy.BucketAccessPolicy{}, gcsToObjectError(traceError(PolicyNotFound{}), bucket)
}
return policyInfo, nil
}

Loading…
Cancel
Save