From 07781aa04e9263e678fecff936f78ef9b5f11dc1 Mon Sep 17 00:00:00 2001 From: Zewei Yang Date: Wed, 4 Feb 2026 11:11:20 +0800 Subject: [PATCH] [WRAPPER] avoid running ldconfig (static x86) Signed-off-by: Zewei Yang --- src/wrapped/wrappedlibc.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index af10a03b9..4d37e22ff 100644 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -2711,6 +2711,9 @@ EXPORT int32_t my_execlp(x64emu_t* emu, const char* path) EXPORT int32_t my_posix_spawn(x64emu_t* emu, pid_t* pid, const char* fullpath, const posix_spawn_file_actions_t *actions, const posix_spawnattr_t* attrp, char* const argv[], char* const envp[]) { + // Some distros call a statically linked x86 ldconfig in scriptlets; skip it. + const char* base = fullpath ? strrchr(fullpath, '/') : NULL; + base = base ? base + 1 : fullpath; int self = isProcSelf(fullpath, "exe"); int x64 = FileIsX64ELF(fullpath); int x86 = my_context->box86path?FileIsX86ELF(fullpath):0; @@ -2721,6 +2724,12 @@ EXPORT int32_t my_posix_spawn(x64emu_t* emu, pid_t* pid, const char* fullpath, if(envp == my_context->envv && environ) { envp = environ; } + if(base && !strcmp(base, "ldconfig")) { + const char* truepath = "/bin/true"; + char* const trueargv[] = { (char*)truepath, NULL }; + printf_log(LOG_INFO, "posix_spawn: skip ldconfig (%s)\n", fullpath); + return posix_spawn(pid, truepath, actions, attrp, trueargv, envp); + } if (x64 || x86 || script || self) { int n=1; while(argv[n]) ++n; @@ -2753,6 +2762,8 @@ EXPORT int32_t my_posix_spawnp(x64emu_t* emu, pid_t* pid, const char* path, // need to use BOX64_PATH / PATH here... char* fullpath = ResolveFileSoft(path, &my_context->box64_path); // use fullpath... + const char* base = fullpath ? strrchr(fullpath, '/') : NULL; + base = base ? base + 1 : fullpath; int self = isProcSelf(fullpath, "exe"); int x64 = FileIsX64ELF(fullpath); int x86 = my_context->box86path?FileIsX86ELF(path):0; @@ -2763,6 +2774,14 @@ EXPORT int32_t my_posix_spawnp(x64emu_t* emu, pid_t* pid, const char* path, if(envp == my_context->envv && environ) { envp = environ; } + if(base && !strcmp(base, "ldconfig")) { + const char* truepath = "/bin/true"; + char* const trueargv[] = { (char*)truepath, NULL }; + printf_log(LOG_INFO, "posix_spawnp: skip ldconfig (%s)\n", fullpath); + ret = posix_spawn(pid, truepath, actions, attrp, trueargv, envp); + box_free(fullpath); + return ret; + } if (x64 || x86 || script || self) { int n=1; while(argv[n]) ++n;