mirror of
https://github.com/s3fs-fuse/s3fs-fuse.git
synced 2025-02-02 18:48:26 +00:00
Fail CheckBucket when S3 returns PermanentRedirect (#1630)
Previously s3fs allowed mounting but all operations returned EIO. References #693. Co-authored-by: Takeshi Nakatani <ggtakec@gmail.com>
This commit is contained in:
parent
77581eda59
commit
e9eb248f2f
22
src/s3fs.cpp
22
src/s3fs.cpp
@ -3459,6 +3459,24 @@ static bool check_region_error(const char* pbody, size_t len, std::string& expec
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool check_endpoint_error(const char* pbody, size_t len, std::string& expectendpoint)
|
||||||
|
{
|
||||||
|
if(!pbody){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string code;
|
||||||
|
if(!simple_parse_xml(pbody, len, "Code", code) || code != "PermanentRedirect"){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!simple_parse_xml(pbody, len, "Endpoint", expectendpoint)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static int s3fs_check_service()
|
static int s3fs_check_service()
|
||||||
{
|
{
|
||||||
S3FS_PRN_INFO("check services.");
|
S3FS_PRN_INFO("check services.");
|
||||||
@ -3481,6 +3499,7 @@ static int s3fs_check_service()
|
|||||||
// check region error(for putting message or retrying)
|
// check region error(for putting message or retrying)
|
||||||
BodyData* body = s3fscurl.GetBodyData();
|
BodyData* body = s3fscurl.GetBodyData();
|
||||||
std::string expectregion;
|
std::string expectregion;
|
||||||
|
std::string expectendpoint;
|
||||||
if(check_region_error(body->str(), body->size(), expectregion)){
|
if(check_region_error(body->str(), body->size(), expectregion)){
|
||||||
// [NOTE]
|
// [NOTE]
|
||||||
// If endpoint is not specified(using us-east-1 region) and
|
// If endpoint is not specified(using us-east-1 region) and
|
||||||
@ -3510,6 +3529,9 @@ static int s3fs_check_service()
|
|||||||
res = s3fscurl.CheckBucket();
|
res = s3fscurl.CheckBucket();
|
||||||
responseCode = s3fscurl.GetLastResponseCode();
|
responseCode = s3fscurl.GetLastResponseCode();
|
||||||
}
|
}
|
||||||
|
}else if(check_endpoint_error(body->str(), body->size(), expectendpoint)){
|
||||||
|
S3FS_PRN_ERR("S3 service returned PermanentRedirect with endpoint: %s", expectendpoint.c_str());
|
||||||
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user