diff options
author | Randolph Tan <randolph@10gen.com> | 2020-04-02 16:02:52 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-14 22:02:54 +0000 |
commit | eb939801412d100b3d0a09ab9dacfc1c64694395 (patch) | |
tree | 788676aa8a2585440b19e49d5c201f9c124c9f61 /src/mongo/s | |
parent | d0b9ca3aa8015954b9d0fa4f2f14c142c32625f5 (diff) | |
download | mongo-eb939801412d100b3d0a09ab9dacfc1c64694395.tar.gz |
SERVER-35804 Disallow dropping config and admin from mongos
Diffstat (limited to 'src/mongo/s')
-rw-r--r-- | src/mongo/s/commands/cluster_drop_cmd.cpp | 8 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_drop_database_cmd.cpp | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/mongo/s/commands/cluster_drop_cmd.cpp b/src/mongo/s/commands/cluster_drop_cmd.cpp index c8ddc7a5dd2..d86a94c9816 100644 --- a/src/mongo/s/commands/cluster_drop_cmd.cpp +++ b/src/mongo/s/commands/cluster_drop_cmd.cpp @@ -73,6 +73,14 @@ public: const NamespaceString nss(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj)); + uassert(ErrorCodes::IllegalOperation, + "Cannot drop collection in config database", + nss.db() != NamespaceString::kConfigDb); + + uassert(ErrorCodes::IllegalOperation, + "Cannot drop collection in admin database", + nss.db() != NamespaceString::kAdminDb); + // Invalidate the routing table cache entry for this collection so that we reload it the // next time it is accessed, even if sending the command to the config server fails due // to e.g. a NetworkError. diff --git a/src/mongo/s/commands/cluster_drop_database_cmd.cpp b/src/mongo/s/commands/cluster_drop_database_cmd.cpp index 97e29270615..497b167b844 100644 --- a/src/mongo/s/commands/cluster_drop_database_cmd.cpp +++ b/src/mongo/s/commands/cluster_drop_database_cmd.cpp @@ -74,6 +74,10 @@ public: "Cannot drop the config database", dbname != NamespaceString::kConfigDb); + uassert(ErrorCodes::IllegalOperation, + "Cannot drop the admin database", + dbname != NamespaceString::kAdminDb); + uassert(ErrorCodes::BadValue, "have to pass 1 as db parameter", cmdObj.firstElement().isNumber() && cmdObj.firstElement().number() == 1); |