diff options
author | Spencer T Brody <spencer@10gen.com> | 2013-07-31 14:10:55 -0400 |
---|---|---|
committer | Spencer T Brody <spencer@10gen.com> | 2013-07-31 14:50:03 -0400 |
commit | ac382bfb46c692841a766712c078f229366ae2de (patch) | |
tree | 080a78adbfdf56f9062b1b1209caa09e5c8dd43a /src | |
parent | c5afca5be18c26faeb7a8c0ca6ad8281d7dc376c (diff) | |
download | mongo-ac382bfb46c692841a766712c078f229366ae2de.tar.gz |
SERVER-9518 Fix mongos implementation of functions to get database names and user objs for a database
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/auth/authz_manager_external_state_s.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/mongo/db/auth/authz_manager_external_state_s.cpp b/src/mongo/db/auth/authz_manager_external_state_s.cpp index 5dcb0530731..1d68983fb53 100644 --- a/src/mongo/db/auth/authz_manager_external_state_s.cpp +++ b/src/mongo/db/auth/authz_manager_external_state_s.cpp @@ -129,21 +129,19 @@ namespace { Status AuthzManagerExternalStateMongos::getAllDatabaseNames( std::vector<std::string>* dbnames) const { try { - std::vector<BSONObj> dbDocs; scoped_ptr<ScopedDbConnection> conn( - getConnectionForUsersCollection("config.databases")); - conn->get()->findN(dbDocs, DatabaseType::ConfigNS, Query(), 0); - conn->done(); + getConnectionForUsersCollection(DatabaseType::ConfigNS)); + auto_ptr<DBClientCursor> c = conn->get()->query(DatabaseType::ConfigNS, Query()); - for (std::vector<BSONObj>::const_iterator it = dbDocs.begin(); - it != dbDocs.end(); ++it) { + while (c->more()) { DatabaseType dbInfo; std::string errmsg; - if (!dbInfo.parseBSON( *it, &errmsg) || !dbInfo.isValid( &errmsg )) { - return Status(ErrorCodes::FailedToParse, errmsg); + if (!dbInfo.parseBSON( c->nextSafe(), &errmsg) || !dbInfo.isValid( &errmsg )) { + return Status(ErrorCodes::FailedToParse, errmsg); } dbnames->push_back(dbInfo.getName()); } + conn->done(); dbnames->push_back("config"); // config db isn't listed in config.databases return Status::OK(); } catch (const DBException& e) { @@ -154,13 +152,15 @@ namespace { Status AuthzManagerExternalStateMongos::getAllV1PrivilegeDocsForDB( const std::string& dbname, std::vector<BSONObj>* privDocs) const { try { - std::vector<BSONObj> userDocs; std::string usersNamespace = dbname + ".system.users"; scoped_ptr<ScopedDbConnection> conn(getConnectionForUsersCollection(usersNamespace)); - conn->get()->findN(userDocs, usersNamespace, Query(), 0); + auto_ptr<DBClientCursor> c = conn->get()->query(usersNamespace, Query()); + + while (c->more()) { + privDocs->push_back(c->nextSafe().getOwned()); + } conn->done(); - *privDocs = userDocs; - return Status::OK(); + return Status::OK(); } catch (const DBException& e) { return e.toStatus(); } |