summaryrefslogtreecommitdiff
path: root/src/mongo/db/auth/auth_index_d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/auth/auth_index_d.cpp')
-rw-r--r--src/mongo/db/auth/auth_index_d.cpp49
1 files changed, 22 insertions, 27 deletions
diff --git a/src/mongo/db/auth/auth_index_d.cpp b/src/mongo/db/auth/auth_index_d.cpp
index ddcb6986de7..410a6e24de6 100644
--- a/src/mongo/db/auth/auth_index_d.cpp
+++ b/src/mongo/db/auth/auth_index_d.cpp
@@ -74,38 +74,33 @@ namespace {
} // namespace
- void configureSystemIndexes(OperationContext* txn) {
- int authzVersion;
- Status status = getGlobalAuthorizationManager()->getAuthorizationVersion(
- txn, &authzVersion);
- if (!status.isOK()) {
- return;
- }
-
- if (authzVersion >= AuthorizationManager::schemaVersion26Final) {
- const NamespaceString systemUsers("admin", "system.users");
+ Status verifySystemIndexes(OperationContext* txn) {
+ const NamespaceString systemUsers = AuthorizationManager::usersCollectionNamespace;
- // Make sure the old unique index from v2.4 on system.users doesn't exist.
- AutoGetDb autoDb(txn, systemUsers.db(), MODE_X);
- if (!autoDb.getDb()) {
- return;
- }
+ // Make sure the old unique index from v2.4 on system.users doesn't exist.
+ AutoGetDb autoDb(txn, systemUsers.db(), MODE_X);
+ if (!autoDb.getDb()) {
+ return Status::OK();
+ }
- Collection* collection = autoDb.getDb()->getCollection(txn,
- NamespaceString(systemUsers));
- if (!collection) {
- return;
- }
+ Collection* collection = autoDb.getDb()->getCollection(txn,
+ NamespaceString(systemUsers));
+ if (!collection) {
+ return Status::OK();
+ }
- IndexCatalog* indexCatalog = collection->getIndexCatalog();
- IndexDescriptor* oldIndex = NULL;
+ IndexCatalog* indexCatalog = collection->getIndexCatalog();
+ IndexDescriptor* oldIndex = NULL;
- WriteUnitOfWork wunit(txn);
- while ((oldIndex = indexCatalog->findIndexByKeyPattern(txn, v1SystemUsersKeyPattern))) {
- indexCatalog->dropIndex(txn, oldIndex);
- }
- wunit.commit();
+ if (indexCatalog &&
+ (oldIndex = indexCatalog->findIndexByKeyPattern(txn, v1SystemUsersKeyPattern))) {
+ 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.");
}
+
+ return Status::OK();
}
void createSystemIndexes(OperationContext* txn, Collection* collection) {