Skip to content

Commit

Permalink
Merge pull request s3fs-fuse#597 from ggtakec/master
Browse files Browse the repository at this point in the history
Not fallback to HTTP - s3fs-fuse#596
  • Loading branch information
ggtakec authored May 13, 2017
2 parents b068124 + 337da59 commit 13503c0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 35 deletions.
3 changes: 0 additions & 3 deletions doc/man/s3fs.1
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ If the disk free space is smaller than this value, s3fs do not use diskspace as
.TP
\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".
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.
.TP
\fB\-o\fR endpoint (default="us-east-1")
Expand Down
29 changes: 3 additions & 26 deletions src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ bool foreground = false;
bool nomultipart = false;
bool pathrequeststyle = false;
bool complement_stat = false;
bool is_changed_default_host = false; // for checking default http protocol
std::string program_name;
std::string service_path = "/";
std::string host = "https://s3.amazonaws.com";
Expand Down Expand Up @@ -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 std::string build_xattrs(const xattrs_t& xattrs);
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_passwd_file_perms(void);
static int read_passwd_file(void);
Expand Down Expand Up @@ -3750,7 +3749,7 @@ static bool check_region_error(const char* pbody, string& expectregion)
return true;
}

static int s3fs_check_service(bool need_try_http)
static int s3fs_check_service(void)
{
S3FS_PRN_INFO("check services.");

Expand All @@ -3762,7 +3761,6 @@ static int s3fs_check_service(bool need_try_http)

S3fsCurl s3fscurl;
int res;
string bup_endpoint = endpoint;
if(0 > (res = s3fscurl.CheckBucket())){
// get response code
long responseCode = s3fscurl.GetLastResponseCode();
Expand Down Expand Up @@ -3821,26 +3819,7 @@ static int s3fs_check_service(bool need_try_http)
// another error
S3FS_PRN_CRIT("unable to connect(host=%s) - result of checking service.", host.c_str());
}

// [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;
}
return EXIT_FAILURE;
}
}

Expand Down Expand Up @@ -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=")){
host = strchr(arg, '=') + sizeof(char);
is_changed_default_host = true;
return 0;
}
if(0 == STR2NCMP(arg, "servicepath=")){
Expand Down Expand Up @@ -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=")){
host = strchr(arg, '=') + sizeof(char);
is_changed_default_host = true;
// strip the trailing '/', if any, off the end of the host
// string
size_t found, length;
Expand Down
8 changes: 2 additions & 6 deletions src/s3fs_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1129,12 +1129,8 @@ void show_help (void)
" url (default=\"https://s3.amazonaws.com\")\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"
" If you start s3fs without specifying the url option, s3fs will\n"
" check the bucket using https://s3.amazonaws.com. And when bucket\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"
" If you do not use https, please specify the URL with the url\n"
" option.\n"
"\n"
" endpoint (default=\"us-east-1\")\n"
" - sets the endpoint to use on signature version 4\n"
Expand Down

0 comments on commit 13503c0

Please sign in to comment.