Merge pull request #877 from gaul/aws/credentials

Check arguments and environment before .aws/creds
This commit is contained in:
Takeshi Nakatani 2019-01-06 17:03:11 +09:00 committed by GitHub
commit fd6b37d3da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4128,9 +4128,10 @@ static int read_passwd_file(void)
// keys:
//
// 1 - from the command line (security risk)
// 1a - from ${HOME}/.aws/credentials
// 2 - from a password file specified on the command line
// 3 - from environment variables
// 3a - from the AWS_CREDENTIAL_FILE environment variable
// 3b - from ${HOME}/.aws/credentials
// 4 - from the users ~/.passwd-s3fs
// 5 - from /etc/passwd-s3fs
//
@ -4151,15 +4152,6 @@ static int get_access_keys(void)
return EXIT_SUCCESS;
}
// 1a - check ${HOME}/.aws/credentials
std::string aws_credentials = std::string(getpwuid(getuid())->pw_dir) + "/.aws/credentials";
if(read_aws_credentials_file(aws_credentials) == EXIT_SUCCESS) {
return EXIT_SUCCESS;
}else if(aws_profile != "default"){
S3FS_PRN_EXIT("Could not find profile: %s in file: %s", aws_profile.c_str(), aws_credentials.c_str());
return EXIT_FAILURE;
}
// 2 - was specified on the command line
if(passwd_file.size() > 0){
ifstream PF(passwd_file.c_str());
@ -4205,6 +4197,15 @@ static int get_access_keys(void)
}
}
// 3b - check ${HOME}/.aws/credentials
std::string aws_credentials = std::string(getpwuid(getuid())->pw_dir) + "/.aws/credentials";
if(read_aws_credentials_file(aws_credentials) == EXIT_SUCCESS) {
return EXIT_SUCCESS;
}else if(aws_profile != "default"){
S3FS_PRN_EXIT("Could not find profile: %s in file: %s", aws_profile.c_str(), aws_credentials.c_str());
return EXIT_FAILURE;
}
// 4 - from the default location in the users home directory
char * HOME;
HOME = getenv ("HOME");