From ce2abd86eda2eae1045bafda865b9695dc82ab53 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Mon, 10 Oct 2016 11:06:15 +0100 Subject: [PATCH] Truly skip shared config on read errors Make it skip shared config file if it can't be read for whatever reason (not exist, permissions, IO error, etc). Previously files were skipped only if they didn't exist, but other conditions can prevent them from being read and same logic should be applicable to them. --- aws/session/shared_config.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/aws/session/shared_config.go b/aws/session/shared_config.go index 0147eedeb94..b58076f5e32 100644 --- a/aws/session/shared_config.go +++ b/aws/session/shared_config.go @@ -2,7 +2,7 @@ package session import ( "fmt" - "os" + "io/ioutil" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/credentials" @@ -105,12 +105,13 @@ func loadSharedConfigIniFiles(filenames []string) ([]sharedConfigFile, error) { files := make([]sharedConfigFile, 0, len(filenames)) for _, filename := range filenames { - if _, err := os.Stat(filename); os.IsNotExist(err) { - // Trim files from the list that don't exist. + b, err := ioutil.ReadFile(filename) + if err != nil { + // Skip files which can't be opened and read for whatever reason continue } - f, err := ini.Load(filename) + f, err := ini.Load(b) if err != nil { return nil, SharedConfigLoadError{Filename: filename} }