Repository navigation
fix: map the app's cache group like its real group - #10
Merged
Merged
Conversation
Android gives every app a cache group (app id - 10000 + 20000, e.g. u0_a515_cache = 20515) and makes the app's cache dir setgid to it. pr-cli binds that dir at /tmp, so files created there showed gid 20515 in a fake-root session instead of the fake group. fake_id0 now computes the cache gid from the real uid at initialization and keeps it in Config.app_cache_gid, only if PRoot's process is in that group (an app process is; run-as, the VM and desktop Linux get -1). fake_owner_gid() maps it like the real gid, so stat, statx and the USERLAND fstat path show the fake group.
In the app /tmp is the cache dir, setgid to the app's cache group; the test fails there before the fix (0:20515, want 0:0). Under run-as and in the VM /tmp is not the cache dir, so it passes either way.
proot-improvement.md section 35, the new fakeroot test, and test counts 54 -> 55.
libproot.so maps the app cache group; libpr-cli.so embeds the test binary with the /tmp group test.
oonid
force-pushed
the
fix/app-cache-gid
branch
from
October 17, 2026 10:05
2c86d29 to
2bdf722
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the app,
/tmpis the app's cache dir, which Android makes setgid to the app's cache group (u0_a515_cache, gid 20515). Files created there showed that gid in a fake-root session (ls -ln /tmp→0 20515), because the owner rule (#9) mapped only the app's primary gid. Found while verifying #9.multiuser_get_cache_gid: app id - 10000 + 20000) and keeps it inConfig.app_cache_gidonly if PRoot's process is in that group. An app process is;run-as, the VM and desktop Linux get(gid_t) -1, so nothing changes there.fake_owner_gid()maps it like the real gid, so stat, statx and the USERLAND fstat path show the fake group. The gid and the constants match bionic'su0_aNNNN_cachemapping (grp_pwd.cpp)./tmphasgeteuid():getegid(). Docs:proot-improvement.md§35, counts 54 → 55.Verification
/tmponly there): before the fix the new test fails (/tmp/pit-fr-tmp-group is 0:20515, want 0:0); after itfakeroot7/7 andls -ln /tmp/pitshows0 0.pit allfrom in-app terminals 55/55 on alpine and ubuntu;pr-cli test alpineandpr-cli test ubuntu55/55..l2s51/51 (ssh skipped), Ubuntu 26.04 55/55, fakeroot without link2symlink 7/7; as a uid != gid user general 9/9, chroot 2/2, fakeroot 7/7.cargo test169; every commit builds with only the 8 upstream warnings.libproot.soandlibpr-cli.sorebuild bit-identically from the branch.Found, not changed
Directories created in the app's
/tmpinherit the cache dir's setgid bit (drwxr-sr-x). Mode bits are not faked: the bit is real and decides the group of files created inside.