fix: IAM reload should only list at config/iam/ precisely (#14753)

This commit is contained in:
Harshavardhana 2022-04-15 12:12:45 -07:00 committed by GitHub
parent 53ca589c11
commit e69c42956b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -407,15 +407,15 @@ func (iamOS *IAMObjectStore) loadMappedPolicies(ctx context.Context, userType IA
} }
var ( var (
usersListKey = "/users/" usersListKey = "users/"
svcAccListKey = "/service-accounts/" svcAccListKey = "service-accounts/"
groupsListKey = "/groups/" groupsListKey = "groups/"
policiesListKey = "/policies/" policiesListKey = "policies/"
stsListKey = "/sts/" stsListKey = "sts/"
policyDBUsersListKey = "/policydb/users/" policyDBUsersListKey = "policydb/users/"
policyDBSTSUsersListKey = "/policydb/sts-users/" policyDBSTSUsersListKey = "policydb/sts-users/"
policyDBServiceAccountsListKey = "/policydb/service-accounts/" policyDBServiceAccountsListKey = "policydb/service-accounts/"
policyDBGroupsListKey = "/policydb/groups/" policyDBGroupsListKey = "policydb/groups/"
allListKeys = []string{ allListKeys = []string{
usersListKey, usersListKey,
@ -433,7 +433,7 @@ var (
func (iamOS *IAMObjectStore) listAllIAMConfigItems(ctx context.Context) (map[string][]string, error) { func (iamOS *IAMObjectStore) listAllIAMConfigItems(ctx context.Context) (map[string][]string, error) {
res := make(map[string][]string) res := make(map[string][]string)
for item := range listIAMConfigItems(ctx, iamOS.objAPI, iamConfigPrefix) { for item := range listIAMConfigItems(ctx, iamOS.objAPI, iamConfigPrefix+SlashSeparator) {
if item.Err != nil { if item.Err != nil {
return nil, item.Err return nil, item.Err
} }
@ -448,7 +448,7 @@ func (iamOS *IAMObjectStore) listAllIAMConfigItems(ctx context.Context) (map[str
} }
} }
if !found && !(item.Item == "config/config.json" || item.Item == "/format.json" || strings.Contains(item.Item, "config/history/")) { if !found && (item.Item != "format.json") {
logger.LogIf(ctx, fmt.Errorf("unknown type of IAM file listed: %v", item.Item)) logger.LogIf(ctx, fmt.Errorf("unknown type of IAM file listed: %v", item.Item))
} }
} }