mirror of
https://github.com/minio/minio.git
synced 2024-12-24 06:05:55 -05:00
fs mode: List already existing buckets with capital letters (#7244)
if a bucket with `Captialized letters` is created, `InvalidBucketName` error will be returned. In the case of pre-existing buckets, it will be listed. Fixes #6938
This commit is contained in:
parent
ef132c5714
commit
c57159a0fe
@ -30,6 +30,7 @@ import (
|
|||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/minio/minio-go/pkg/s3utils"
|
||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
"github.com/minio/minio/pkg/lock"
|
"github.com/minio/minio/pkg/lock"
|
||||||
"github.com/minio/minio/pkg/madmin"
|
"github.com/minio/minio/pkg/madmin"
|
||||||
@ -289,10 +290,8 @@ func (fs *FSObjects) MakeBucketWithLocation(ctx context.Context, bucket, locatio
|
|||||||
}
|
}
|
||||||
defer bucketLock.Unlock()
|
defer bucketLock.Unlock()
|
||||||
// Verify if bucket is valid.
|
// Verify if bucket is valid.
|
||||||
if !IsValidBucketName(bucket) {
|
if s3utils.CheckValidBucketNameStrict(bucket) != nil {
|
||||||
err := BucketNameInvalid{Bucket: bucket}
|
return BucketNameInvalid{Bucket: bucket}
|
||||||
logger.LogIf(ctx, err)
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
bucketDir, err := fs.getBucketDir(ctx, bucket)
|
bucketDir, err := fs.getBucketDir(ctx, bucket)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -341,7 +340,7 @@ func (fs *FSObjects) ListBuckets(ctx context.Context) ([]BucketInfo, error) {
|
|||||||
|
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
// Ignore all reserved bucket names and invalid bucket names.
|
// Ignore all reserved bucket names and invalid bucket names.
|
||||||
if isReservedOrInvalidBucket(entry) {
|
if isReservedOrInvalidBucket(entry, false) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
var fi os.FileInfo
|
var fi os.FileInfo
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
|
|
||||||
"github.com/minio/cli"
|
"github.com/minio/cli"
|
||||||
miniogopolicy "github.com/minio/minio-go/pkg/policy"
|
miniogopolicy "github.com/minio/minio-go/pkg/policy"
|
||||||
|
"github.com/minio/minio-go/pkg/s3utils"
|
||||||
minio "github.com/minio/minio/cmd"
|
minio "github.com/minio/minio/cmd"
|
||||||
xhttp "github.com/minio/minio/cmd/http"
|
xhttp "github.com/minio/minio/cmd/http"
|
||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
@ -349,7 +350,7 @@ func ossIsValidBucketName(bucket string) bool {
|
|||||||
if strings.Contains(bucket, ".") {
|
if strings.Contains(bucket, ".") {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !minio.IsValidBucketName(bucket) {
|
if s3utils.CheckValidBucketNameStrict(bucket) != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -34,6 +34,7 @@ import (
|
|||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
snappy "github.com/golang/snappy"
|
snappy "github.com/golang/snappy"
|
||||||
|
"github.com/minio/minio-go/pkg/s3utils"
|
||||||
"github.com/minio/minio/cmd/crypto"
|
"github.com/minio/minio/cmd/crypto"
|
||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
"github.com/minio/minio/pkg/dns"
|
"github.com/minio/minio/pkg/dns"
|
||||||
@ -273,10 +274,16 @@ func isStringEqual(s1 string, s2 string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ignores all reserved bucket names or invalid bucket names.
|
// Ignores all reserved bucket names or invalid bucket names.
|
||||||
func isReservedOrInvalidBucket(bucketEntry string) bool {
|
func isReservedOrInvalidBucket(bucketEntry string, strict bool) bool {
|
||||||
bucketEntry = strings.TrimSuffix(bucketEntry, slashSeparator)
|
bucketEntry = strings.TrimSuffix(bucketEntry, slashSeparator)
|
||||||
if !IsValidBucketName(bucketEntry) {
|
if strict {
|
||||||
return true
|
if err := s3utils.CheckValidBucketNameStrict(bucketEntry); err != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := s3utils.CheckValidBucketName(bucketEntry); err != nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return isMinioMetaBucket(bucketEntry) || isMinioReservedBucket(bucketEntry)
|
return isMinioMetaBucket(bucketEntry) || isMinioReservedBucket(bucketEntry)
|
||||||
}
|
}
|
||||||
|
@ -157,7 +157,7 @@ func (web *webAPIHandlers) MakeBucket(r *http.Request, args *MakeBucketArgs, rep
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if bucket is a reserved bucket name or invalid.
|
// Check if bucket is a reserved bucket name or invalid.
|
||||||
if isReservedOrInvalidBucket(args.BucketName) {
|
if isReservedOrInvalidBucket(args.BucketName, true) {
|
||||||
return toJSONError(errInvalidBucketName)
|
return toJSONError(errInvalidBucketName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/minio/minio-go/pkg/s3utils"
|
||||||
"github.com/minio/minio/cmd/logger"
|
"github.com/minio/minio/cmd/logger"
|
||||||
"github.com/minio/minio/pkg/policy"
|
"github.com/minio/minio/pkg/policy"
|
||||||
)
|
)
|
||||||
@ -36,8 +37,7 @@ var bucketMetadataOpIgnoredErrs = append(bucketOpIgnoredErrs, errVolumeNotFound)
|
|||||||
// MakeBucket - make a bucket.
|
// MakeBucket - make a bucket.
|
||||||
func (xl xlObjects) MakeBucketWithLocation(ctx context.Context, bucket, location string) error {
|
func (xl xlObjects) MakeBucketWithLocation(ctx context.Context, bucket, location string) error {
|
||||||
// Verify if bucket is valid.
|
// Verify if bucket is valid.
|
||||||
if !IsValidBucketName(bucket) {
|
if err := s3utils.CheckValidBucketNameStrict(bucket); err != nil {
|
||||||
logger.LogIf(ctx, BucketNameInvalid{Bucket: bucket})
|
|
||||||
return BucketNameInvalid{Bucket: bucket}
|
return BucketNameInvalid{Bucket: bucket}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ func (xl xlObjects) listBuckets(ctx context.Context) (bucketsInfo []BucketInfo,
|
|||||||
// should take care of this.
|
// should take care of this.
|
||||||
var bucketsInfo []BucketInfo
|
var bucketsInfo []BucketInfo
|
||||||
for _, volInfo := range volsInfo {
|
for _, volInfo := range volsInfo {
|
||||||
if isReservedOrInvalidBucket(volInfo.Name) {
|
if isReservedOrInvalidBucket(volInfo.Name, true) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
bucketsInfo = append(bucketsInfo, BucketInfo(volInfo))
|
bucketsInfo = append(bucketsInfo, BucketInfo(volInfo))
|
||||||
|
Loading…
Reference in New Issue
Block a user