MCPcopy Create free account
hub / github.com/apache/impala / RecvConnectionContext

Method RecvConnectionContext

be/src/kudu/rpc/server_negotiation.cc:1027–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1025}
1026
1027Status ServerNegotiation::RecvConnectionContext(faststring* recv_buf) {
1028 TRACE("Waiting for connection context");
1029 RequestHeader header;
1030 Slice param_buf;
1031 RETURN_NOT_OK(ReceiveFramedMessageBlocking(
1032 socket_.get(), recv_buf, &header, &param_buf, deadline_));
1033 DCHECK(header.IsInitialized());
1034
1035 if (header.call_id() != kConnectionContextCallId) {
1036 return Status::NotAuthorized("expected ConnectionContext callid, received",
1037 std::to_string(header.call_id()));
1038 }
1039
1040 ConnectionContextPB conn_context;
1041 if (!conn_context.ParseFromArray(param_buf.data(), param_buf.size())) {
1042 return Status::NotAuthorized("invalid ConnectionContextPB message, missing fields",
1043 conn_context.InitializationErrorString());
1044 }
1045
1046 if (nonce_) {
1047 Status s;
1048 // Validate that the client returned the correct SASL protected nonce.
1049 if (!conn_context.has_encoded_nonce()) {
1050 return Status::NotAuthorized("ConnectionContextPB wrapped nonce missing");
1051 }
1052
1053 Slice decoded_nonce;
1054 s = SaslDecode(sasl_conn_.get(), conn_context.encoded_nonce(), &decoded_nonce);
1055 if (!s.ok()) {
1056 return Status::NotAuthorized("failed to decode nonce", s.message());
1057 }
1058
1059 if (*nonce_ != decoded_nonce) {
1060 Sockaddr addr;
1061 RETURN_NOT_OK(socket_->GetPeerAddress(&addr));
1062 LOG(WARNING) << "Received an invalid connection nonce from client "
1063 << addr.ToString()
1064 << ", this could indicate a replay attack";
1065 return Status::NotAuthorized("nonce mismatch");
1066 }
1067 }
1068
1069 return Status::OK();
1070}
1071
1072int ServerNegotiation::GetOptionCb(const char* plugin_name,
1073 const char* option,

Callers

nothing calls this directly

Calls 13

NotAuthorizedFunction · 0.85
SaslDecodeFunction · 0.85
OKFunction · 0.85
getMethod · 0.65
IsInitializedMethod · 0.45
call_idMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
okMethod · 0.45
messageMethod · 0.45
GetPeerAddressMethod · 0.45

Tested by

no test coverage detected