From e3a4cabf617c075f680b60652b6a5d81ff1b8a43 Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 17 Dec 2021 21:04:05 -0500 Subject: [PATCH] Stop Using Static QEMU --- debian/client-amd64 | 2 +- debian/server-amd64 | 2 +- docs/BUILDING.md | 2 +- launcher/src/bootstrap.c | 20 ++++++++++++++++++-- 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/debian/client-amd64 b/debian/client-amd64 index 59d8eafc4..ae1265473 100644 --- a/debian/client-amd64 +++ b/debian/client-amd64 @@ -4,4 +4,4 @@ Maintainer: TheBrokenRail Description: Fun with Blocks Homepage: https://www.minecraft.net/en-us/edition/pi Architecture: amd64 -Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1, qemu-user-static +Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, zenity, libgles1, libegl1, libglfw3 | libglfw3-wayland, libfreeimage3, libopenal1, qemu-user diff --git a/debian/server-amd64 b/debian/server-amd64 index 5c9e71b24..4ef2278ff 100644 --- a/debian/server-amd64 +++ b/debian/server-amd64 @@ -4,4 +4,4 @@ Maintainer: TheBrokenRail Description: Fun with Blocks Homepage: https://www.minecraft.net/en-us/edition/pi Architecture: amd64 -Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user-static +Depends: libc6, libstdc++6, libc6-armhf-cross, libstdc++6-armhf-cross, qemu-user diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 614b6aca7..545303bb8 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -28,7 +28,7 @@ ## Runtime Dependencies * Non-ARM Host Architectures - * QEMU User-Mode Static + * QEMU User-Mode * Host Architecture Dependencies * CLient Mode Only * OpenGL ES 1.1 diff --git a/launcher/src/bootstrap.c b/launcher/src/bootstrap.c index 4f7f46f9e..ddd7178a7 100644 --- a/launcher/src/bootstrap.c +++ b/launcher/src/bootstrap.c @@ -42,6 +42,19 @@ static void set_and_print_env(const char *name, char *value) { // Set The Value setenv(name, value, 1); } +#ifndef __ARM_ARCH +#define PASS_ENVIRONMENTAL_VARIABLE_TO_QEMU(name) \ + { \ + char *old_value = getenv("QEMU_SET_ENV"); \ + char *new_value = NULL; \ + /* Pass Variable */ \ + safe_asprintf(&new_value, "%s%s%s=%s", old_value == NULL ? "" : old_value, old_value == NULL ? "" : ",", name, getenv(name)); \ + setenv("QEMU_SET_ENV", new_value, 1); \ + free(new_value); \ + /* Reset Variable */ \ + RESET_ENVIRONMENTAL_VARIABLE(name); \ + } +#endif // Get Environmental Variable static char *get_env_safe(const char *name) { @@ -202,8 +215,11 @@ void bootstrap(int argc, char *argv[]) { // Run safe_execvpe(full_path, argv, environ); #else - // Use Static QEMU So It Isn't Affected By LD_* Variables -#define EXE_INTERPRETER "qemu-arm-static" + // Prevent QEMU From Being Modded + PASS_ENVIRONMENTAL_VARIABLE_TO_QEMU("LD_LIBRARY_PATH"); + PASS_ENVIRONMENTAL_VARIABLE_TO_QEMU("LD_PRELOAD"); + // Use QEMU +#define EXE_INTERPRETER "qemu-arm" // Create Arguments List char *new_argv[argc + 2]; for (int i = 1; i <= argc; i++) {