From 44d2cc15f7e69f6810eb0198253d8473c9e6c9c4 Mon Sep 17 00:00:00 2001 From: Andrew Gaul Date: Fri, 18 Sep 2020 08:12:47 +0900 Subject: [PATCH] Ensure environment variable is set when using ECS Previously s3fs crashed when AWS_CONTAINER_CREDENTIALS_RELATIVE_URI was not set. References #1162. --- src/curl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/curl.cpp b/src/curl.cpp index b67142c..1e99519 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -2678,7 +2678,12 @@ int S3fsCurl::GetIAMCredentials() // url if(is_ecs){ - url = std::string(S3fsCurl::IAM_cred_url) + std::getenv(ECS_IAM_ENV_VAR.c_str()); + const char *env = std::getenv(ECS_IAM_ENV_VAR.c_str()); + if(env == NULL){ + S3FS_PRN_ERR("%s is not set.", ECS_IAM_ENV_VAR.c_str()); + return -EIO; + } + url = std::string(S3fsCurl::IAM_cred_url) + env; }else{ url = std::string(S3fsCurl::IAM_cred_url) + S3fsCurl::IAM_role; }