termux / proot

An chroot-like implementation using ptrace.
https://wiki.termux.com/wiki/PRoot
Other
751 stars 161 forks source link

Add support for faccessat2 #179

Closed r1olo closed 2 years ago

michalbednarski commented 2 years ago

Overall looks nice, although it seems faccessat2 won't be available on Android as it is not on list of syscalls allowed by Androids seccomp policy and probably won't be

What was this tested with and what program needs faccessat2 to function? Was this on Android? (or this change is just for running proot on normal Linux)? If faccessat2 is required for program operation then on Android it would be necessary to add SIGSYS handler for it.

r1olo commented 2 years ago

Ah yes, my bad, I should have provided more info. This is to make proot work on normal Linux systems that implement the new faccessat2. I sent the pull request here and not to the original proot repo because Termux's fork doesn't crash and also supports statx system call (without that ls and other commands just don't work).

michalbednarski commented 2 years ago

Ok, thanks, merged.

Out of curiosity, is faccessat2 needed for any particular program?

r1olo commented 2 years ago

Yes, for example bash uses it to test whether a file is readable or writable ([[ -r $file]] and [[ -w $file ]]), so any script that relied on that was broken. pacman also uses it to check whether its database exists in the system.

michalbednarski commented 2 years ago

So I've re-checked and it looks like faccessat2 usage was introduced in glibc-2.33, with fallback to faccessat+fstatat64. That version wasn't yet released for Arch Linux ARM (aarch64), while Arch Linux (x86_64) ships glibc with fallback enabled (no __ASSUME_FACCESSAT2), so for Android current default proot fallback implementation return -ENOSYS; should be sufficient.

Anyway, thanks again, I didn't know about faccessat2 before