From b5ed42c845cb35cd4ebf24f6787f34d3d7c45ec6 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Sat, 9 May 2020 13:59:12 -0700 Subject: [PATCH] ignore policy/group missing errors appropriately (#9559) --- cmd/iam-object-store.go | 2 +- cmd/iam.go | 8 ++++---- go.sum | 2 -- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/cmd/iam-object-store.go b/cmd/iam-object-store.go index adf7870e5..a32f8d957 100644 --- a/cmd/iam-object-store.go +++ b/cmd/iam-object-store.go @@ -398,7 +398,7 @@ func (iamOS *IAMObjectStore) loadMappedPolicies(ctx context.Context, userType IA policyFile := item.Item userOrGroupName := strings.TrimSuffix(policyFile, ".json") err := iamOS.loadMappedPolicy(userOrGroupName, userType, isGroup, m) - if err != nil { + if err != nil && err != errNoSuchPolicy { return err } } diff --git a/cmd/iam.go b/cmd/iam.go index 90450d1eb..e215a52eb 100644 --- a/cmd/iam.go +++ b/cmd/iam.go @@ -260,11 +260,11 @@ func (sys *IAMSys) LoadGroup(objAPI ObjectLayer, group string) error { defer sys.store.unlock() err := sys.store.loadGroup(group, sys.iamGroupsMap) - if err != nil && err != errConfigNotFound { + if err != nil && err != errNoSuchGroup { return err } - if err == errConfigNotFound { + if err == errNoSuchGroup { // group does not exist - so remove from memory. sys.removeGroupFromMembershipsMap(group) delete(sys.iamGroupsMap, group) @@ -322,7 +322,7 @@ func (sys *IAMSys) LoadPolicyMapping(objAPI ObjectLayer, userOrGroup string, isG } // Ignore policy not mapped error - if err != nil && err != errConfigNotFound { + if err != nil && err != errNoSuchPolicy { return err } } @@ -346,7 +346,7 @@ func (sys *IAMSys) LoadUser(objAPI ObjectLayer, accessKey string, userType IAMUs } err = sys.store.loadMappedPolicy(accessKey, userType, false, sys.iamUserPolicyMap) // Ignore policy not mapped error - if err != nil && err != errConfigNotFound { + if err != nil && err != errNoSuchPolicy { return err } } diff --git a/go.sum b/go.sum index 829bfaedb..d38fda368 100644 --- a/go.sum +++ b/go.sum @@ -224,8 +224,6 @@ github.com/klauspost/pgzip v1.2.1 h1:oIPZROsWuPHpOdMVWLuJZXwgjhrW8r1yEX8UqMyeNHM github.com/klauspost/pgzip v1.2.1/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/klauspost/readahead v1.3.1 h1:QqXNYvm+VvqYcbrRT4LojUciM0XrznFRIDrbHiJtu/0= github.com/klauspost/readahead v1.3.1/go.mod h1:AH9juHzNH7xqdqFHrMRSHeH2Ps+vFf+kblDqzPFiLJg= -github.com/klauspost/reedsolomon v1.9.3 h1:N/VzgeMfHmLc+KHMD1UL/tNkfXAt8FnUqlgXGIduwAY= -github.com/klauspost/reedsolomon v1.9.3/go.mod h1:CwCi+NUr9pqSVktrkN+Ondf06rkhYZ/pcNv7fu+8Un4= github.com/klauspost/reedsolomon v1.9.7 h1:+azeqnT4iNG9UEcWC+7utJ4xXQ9S8pSlkZor0DOArEQ= github.com/klauspost/reedsolomon v1.9.7/go.mod h1:+8WD025Xpby8/kG5h/HDPIFhiiuGEtZOKw+5Y4drAD8= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=