summaryrefslogtreecommitdiff
path: root/s/s_only.cpp
diff options
context:
space:
mode:
Diffstat (limited to 's/s_only.cpp')
-rw-r--r--s/s_only.cpp63
1 files changed, 60 insertions, 3 deletions
diff --git a/s/s_only.cpp b/s/s_only.cpp
index 78310fd..74ee9c0 100644
--- a/s/s_only.cpp
+++ b/s/s_only.cpp
@@ -15,11 +15,16 @@
* limitations under the License.
*/
-#include "../stdafx.h"
+#include "pch.h"
#include "../client/dbclient.h"
#include "../db/dbhelpers.h"
#include "../db/matcher.h"
+#include "../db/commands.h"
+/*
+ most a pile of hacks to make linking nicer
+
+ */
namespace mongo {
auto_ptr<CursorIterator> Helpers::find( const char *ns , BSONObj query , bool requireIndex ){
@@ -28,6 +33,58 @@ namespace mongo {
return i;
}
- // need this stub to reduce mongos link dependencies
- inline Matcher::~Matcher() { assert(!"this shouldn't be called"); }
+ boost::thread_specific_ptr<Client> currentClient;
+
+ Client::Client(const char *desc) :
+ _context(0),
+ _shutdown(false),
+ _desc(desc),
+ _god(0),
+ _lastOp(0)
+ {
+ }
+ Client::~Client(){}
+ bool Client::shutdown(){ return true; }
+
+ bool webHaveAdminUsers(){
+ return false;
+ }
+
+ BSONObj webGetAdminUser( const string& username ){
+ return BSONObj();
+ }
+
+ bool execCommand( Command * c ,
+ Client& client , int queryOptions ,
+ const char *ns, BSONObj& cmdObj ,
+ BSONObjBuilder& result,
+ bool fromRepl ){
+ assert(c);
+
+ string dbname = nsToDatabase( ns );
+
+ if ( cmdObj["help"].trueValue() ){
+ stringstream ss;
+ ss << "help for: " << c->name << " ";
+ c->help( ss );
+ result.append( "help" , ss.str() );
+ result.append( "lockType" , c->locktype() );
+ return true;
+ }
+
+ if ( c->adminOnly() ){
+ if ( dbname != "admin" ) {
+ result.append( "errmsg" , "access denied- use admin db" );
+ log() << "command denied: " << cmdObj.toString() << endl;
+ return false;
+ }
+ log( 2 ) << "command: " << cmdObj << endl;
+ }
+
+ string errmsg;
+ int ok = c->run( dbname , cmdObj , errmsg , result , fromRepl );
+ if ( ! ok )
+ result.append( "errmsg" , errmsg );
+ return ok;
+ }
}