Not fallback to HTTP - #596

This commit is contained in:
Takeshi Nakatani 2017-05-13 15:47:39 +00:00
parent b0681246b9
commit 337da59368
3 changed files with 5 additions and 35 deletions

View File

@ -190,9 +190,6 @@ If the disk free space is smaller than this value, s3fs do not use diskspace as
.TP .TP
\fB\-o\fR url (default="https://s3.amazonaws.com") \fB\-o\fR url (default="https://s3.amazonaws.com")
sets the url to use to access Amazon S3. If you want to use HTTP, then you can set "url=http://s3.amazonaws.com". sets the url to use to access Amazon S3. If you want to use HTTP, then you can set "url=http://s3.amazonaws.com".
If you start s3fs without specifying the url option, s3fs will check the bucket using https://s3.amazonaws.com.
And when bucket check fails, s3fs retries the bucket check using http://s3.amazonaws.com.
This is the function left behind for backward compatibility.
If you do not use https, please specify the URL with the url option. If you do not use https, please specify the URL with the url option.
.TP .TP
\fB\-o\fR endpoint (default="us-east-1") \fB\-o\fR endpoint (default="us-east-1")

View File

@ -89,7 +89,6 @@ bool foreground = false;
bool nomultipart = false; bool nomultipart = false;
bool pathrequeststyle = false; bool pathrequeststyle = false;
bool complement_stat = false; bool complement_stat = false;
bool is_changed_default_host = false; // for checking default http protocol
std::string program_name; std::string program_name;
std::string service_path = "/"; std::string service_path = "/";
std::string host = "https://s3.amazonaws.com"; std::string host = "https://s3.amazonaws.com";
@ -176,7 +175,7 @@ static bool parse_xattr_keyval(const std::string& xattrpair, string& key, PXATTR
static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs); static size_t parse_xattrs(const std::string& strxattrs, xattrs_t& xattrs);
static std::string build_xattrs(const xattrs_t& xattrs); static std::string build_xattrs(const xattrs_t& xattrs);
static int s3fs_utility_mode(void); static int s3fs_utility_mode(void);
static int s3fs_check_service(bool need_try_http = true); static int s3fs_check_service(void);
static int check_for_aws_format(void); static int check_for_aws_format(void);
static int check_passwd_file_perms(void); static int check_passwd_file_perms(void);
static int read_passwd_file(void); static int read_passwd_file(void);
@ -3750,7 +3749,7 @@ static bool check_region_error(const char* pbody, string& expectregion)
return true; return true;
} }
static int s3fs_check_service(bool need_try_http) static int s3fs_check_service(void)
{ {
S3FS_PRN_INFO("check services."); S3FS_PRN_INFO("check services.");
@ -3762,7 +3761,6 @@ static int s3fs_check_service(bool need_try_http)
S3fsCurl s3fscurl; S3fsCurl s3fscurl;
int res; int res;
string bup_endpoint = endpoint;
if(0 > (res = s3fscurl.CheckBucket())){ if(0 > (res = s3fscurl.CheckBucket())){
// get response code // get response code
long responseCode = s3fscurl.GetLastResponseCode(); long responseCode = s3fscurl.GetLastResponseCode();
@ -3821,26 +3819,7 @@ static int s3fs_check_service(bool need_try_http)
// another error // another error
S3FS_PRN_CRIT("unable to connect(host=%s) - result of checking service.", host.c_str()); S3FS_PRN_CRIT("unable to connect(host=%s) - result of checking service.", host.c_str());
} }
return EXIT_FAILURE;
// [NOTE]
// If using default host(https://s3.amazonaws.com), try to change https to http protocol
// (old version default protocol) and try to connect.
//
if(need_try_http && !is_changed_default_host){
// host is set second default value(http)
S3FS_PRN_CRIT("Retry checking the bucket with HTTP(http://s3.amazonaws.com), not HTTPS(https://s3.amazonaws.com).");
host = "http://s3.amazonaws.com";
endpoint = bup_endpoint;
// check http protocol
int result = s3fs_check_service(false);
if(EXIT_SUCCESS == result){
S3FS_PRN_CRIT("Switch to HTTP protocol instead of HTTPS. You should use the host or url option and specify the HTTP protocol endpoint.");
}
return result;
}else{
return EXIT_FAILURE;
}
} }
} }
@ -4589,7 +4568,6 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
} }
if(0 == STR2NCMP(arg, "host=")){ if(0 == STR2NCMP(arg, "host=")){
host = strchr(arg, '=') + sizeof(char); host = strchr(arg, '=') + sizeof(char);
is_changed_default_host = true;
return 0; return 0;
} }
if(0 == STR2NCMP(arg, "servicepath=")){ if(0 == STR2NCMP(arg, "servicepath=")){
@ -4710,7 +4688,6 @@ static int my_fuse_opt_proc(void* data, const char* arg, int key, struct fuse_ar
} }
if(0 == STR2NCMP(arg, "url=")){ if(0 == STR2NCMP(arg, "url=")){
host = strchr(arg, '=') + sizeof(char); host = strchr(arg, '=') + sizeof(char);
is_changed_default_host = true;
// strip the trailing '/', if any, off the end of the host // strip the trailing '/', if any, off the end of the host
// string // string
size_t found, length; size_t found, length;

View File

@ -1129,12 +1129,8 @@ void show_help (void)
" url (default=\"https://s3.amazonaws.com\")\n" " url (default=\"https://s3.amazonaws.com\")\n"
" - sets the url to use to access Amazon S3. If you want to use HTTP,\n" " - sets the url to use to access Amazon S3. If you want to use HTTP,\n"
" then you can set \"url=http://s3.amazonaws.com\".\n" " then you can set \"url=http://s3.amazonaws.com\".\n"
" If you start s3fs without specifying the url option, s3fs will\n" " If you do not use https, please specify the URL with the url\n"
" check the bucket using https://s3.amazonaws.com. And when bucket\n" " option.\n"
" check fails, s3fs retries the bucket check using\n"
" http://s3.amazonaws.com. This is the function left behind for\n"
" backward compatibility. If you do not use https, please specify\n"
" the URL with the url option.\n"
"\n" "\n"
" endpoint (default=\"us-east-1\")\n" " endpoint (default=\"us-east-1\")\n"
" - sets the endpoint to use on signature version 4\n" " - sets the endpoint to use on signature version 4\n"