Skip to content

Commit

Permalink
fix auth for serverStatus #527
Browse files Browse the repository at this point in the history
  • Loading branch information
leifwalsh committed Sep 21, 2013
1 parent 235cfa7 commit 02f5524
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/mongo/db/dbcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,14 +470,17 @@ namespace mongo {
virtual void help( stringstream& help ) const {
help << "returns lots of administrative server statistics";
}

virtual void addRequiredPrivileges(const std::string& dbname,
const BSONObj& cmdObj,
std::vector<Privilege>* out) {
ActionSet actions;
actions.addAction(ActionType::serverStatus);
out->push_back(Privilege(AuthorizationManager::SERVER_RESOURCE_NAME, actions));
}
bool run(const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result, bool fromRepl) {
long long start = Listener::getElapsedTimeMillis();
BSONObjBuilder timeBuilder(128);


bool authed = cc().getAuthenticationInfo()->isAuthorizedReads("admin");

result.append("host", prettyHostName() );
result.append("version", mongodbVersionString);
result.append("tokumxVersion", tokumxVersionString);
Expand Down Expand Up @@ -605,9 +608,6 @@ namespace mongo {
}
}

if ( ! authed )
result.append( "note" , "run against admin for more info" );

timeBuilder.appendNumber( "at end" , Listener::getElapsedTimeMillis() - start );
if ( Listener::getElapsedTimeMillis() - start > 1000 ) {
BSONObj t = timeBuilder.obj();
Expand Down

0 comments on commit 02f5524

Please sign in to comment.