mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2024-11-19 02:35:13 +00:00
Merge pull request #422 from nturner/fix/iam-role-auto
Fixes for iam_role=auto
This commit is contained in:
commit
980c0f81dd
38
src/curl.cpp
38
src/curl.cpp
@ -315,9 +315,6 @@ void CurlHandlerPool::ReturnHandler(CURL* h)
|
|||||||
#define IAMCRED_ACCESSTOKEN "Token"
|
#define IAMCRED_ACCESSTOKEN "Token"
|
||||||
#define IAMCRED_EXPIRATION "Expiration"
|
#define IAMCRED_EXPIRATION "Expiration"
|
||||||
#define IAMCRED_KEYCOUNT 4
|
#define IAMCRED_KEYCOUNT 4
|
||||||
#define IAM_DEFAULT_ROLE_URL "http://169.254.169.254/latest/meta-data/iam/info"
|
|
||||||
#define IAMDEFROLE_PROFARN "InstanceProfileArn"
|
|
||||||
#define IAMDEFROLE_PROFARN_PART ":instance-profile/"
|
|
||||||
|
|
||||||
// [NOTICE]
|
// [NOTICE]
|
||||||
// This symbol is for libcurl under 7.23.0
|
// This symbol is for libcurl under 7.23.0
|
||||||
@ -1447,41 +1444,14 @@ bool S3fsCurl::ParseIAMRoleFromMetaDataResponse(const char* response, string& ro
|
|||||||
// [NOTE]
|
// [NOTE]
|
||||||
// expected following strings.
|
// expected following strings.
|
||||||
//
|
//
|
||||||
// {
|
// myrolename
|
||||||
// "Code" : "Success",
|
|
||||||
// "LastUpdated" : "2016-01-01T00:00:00Z",
|
|
||||||
// "InstanceProfileArn" : "arn:aws:iam::111111111111:instance-profile/myrolename",
|
|
||||||
// "InstanceProfileId" : "AAAAAAAAAAAAAAAAAAAAA"
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
istringstream ssrole(response);
|
istringstream ssrole(response);
|
||||||
string oneline;
|
string oneline;
|
||||||
while(getline(ssrole, oneline, '\n')){
|
if (getline(ssrole, oneline, '\n')){
|
||||||
string::size_type pos;
|
rolename = oneline;
|
||||||
if(string::npos != (pos = oneline.find(IAMDEFROLE_PROFARN))){
|
|
||||||
if(string::npos == (pos = oneline.find(':', pos + strlen(IAMDEFROLE_PROFARN)))){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(string::npos == (pos = oneline.find('\"', pos))){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// value
|
|
||||||
oneline = oneline.substr(pos + sizeof(char));
|
|
||||||
if(string::npos == (pos = oneline.find('\"'))){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
oneline = oneline.substr(0, pos);
|
|
||||||
|
|
||||||
// role name
|
|
||||||
if(string::npos == (pos = oneline.find(IAMDEFROLE_PROFARN_PART))){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
rolename = oneline.substr(pos + strlen(IAMDEFROLE_PROFARN_PART));
|
|
||||||
|
|
||||||
return !rolename.empty();
|
return !rolename.empty();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2384,7 +2354,7 @@ bool S3fsCurl::LoadIAMRoleFromMetaData(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// url
|
// url
|
||||||
url = IAM_DEFAULT_ROLE_URL;
|
url = IAM_CRED_URL;
|
||||||
requestHeaders = NULL;
|
requestHeaders = NULL;
|
||||||
responseHeaders.clear();
|
responseHeaders.clear();
|
||||||
bodydata = new BodyData();
|
bodydata = new BodyData();
|
||||||
|
@ -3354,7 +3354,7 @@ static void* s3fs_init(struct fuse_conn_info* conn)
|
|||||||
|
|
||||||
// check loading IAM role name
|
// check loading IAM role name
|
||||||
if(load_iamrole){
|
if(load_iamrole){
|
||||||
// load IAM role name from http://169.254.169.254/latest/meta-data/iam/info
|
// load IAM role name from http://169.254.169.254/latest/meta-data/iam/security-credentials
|
||||||
//
|
//
|
||||||
S3fsCurl s3fscurl;
|
S3fsCurl s3fscurl;
|
||||||
if(!s3fscurl.LoadIAMRoleFromMetaData()){
|
if(!s3fscurl.LoadIAMRoleFromMetaData()){
|
||||||
|
Loading…
Reference in New Issue
Block a user