mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-15 19:56:39 +00:00
s3: reject reserved bucket name "filemeta" (#9760)
filemeta is the filer SQL store's default table name. A bucket of that name passes VerifyS3BucketName but is rejected by the store's isValidBucket guard on every operation, so it creates fine yet can't be deleted and wedges fsck. Reject it at creation so both checks agree.
This commit is contained in:
@@ -7,11 +7,19 @@ import (
|
||||
"unicode"
|
||||
)
|
||||
|
||||
// Reserved because it is the default table/collection name of the filer
|
||||
// store; a bucket of the same name collides with it and wedges the bucket
|
||||
// (cannot be deleted, breaks fsck) on SQL backends with per-bucket tables.
|
||||
const reservedBucketName = "filemeta"
|
||||
|
||||
// https://docs.aws.amazon.com/AmazonS3/latest/userguide/bucketnamingrules.html
|
||||
func VerifyS3BucketName(name string) (err error) {
|
||||
if len(name) < 3 || len(name) > 63 {
|
||||
return fmt.Errorf("bucket name must between [3, 63] characters")
|
||||
}
|
||||
if name == reservedBucketName {
|
||||
return fmt.Errorf("bucket name %q is reserved", name)
|
||||
}
|
||||
for idx, ch := range name {
|
||||
if !(unicode.IsLower(ch) || ch == '.' || ch == '-' || unicode.IsNumber(ch)) {
|
||||
return fmt.Errorf("bucket name can only contain lower case characters, numbers, dots, and hyphens")
|
||||
|
||||
@@ -17,6 +17,7 @@ func Test_verifyBucketName(t *testing.T) {
|
||||
"grehtrry-",
|
||||
"----------",
|
||||
"x@fdsgr032",
|
||||
"filemeta",
|
||||
}
|
||||
for _, invalidName := range invalidS3BucketNames {
|
||||
err := VerifyS3BucketName(invalidName)
|
||||
|
||||
Reference in New Issue
Block a user