From fc9ae2e9c2294fc1f65b61ce9f588e6537e029ae Mon Sep 17 00:00:00 2001 From: Ikey Doherty Date: Tue, 1 Jan 2019 14:14:39 +0000 Subject: [PATCH] shim: Use `setarch` instead of relying on `linux32` link On some distributions, `linux32` command is not readily available in the default install. However, `setarch` is commonly available as part of the `util-linux` packaging, so let's invoke `setarch` directly now without relying on links. Signed-off-by: Ikey Doherty --- TECHNICAL.md | 2 +- src/shim/shim.c | 24 ++++++++++-------------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/TECHNICAL.md b/TECHNICAL.md index cc4db99..b069812 100644 --- a/TECHNICAL.md +++ b/TECHNICAL.md @@ -196,7 +196,7 @@ Currently this INI file supports three options. The root section in this INI fil `force-32bit = $boolean` If set to a true boolean value (yes/true/on), the shadowed Steam binary will - be run via the `linux32` command. This will force the `steam` process + be run via the `setarch linux32` command. This will force the `steam` process and all children to believe they are running on a 32-bit system. This may be useful for 64-bit games that are buggy only on 64-bit. diff --git a/src/shim/shim.c b/src/shim/shim.c index d66cc58..944e07e 100644 --- a/src/shim/shim.c +++ b/src/shim/shim.c @@ -26,12 +26,6 @@ #include "lsi.h" #include "shim.h" -/** - * Required to force Steam into 32-bit detection mode, which is useful for - * recent issues like the CS:GO 64-bit update with huge FPS drops - */ -#define EMUL32BIN "linux32" - /** * Audit path is used for the libintercept library to ensure Steam only uses the * host SDL, etc. @@ -343,22 +337,24 @@ bool shim_bootstrap() static int shim_execute_internal(const char *command, int argc, char **argv, bool use_path) { bool is_x86_64; - const char *n_argv[argc + 3]; + const char *n_argv[argc + 5]; const char *exec_command = NULL; int i = 1; int8_t off = 1; int (*vfunc)(const char *, char *const argv[]) = NULL; is_x86_64 = lsi_system_is_64bit(); - memset(&n_argv, 0, sizeof(char *) * (argc + 3)); + memset(&n_argv, 0, sizeof(char *) * (argc + 5)); - /* If we're 64-bit and 32-bit is forced, proxy via linux32 */ + /* If we're 64-bit and 32-bit is forced, proxy via setarch linux32 */ if (lsi_config.force_32 && is_x86_64) { - exec_command = EMUL32BIN; - n_argv[0] = EMUL32BIN; - n_argv[1] = command; - off = 2; - /* Use linux32 in the path */ + exec_command = "setarch"; + n_argv[0] = "setarch"; + n_argv[1] = "linux32"; + n_argv[2] = "--"; + n_argv[3] = command; + off = 4; + /* Use setarch in the path */ vfunc = execvp; } else { /* Directly call lsi_exec_bin */