mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 15:26:04 +00:00
fix(nativeguest): load glibc locales and iconv modules without proot (#3096)
* fix(nativeguest): load glibc locales and iconv modules without proot glibc opens its locale files and gconv modules with its own internal open(), which the hook never sees, so every program ran in the C locale and iconv knew only built-in charsets: Qt warned it could not switch to UTF-8, setlocale() failed for C.UTF-8 and the app's language, and iconv -t latin1 was unsupported. The hook now points LOCPATH and GCONV_PATH at the rootfs; droiddeck-fex keeps x86 guests on their own gconv modules. * test(nativeguest): the locale default test ignores the developer's own paths
This commit is contained in:
1 parent
59e98afae7
commit
ec31c9e2b6
4 files changed
+33
-1
No files matched your search
@@ -670,6 +670,8 @@ def guest_environment(fex, env):
|
||||
result.setdefault("FEX_SILENTLOG", "0")
|
||||
result.setdefault("FEX_OUTPUTLOG", "stderr")
|
||||
result.pop("GLIBC_TUNABLES", None)
|
||||
if "aarch64" in result.get("GCONV_PATH", ""):
|
||||
result["GCONV_PATH"] = ""
|
||||
result.setdefault("GC_DISABLE_INCREMENTAL", "1")
|
||||
if fex["portable"]:
|
||||
result["FEX_PORTABLE"] = "1"
|
||||
|
||||
@@ -84,6 +84,19 @@ static void init_ddnatv_hook(void) {
|
||||
setenv("TZDIR", tzdir_buf, 0);
|
||||
}
|
||||
|
||||
const char *curr_locpath = getenv("LOCPATH");
|
||||
if (!curr_locpath || curr_locpath[0] == '\0') {
|
||||
char locpath_buf[PATH_MAX];
|
||||
snprintf(locpath_buf, sizeof(locpath_buf), "%s/usr/lib/locale", g_ddnatv_root);
|
||||
setenv("LOCPATH", locpath_buf, 1);
|
||||
}
|
||||
|
||||
if (!getenv("GCONV_PATH")) {
|
||||
char gconv_buf[PATH_MAX];
|
||||
snprintf(gconv_buf, sizeof(gconv_buf), "%s/usr/lib/aarch64-linux-gnu/gconv", g_ddnatv_root);
|
||||
setenv("GCONV_PATH", gconv_buf, 0);
|
||||
}
|
||||
|
||||
const char *curr_cert = getenv("SSL_CERT_FILE");
|
||||
if (!curr_cert || curr_cert[0] == '\0' || strcmp(curr_cert, "/etc/ssl/certs/ca-certificates.crt") == 0) {
|
||||
char cert_buf[PATH_MAX];
|
||||
|
||||
@@ -1055,6 +1055,12 @@ class LaunchTest(FexTestCase):
|
||||
guest = FEX["guest_environment"]({"portable": True}, {"GLIBC_TUNABLES": "glibc.pthread.rseq=0"})
|
||||
self.assertNotIn("GLIBC_TUNABLES", guest)
|
||||
|
||||
def test_host_iconv_modules_stay_on_the_host(self):
|
||||
guest = FEX["guest_environment"]({"portable": True}, {"GCONV_PATH": "/r/usr/lib/aarch64-linux-gnu/gconv"})
|
||||
self.assertEqual(guest["GCONV_PATH"], "")
|
||||
own = FEX["guest_environment"]({"portable": True}, {"GCONV_PATH": "/opt/gconv"})
|
||||
self.assertEqual(own["GCONV_PATH"], "/opt/gconv")
|
||||
|
||||
def test_proton_runs_in_the_runtime_its_manifest_requires(self):
|
||||
self.fex_tool()
|
||||
self.runtime()
|
||||
|
||||
@@ -12,6 +12,7 @@ PROBE = r"""
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
@@ -20,6 +21,11 @@ int main(int argc, char **argv) {
|
||||
char cwd[4096];
|
||||
for (int i = 1; i < argc; i++) {
|
||||
struct stat st;
|
||||
if (strncmp(argv[i], "env:", 4) == 0) {
|
||||
const char *value = getenv(argv[i] + 4);
|
||||
printf("%s\t%s\n", argv[i], value ? value : "-");
|
||||
continue;
|
||||
}
|
||||
if (strncmp(argv[i], "cd:", 3) == 0) {
|
||||
int ok = chdir(argv[i] + 3) == 0 && getcwd(cwd, sizeof(cwd)) != NULL;
|
||||
printf("%s\t%s\n", argv[i], ok ? cwd : "-");
|
||||
@@ -120,7 +126,7 @@ class NativeHookMountTest(unittest.TestCase):
|
||||
def run_probe(self, *args):
|
||||
binds = f"{self.library}:/mnt/library|{self.private}:/mnt/private|{self.eqlen_src}:{self.eqlen_dst}"
|
||||
hook_env = {"DDNATV_ROOT": str(self.root), "DDNATV_BINDS": binds, "LD_PRELOAD": str(self.hook)}
|
||||
env = {k: v for k, v in os.environ.items() if k != "LD_PRELOAD"}
|
||||
env = {k: v for k, v in os.environ.items() if k not in ("LD_PRELOAD", "LOCPATH", "GCONV_PATH")}
|
||||
if self.prefix:
|
||||
cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")]
|
||||
else:
|
||||
@@ -147,6 +153,11 @@ class NativeHookMountTest(unittest.TestCase):
|
||||
path = f"/pfx/guest/dosdevices/z:{GAME}/game.txt"
|
||||
self.assertEqual(self.run_probe(path)[path], ["1", "library"])
|
||||
|
||||
def test_glibc_locale_and_iconv_data_come_from_the_rootfs(self):
|
||||
result = self.run_probe("env:LOCPATH", "env:GCONV_PATH")
|
||||
self.assertEqual(result["env:LOCPATH"], [f"{self.root}/usr/lib/locale"])
|
||||
self.assertEqual(result["env:GCONV_PATH"], [f"{self.root}/usr/lib/aarch64-linux-gnu/gconv"])
|
||||
|
||||
def test_rootfs_paths_outside_mounts_are_unchanged(self):
|
||||
paths = ["/pfx/native/dosdevices/z:/etc/hostname", f"{self.root}/etc/hostname", "/etc/hostname"]
|
||||
result = self.run_probe(*paths)
|
||||
|
||||
Reference in new issue
Block a user