1
0
Fork 0

Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
Thomas Richter 2013-05-15 16:07:12 +02:00
commit 38ce7df1a8
13 changed files with 123 additions and 42 deletions

View File

@ -1,6 +1,8 @@
v1.4
------
* fixed usage of --temp-path in aranogd and arangosh
* issue #526: Unable to escape when an errorneous command is entered into the js shell
* issue #523: Graph and vertex methods for the javascript api

View File

@ -256,7 +256,7 @@ void ArangoServer::buildApplicationServer () {
// V8 engine
// .............................................................................
_applicationV8 = new ApplicationV8(_binaryPath, _tempPath);
_applicationV8 = new ApplicationV8(_binaryPath);
_applicationServer->addFeature(_applicationV8);
// .............................................................................
@ -411,9 +411,15 @@ void ArangoServer::buildApplicationServer () {
CLEANUP_LOGGING_AND_EXIT_ON_FATAL_ERROR();
}
// set the temp-path
if (_applicationServer->programOptions().has("temp-path")) {
TRI_SetUserTempPath((char*) _tempPath.c_str());
}
// dump version details
LOGGER_INFO(rest::Version::getVerboseVersionString());
// configure v8
if (_applicationServer->programOptions().has("development-mode")) {
_developmentMode = true;
_applicationV8->enableDevelopmentMode();

View File

@ -174,9 +174,8 @@ void ApplicationV8::V8Context::handleGlobalContextMethods () {
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
ApplicationV8::ApplicationV8 (string const& binaryPath, string const& tempPath)
ApplicationV8::ApplicationV8 (string const& binaryPath)
: ApplicationFeature("V8"),
_tempPath(tempPath),
_startupPath(),
_modulesPath(),
_packagePath(),
@ -739,7 +738,7 @@ bool ApplicationV8::prepareV8Instance (const size_t i) {
TRI_InitV8Buffer(context->_context);
TRI_InitV8Conversions(context->_context);
TRI_InitV8Utils(context->_context, _modulesPath, _packagePath, _tempPath);
TRI_InitV8Utils(context->_context, _modulesPath, _packagePath);
TRI_InitV8Shell(context->_context);
{

View File

@ -173,7 +173,7 @@ namespace triagens {
/// @brief constructor
////////////////////////////////////////////////////////////////////////////////
ApplicationV8 (string const&, string const&);
ApplicationV8 (string const&);
////////////////////////////////////////////////////////////////////////////////
/// @brief destructor
@ -345,12 +345,6 @@ namespace triagens {
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief temporary path
////////////////////////////////////////////////////////////////////////////////
string _tempPath;
////////////////////////////////////////////////////////////////////////////////
/// @brief path to the directory containing alternate startup scripts
///

View File

@ -2224,8 +2224,11 @@ void TRI_ReleaseCollectionVocBase (TRI_vocbase_t* vocbase, TRI_vocbase_col_t* co
////////////////////////////////////////////////////////////////////////////////
void TRI_InitialiseVocBase () {
// TODO: these two fcalls can probably be removed because we're initialising
// BasicsC anyway
TRI_InitialiseHashes();
TRI_InitialiseRandom();
TRI_GlobalInitStatementListAql();
ServerIdentifier = TRI_UInt16Random();

View File

@ -341,6 +341,11 @@ void ArangoClient::parse (ProgramOptions& options,
}
}
// set temp path
if (options.has("temp-path")) {
TRI_SetUserTempPath((char*) _tempPath.c_str());
}
// check if have a password
_hasPassword = options.has("server.password") ||
options.has("server.disable-authentication") ||
@ -668,14 +673,6 @@ void ArangoClient::setUsePager (bool value) {
_usePager = value;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the temporary path
////////////////////////////////////////////////////////////////////////////////
string const& ArangoClient::tempPath () const {
return _tempPath;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief gets endpoint to connect to as string
////////////////////////////////////////////////////////////////////////////////

View File

@ -325,12 +325,6 @@ namespace triagens {
void setUsePager (bool);
////////////////////////////////////////////////////////////////////////////////
/// @brief gets the temporary path
////////////////////////////////////////////////////////////////////////////////
string const& tempPath () const;
////////////////////////////////////////////////////////////////////////////////
/// @brief gets endpoint to connect to as string
////////////////////////////////////////////////////////////////////////////////

View File

@ -1454,7 +1454,8 @@ int main (int argc, char* argv[]) {
TRI_AddGlobalVariableVocbase(context, "SYS_OUTPUT", v8::FunctionTemplate::New(JS_PagerOutput)->GetFunction());
TRI_InitV8Buffer(context);
TRI_InitV8Utils(context, StartupModules, StartupPackages, BaseClient.tempPath());
TRI_InitV8Utils(context, StartupModules, StartupPackages);
TRI_InitV8Shell(context);
// reset the prompt error flag (will determine prompt colors)

View File

@ -67,6 +67,12 @@
static bool Initialised = false;
////////////////////////////////////////////////////////////////////////////////
/// @brief user-defined temporary path
////////////////////////////////////////////////////////////////////////////////
static char* TempPath;
////////////////////////////////////////////////////////////////////////////////
/// @brief names of blocking files
////////////////////////////////////////////////////////////////////////////////
@ -1746,7 +1752,8 @@ int TRI_GetTempName (char const* directory,
char* temp;
int tries;
temp = TRI_GetTempPath();
temp = TRI_GetUserTempPath();
if (directory != NULL) {
dir = TRI_Concatenate2File(temp, directory);
}
@ -1816,6 +1823,58 @@ int TRI_GetTempName (char const* directory,
return TRI_ERROR_INTERNAL;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief return the user-defined temp path, with a fallback to the system's
/// temp path if none is specified
////////////////////////////////////////////////////////////////////////////////
char* TRI_GetUserTempPath (void) {
if (TempPath == NULL) {
return TRI_GetTempPath();
}
return TRI_DuplicateString(TempPath);
}
////////////////////////////////////////////////////////////////////////////////
/// @brief set a new user-defined temp path
////////////////////////////////////////////////////////////////////////////////
void TRI_SetUserTempPath (char* path) {
if (TempPath != NULL) {
TRI_FreeString(TRI_CORE_MEM_ZONE, TempPath);
}
if (path == NULL) {
// unregister user-defined temp path
TempPath = NULL;
}
else {
// copy the user-defined temp path
TempPath = TRI_DuplicateString(path);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief initialise the files subsystem
////////////////////////////////////////////////////////////////////////////////
void TRI_InitialiseFiles (void) {
// clear user-defined temp path
TempPath = NULL;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief shutdown the files subsystem
////////////////////////////////////////////////////////////////////////////////
void TRI_ShutdownFiles (void) {
if (TempPath != NULL) {
// free any user-defined temp-path
TRI_FreeString(TRI_CORE_MEM_ZONE, TempPath);
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////

View File

@ -270,6 +270,31 @@ char* TRI_GetTempPath (void);
int TRI_GetTempName (char const*, char**, const bool);
////////////////////////////////////////////////////////////////////////////////
/// @brief return the user-defined temp path, with a fallback to the system's
/// temp path if none is specified
////////////////////////////////////////////////////////////////////////////////
char* TRI_GetUserTempPath (void);
////////////////////////////////////////////////////////////////////////////////
/// @brief set a new user-defined temp path
////////////////////////////////////////////////////////////////////////////////
void TRI_SetUserTempPath (char*);
////////////////////////////////////////////////////////////////////////////////
/// @brief initialise the files subsystem
////////////////////////////////////////////////////////////////////////////////
void TRI_InitialiseFiles (void);
////////////////////////////////////////////////////////////////////////////////
/// @brief shutdown the files subsystem
////////////////////////////////////////////////////////////////////////////////
void TRI_ShutdownFiles (void);
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////

View File

@ -27,6 +27,7 @@
#include "init.h"
#include "BasicsC/files.h"
#include "BasicsC/hashes.h"
#include "BasicsC/logging.h"
#include "BasicsC/mersenne.h"
@ -53,6 +54,7 @@ void TRI_InitialiseC (int argc, char* argv[]) {
TRI_InitialiseMemory();
TRI_InitialiseMersenneTwister();
TRI_InitialiseError();
TRI_InitialiseFiles();
TRI_InitialiseMimetypes();
TRI_InitialiseLogging(false);
TRI_InitialiseHashes();
@ -74,6 +76,7 @@ void TRI_ShutdownC () {
TRI_ShutdownHashes();
TRI_ShutdownLogging();
TRI_ShutdownMimetypes();
TRI_ShutdownFiles();
TRI_ShutdownError();
TRI_ShutdownMemory();
}

View File

@ -698,7 +698,7 @@ static v8::Handle<v8::Value> JS_GetTempPath (v8::Arguments const& argv) {
}
// return result
return scope.Close(v8::String::New(TempPath.c_str(), TempPath.size()));
return scope.Close(v8::String::New(TRI_GetUserTempPath()));
}
////////////////////////////////////////////////////////////////////////////////
@ -1693,16 +1693,24 @@ static v8::Handle<v8::Value> JS_RemoveRecursiveDirectory (v8::Arguments const& a
TRI_V8_EXCEPTION_PARAMETER(scope, "<path> must be a valid directory name");
}
if (TempPath.size() < 8) {
char* tempPath = TRI_GetUserTempPath();
if (tempPath == NULL || strlen(tempPath) < 6) {
// some security measure so we don't accidently delete all our files
TRI_FreeString(TRI_CORE_MEM_ZONE, tempPath);
TRI_V8_EXCEPTION_PARAMETER(scope, "temporary directory name is too short. will not remove directory");
}
const string path(*name);
if (path.substr(0, TempPath.size()) != TempPath) {
if (! TRI_EqualString2(path.c_str(), tempPath, strlen(tempPath))) {
TRI_FreeString(TRI_CORE_MEM_ZONE, tempPath);
TRI_V8_EXCEPTION_PARAMETER(scope, "directory to be removed is outside of temporary path");
}
TRI_FreeString(TRI_CORE_MEM_ZONE, tempPath);
int res = TRI_RemoveDirectory(*name);
if (res != TRI_ERROR_NO_ERROR) {
@ -2389,8 +2397,7 @@ v8::Handle<v8::Array> TRI_V8PathList (string const& modules) {
void TRI_InitV8Utils (v8::Handle<v8::Context> context,
string const& modules,
string const& packages,
string const& tempPath) {
string const& packages) {
v8::HandleScope scope;
// check the isolate
@ -2400,8 +2407,6 @@ void TRI_InitV8Utils (v8::Handle<v8::Context> context,
v8::Handle<v8::FunctionTemplate> ft;
v8::Handle<v8::ObjectTemplate> rt;
TempPath = tempPath;
// .............................................................................
// generate the general error template
// .............................................................................

View File

@ -65,12 +65,6 @@ class TRI_Utf8ValueNFC {
// --SECTION-- public constants
// -----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
/// @brief temporary path
////////////////////////////////////////////////////////////////////////////////
static std::string TempPath;
///////////////////////////////////////////////////////////////////////////////
/// @brief slot for a type
////////////////////////////////////////////////////////////////////////////////
@ -201,8 +195,7 @@ v8::Handle<v8::Array> TRI_V8PathList (std::string const& modules);
void TRI_InitV8Utils (v8::Handle<v8::Context>,
std::string const& modules,
std::string const& nodes,
std::string const& tempPath);
std::string const& nodes);
#endif