mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-01-31 01:28:27 +00:00
Check arguments and environment before .aws/creds
Fixes #857. Fixes #864.
This commit is contained in:
parent
d9e89deef6
commit
0569cec3ea
21
src/s3fs.cpp
21
src/s3fs.cpp
@ -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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user