summaryrefslogtreecommitdiff
path: root/src/mongo/db
diff options
context:
space:
mode:
authorYoonsoo Kim <yoonsoo.kim@mongodb.com>2021-08-02 01:57:55 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-08-02 02:50:42 +0000
commitb6f5fa2c56195844a543a5561ea336379c5b1f02 (patch)
treea2a925b7e4299ad9d057e0eaf29fdb5a014182f8 /src/mongo/db
parentf0c88f12d3ce0331010251cc7b0f55cbc3a97e1d (diff)
downloadmongo-b6f5fa2c56195844a543a5561ea336379c5b1f02.tar.gz
SERVER-58338 Return an error if client attempts an OP_QUERY command other than isMaster/hello
Diffstat (limited to 'src/mongo/db')
-rw-r--r--src/mongo/db/commands/user_management_commands.cpp3
-rw-r--r--src/mongo/db/service_entry_point_common.cpp13
2 files changed, 8 insertions, 8 deletions
diff --git a/src/mongo/db/commands/user_management_commands.cpp b/src/mongo/db/commands/user_management_commands.cpp
index 9c42dec4997..2157df890d4 100644
--- a/src/mongo/db/commands/user_management_commands.cpp
+++ b/src/mongo/db/commands/user_management_commands.cpp
@@ -891,8 +891,7 @@ private:
auto svcCtx = _client->getServiceContext();
auto sep = svcCtx->getServiceEntryPoint();
auto opMsgRequest = OpMsgRequest::fromDBAndBody(kAdminDB, cmdBuilder->obj());
- auto requestMessage = rpc::messageFromOpMsgRequest(
- rpc::supports::kAll, rpc::supports::kOpQueryOnly, opMsgRequest);
+ auto requestMessage = rpc::messageFromOpMsgRequest(rpc::Protocol::kOpMsg, opMsgRequest);
// Switch to our local client and create a short-lived opCtx for this transaction op.
AlternativeClientRegion clientRegion(_client);
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 7d3d299d735..7d7320f9f25 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -1432,11 +1432,6 @@ void ExecCommandDatabase::_initiateCommand() {
globalOpCounters.gotCommand();
}
- if (!isHello() && _execContext->getMessage().operation() == dbQuery) {
- warnDeprecation(*client, networkOpToString(dbQuery));
- globalOpCounters.gotQueryDeprecated();
- }
-
// Parse the 'maxTimeMS' command option, and use it to set a deadline for the operation on the
// OperationContext. The 'maxTimeMS' option unfortunately has a different meaning for a getMore
// command, where it is used to communicate the maximum time to wait for new inserts on tailable
@@ -1731,7 +1726,13 @@ void curOpCommandSetup(OperationContext* opCtx, const OpMsgRequest& request) {
}
Future<void> parseCommand(std::shared_ptr<HandleRequest::ExecutionContext> execContext) try {
- execContext->setRequest(rpc::opMsgRequestFromAnyProtocol(execContext->getMessage()));
+ const auto& msg = execContext->getMessage();
+ auto opMsgReq = rpc::opMsgRequestFromAnyProtocol(msg);
+ if (msg.operation() == dbQuery) {
+ checkAllowedOpQueryCommand(*(execContext->getOpCtx()->getClient()),
+ opMsgReq.getCommandName());
+ }
+ execContext->setRequest(opMsgReq);
return Status::OK();
} catch (const DBException& ex) {
// Need to set request as `makeCommandResponse` expects an empty request on failure.