Simulation::Simulation(bool vis_sim) { broad_phase_ = new btDbvtBroadphase(); collision_configuration_ = new btDefaultCollisionConfiguration(); dispatcher_ = new btCollisionDispatcher(collision_configuration_); solver_ = new btSequentialImpulseConstraintSolver; dynamics_world_ = new btDiscreteDynamicsWorld(dispatcher_, broad_phase_, solver_, collision_configuration_); time_to_simulate_ = SettingsManager::Instance()->GetSimulationTime(); counter_ = 0.0; fps_ = 60; vis_sim_ = vis_sim; // Material ground_material_.texture_diffuse_type = CHECKERBOARD; light_material_.texture_diffuse_type = LIGHTSOURCE; // no self collision bt_creature_collidies_with_ = collisiontypes::COL_GROUND; ground_collidies_with_ = collisiontypes::COL_CREATURE; SetupEnvironment(); }
pid_t HandleWebsocketExecRequest(STREAM *ClientCon, char *Data) { char *Tempstr=NULL, *Name=NULL, *Value=NULL; char *ScriptPath=NULL; int result, i; HTTPSession *Response; //We will never read from this stream again. Any further data will be read //by the process we spawn off ClientCon->State |= SS_EMBARGOED; Response=ParseSessionInfo(Data); CleanStr(Response->Path); CleanStr(Response->SearchPath); CleanStr(Response->StartDir); ScriptPath=FindFileInPath(ScriptPath, Response->Path, Response->SearchPath); LogToFile(Settings.LogPath,"Script: Found=[%s] SearchPath=[%s] ScriptName=[%s] Arguments=[%s]", ScriptPath, Response->SearchPath, Response->Path, Response->Arguments); if (access(ScriptPath,F_OK) !=0) { LogToFile(Settings.LogPath,"No such script: %s in path %s = %s",Response->Path, Response->SearchPath, ScriptPath); } else if ( (access(ScriptPath,X_OK) !=0) || (! CheckScriptIntegrity(ScriptPath)) ) { LogToFile(Settings.LogPath,"Cannot execute script: %s", ScriptPath); } else { STREAMFlush(ClientCon); result=fork(); if (result==0) { //do this so that when we exec the script, anything output goes to the client close(0); dup(ClientCon->in_fd); close(1); dup(ClientCon->out_fd); if (! SwitchGroup(Response->Group)) { LogToFile(Settings.LogPath,"WARN: Failed to switch to group '%s' to execute script: %s using handler '%s'", Response->RealUser, ScriptPath, Tempstr); } //Switch user. ALAYA WILL NOT RUN SCRIPTS AS ROOT! if (! SwitchUser(Response->RealUser)) { LogToFile(Settings.LogPath,"ERROR: Failed to switch to user '%s' to execute script: %s using handler '%s'", Response->RealUser, ScriptPath, Tempstr); LogFileFlushAll(TRUE); _exit(0); } if (geteuid()==0) { LogToFile(Settings.LogPath, "Failed to switch user to '%s' for running a .cgi program. Will not run programs as 'root'. Set 'DefaultUser' in config file or command line.", Response->RealUser); } else { SetupEnvironment(Response, ScriptPath); Tempstr=FindScriptHandlerForScript(Tempstr,ScriptPath); if (Tempstr) LogToFile(Settings.LogPath,"Execute script: %s using handler '%s'",ScriptPath,Tempstr); else LogToFile(Settings.LogPath,"Execute script: %s QUERY_STRING= '%s'",ScriptPath,getenv("QUERY_STRING")); //Only do this late! Otherwise logging won't work. for (i=3; i < 1000; i++) close(i); if (StrLen(Tempstr)) execl(Tempstr, Tempstr, ScriptPath,NULL); else execl(ScriptPath,ScriptPath,NULL); //Logging won't work after we've closed all the file descriptors! LogToFile(Settings.LogPath,"Cannot execute script: %s",ScriptPath); } LogFileFlushAll(TRUE); _exit(0); } else { } } HTTPSessionDestroy(Response); DestroyString(ScriptPath); DestroyString(Tempstr); DestroyString(Name); DestroyString(Value); //Always return STREAM_CLOSED, so that pipe gets closed regardless of exit status of //forked helper process return(STREAM_CLOSED); }
// This is all you need to run all the tests int main(int argc, char *argv[]) { SetupEnvironment(); SetupNetworking(); SelectParams(CBaseChainParams::MAIN); noui_connect(); ClearDatadirCache(); fs::path pathTemp = fs::temp_directory_path() / strprintf("test_bitcoin-qt_%lu_%i", (unsigned long)GetTime(), (int)GetRand(100000)); fs::create_directories(pathTemp); gArgs.ForceSetArg("-datadir", pathTemp.string()); bool fInvalid = false; // Prefer the "minimal" platform for the test instead of the normal default // platform ("xcb", "windows", or "cocoa") so tests can't unintentionally // interfere with any background GUIs and don't require extra resources. #if defined(WIN32) _putenv_s("QT_QPA_PLATFORM", "minimal"); #else setenv("QT_QPA_PLATFORM", "minimal", 0); #endif // Don't remove this, it's needed to access // QApplication:: and QCoreApplication:: in the tests QApplication app(argc, argv); app.setApplicationName("Bitcoin-Qt-test"); SSL_library_init(); URITests test1; if (QTest::qExec(&test1) != 0) { fInvalid = true; } #if defined(ENABLE_WALLET) && defined(ENABLE_BIP70) PaymentServerTests test2; if (QTest::qExec(&test2) != 0) { fInvalid = true; } #endif RPCNestedTests test3; if (QTest::qExec(&test3) != 0) { fInvalid = true; } CompatTests test4; if (QTest::qExec(&test4) != 0) { fInvalid = true; } #ifdef ENABLE_WALLET WalletTests test5; if (QTest::qExec(&test5) != 0) { fInvalid = true; } AddressBookTests test6; if (QTest::qExec(&test6) != 0) { fInvalid = true; } #endif fs::remove_all(pathTemp); return fInvalid; }
int main(int argc, char *argv[]) { SetupEnvironment(); return (AppInit(argc, argv) ? 0 : 1); }