fix(nativeguest): a script interpreter reached through a bind runs as a guest program (#3112)

* fix(nativeguest): a script interpreter reached through a bind runs as a guest program

A Flatpak runtime binds its own /usr outside the sandbox root, so the hook
took #!/usr/bin/bash there for an Android program and handed it to the
kernel, which failed with "bad interpreter". An interpreter whose guest
path is a bind now starts like any guest program.

* Native hook: keep Android interpreters a bind reaches on the host

* Native hook: match the root of an interpreter on a folder boundary
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-11-23 23:42:04 -05:00
1 parent 5f2699e56b
commit e349d2544e
3 files changed
+50 -7

No files matched your search

+8 -4
View File
@@ -966,10 +966,14 @@ static void parse_shebang(char *hdr, char **interp, char **interp_arg) {
*interp_arg = arg;
}
// Interpreters outside the rootfs (Android's /system/bin/sh) run with Android's environment.
static int is_host_interpreter(const char *interp) {
return strncmp(interp, "/system", 7) == 0 ||
(g_ddnatv_root[0] != '\0' && strncmp(interp, g_ddnatv_root, g_ddnatv_root_len) != 0);
// Interpreters outside the rootfs and its binds (Android's /system/bin/sh) run with Android's environment.
static int is_host_interpreter(const char *interp, const char *rewritten) {
if (strncmp(rewritten, "/system", 7) == 0) return 1;
if (g_ddnatv_root[0] == '\0' || get_rootfs_subpath(rewritten)) return 0;
if (!is_mapped_guest_path(interp)) return 1;
struct exec_probe probe;
probe_exec_file(rewritten, &probe);
return probe.android_interp;
}
// argv for running `script` with its interpreter: interp [arg] script args... (the script's own