From 478ff1148599ce6dd650d310a7bb4140b640cb30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 18 Dec 2015 05:43:44 +0100 Subject: GH-1355 do not allow setting LD_LIBRARY_PATh for Minecraft to the MultiMC bin folder --- logic/minecraft/MinecraftInstance.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/logic/minecraft/MinecraftInstance.cpp b/logic/minecraft/MinecraftInstance.cpp index 0dab4dfe..05dedf1d 100644 --- a/logic/minecraft/MinecraftInstance.cpp +++ b/logic/minecraft/MinecraftInstance.cpp @@ -132,6 +132,24 @@ QMap MinecraftInstance::getVariables() const return out; } +static QString processLD_LIBRARY_PATH(const QString & LD_LIBRARY_PATH) +{ + QDir mmcBin(QCoreApplication::applicationDirPath()); + auto items = LD_LIBRARY_PATH.split(':'); + QStringList final; + for(auto & item: items) + { + QDir test(item); + if(test == mmcBin) + { + qDebug() << "Env:LD_LIBRARY_PATH ignoring path" << item; + continue; + } + final.append(item); + } + return final.join(':'); +} + QProcessEnvironment MinecraftInstance::createEnvironment() { // prepare the process environment @@ -186,7 +204,7 @@ QProcessEnvironment MinecraftInstance::createEnvironment() } if(key == "GAME_LIBRARY_PATH") { - env.insert("LD_LIBRARY_PATH", value); + env.insert("LD_LIBRARY_PATH", processLD_LIBRARY_PATH(value)); continue; } #endif -- cgit v1.2.3