fix: on windows avoid ':' as part of the object name (#19907)

fixes #18865
avoid-colon
This commit is contained in:
Harshavardhana 2024-06-10 20:13:30 -07:00 committed by GitHub
parent 614981e566
commit 55aa431578
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 14 deletions

View File

@ -1633,7 +1633,7 @@ func (a adminAPIHandlers) StartBatchJob(w http.ResponseWriter, r *http.Request)
return
}
job.ID = fmt.Sprintf("%s%s%d", shortuuid.New(), getBatchJobIDSeparator(), GetProxyEndpointLocalIndex(globalProxyEndpoints))
job.ID = fmt.Sprintf("%s%s%d", shortuuid.New(), getKeySeparator(), GetProxyEndpointLocalIndex(globalProxyEndpoints))
job.User = user
job.Started = time.Now()

View File

@ -19,7 +19,6 @@ package cmd
import (
"fmt"
"runtime"
"strings"
"time"
@ -289,12 +288,3 @@ func (s *BatchJobSize) UnmarshalYAML(unmarshal func(interface{}) error) error {
*s = BatchJobSize(sz)
return nil
}
// getBatchJobIDSeparator - returns the separator to be used in the batch job ID
// windows requires `_` as the separator `:` will be an invalid one
func getBatchJobIDSeparator() string {
if runtime.GOOS == globalWindowsOSName {
return "_"
}
return ":"
}

View File

@ -231,7 +231,7 @@ func parseRequestToken(token string) (subToken string, nodeIndex int) {
if token == "" {
return token, -1
}
i := strings.Index(token, getBatchJobIDSeparator())
i := strings.Index(token, getKeySeparator())
if i < 0 {
return token, -1
}

View File

@ -80,6 +80,18 @@ const (
compMinIndexSize = 8 << 20
)
// getkeyeparator - returns the separator to be used for
// persisting on drive.
//
// - ":" is used on non-windows platforms
// - "_" is used on windows platforms
func getKeySeparator() string {
if runtime.GOOS == globalWindowsOSName {
return "_"
}
return ":"
}
// isMinioBucket returns true if given bucket is a MinIO internal
// bucket and false otherwise.
func isMinioMetaBucketName(bucket string) bool {

View File

@ -865,7 +865,7 @@ func (sts *stsAPIHandlers) AssumeRoleWithCertificate(w http.ResponseWriter, r *h
}
// Associate any service accounts to the certificate CN
parentUser := "tls:" + certificate.Subject.CommonName
parentUser := "tls" + getKeySeparator() + certificate.Subject.CommonName
claims[expClaim] = UTCNow().Add(expiry).Unix()
claims[subClaim] = certificate.Subject.CommonName
@ -990,7 +990,7 @@ func (sts *stsAPIHandlers) AssumeRoleWithCustomToken(w http.ResponseWriter, r *h
expiry = requestedDuration
}
parentUser := "custom:" + res.Success.User
parentUser := "custom" + getKeySeparator() + res.Success.User
// metadata map
claims[expClaim] = UTCNow().Add(time.Duration(expiry) * time.Second).Unix()