HDFS-11730: libhdfs++: RpcConnection should handle authorization error call id. Contributed by James Clampffer
This commit is contained in:
parent
fdb88eb57e
commit
b584e34f2f
|
@ -44,6 +44,8 @@ class Status {
|
||||||
static Status Error(const char *error_message);
|
static Status Error(const char *error_message);
|
||||||
static Status AuthenticationFailed();
|
static Status AuthenticationFailed();
|
||||||
static Status AuthenticationFailed(const char *msg);
|
static Status AuthenticationFailed(const char *msg);
|
||||||
|
static Status AuthorizationFailed();
|
||||||
|
static Status AuthorizationFailed(const char *msg);
|
||||||
static Status Canceled();
|
static Status Canceled();
|
||||||
static Status PathNotFound(const char *msg);
|
static Status PathNotFound(const char *msg);
|
||||||
static Status InvalidOffset(const char *msg);
|
static Status InvalidOffset(const char *msg);
|
||||||
|
|
|
@ -143,6 +143,19 @@ Status Status::AuthenticationFailed(const char *msg) {
|
||||||
return Status(kAuthenticationFailed, formatted.c_str());
|
return Status(kAuthenticationFailed, formatted.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status Status::AuthorizationFailed() {
|
||||||
|
return Status::AuthorizationFailed(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status Status::AuthorizationFailed(const char *msg) {
|
||||||
|
std::string formatted = "AuthorizationFailed";
|
||||||
|
if(msg) {
|
||||||
|
formatted += ": ";
|
||||||
|
formatted += msg;
|
||||||
|
}
|
||||||
|
return Status(kPermissionDenied, formatted.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
Status Status::Canceled() {
|
Status Status::Canceled() {
|
||||||
return Status(kOperationCanceled, "Operation canceled");
|
return Status(kOperationCanceled, "Operation canceled");
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,9 +175,11 @@ Status RpcConnection::HandleRpcResponse(std::shared_ptr<Response> response) {
|
||||||
|
|
||||||
auto req = RemoveFromRunningQueue(h.callid());
|
auto req = RemoveFromRunningQueue(h.callid());
|
||||||
if (!req) {
|
if (!req) {
|
||||||
LOG_WARN(kRPC, << "RPC response with Unknown call id " << h.callid());
|
LOG_WARN(kRPC, << "RPC response with Unknown call id " << (int32_t)h.callid());
|
||||||
if((int32_t)h.callid() == RpcEngine::kCallIdSasl) {
|
if((int32_t)h.callid() == RpcEngine::kCallIdSasl) {
|
||||||
return Status::AuthenticationFailed("You have an unsecured client connecting to a secured server");
|
return Status::AuthenticationFailed("You have an unsecured client connecting to a secured server");
|
||||||
|
} else if((int32_t)h.callid() == RpcEngine::kCallIdAuthorizationFailed) {
|
||||||
|
return Status::AuthorizationFailed("RPC call id indicates an authorization failure");
|
||||||
} else {
|
} else {
|
||||||
return Status::Error("Rpc response with unknown call id");
|
return Status::Error("Rpc response with unknown call id");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue