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

Support packages which depend on external native executables #605

Open
mhsmith opened this issue Apr 20, 2022 · 0 comments
Open

Support packages which depend on external native executables #605

mhsmith opened this issue Apr 20, 2022 · 0 comments

Comments

@mhsmith
Copy link
Member

mhsmith commented Apr 20, 2022

In #678 I did the obvious implementation of extracting chaquopy/bin and adding it to the PATH. However, when the targetSdk is 29 or higher, Android uses SELinux to block running executables in the data directory:

As stated in the issuetracker link above, the only workaround that's definitely supported by Google is to bundle the executables in the APK's lib directory and use extractNativeLibs to make sure they exist as separate files at runtime.

See related notes in #1198. Renaming the files to .so to make the Gradle plugin include them is probably fine, as long as SELinux would allow us to call them through symlinks in the data directory.

We'd need to detect either at build time or at runtime when an app contains an executable but the libs aren't extracted, and fail with an actionable error message mentioning extractNativeLibs.

But extractNativeLibs could cause significant wasted space if the lib directory also contained all the native ABI requirements, as #1198 would require. Other possible options to look into:

  • Is it possible to pass a ZIP path to exec as you can to dlopen?
  • Is it possible to use a ZIP path as the target of a symlink?
  • Where exactly is SELinux enforcing this? If it's in the exec system call, can we reimplement that somehow by forking and then mmapping the executable from the lib or assets dir of the APK? If the reimplementation happened within Python, this wouldn't fix executables called through native code, or through one executable calling another, but maybe neither of those things are actually needed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant