From 34f86b9ad6a95cb6a8071fc3728c10f7b363bc04 Mon Sep 17 00:00:00 2001 From: Andrey Kostov Date: Fri, 23 Jan 2015 15:50:55 -0800 Subject: [PATCH] Fixes an IAM role authentication bug More specifically, the driver panics if initialized with FromParameters with empty accesskey or secretkey. --- storagedriver/s3/s3.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/storagedriver/s3/s3.go b/storagedriver/s3/s3.go index 2d76b007..f2b4c417 100644 --- a/storagedriver/s3/s3.go +++ b/storagedriver/s3/s3.go @@ -82,8 +82,14 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) { // Providing no values for these is valid in case the user is authenticating // with an IAM on an ec2 instance (in which case the instance credentials will // be summoned when GetAuth is called) - accessKey, _ := parameters["accesskey"] - secretKey, _ := parameters["secretkey"] + accessKey, ok := parameters["accesskey"] + if !ok { + accessKey = "" + } + secretKey, ok := parameters["secretkey"] + if !ok { + secretKey = "" + } regionName, ok := parameters["region"] if !ok || fmt.Sprint(regionName) == "" {