summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2020-09-02 20:25:08 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-10-21 18:26:47 +0000
commit6fe78a092be6b3a87ec9a91693c7dc77bd45fe5e (patch)
treef3d4b918610223d1b47550cc20a30728fe82ee44 /src/mongo
parent78a269596edf46413b8533132d10da995953d5ee (diff)
downloadmongo-6fe78a092be6b3a87ec9a91693c7dc77bd45fe5e.tar.gz
SERVER-50116 Forbid oplog writes when replication is enabled
(cherry picked from commit 7b2913a64bc8812a9ab71ce27fe14bb2f517376f) (cherry picked from commit 73dd69d37bc64c58a800c8d1225e35d3ca6241cb)
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/ops/insert.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp
index dfc841588dc..4267cffe015 100644
--- a/src/mongo/db/ops/insert.cpp
+++ b/src/mongo/db/ops/insert.cpp
@@ -35,6 +35,7 @@
#include "mongo/bson/bson_depth.h"
#include "mongo/db/logical_clock.h"
#include "mongo/db/logical_time.h"
+#include "mongo/db/repl/replication_coordinator.h"
#include "mongo/db/views/durable_view_catalog.h"
#include "mongo/util/str.h"
@@ -183,6 +184,9 @@ Status userAllowedWriteNS(StringData db, StringData coll) {
if (coll == "system.profile") {
return Status(ErrorCodes::InvalidNamespace,
str::stream() << "cannot write to '" << db << ".system.profile'");
+ } else if (db == "local" && coll == "oplog.rs" &&
+ repl::ReplicationCoordinator::get(getGlobalServiceContext())->isReplEnabled()) {
+ return Status(ErrorCodes::InvalidNamespace, "cannot write to 'local.oplog.rs'");
}
return userAllowedCreateNS(db, coll);
}