HDFS-10685: libhdfs++: return explicit error when non-secured client connects to secured server. Contributed by Kai Jiang.

This commit is contained in:
James 2017-01-11 10:54:50 -05:00 committed by James Clampffer
parent 69d55340f8
commit 58de2df860
4 changed files with 17 additions and 3 deletions

View File

@ -43,6 +43,7 @@ class Status {
static Status Exception(const char *exception_class_name, const char *exception_details);
static Status Error(const char *error_message);
static Status AuthenticationFailed();
static Status AuthenticationFailed(const char *msg);
static Status Canceled();
static Status PathNotFound(const char *msg);
static Status InvalidOffset(const char *msg);

View File

@ -131,7 +131,16 @@ Status Status::Error(const char *error_message) {
}
Status Status::AuthenticationFailed() {
return Status(kAuthenticationFailed, "Authentication failed");
return Status::AuthenticationFailed(nullptr);
}
Status Status::AuthenticationFailed(const char *msg) {
std::string formatted = "AuthenticationFailed";
if(msg) {
formatted += ": ";
formatted += msg;
}
return Status(kAuthenticationFailed, formatted.c_str());
}
Status Status::Canceled() {

View File

@ -91,7 +91,7 @@ Status make_status(int rc) {
if (rc != SASL_OK &&
rc != SASL_CONTINUE &&
rc != SASL_INTERACT) {
return Status::Error(errStr(rc).c_str());
return Status::AuthenticationFailed(errStr(rc).c_str());
}
return Status::OK();
}

View File

@ -293,8 +293,12 @@ Status RpcConnection::HandleRpcResponse(std::shared_ptr<Response> response) {
auto req = RemoveFromRunningQueue(h.callid());
if (!req) {
LOG_WARN(kRPC, << "RPC response with Unknown call id " << h.callid());
if((int32_t)h.callid() == RpcEngine::kCallIdSasl) {
return Status::AuthenticationFailed("You have an unsecured client connecting to a secured server");
} else {
return Status::Error("Rpc response with unknown call id");
}
}
Status status;
if(event_handlers_) {