diff options
author | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 00:22:50 -0400 |
---|---|---|
committer | Mark Benvenuto <mark.benvenuto@mongodb.com> | 2015-06-20 10:56:02 -0400 |
commit | 9c2ed42daa8fbbef4a919c21ec564e2db55e8d60 (patch) | |
tree | 3814f79c10d7b490948d8cb7b112ac1dd41ceff1 /src/mongo/db/auth/auth_index_d.cpp | |
parent | 01965cf52bce6976637ecb8f4a622aeb05ab256a (diff) | |
download | mongo-9c2ed42daa8fbbef4a919c21ec564e2db55e8d60.tar.gz |
SERVER-18579: Clang-Format - reformat code, no comment reflow
Diffstat (limited to 'src/mongo/db/auth/auth_index_d.cpp')
-rw-r--r-- | src/mongo/db/auth/auth_index_d.cpp | 124 |
1 files changed, 59 insertions, 65 deletions
diff --git a/src/mongo/db/auth/auth_index_d.cpp b/src/mongo/db/auth/auth_index_d.cpp index 8cbd093c2c7..546df4c1da9 100644 --- a/src/mongo/db/auth/auth_index_d.cpp +++ b/src/mongo/db/auth/auth_index_d.cpp @@ -46,85 +46,79 @@ namespace mongo { - using std::endl; +using std::endl; namespace authindex { namespace { - BSONObj v1SystemUsersKeyPattern; - BSONObj v3SystemUsersKeyPattern; - BSONObj v3SystemRolesKeyPattern; - std::string v3SystemUsersIndexName; - std::string v3SystemRolesIndexName; - - MONGO_INITIALIZER(AuthIndexKeyPatterns)(InitializerContext*) { - v1SystemUsersKeyPattern = BSON("user" << 1 << "userSource" << 1); - v3SystemUsersKeyPattern = BSON(AuthorizationManager::USER_NAME_FIELD_NAME << 1 << - AuthorizationManager::USER_DB_FIELD_NAME << 1); - v3SystemRolesKeyPattern = BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME << 1 << - AuthorizationManager::ROLE_DB_FIELD_NAME << 1); - v3SystemUsersIndexName = std::string( - str::stream() << - AuthorizationManager::USER_NAME_FIELD_NAME << "_1_" << - AuthorizationManager::USER_DB_FIELD_NAME << "_1"); - v3SystemRolesIndexName = std::string( - str::stream() << - AuthorizationManager::ROLE_NAME_FIELD_NAME << "_1_" << - AuthorizationManager::ROLE_DB_FIELD_NAME << "_1"); - - return Status::OK(); - } +BSONObj v1SystemUsersKeyPattern; +BSONObj v3SystemUsersKeyPattern; +BSONObj v3SystemRolesKeyPattern; +std::string v3SystemUsersIndexName; +std::string v3SystemRolesIndexName; + +MONGO_INITIALIZER(AuthIndexKeyPatterns)(InitializerContext*) { + v1SystemUsersKeyPattern = BSON("user" << 1 << "userSource" << 1); + v3SystemUsersKeyPattern = BSON(AuthorizationManager::USER_NAME_FIELD_NAME + << 1 << AuthorizationManager::USER_DB_FIELD_NAME << 1); + v3SystemRolesKeyPattern = BSON(AuthorizationManager::ROLE_NAME_FIELD_NAME + << 1 << AuthorizationManager::ROLE_DB_FIELD_NAME << 1); + v3SystemUsersIndexName = + std::string(str::stream() << AuthorizationManager::USER_NAME_FIELD_NAME << "_1_" + << AuthorizationManager::USER_DB_FIELD_NAME << "_1"); + v3SystemRolesIndexName = + std::string(str::stream() << AuthorizationManager::ROLE_NAME_FIELD_NAME << "_1_" + << AuthorizationManager::ROLE_DB_FIELD_NAME << "_1"); + + return Status::OK(); +} } // namespace - Status verifySystemIndexes(OperationContext* txn) { - const NamespaceString systemUsers = AuthorizationManager::usersCollectionNamespace; +Status verifySystemIndexes(OperationContext* txn) { + const NamespaceString systemUsers = AuthorizationManager::usersCollectionNamespace; - // Make sure the old unique index from v2.4 on system.users doesn't exist. - ScopedTransaction scopedXact(txn, MODE_IX); - AutoGetDb autoDb(txn, systemUsers.db(), MODE_X); - if (!autoDb.getDb()) { - return Status::OK(); - } - - Collection* collection = autoDb.getDb()->getCollection(NamespaceString(systemUsers)); - if (!collection) { - return Status::OK(); - } + // Make sure the old unique index from v2.4 on system.users doesn't exist. + ScopedTransaction scopedXact(txn, MODE_IX); + AutoGetDb autoDb(txn, systemUsers.db(), MODE_X); + if (!autoDb.getDb()) { + return Status::OK(); + } - IndexCatalog* indexCatalog = collection->getIndexCatalog(); - IndexDescriptor* oldIndex = NULL; + Collection* collection = autoDb.getDb()->getCollection(NamespaceString(systemUsers)); + if (!collection) { + return Status::OK(); + } - 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."); - } + IndexCatalog* indexCatalog = collection->getIndexCatalog(); + IndexDescriptor* oldIndex = NULL; - return Status::OK(); + 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."); } - void createSystemIndexes(OperationContext* txn, Collection* collection) { - invariant( collection ); - const NamespaceString& ns = collection->ns(); - if (ns == AuthorizationManager::usersCollectionNamespace) { - collection->getIndexCatalog()->createIndexOnEmptyCollection( - txn, - BSON("name" << v3SystemUsersIndexName - << "ns" << collection->ns().ns() - << "key" << v3SystemUsersKeyPattern - << "unique" << true)); - } else if (ns == AuthorizationManager::rolesCollectionNamespace) { - collection->getIndexCatalog()->createIndexOnEmptyCollection( - txn, - BSON("name" << v3SystemRolesIndexName - << "ns" << collection->ns().ns() - << "key" << v3SystemRolesKeyPattern - << "unique" << true)); - } + return Status::OK(); +} + +void createSystemIndexes(OperationContext* txn, Collection* collection) { + invariant(collection); + const NamespaceString& ns = collection->ns(); + if (ns == AuthorizationManager::usersCollectionNamespace) { + collection->getIndexCatalog()->createIndexOnEmptyCollection( + txn, + BSON("name" << v3SystemUsersIndexName << "ns" << collection->ns().ns() << "key" + << v3SystemUsersKeyPattern << "unique" << true)); + } else if (ns == AuthorizationManager::rolesCollectionNamespace) { + collection->getIndexCatalog()->createIndexOnEmptyCollection( + txn, + BSON("name" << v3SystemRolesIndexName << "ns" << collection->ns().ns() << "key" + << v3SystemRolesKeyPattern << "unique" << true)); } +} } // namespace authindex } // namespace mongo |