summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands.cpp
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2017-08-01 11:29:51 -0400
committerJason Carey <jcarey@argv.me>2017-08-17 12:16:40 -0400
commitcb20cab73393fbf725627d5f7b1af5e797866870 (patch)
treed2282b9e7490f7e73ead3cf35a746d0f126b42fd /src/mongo/db/commands.cpp
parent427647f7cea35a782f3532c02d3e16323c4aea99 (diff)
downloadmongo-cb20cab73393fbf725627d5f7b1af5e797866870.tar.gz
SERVER-28338 KillSessions Support
Diffstat (limited to 'src/mongo/db/commands.cpp')
-rw-r--r--src/mongo/db/commands.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/mongo/db/commands.cpp b/src/mongo/db/commands.cpp
index 5f5982d76f4..c8f99250182 100644
--- a/src/mongo/db/commands.cpp
+++ b/src/mongo/db/commands.cpp
@@ -189,7 +189,7 @@ BSONObj Command::runCommandDirectly(OperationContext* opCtx, const OpMsgRequest&
BSONObjBuilder out;
try {
- bool ok = command->enhancedRun(opCtx, request, out);
+ bool ok = command->publicRun(opCtx, request, out);
appendCommandStatus(out, ok);
} catch (const StaleConfigException& ex) {
// These exceptions are intended to be handled at a higher level and cannot losslessly
@@ -321,6 +321,20 @@ Status Command::checkAuthorization(Command* c,
return status;
}
+bool Command::publicRun(OperationContext* opCtx,
+ const OpMsgRequest& request,
+ BSONObjBuilder& result) {
+ try {
+ return enhancedRun(opCtx, request, result);
+ } catch (const DBException& e) {
+ if (e.code() == ErrorCodes::Unauthorized) {
+ audit::logCommandAuthzCheck(
+ opCtx->getClient(), request, this, ErrorCodes::Unauthorized);
+ }
+ throw;
+ }
+}
+
bool Command::isHelpRequest(const BSONElement& helpElem) {
return !helpElem.eoo() && helpElem.trueValue();
}