Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Support secondary users via binary patching and extra slashes #2734

Open
chriswoope opened this issue Apr 24, 2022 · 3 comments
Open

Comments

@chriswoope
Copy link

Feature description

A better way to support secondary users than the ones proposed so far could be to set the prefix to something like /data/////////data/ or /data/././././data, with enough slashes or /.s to be able to binary patch all instances of it in files of the package upon package installation to /data/user/NN/ for all practical values of NN without changing the string length (looking into any gzip/bz2/xz/zip archives if any, with special handling of checksummed files if any).

While somewhat inelegant, it seems to me this is likely to work, with the exception of any non-standard compressed files or files with checksums (both of these are rare or nonexistent in common Linux packages and can be handled with ad-hoc code), or anything that doesn't like the paths not being canonical (also probably rare or non-existent, since due to the /usr merge everything is accessible via both / and /usr in common Linux distributions).

The few applications that might not work, if any, can be patched.

Unlike other solutions, it doesn't have any performance or functionality downside, although it might have some slight aesthetic downside and there's a small risk of breaking compatibility in existing installation (but it's possible to build all packages twice, once like now and once with this scheme).

Additional information

Yes for secondary users support. None known for binary patching.

@segfault-bilibili
Copy link

segfault-bilibili commented Jul 11, 2023

To summarize my thoughts in #2765 :

  1. According to AOSP source code, the (currently) max allowed userId is up to 21473.
  2. Adding redundant eliminate-able part to make longer equivalent path might break some simple string comparisons like [[ "$path1" == "/data/user/0/./././com.termux" ]] where path1 went through realpath but /data/user/0/./././com.termux didn't.
  3. There are references pointing to somewhere outside Termux's data directory, like /data/data/com.wireguard.android, which still needs to be handled.

Personally I suggest something like /data/user/0/com.termux/xxxxx/usr/ as the prefix. The number of x could be increased to be somewhat more future-proof.

In case it's installed as a secondary Android user (userId=10), the path should then be modified into /data/user/10/com.termux/xxxx/usr (only 4 x characters here, because 10 is one character longer than 0)

@romanovj
Copy link

romanovj commented Jul 15, 2023

I installed all required packages for home assistant (python, clang, rust, etc ...)

Moved termux to /data/local/tmp/termu

Hexpatched /data/data/com.termux -> /data/local/tmp/termu (with magiskboot hexpatch)

Then I installed home assistant without problems.

@basilgello
Copy link

As a long-term everyday Termux user and Debian maintainer, I came across this topic and decided to share some thoughts about the idea:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants