summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorIan Whalen <ian.whalen@gmail.com>2017-09-22 16:10:50 -0400
committerIan Whalen <ian.whalen@gmail.com>2017-09-22 16:10:50 -0400
commitab7ceed2108a7d19518490929b03fa6f4a13257c (patch)
treea46f487d592c62089f3e58d236e29f843c802b21 /src/mongo
parentc4b90fe5509eb70e4009e0d7ddbd71b4b92d0274 (diff)
downloadmongo-ab7ceed2108a7d19518490929b03fa6f4a13257c.tar.gz
Revert "SERVER-31174 Move the sessions collection to config.system.sessions"
This reverts commit ba1704f7cbc0b9a03a181df145f75f433a59b7df.
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/namespace_string.cpp3
-rw-r--r--src/mongo/db/ops/insert.cpp6
-rw-r--r--src/mongo/db/pipeline/document_source_list_sessions.h2
-rw-r--r--src/mongo/db/sessions_collection.h4
-rw-r--r--src/mongo/db/system_index.cpp128
-rw-r--r--src/mongo/dbtests/logical_sessions_tests.cpp2
6 files changed, 65 insertions, 80 deletions
diff --git a/src/mongo/db/namespace_string.cpp b/src/mongo/db/namespace_string.cpp
index 035228b65ad..35fbde965dd 100644
--- a/src/mongo/db/namespace_string.cpp
+++ b/src/mongo/db/namespace_string.cpp
@@ -115,8 +115,7 @@ bool NamespaceString::isLegalClientSystemNS() const {
return true;
if (ns() == "admin.system.backup_users")
return true;
- } else if (db() == "config") {
- if (ns() == "config.system.sessions")
+ if (ns() == "admin.system.sessions")
return true;
}
if (ns() == "local.system.replset")
diff --git a/src/mongo/db/ops/insert.cpp b/src/mongo/db/ops/insert.cpp
index de02fda5642..0b422f8882c 100644
--- a/src/mongo/db/ops/insert.cpp
+++ b/src/mongo/db/ops/insert.cpp
@@ -235,6 +235,8 @@ Status userAllowedCreateNS(StringData db, StringData coll) {
if (db == "admin") {
if (coll == "system.version")
return Status::OK();
+ if (coll == "system.sessions")
+ return Status::OK();
if (coll == "system.roles")
return Status::OK();
if (coll == "system.new_users")
@@ -244,10 +246,6 @@ Status userAllowedCreateNS(StringData db, StringData coll) {
if (coll == "system.keys")
return Status::OK();
}
- if (db == "config") {
- if (coll == "system.sessions")
- return Status::OK();
- }
if (db == "local") {
if (coll == "system.replset")
return Status::OK();
diff --git a/src/mongo/db/pipeline/document_source_list_sessions.h b/src/mongo/db/pipeline/document_source_list_sessions.h
index 47c08af9d73..38ba2b21b67 100644
--- a/src/mongo/db/pipeline/document_source_list_sessions.h
+++ b/src/mongo/db/pipeline/document_source_list_sessions.h
@@ -37,7 +37,7 @@ namespace mongo {
/**
* $listSessions: { allUsers: true/false, users: [ {user:"jsmith", db:"test"}, ... ] }
- * Return all sessions in the config.system.sessions collection
+ * Return all sessions in the admin.system.sessions collection
* or just sessions for the currently logged in user. (Default: false)
*
* This is essentially an alias for {$match:{"_id.uid": myid}} or {$match:{}}
diff --git a/src/mongo/db/sessions_collection.h b/src/mongo/db/sessions_collection.h
index 63fd34667cf..9d29924069c 100644
--- a/src/mongo/db/sessions_collection.h
+++ b/src/mongo/db/sessions_collection.h
@@ -49,9 +49,9 @@ class SessionsCollection {
public:
virtual ~SessionsCollection();
- static constexpr StringData kSessionsDb = "config"_sd;
+ static constexpr StringData kSessionsDb = "admin"_sd;
static constexpr StringData kSessionsCollection = "system.sessions"_sd;
- static constexpr StringData kSessionsFullNS = "config.system.sessions"_sd;
+ static constexpr StringData kSessionsFullNS = "admin.system.sessions"_sd;
static const NamespaceString kSessionsNamespaceString;
diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp
index be95f1d0758..0c07a4e46ad 100644
--- a/src/mongo/db/system_index.cpp
+++ b/src/mongo/db/system_index.cpp
@@ -67,7 +67,7 @@ IndexSpec v3SystemUsersIndexSpec;
IndexSpec v3SystemRolesIndexSpec;
IndexSpec v1SystemSessionsIndexSpec;
-const NamespaceString sessionCollectionNamespace("config.system.sessions");
+const NamespaceString sessionCollectionNamespace("admin.system.sessions");
MONGO_INITIALIZER(AuthIndexKeyPatterns)(InitializerContext*) {
v1SystemUsersKeyPattern = BSON("user" << 1 << "userSource" << 1);
@@ -145,84 +145,72 @@ Status verifySystemIndexes(OperationContext* opCtx) {
const NamespaceString& systemUsers = AuthorizationManager::usersCollectionNamespace;
const NamespaceString& systemRoles = AuthorizationManager::rolesCollectionNamespace;
- // Create indexes for collections on the admin db
- {
- AutoGetDb autoDb(opCtx, systemUsers.db(), MODE_X);
- if (!autoDb.getDb()) {
- return Status::OK();
- }
-
- Collection* collection = autoDb.getDb()->getCollection(opCtx, systemUsers);
- if (collection) {
- IndexCatalog* indexCatalog = collection->getIndexCatalog();
- invariant(indexCatalog);
-
- // Make sure the old unique index from v2.4 on system.users doesn't exist.
- std::vector<IndexDescriptor*> indexes;
- indexCatalog->findIndexesByKeyPattern(opCtx, v1SystemUsersKeyPattern, false, &indexes);
-
- if (!indexes.empty()) {
- fassert(ErrorCodes::AmbiguousIndexKeyPattern, indexes.size() == 1);
- return Status(ErrorCodes::AuthSchemaIncompatible,
- "Old 2.4 style user index identified. "
- "The authentication schema needs to be updated by "
- "running authSchemaUpgrade on a 2.6 server.");
- }
+ AutoGetDb autoDb(opCtx, systemUsers.db(), MODE_X);
+ if (!autoDb.getDb()) {
+ return Status::OK();
+ }
- // Ensure that system indexes exist for the user collection
- indexCatalog->findIndexesByKeyPattern(opCtx, v3SystemUsersKeyPattern, false, &indexes);
- if (indexes.empty()) {
- try {
- generateSystemIndexForExistingCollection(
- opCtx, collection, systemUsers, v3SystemUsersIndexSpec);
- } catch (...) {
- return exceptionToStatus();
- }
- }
+ Collection* collection = autoDb.getDb()->getCollection(opCtx, systemUsers);
+ if (collection) {
+ IndexCatalog* indexCatalog = collection->getIndexCatalog();
+ invariant(indexCatalog);
+
+ // Make sure the old unique index from v2.4 on system.users doesn't exist.
+ std::vector<IndexDescriptor*> indexes;
+ indexCatalog->findIndexesByKeyPattern(opCtx, v1SystemUsersKeyPattern, false, &indexes);
+
+ if (!indexes.empty()) {
+ fassert(ErrorCodes::AmbiguousIndexKeyPattern, indexes.size() == 1);
+ return Status(ErrorCodes::AuthSchemaIncompatible,
+ "Old 2.4 style user index identified. "
+ "The authentication schema needs to be updated by "
+ "running authSchemaUpgrade on a 2.6 server.");
}
- // Ensure that system indexes exist for the roles collection, if it exists.
- collection = autoDb.getDb()->getCollection(opCtx, systemRoles);
- if (collection) {
- IndexCatalog* indexCatalog = collection->getIndexCatalog();
- invariant(indexCatalog);
-
- std::vector<IndexDescriptor*> indexes;
- indexCatalog->findIndexesByKeyPattern(opCtx, v3SystemRolesKeyPattern, false, &indexes);
- if (indexes.empty()) {
- try {
- generateSystemIndexForExistingCollection(
- opCtx, collection, systemRoles, v3SystemRolesIndexSpec);
- } catch (...) {
- return exceptionToStatus();
- }
+ // Ensure that system indexes exist for the user collection
+ indexCatalog->findIndexesByKeyPattern(opCtx, v3SystemUsersKeyPattern, false, &indexes);
+ if (indexes.empty()) {
+ try {
+ generateSystemIndexForExistingCollection(
+ opCtx, collection, systemUsers, v3SystemUsersIndexSpec);
+ } catch (...) {
+ return exceptionToStatus();
}
}
}
- // Create indexes for system collections in the config db.
- {
- AutoGetDb autoDb(opCtx, sessionCollectionNamespace.db(), MODE_X);
- if (!autoDb.getDb()) {
- return Status::OK();
+ // Ensure that system indexes exist for the roles collection, if it exists.
+ collection = autoDb.getDb()->getCollection(opCtx, systemRoles);
+ if (collection) {
+ IndexCatalog* indexCatalog = collection->getIndexCatalog();
+ invariant(indexCatalog);
+
+ std::vector<IndexDescriptor*> indexes;
+ indexCatalog->findIndexesByKeyPattern(opCtx, v3SystemRolesKeyPattern, false, &indexes);
+ if (indexes.empty()) {
+ try {
+ generateSystemIndexForExistingCollection(
+ opCtx, collection, systemRoles, v3SystemRolesIndexSpec);
+ } catch (...) {
+ return exceptionToStatus();
+ }
}
+ }
- // Ensure that system indexes exist for the sessions collection, if it exists.
- auto collection = autoDb.getDb()->getCollection(opCtx, sessionCollectionNamespace);
- if (collection) {
- IndexCatalog* indexCatalog = collection->getIndexCatalog();
- invariant(indexCatalog);
-
- std::vector<IndexDescriptor*> indexes;
- indexCatalog->findIndexesByKeyPattern(
- opCtx, v1SystemSessionsKeyPattern, false, &indexes);
- if (indexes.empty()) {
- try {
- generateSystemIndexForExistingCollection(
- opCtx, collection, sessionCollectionNamespace, v1SystemSessionsIndexSpec);
- } catch (...) {
- return exceptionToStatus();
- }
+ // Ensure that system indexes exist for the sessions collection, if it exists.
+ collection = autoDb.getDb()->getCollection(opCtx, sessionCollectionNamespace);
+ if (collection) {
+ IndexCatalog* indexCatalog = collection->getIndexCatalog();
+ invariant(indexCatalog);
+
+ std::vector<IndexDescriptor*> indexes;
+ indexCatalog->findIndexesByKeyPattern(opCtx, v1SystemSessionsKeyPattern, false, &indexes);
+ if (indexes.empty()) {
+ try {
+ generateSystemIndexForExistingCollection(
+ opCtx, collection, sessionCollectionNamespace, v1SystemSessionsIndexSpec);
+ } catch (...) {
+ return exceptionToStatus();
}
}
}
diff --git a/src/mongo/dbtests/logical_sessions_tests.cpp b/src/mongo/dbtests/logical_sessions_tests.cpp
index 0b1b42df660..13ca0c434c8 100644
--- a/src/mongo/dbtests/logical_sessions_tests.cpp
+++ b/src/mongo/dbtests/logical_sessions_tests.cpp
@@ -45,7 +45,7 @@
namespace LogicalSessionTests {
namespace {
-constexpr StringData kTestNS = "config.system.sessions"_sd;
+constexpr StringData kTestNS = "admin.system.sessions"_sd;
LogicalSessionRecord makeRecord(Date_t time = Date_t::now()) {
auto record = makeLogicalSessionRecordForTest();