diff options
-rw-r--r-- | db/client.cpp | 5 | ||||
-rw-r--r-- | db/client.h | 2 | ||||
-rw-r--r-- | db/repl.cpp | 11 |
3 files changed, 12 insertions, 6 deletions
diff --git a/db/client.cpp b/db/client.cpp index 294ceecc17d..dc82a2550da 100644 --- a/db/client.cpp +++ b/db/client.cpp @@ -93,14 +93,15 @@ namespace mongo { BSONObj CurOp::_tooBig = fromjson("{\"$msg\":\"query not recording (too large)\"}"); AtomicUInt CurOp::_nextOpNum; - Client::Context::Context( string ns , Database * db ) + Client::Context::Context( string ns , Database * db, bool doauth ) : _client( currentClient.get() ) , _oldContext( _client->_context ) , _path( dbpath ) , _lock(0) , _justCreated(false) { assert( db && db->isOk() ); _ns = ns; _db = db; _client->_context = this; - _auth(); + if ( doauth ) + _auth(); } void Client::Context::_finishInit( bool doauth ){ diff --git a/db/client.h b/db/client.h index 8521f6e1642..ab4350949b4 100644 --- a/db/client.h +++ b/db/client.h @@ -96,7 +96,7 @@ namespace mongo { * if you are doing this after allowing a write there could be a race condition * if someone closes that db. this checks that the DB is still valid */ - Context( string ns , Database * db ); + Context( string ns , Database * db, bool doauth=true ); ~Context(); diff --git a/db/repl.cpp b/db/repl.cpp index 2a0e9f372d0..62b29867062 100644 --- a/db/repl.cpp +++ b/db/repl.cpp @@ -1539,14 +1539,14 @@ namespace mongo { Record *r; if ( strncmp( logNS, "local.", 6 ) == 0 ) { // For now, assume this is olog main if ( localOplogMainDetails == 0 ) { - Client::Context ctx("local."); + Client::Context ctx("local.", dbpath, 0, false); localOplogDB = ctx.db(); localOplogMainDetails = nsdetails(logNS); } - Client::Context ctx( "" , localOplogDB ); + Client::Context ctx( "" , localOplogDB, false ); r = theDataFileMgr.fast_oplog_insert(localOplogMainDetails, logNS, len); } else { - Client::Context ctx( logNS ); + Client::Context ctx( logNS, dbpath, 0, false ); assert( nsdetails( logNS ) ); r = theDataFileMgr.fast_oplog_insert( nsdetails( logNS ), logNS, len); } @@ -1718,6 +1718,10 @@ namespace mongo { sleepsecs(4); Client::initThread("replmaster"); while( 1 ) { + { + dblock lk; + cc().getAuthenticationInfo()->authorize("admin"); + } sleepsecs(10); /* write a keep-alive like entry to the log. this will make things like printReplicationStatus() and printSlaveReplicationStatus() stay up-to-date @@ -1835,6 +1839,7 @@ namespace mongo { { dblock lk; + cc().getAuthenticationInfo()->authorize("admin"); pairSync->init(); } |