From 148914a1b006e7334f6646065f08643002689d9f Mon Sep 17 00:00:00 2001 From: surepy <24486494+surepy@users.noreply.github.com> Date: Thu, 13 Jun 2024 23:19:54 -0700 Subject: [PATCH 1/3] start the game with the sniper runtime & use tf.sh instead of doing the library work ourselves. see if this helps #37 --- tf2_bot_detector/Config/Settings.cpp | 4 +-- tf2_bot_detector/Platform/Linux/Processes.cpp | 3 +- .../SetupFlow/TF2CommandLinePage.cpp | 32 +++++++++---------- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/tf2_bot_detector/Config/Settings.cpp b/tf2_bot_detector/Config/Settings.cpp index 2e54cb63..15ebded8 100644 --- a/tf2_bot_detector/Config/Settings.cpp +++ b/tf2_bot_detector/Config/Settings.cpp @@ -276,13 +276,13 @@ std::string GeneralSettings::GetBinaryName() const switch (m_TFBinaryMode) { case TFBinaryMode::x64: case TFBinaryMode::x86: // ignored in linux - return "tf_linux64"; + return "tf.sh"; case TFBinaryMode::x86_legacy: return "hl2_linux"; }; // it might be probably better to error out? - return "tf_linux64"; + return "tf.sh"; } #endif diff --git a/tf2_bot_detector/Platform/Linux/Processes.cpp b/tf2_bot_detector/Platform/Linux/Processes.cpp index 6541f10f..150617a8 100644 --- a/tf2_bot_detector/Platform/Linux/Processes.cpp +++ b/tf2_bot_detector/Platform/Linux/Processes.cpp @@ -82,11 +82,10 @@ void tf2_bot_detector::Processes::Launch(const std::filesystem::path& executable // TODO: implement elevated? execute_command = fmt::format("{} {}", executable, args); - // we need to change cwd apparently + // we need to change cwd apparently? execute_command = fmt::format("cd {} && {} &", executable.parent_path(), execute_command); Log(execute_command); - system(execute_command.c_str()); } diff --git a/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp b/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp index b9f97d22..224086ad 100644 --- a/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp +++ b/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp @@ -229,10 +229,10 @@ static std::string FindUserLaunchOptions(const Settings& settings) /// static void OpenTF2(const Settings& settings, const std::string_view& rconPassword, uint16_t rconPort) { - const std::filesystem::path hl2Path = settings.GetTFDir() / ".." / settings.GetBinaryName(); + const std::filesystem::path gameEXE = settings.GetTFDir() / ".." / settings.GetBinaryName(); - if (!std::filesystem::exists(hl2Path)) { - LogError("Can't open this file! (empty() returned true) path={}", hl2Path); + if (!std::filesystem::exists(gameEXE)) { + LogError("Can't open this file! (empty() returned true) path={}", gameEXE); return; } @@ -280,23 +280,21 @@ static void OpenTF2(const Settings& settings, const std::string_view& rconPasswo if (args.length() > 512) { // the game will not launch, but let's try anyway. LogWarning("args length is >512! (={}) the game might (will) not launch!", args.length()); + // TODO: fail more dramatically, warn the user. } - // bad fix - char* library_path = getenv("LD_LIBRARY_PATH"); - const std::filesystem::path libPath32 = settings.GetTFDir() / ".." / "bin"; - const std::filesystem::path libPath64 = settings.GetTFDir() / ".." / "bin" / "linux64"; + // we have to run w/ sniper runtime lib apparently. + // TODO: is this correct path for sniper in all linux vers?? + // "TF2 requires the sniper container runtime" - tf.sh + const std::filesystem::path runtime_sniper = settings.GetSteamDir() / "ubuntu12_64" / "steam-runtime-sniper" / "run"; - std::string new_library_path = fmt::format("{}:{}:$LD_LIBRARY_PATH", libPath32.string(), libPath64.string()); - Log("[Linux] new LD_LIBRARY_PATH = {}", new_library_path); - setenv("LD_LIBRARY_PATH", new_library_path.c_str(), true); - setenv("SteamEnv", "1", true); -#endif - Processes::Launch(hl2Path, args); -#ifdef __linux__ - if (library_path) { - setenv("LD_LIBRARY_PATH", library_path, true); - } + // run the game with sniper w/ args. + // we now use tf.sh to handle libraries instead of calling tf_linux64 directly and handling libraries ourselves. + std::string sniper_args = fmt::format("\"{}\" -- \"{}\"", gameEXE.string(), args); + Processes::Launch(runtime_sniper, sniper_args); +#else + // if not linux we don't have to do all of that and just launch the game. + Processes::Launch(gameEXE, args); #endif } From 8a56cb5077766971e3d37b8b100e433600adc832 Mon Sep 17 00:00:00 2001 From: surepy <24486494+surepy@users.noreply.github.com> Date: Mon, 17 Jun 2024 21:13:09 -0700 Subject: [PATCH 2/3] fix vac aka fix insecure mode #37 --- tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp b/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp index 224086ad..a0cecadc 100644 --- a/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp +++ b/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp @@ -290,7 +290,11 @@ static void OpenTF2(const Settings& settings, const std::string_view& rconPasswo // run the game with sniper w/ args. // we now use tf.sh to handle libraries instead of calling tf_linux64 directly and handling libraries ourselves. - std::string sniper_args = fmt::format("\"{}\" -- \"{}\"", gameEXE.string(), args); + std::string sniper_args = fmt::format("--steam-app-id=440 --systemd-scope --keep-game-overlay \"{}\" -- {}", gameEXE.string(), args); + // probably do not need + setenv("SteamEnv", "1", true); + + // getenv("TF2BD_TF2_LD_PRELOAD") Processes::Launch(runtime_sniper, sniper_args); #else // if not linux we don't have to do all of that and just launch the game. From d4a33de57840f90f00a3d0953b452325aa9d5050 Mon Sep 17 00:00:00 2001 From: surepy <24486494+surepy@users.noreply.github.com> Date: Wed, 19 Jun 2024 05:09:37 -0700 Subject: [PATCH 3/3] use the correct sniper located in common --- tf2_bot_detector/Platform/Linux/Processes.cpp | 1 - .../SetupFlow/TF2CommandLinePage.cpp | 21 ++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tf2_bot_detector/Platform/Linux/Processes.cpp b/tf2_bot_detector/Platform/Linux/Processes.cpp index 150617a8..5bcabc37 100644 --- a/tf2_bot_detector/Platform/Linux/Processes.cpp +++ b/tf2_bot_detector/Platform/Linux/Processes.cpp @@ -80,7 +80,6 @@ void tf2_bot_detector::Processes::Launch(const std::filesystem::path& executable std::string execute_command; // TODO: implement elevated? - execute_command = fmt::format("{} {}", executable, args); // we need to change cwd apparently? execute_command = fmt::format("cd {} && {} &", executable.parent_path(), execute_command); diff --git a/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp b/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp index a0cecadc..35ebe502 100644 --- a/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp +++ b/tf2_bot_detector/SetupFlow/TF2CommandLinePage.cpp @@ -284,16 +284,31 @@ static void OpenTF2(const Settings& settings, const std::string_view& rconPasswo } // we have to run w/ sniper runtime lib apparently. - // TODO: is this correct path for sniper in all linux vers?? // "TF2 requires the sniper container runtime" - tf.sh - const std::filesystem::path runtime_sniper = settings.GetSteamDir() / "ubuntu12_64" / "steam-runtime-sniper" / "run"; + const std::filesystem::path runtime_sniper = settings.GetSteamDir()/"steamapps"/"common"/"SteamLinuxRuntime_sniper"/"run"; // run the game with sniper w/ args. // we now use tf.sh to handle libraries instead of calling tf_linux64 directly and handling libraries ourselves. std::string sniper_args = fmt::format("--steam-app-id=440 --systemd-scope --keep-game-overlay \"{}\" -- {}", gameEXE.string(), args); // probably do not need setenv("SteamEnv", "1", true); - + /* + setenv("PRESSURE_VESSEL_PREFIX", "1", true); + setenv("PRESSURE_VESSEL_VARIABLE_DIR", "1", true); + // TODO: disable game overlay if the user wants it disabled + + setenv("LD_PRELOAD", "1", true); + + setenv("STEAM_RUNTIME", "1", true); + + // copied from "steam-runtime-launch-options -- %command% -novid" + // https://gitlab.steamos.cloud/steamrt/steam-runtime-tools/-/blob/main/docs/slr-for-game-developers.md#using-steam-runtime-launch-options + std::string tf2_cmd = fmt::format("{} {}", gameEXE, args); + const std::string sniper_entrypoint = fmt::format("{}/steamapps/common/SteamLinuxRuntime_sniper/_v2-entry-point --verb=waitforexitandrun -- {}", settings.GetSteamDir(), tf2_cmd); + const std::string steam_launch_wrapper = fmt::format("{}/ubuntu12_32/steam-launch-wrapper -- {}", settings.GetSteamDir(), sniper_entrypoint); + // steam reaper + const std::string final_cmd = fmt::format("{}/ubuntu12_32/reaper SteamLaunch AppId=440 -- {}", settings.GetSteamDir(), steam_launch_wrapper); + */ // getenv("TF2BD_TF2_LD_PRELOAD") Processes::Launch(runtime_sniper, sniper_args); #else