From d50c40c473fc538a40de558f4116425e02c02aaa Mon Sep 17 00:00:00 2001 From: kervala Date: Sat, 21 Nov 2015 17:39:49 +0100 Subject: [PATCH] Fixed: Unable to open URLs under Linux while using Steam Runtime --HG-- branch : develop --- code/nel/src/misc/common.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index a51851d87..c16b4b51e 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -768,6 +768,12 @@ bool launchProgram(const std::string &programName, const std::string &arguments, argv[i+1] = (char *) args[i].c_str(); } 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 (); ///////////////////////////////////////////////////////// @@ -779,10 +785,12 @@ 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) { - // Exec (the only allowed instruction after vfork) status = execvp(programName.c_str(), &argv.front()); @@ -795,6 +803,10 @@ 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; } #else