From ba6a97557a0d90d77e9eba560931414e39042447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 28 May 2020 23:17:50 +0200 Subject: [PATCH] NOISSUE prevent evil from winning --- CMakeLists.txt | 11 ++++++++++- application/MultiMC.cpp | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 747ec5c8f..11b6b63f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,15 @@ cmake_minimum_required(VERSION 3.1) string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BUILD_DIR}" IS_IN_SOURCE_BUILD) if(IS_IN_SOURCE_BUILD) - message(AUTHOR_WARNING "You are building MultiMC in-source. This is NOT recommended!") + message(FATAL_ERROR "You are building MultiMC in-source. Please separate the build tree from the source tree.") +endif() + +if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + if(CMAKE_HOST_SYSTEM_VERSION MATCHES ".*[Mm]icrosoft.*" OR + CMAKE_HOST_SYSTEM_VERSION MATCHES ".*WSL.*" + ) + message(FATAL_ERROR "This is not a supported environment for any purpose and should never be used.") + endif() endif() if(WIN32) @@ -13,6 +21,7 @@ endif() project(MultiMC) enable_testing() + ##################################### Set CMake options ##################################### set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) diff --git a/application/MultiMC.cpp b/application/MultiMC.cpp index 393ea0467..6ab3ad26a 100644 --- a/application/MultiMC.cpp +++ b/application/MultiMC.cpp @@ -146,6 +146,28 @@ MultiMC::MultiMC(int &argc, char **argv) : QApplication(argc, argv) startTime = QDateTime::currentDateTime(); +#ifdef Q_OS_LINUX + { + QFile osrelease("/proc/sys/kernel/osrelease"); + if (osrelease.open(QFile::ReadOnly | QFile::Text)) { + QTextStream in(&osrelease); + auto contents = in.readAll(); + if( + contents.contains("WSL", Qt::CaseInsensitive) || + contents.contains("Microsoft", Qt::CaseInsensitive) || + true + ) { + showFatalErrorMessage( + "Unsupported system detected!", + "It seems you are supporting the exploitation of Free Software.\n\n" + "You smell bad and you should feel bad." + ); + return; + } + } + } +#endif + // Don't quit on hiding the last window this->setQuitOnLastWindowClosed(false);