From 3fae0fe91f58ac51479bd7007c1c98673fc37e16 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 3 Jan 2016 17:51:09 +0100 Subject: [PATCH] Changed: Use LD_LIBRARY_PATH only when opening a document or URL --- code/nel/src/misc/common.cpp | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 8ad3488f6..4799ac10e 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -784,12 +784,6 @@ bool launchProgram(const std::string &programName, const std::string &arguments, } argv[i+1] = NULL; - // save LD_LIBRARY_PATH - const char *previousEnv = getenv("LD_LIBRARY_PATH"); - - // clear LD_LIBRARY_PATH to avoid problems with Steam Runtime - setenv("LD_LIBRARY_PATH", "", 1); - int status = vfork (); ///////////////////////////////////////////////////////// /// WARNING : NO MORE INSTRUCTION AFTER VFORK ! @@ -800,9 +794,6 @@ bool launchProgram(const std::string &programName, const std::string &arguments, char *err = strerror (errno); if (log) nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), errno, err); - - // restore previous LD_LIBRARY_PATH - setenv("LD_LIBRARY_PATH", previousEnv, 1); } else if (status == 0) { @@ -818,9 +809,6 @@ bool launchProgram(const std::string &programName, const std::string &arguments, else { //nldebug("LAUNCH: Successful launch '%s' with arg '%s'", programName.c_str(), arguments.c_str()); - - // restore previous LD_LIBRARY_PATH - setenv("LD_LIBRARY_PATH", previousEnv, 1); return true; } @@ -890,12 +878,6 @@ sint launchProgramAndWaitForResult(const std::string &programName, const std::st CloseHandle(pi.hThread); } #else - // save LD_LIBRARY_PATH - const char *previousEnv = getenv("LD_LIBRARY_PATH"); - - // clear LD_LIBRARY_PATH to avoid problems with Steam Runtime - setenv("LD_LIBRARY_PATH", "", 1); - // program name is the only required string std::string command = programName; @@ -905,9 +887,6 @@ sint launchProgramAndWaitForResult(const std::string &programName, const std::st // execute the command res = system(command.c_str()); - // restore previous LD_LIBRARY_PATH - setenv("LD_LIBRARY_PATH", previousEnv, 1); - if (res && log) nlwarning ("LAUNCH: Failed launched '%s' with arg '%s' return code %d", programName.c_str(), arguments.c_str(), res); #endif @@ -1253,8 +1232,18 @@ static bool openDocWithExtension (const char *document, const char *ext) return false; } - return launchProgram(command, document); + // save LD_LIBRARY_PATH + const char *previousEnv = getenv("LD_LIBRARY_PATH"); + // clear LD_LIBRARY_PATH to avoid problems with Steam Runtime + setenv("LD_LIBRARY_PATH", "", 1); + + bool res = launchProgram(command, document); + + // restore previous LD_LIBRARY_PATH + setenv("LD_LIBRARY_PATH", previousEnv, 1); + + return res; #endif // NL_OS_WINDOWS return false;