mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-30 08:50:48 +01:00
* mount, s3: clarify allowOthers requirement and bucket name error
`weed mount -allowOthers` defaults to true. On Linux, a non-root
user's mount then needs `user_allow_other` in /etc/fuse.conf, but the
help text only said "allows other users to access the file system".
Say so in the help, and point at -allowOthers=false.
Also fix the grammar of the bucket name length error ("must between
[3, 63]" -> "must be between 3 and 63").
Help and error text only; no behaviour change.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* s3: normalize the remaining VerifyS3BucketName error messages
The length message was clarified; the rest of the function still had
inconsistent phrasing ("name must start", "cannot be ip addresses",
"prefix xn-- ... in bucket prefix"). Align them on "bucket name ..."
wording matching the AWS bucket naming rules.
---------
Co-authored-by: pingqiu <pingqiu999@gmail.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: user.email <chrislusf@users.noreply.github.com>
49 lines
1.6 KiB
Go
49 lines
1.6 KiB
Go
package s3bucket
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"strings"
|
|
"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 be between 3 and 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 lowercase letters, numbers, dots, and hyphens")
|
|
}
|
|
if idx > 0 && (ch == '.' && name[idx-1] == '.') {
|
|
return fmt.Errorf("bucket names must not contain two adjacent periods")
|
|
}
|
|
//TODO buckets with s3 transfer acceleration cannot have . in name
|
|
}
|
|
if name[0] == '.' || name[0] == '-' {
|
|
return fmt.Errorf("bucket name must start with a letter or number")
|
|
}
|
|
if name[len(name)-1] == '.' || name[len(name)-1] == '-' {
|
|
return fmt.Errorf("bucket name must end with a letter or number")
|
|
}
|
|
if strings.HasPrefix(name, "xn--") {
|
|
return fmt.Errorf("bucket name must not start with 'xn--'")
|
|
}
|
|
if strings.HasSuffix(name, "-s3alias") {
|
|
return fmt.Errorf("bucket name must not end with '-s3alias'")
|
|
}
|
|
if net.ParseIP(name) != nil {
|
|
return fmt.Errorf("bucket name must not be formatted as an IP address")
|
|
}
|
|
return nil
|
|
}
|