diff options
| author | Chris Lu <chrislusf@users.noreply.github.com> | 2022-07-12 21:47:39 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-12 21:47:39 -0700 |
| commit | 31f9f528db11a10d72e86e895bbd663397a0b32f (patch) | |
| tree | 77277ec90374447e8303370a6fdb2814de7058c5 | |
| parent | fba5219dab83f312de5a0b8ea7ace0e26f6e73a1 (diff) | |
| parent | 392da4e0385ac8bcce5ac0d286277a71651af225 (diff) | |
| download | seaweedfs-31f9f528db11a10d72e86e895bbd663397a0b32f.tar.xz seaweedfs-31f9f528db11a10d72e86e895bbd663397a0b32f.zip | |
Merge pull request #3305 from shichanglin5/fix_iam_shell_override
Check whether there is a duplicate accessKey when modifying iam
| -rw-r--r-- | weed/shell/command_s3_configure.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/weed/shell/command_s3_configure.go b/weed/shell/command_s3_configure.go index ddcafd847..0660b7889 100644 --- a/weed/shell/command_s3_configure.go +++ b/weed/shell/command_s3_configure.go @@ -2,6 +2,7 @@ package shell import ( "bytes" + "errors" "flag" "fmt" "github.com/chrislusf/seaweedfs/weed/filer" @@ -164,6 +165,17 @@ func (c *commandS3Configure) Do(args []string, commandEnv *CommandEnv, writer io s3cfg.Identities = append(s3cfg.Identities, &identity) } + accessKeySet := make(map[string]string) + for _, ident := range s3cfg.Identities { + for _, cred := range ident.Credentials { + if userName, found := accessKeySet[cred.AccessKey]; !found { + accessKeySet[cred.AccessKey] = ident.Name + } else { + return errors.New(fmt.Sprintf("duplicate accessKey[%s], already configured in user[%s]", cred.AccessKey, userName)) + } + } + } + buf.Reset() filer.ProtoToText(&buf, s3cfg) |
