summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Morrow <acm@mongodb.com>2019-07-21 17:20:33 -0400
committerAndrew Morrow <acm@mongodb.com>2019-08-28 17:39:26 -0400
commit9d796ee7c61a783c0b553bf715461864ba5f6fcb (patch)
tree2fdb7849b1111622cabcec42a59ed332f2a5b6ec /src
parentbb3db9e0d9faec810b3a17e67ab28d683da65fdb (diff)
downloadmongo-9d796ee7c61a783c0b553bf715461864ba5f6fcb.tar.gz
SERVER-42257 Announce known emulations
(cherry picked from commit 0789a935ccee8e402cce8c7cdf52a41b9cc17010)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/shell/dbshell.cpp6
-rw-r--r--src/mongo/shell/utils.js45
2 files changed, 51 insertions, 0 deletions
diff --git a/src/mongo/shell/dbshell.cpp b/src/mongo/shell/dbshell.cpp
index f6bf6a3cc2f..6ff4bcaeba0 100644
--- a/src/mongo/shell/dbshell.cpp
+++ b/src/mongo/shell/dbshell.cpp
@@ -993,6 +993,12 @@ int _main(int argc, char* argv[], char** envp) {
false,
true,
false);
+
+ scope->exec("shellHelper( 'show', 'nonGenuineMongoDBCheck' )",
+ "(nonGenuineMongoDBCheck)",
+ false,
+ true,
+ false);
}
shellHistoryInit();
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js
index edcd73f1b0c..4b5e59b9156 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -994,6 +994,51 @@ shellHelper.show = function(what) {
}
}
+ if (what == "nonGenuineMongoDBCheck") {
+ let matchesKnownImposterSignature = false;
+
+ // A MongoDB emulation service offered by a company
+ // responsible for a certain disk operating system.
+ try {
+ const buildInfo = db.runCommand({buildInfo: 1});
+ if (buildInfo.hasOwnProperty('_t')) {
+ matchesKnownImposterSignature = true;
+ }
+ } catch (e) {
+ // Don't do anything here. Just throw the error away.
+ }
+
+ // A MongoDB emulation service offered by a company named
+ // after some sort of minor river or something.
+ if (!matchesKnownImposterSignature) {
+ try {
+ const cmdLineOpts = db.adminCommand({getCmdLineOpts: 1});
+ if (cmdLineOpts.hasOwnProperty('errmsg') &&
+ cmdLineOpts.errmsg.indexOf('not supported') !== -1) {
+ matchesKnownImposterSignature = true;
+ }
+ } catch (e) {
+ // Don't do anything here. Just throw the error away.
+ }
+ }
+
+ if (matchesKnownImposterSignature) {
+ print("\n" + "Warning: Non-Genuine MongoDB Detected\n\n" +
+
+ "This server or service appears to be an emulation of MongoDB " +
+ "rather than an official MongoDB product.\n\n" +
+
+ "Some documented MongoDB features may work differently, " +
+ "be entirely missing or incomplete, " +
+ "or have unexpected performance characteristics.\n\n" +
+
+ "To learn more please visit: " +
+ "https://dochub.mongodb.org/core/non-genuine-mongodb-server-warning.\n");
+ }
+
+ return "";
+ }
+
throw Error("don't know how to show [" + what + "]");
};