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

Make app compatible with Android 10+ by installing native libraries to /data/app #14

Open
rubenpgrady opened this issue Aug 20, 2024 · 4 comments

Comments

@rubenpgrady
Copy link

rubenpgrady commented Aug 20, 2024

Currently, the app downloads and installs the binaries to /data/user/0:

However, since Android 10 and the introduction of the W^X policy, it's not permitted to run binaries from an application's home directory in /data/user/0 (i.e. /data/data). On a rooted phone, it would be possible to install the binaries to /system/xbin to make them available system-wide. Unfortunately, oftentimes it's not an option to users to root their phone due to various reasons. However, as far as I understand, there is an alternative solution for non-rooted phones:

While exec() no longer works on files within the application home directory, it continues to be supported for files within the read-only /data/app directory. In particular, it should be possible to package the binaries into your application's native libs directory and enable android:extractNativeLibs=true, and then call exec() on the /data/app artifacts.

Source: https://issuetracker.google.com/issues/128554619

So what you could do, to continue to offer busybox on non-rooted phones, is to package the busybox binaries into the app as a native library. (There are a few rules regarding naming the file beginning lib and ending in .so, but that's it.) After installing the APK, due to extractNativeLibs=true, the files will be available under something like /data/app/<package name>/lib/arm/libbusybox.so to the whole system. No root required! Users can then symlink to that file or write shell scripts which include it.

Also, I've been suggesting adding this app to the F droid app store. However, a few fixes would be required to do so. For example, the busybox binaries should be built in this repository during APK building, too. So you include the busybox source code here, build busybox and include the resulting binary as a native library into your APK instead of downloading the binaries during app runtime. Also, you'd have to remove non-free libraries. See https://gitlab.com/fdroid/rfp/-/issues/2849 for more information.

Please let me know what you think. I'd appreciate it if you'd consider adding this feature.

Cheers
Ruben

@CamsShaft
Copy link

Wow, that's pretty sweet. I'm now on android 14 but it sounds like this is still possible on new devices too. I'm going to give it a shot. Thanks a lot for your reply, I completely forgot I even wrote this! Haha. I'll let you know how it went. Thanks again. Cheers.

@CamsShaft
Copy link

Here's an update so far, I found a busybox binary and as shell user went to /data/user/0/com.android.shell, mkdir files then moved the binary from /sdcard into the files folder I created and chmod +x busybox. The only thing I haven't looked into is figuring out how to make it stick in my $PATH. This is on a Samsung S22 Android 14. Could probably run a chroot or whatever in there. Anyways, nice to know it's close to being done

@wr3cckl3ss
Copy link

Good work lads. The Bear shall go to work. Cheers 🍻

@CamsShaft
Copy link

Yo @wr3cckl3ss, updated telegram and now I can't login. Keeps sending a login code to my telegram so it must be logged in somehow. Looks like I'm hooped for telegram for now bud. At work so I'll try again later

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

3 participants