mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
ability to make a Client god for a little while
This commit is contained in:
parent
3146b3110b
commit
8fd95e2a19
@ -35,7 +35,8 @@ namespace mongo {
|
||||
_op(new CurOp()),
|
||||
_database(0), _ns("")/*, _nsstr("")*/
|
||||
,_shutdown(false),
|
||||
_desc(desc)
|
||||
_desc(desc),
|
||||
_god(0)
|
||||
{
|
||||
ai = new AuthenticationInfo();
|
||||
|
||||
@ -47,6 +48,7 @@ namespace mongo {
|
||||
delete _op;
|
||||
delete ai;
|
||||
ai = 0;
|
||||
_god = 0;
|
||||
if ( !_shutdown ) {
|
||||
cout << "ERROR: Client::shutdown not called!" << endl;
|
||||
}
|
||||
|
18
db/client.h
18
db/client.h
@ -31,6 +31,7 @@ namespace mongo {
|
||||
|
||||
class AuthenticationInfo;
|
||||
class Database;
|
||||
class ClientGod;
|
||||
struct CurOp;
|
||||
|
||||
class Client : boost::noncopyable {
|
||||
@ -45,6 +46,7 @@ namespace mongo {
|
||||
bool _shutdown;
|
||||
list<string> _tempCollections;
|
||||
const char *_desc;
|
||||
bool _god;
|
||||
public:
|
||||
AuthenticationInfo *ai;
|
||||
Top top;
|
||||
@ -77,6 +79,11 @@ namespace mongo {
|
||||
@return true if anything was done
|
||||
*/
|
||||
bool shutdown();
|
||||
|
||||
bool isGod(){ return _god; }
|
||||
|
||||
private:
|
||||
friend class ClientGod;
|
||||
};
|
||||
|
||||
/* defined in security.cpp */
|
||||
@ -91,4 +98,15 @@ namespace mongo {
|
||||
currentClient.reset( new Client(desc) );
|
||||
}
|
||||
|
||||
class ClientGod {
|
||||
public:
|
||||
ClientGod(){
|
||||
_prev = cc()._god;
|
||||
cc()._god = true;
|
||||
}
|
||||
~ClientGod(){
|
||||
cc()._god = _prev;
|
||||
}
|
||||
bool _prev;
|
||||
};
|
||||
};
|
||||
|
@ -135,6 +135,9 @@ namespace mongo {
|
||||
}
|
||||
}
|
||||
|
||||
if ( cc().isGod() )
|
||||
return true;
|
||||
|
||||
return strcmp( client, "local" ) == 0;
|
||||
}
|
||||
inline bool isMasterNs( const char *ns ) {
|
||||
|
Loading…
Reference in New Issue
Block a user