-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed: Ensure
am.apk
is not writable before loading it to prevent `…
…SIGABRT` on Android `>= 14` Closes termux/termux-packages#16255
- Loading branch information
1 parent
521ccb3
commit 598a9c0
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,25 @@ | ||
#!/data/data/com.termux/files/usr/bin/sh | ||
|
||
AM_APK_PATH="@TERMUX_PREFIX@/libexec/termux-am/am.apk" | ||
|
||
# If apk file is writable and current effective user is not root (0), | ||
# system (1000) and shell (2000), then remove write bit from apk | ||
# permissions for current used for Android >= 14 since it will trigger | ||
# the `SecurityException: Writable dex file '/path/to/am.apk' is not allowed.` | ||
# exception in logcat by SystemClassLoader and cause a SIGABRT for the | ||
# app_process. | ||
# - https://github.com/termux/termux-packages/issues/16255 | ||
# - https://developer.android.com/about/versions/14/behavior-changes-14#safer-dynamic-code-loading | ||
# - https://cs.android.com/android/_/android/platform/art/+/03ac3eb0fc36be97f301ac60e85e1bb7ca52fa12 | ||
# - https://cs.android.com/android/_/android/platform/art/+/d3a8a9e960d533f39b6bafc785599eae838a6351 | ||
# - https://cs.android.com/android/_/android/platform/art/+/03ac3eb0fc36be97f301ac60e85e1bb7ca52fa12:runtime/native/dalvik_system_DexFile.cc;l=335 | ||
if [ -w "$AM_APK_PATH" ]; then | ||
user="$(id -u)" | ||
if [ "$user" != "0" ] && [ "$user" != "1000" ] && [ "$user" != "2000" ]; then | ||
chmod 0400 "$AM_APK_PATH" || exit $? | ||
fi | ||
fi | ||
|
||
export CLASSPATH="$AM_APK_PATH" | ||
unset LD_LIBRARY_PATH LD_PRELOAD | ||
exec /system/bin/app_process -Xnoimage-dex2oat / com.termux.termuxam.Am "$@" |