fix: allow listing buckets without acl attribute

The admin/root user has access to all buckets. So we don't need a
valid ACL defined on the bucket to list these. Treat a non-existing
ACL as an empty ACL for this case.

Fixes #727
This commit is contained in:
Ben McClelland
2024-08-21 15:20:47 -07:00
parent 2aef5e42d4
commit 2942b162a2
+10 -4
View File
@@ -165,6 +165,10 @@ func (p *Posix) ListBuckets(_ context.Context, owner string, isAdmin bool) (s3re
}
aclTag, err := p.meta.RetrieveAttribute(entry.Name(), "", aclkey)
if errors.Is(err, meta.ErrNoSuchKey) {
// skip buckets without acl tag
continue
}
if err != nil {
return s3response.ListAllMyBucketsResult{}, fmt.Errorf("get acl tag: %w", err)
}
@@ -2681,14 +2685,16 @@ func (p *Posix) ListBucketsAndOwners(ctx context.Context) (buckets []s3response.
}
aclTag, err := p.meta.RetrieveAttribute(entry.Name(), "", aclkey)
if err != nil {
if err != nil && !errors.Is(err, meta.ErrNoSuchKey) {
return buckets, fmt.Errorf("get acl tag: %w", err)
}
var acl auth.ACL
err = json.Unmarshal(aclTag, &acl)
if err != nil {
return buckets, fmt.Errorf("parse acl tag: %w", err)
if len(aclTag) > 0 {
err = json.Unmarshal(aclTag, &acl)
if err != nil {
return buckets, fmt.Errorf("parse acl tag: %w", err)
}
}
buckets = append(buckets, s3response.Bucket{