termux-pacman / glibc-packages

Glibc packages for termux
MIT License
134 stars 19 forks source link

grun auto-translate interpreter ld.so and hook /tmp file-access libc-calls #239

Open leegao opened 6 months ago

leegao commented 6 months ago

Problem description

This is more of a hacky feature request / "could it work" question

I really like grun -c, and it feels like it should be possible to use the same ideas to automatically emulate the proper prefix path for fast on-the-fly translation somehow.

For interpreter:

  1. Check if the interpreter isn't either statically-linked, /system/bin/linker64, or /data/data/com.termux/files/usr/glibc/lib/ld*
  2. If not, then create a copy with the patchelf
  3. Do the same thing with all DT_NEEDED libraries transitively (maybe create a dedicated rpath copy for this)

For automatic /tmp, /etc, /share, /opt, /usr reroute:

  1. (for non-static libraries, still using libc without inlined syscalls) - you could offer a libwrap.so style hook+redirect that just rewrites all paths to prepend the prefix /data/data/com.termux/files/usr/glibc. This could even be something that you can specify as a filter, or only replay if the initial call fails.
  2. (otherwise) - offer a proot/ptrace style hooks (or tell them to use proot in a proper distro for e.g.)

System information

termux-info: