mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
make security work for repl pairs
This commit is contained in:
parent
8ba2174076
commit
ec434bd7c1
29
db/repl.cpp
29
db/repl.cpp
@ -194,26 +194,39 @@ namespace mongo {
|
||||
|
||||
class CmdIsMaster : public Command {
|
||||
public:
|
||||
virtual bool requiresAuth() { return false; }
|
||||
virtual bool slaveOk() {
|
||||
return true;
|
||||
}
|
||||
CmdIsMaster() : Command("ismaster") { }
|
||||
virtual bool run(const char *ns, BSONObj& cmdObj, string& errmsg, BSONObjBuilder& result, bool /*fromRepl*/) {
|
||||
/* currently request to arbiter is (somewhat arbitrarily) an ismaster request that is not
|
||||
authenticated.
|
||||
we allow unauthenticated ismaster but we aren't as verbose informationally if
|
||||
one is not authenticated for admin db to be safe.
|
||||
*/
|
||||
AuthenticationInfo *ai = authInfo.get();
|
||||
bool authed = ai == 0 || ai->isAuthorized("admin");
|
||||
|
||||
if ( allDead ) {
|
||||
result.append("ismaster", 0.0);
|
||||
if ( replPair )
|
||||
result.append("remote", replPair->remote);
|
||||
result.append("info", allDead);
|
||||
if( authed ) {
|
||||
if ( replPair )
|
||||
result.append("remote", replPair->remote);
|
||||
result.append("info", allDead);
|
||||
}
|
||||
}
|
||||
else if ( replPair ) {
|
||||
result.append("ismaster", replPair->state);
|
||||
result.append("remote", replPair->remote);
|
||||
if ( replPair->info.empty() )
|
||||
result.append("info", replPair->info);
|
||||
}
|
||||
if( authed ) {
|
||||
result.append("remote", replPair->remote);
|
||||
if ( !replPair->info.empty() )
|
||||
result.append("info", replPair->info);
|
||||
}
|
||||
}
|
||||
else {
|
||||
result.append("ismaster", 1);
|
||||
result.append("msg", "not paired");
|
||||
result.append("msg", "not paired");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user