termux-api
termux-api copied to clipboard
no output and no exit
Problem description
When running a termux-api command, it does not give any output and doesnt exit, I have seen a solution using some menu called "protected apps", but no such menu exists on this phone
Steps to reproduce
Run any termux-api command
Expected behavior
The command should give its output or exit without output.
Additional information
- Termux application version: 0.98
- Android OS version: 10
- Device model: Nokia 2.2
Have you install the termux-api app?
Yes, I have also installed the termux-api package
What version of the termux-api app do you have? Which commands have you tried?
I tried most commands, some of them only dont exit when they have arguments but give back a message when not supplied with any, the version is 0.43
I'm seeing this as well. Termux and Api both installed from Google Play, both recently (this is a new device for me). Checking now, Play store shows both as up to date.
I used strace
to watch what was happening while trying to set clipboard.
[ much left out ]
mprotect(0x7b6618f000, 409600, PROT_READ) = 0
mprotect(0x7b66242000, 409600, PROT_READ) = 0
mprotect(0x7b660f7000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0x7b660f7000, 4096, PROT_READ) = 0
rt_sigaction(SIGCHLD, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTART|SA_NOCLDSTOP|SA_NOCLDWAIT}, NULL, 8) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 4
bind(3, {sa_family=AF_UNIX, sun_path=@"67f1558812369107-2178-4020-88c6-c8d543d74a0e4cbe1a2a07cd"}, 59) = 0
bind(4, {sa_family=AF_UNIX, sun_path=@"e9589d54c755a07c-2178-4440-90d4-177e860e788bf12056a2911e"}, 59) = 0
listen(3, 1) = 0
listen(4, 1) = 0
clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7b663fb558) = 8570
accept4(3, 0x7fe1282f70, [110], 0) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8570, si_uid=10119, si_status=0, si_utime=61, si_stime=20} ---
accept4(3,
So it's running but never sees anything on the socket. Near as I can tell, I've given every permission needed to Termux and Termux:Api. Yet this error smacks of some sort of Android process sandboxing.
I had exactly the symptoms as described here. I.e. all 'termux-xxx' api cmds hung, preferedly in accept(4(3,..
Application version: 0.117 Packages CPU architecture: aarch64 Android version: 10 Kernel build information: Linux localhost 4.9.190+ #1 SMP PREEMPT Fri May 28 06:32:11 CST 2021 aarch64 Android Device manufacturer: Ulefone Device model: Note 9P
lastest termux-api version from f-droid: 0.49
I now installed the ulefone update "NOTE_9P_SH1_EEA_V02_20210528-0806"
that fixed the issue completely. No longer probs with any termux-xxx cmd so far
Same problem here. Android 11 (LineageOS 18.1) termux-api hangs, no output, no exit.
Update: temux-api works directly on termux shell but doesn't work on chroot.
I'm using the same script to chroot that I used in Android 9, but in Android 11 doesn't work.
F-Droid version of termux and termux-api.
The termux-api package was installed as is, apt update && apt install termux-api
user uid in termux:
~ $ id
uid=10186(u0_a186) gid=10186(u0_a186) groups=10186(u0_a186),3003(inet),9997(everybody),20186(u0_a186_cache),50186(all_a186)
user uid in Gentoo chroot environment:
user@localhost ~ $ id
uid=10186(user) gid=10186(user) groups=10186(user),7(lp),100(users),106(lpadmin),332(scanner),1003(pc_data),1015(aid_sdcard_rw),1023(aid_media_rw),2000(aid_shell),3003(aid_inet),9997(aid_everybody),20186(aid_user_cache),50186(aid_user_all)
If you need a log file or any help, tell me.
Regards, Vasile.
Seems I'm experiencing the exact same issue as Vasile ... https://github.com/termux/proot/issues/23#issuecomment-1012258586 Any feedback or suggestions will be appreciated !
@mvasi90 To have it working in chroot, you need properly configured bind-mounts and environment variables. Things have been changed since Android 10 and old script won't work.
Needed variables:
ANDROID_ART_ROOT
ANDROID_DATA
ANDROID_I18N_ROOT
ANDROID_ROOT
ANDROID_RUNTIME_ROOT
ANDROID_TZDATA_ROOT
BOOTCLASSPATH
DEX2OATBOOTCLASSPATH
EXTERNAL_STORAGE
Needed mounts:
/apex
/linkerconfig/ld.config.txt
/data/dalvik-cache
/data/data/com.termux/files/usr
/system
/vendor
# file, if exists
/plat_property_contexts
# file, if exists
/property_contexts
If you are running real chroot, you may face SELinux context mismatch issue as well as permission denials due to uid/gid mismatch.
I'm on Android 9. Implementing none of the above helped unfortunately (with exception of SELinux bit as I'm not sure how to validate that.) What I can say is that I am able to execute termux-api commands as root, in the termux window, so permissions don't seem to be the problem. And also, that I have permissive mode enabled, so doesn't that rule out SELinux problems?.
As a side note to this matter, that the lack of error verboseness on the output (or ability to seemingly debug the issue, for that matter) seems quite alarming. The command just sits there hanging indefinitely, which is not right surely ? It should at least terminate with an error if it fails to complete the task or something, or have a sane timeout even if it's upward of 10 minutes or something ?
I'll be looking at tasker+intents and termux's native cli/environment as an alternative means of implementing what I need, but I'm really hoping this can be figured out as I'd prefer to keep all scripting within my chroot image if possible
@xeffyr Thank you. I already have all the variables im the script but it doesn't work.
I have also tried LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so /data/data/com.termux/files/usr/bin/termux-clipboard-get
. It doesn't work.
Here is my chroot script:
#!/system/xbin/bash
# Gentoo chroot on Android
#
# Author: Vasile M.
# 2021-08-16
[[ "`id -u`" -ne 0 ]] && sudo bash "$0" && exit
LOOP="loop2"
CHROOT="/data/gentoo"
IMAGE="/data/data/com.termux/files/home/gentoo-chriot.img"
ce() {
if [[ "$1" -ne 0 ]];then
echo "$2"
[[ "$3" ]] && exit $3
fi
}
# Umouting
um() {
# kill all processes that are using the chroot folder
ps=(`lsof -Fp "$CHROOT" | sed "s/^p//"`)
for pid in "${ps[@]}"; do
kill -9 "$pid"
done
umount "$CHROOT/dev/pts"
umount "$CHROOT/dev/shm"
umount "$CHROOT/dev/binderfs"
umount "$CHROOT/dev"
umount "$CHROOT/data/dalvik-cache"
umount "$CHROOT/vendor"
umount "$CHROOT/sys"
umount "$CHROOT/linkerconfig"
umount "$CHROOT/system"
umount "$CHROOT/odm"
umount "$CHROOT/sdcard"
umount "$CHROOT/proc"
umount "$CHROOT/tmp"
umount "$CHROOT/data/data"
cd "$CHROOT/apex"
for f in *; do
umount "$CHROOT/apex/$f"
done
cd - 2>&1 > /dev/null
umount "$CHROOT"
# detaching is not needed. Device is auto detached when the mount point is unmounted
#losetup -d /dev/block/$LOOP
}
if [[ "$1" != "" ]]; then
case "$1" in
umount|exit)
um
;;
*)
echo "Allowed options are: umount and exit (both used to unmount the chroot)."
;;
esac
exit
fi
# Skip the mounting process if chroot is already mounted
grep "$CHROOT" /proc/mounts -q 2>&1 > /dev/null
if [[ "$?" -ne 0 ]]; then
# preparing chroot
mkdir -p "$CHROOT"
ce $? "Error creating $CHROOT" 1
losetup /dev/block/$LOOP "$IMAGE"
ce $? "Error attaching $IMAGE to /dev/block/$LOOP" 6
mount -o noatime,barrier=0,commit=60 /dev/block/$LOOP "$CHROOT"
ce $? "Error mounting /dev/block/$LOOP to $CHROOT" 7
# From Android 10, the /apex folder is needed
mkdir -p "$CHROOT/apex"
ce $? "Error creating /apex" 1
cd "/apex"
for f in *; do
mkdir -p "$CHROOT/apex/$f"
done
cd - 2>&1 > /dev/null
# Creating mountpoints
mkdir -p "$CHROOT/data/data"
ce $? "Error creating /data/data" 1
mkdir -p "$CHROOT/dev/shm"
ce $? "Error creating /dev/shm" 2
mkdir -p "$CHROOT/dev/binderfs"
ce $? "Error creating /dev/binderfs" 2
mkdir -p "$CHROOT/data/dalvik-cache"
ce $? "Error creating /data/dalvik-cache" 3
mkdir -p "$CHROOT/vendor"
ce $? "Error creating /vendor" 4
mkdir -p "$CHROOT/system"
ce $? "Error creating /system" 5
mkdir -p "$CHROOT/odm"
ce $? "Error creating /odm" 5
mkdir -p "$CHROOT/sdcard"
ce $? "Error creating /sdcard" 6
mkdir -p "$CHROOT/linkerconfig"
ce $? "Error creating /linkerconfig" 5
# Mounting
mount --rbind /dev "$CHROOT/dev"
ce $? "Error mounting /dev" 7
mkdir -p "$CHROOT/dev/shm"
ce $? "Error creating /dev/shm after mounting /dev" 8
mkdir -p "$CHROOT/dev/binderfs"
ce $? "Error creating /dev/binderfs" 8
# From Android 10, /apex is needed
cd /apex
for f in *; do
mount --rbind "/apex/$f" "$CHROOT/apex/$f"
ce $? "Error mounting /apex/$f" 15
done
cd - 2>&1 > /dev/null
mount -o bind /data/dalvik-cache "$CHROOT/data/dalvik-cache"
ce $? "Error mounting /data/dalvik-cache" 9
mount --rbind /vendor "$CHROOT/vendor"
ce $? "Error mounting /vendor" 11
mount --rbind /dev/pts "$CHROOT/dev/pts"
ce $? "Error mounting /dev/pts" 12
mount --rbind /dev/binderfs "$CHROOT/dev/binderfs"
ce $? "Error mounting /dev/binderfs" 12
mount -t tmpfs -o nosuid,nodev,noexec shm "$CHROOT/dev/shm"
ce $? "Error mounting /dev/shm" 13
mount --rbind /sys "$CHROOT/sys"
ce $? "Error mounting /sys" 14
mount --rbind /system "$CHROOT/system"
ce $? "Error mounting /system" 15
mount --rbind /odm "$CHROOT/odm"
ce $? "Error mounting /odm" 15
mount --rbind /linkerconfig "$CHROOT/linkerconfig"
ce $? "Error mounting /linkerconfig" 15
mount --rbind /sdcard "$CHROOT/sdcard"
ce $? "Error mounting /sdcard" 16
mount --rbind /proc "$CHROOT/proc"
#mount -t proc /proc "$CHROOT/proc"
ce $? "Error mounting /proc" 17
mount -t tmpfs tmpfs "$CHROOT/tmp"
ce $? "Error mounting tmpfs" 18
mount -o bind /data/data "$CHROOT/data/data"
ce $? "Error mounting /data/data" 19
sed "/export ANDROID_DATA=\"\/data\"/d" -i "$CHROOT/etc/profile"
echo "export ANDROID_DATA=\"/data\"" >> "$CHROOT/etc/profile"
sed "/export ANDROID_ROOT=\"\/system\"/d" -i "$CHROOT/etc/profile"
echo "export ANDROID_ROOT=\"/system\"" >> "$CHROOT/etc/profile"
sed "/export ANDROID_ART_ROOT=\"\/apex\/com.android.art\"/d" -i "$CHROOT/etc/profile"
echo "export ANDROID_ART_ROOT=\"/apex/com.android.art\"" >> "$CHROOT/etc/profile"
sed "/export ANDROID_RUNTIME_ROOT=\"\/apex\/com.android.runtime\"/d" -i "$CHROOT/etc/profile"
echo "export ANDROID_RUNTIME_ROOT=\"/apex/com.android.runtime\"" >> "$CHROOT/etc/profile"
sed "/export ANDROID_I18N_ROOT=\"\/apex\/com.android.i18n\"/d" -i "$CHROOT/etc/profile"
echo "export ANDROID_I18N_ROOT=\"/apex/com.android.i18n\"" >> "$CHROOT/etc/profile"
sed "/export ANDROID_TZDATA_ROOT=\"\/apex\/com.android.tzdata\"/d" -i "$CHROOT/etc/profile"
echo "export ANDROID_TZDATA_ROOT=\"/apex/com.android.tzdata\"" >> "$CHROOT/etc/profile"
sed "/export BOOTCLASSPATH=\"/d" -i "$CHROOT/etc/profile"
echo "export BOOTCLASSPATH=\"/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/core-icu4j.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/framework-atb-backward-compatibility.jar:/system/framework/telephony-ext.jar:/system/framework/WfdCommon.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.media/javalib/updatable-media.jar:/apex/com.android.mediaprovider/javalib/framework-mediaprovider.jar:/apex/com.android.os.statsd/javalib/framework-statsd.jar:/apex/com.android.permission/javalib/framework-permission.jar:/apex/com.android.sdkext/javalib/framework-sdkextensions.jar:/apex/com.android.wifi/javalib/framework-wifi.jar:/apex/com.android.tethering/javalib/framework-tethering.jar\"" >> "$CHROOT/etc/profile"
sed "/export DEX2OATBOOTCLASSPATH=\"/d" -i "$CHROOT/etc/profile"
echo "export DEX2OATBOOTCLASSPATH=\"/apex/com.android.art/javalib/core-oj.jar:/apex/com.android.art/javalib/core-libart.jar:/apex/com.android.art/javalib/core-icu4j.jar:/apex/com.android.art/javalib/okhttp.jar:/apex/com.android.art/javalib/bouncycastle.jar:/apex/com.android.art/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/framework-atb-backward-compatibility.jar:/system/framework/telephony-ext.jar:/system/framework/WfdCommon.jar\"" >> "$CHROOT/etc/profile"
sed "/export DISPLAY=\":1\"/d" -i "$CHROOT/etc/profile"
echo "export DISPLAY=\":1\"" >> "$CHROOT/etc/profile"
sed "/export EXTERNAL_STORAGE=\"/d" -i "$CHROOT/etc/profile"
echo "export EXTERNAL_STORAGE=\"/sdcard/\"" >> "$CHROOT/etc/profile"
fi
unset LD_PRELOAD
unset PREFIX
setarch aarch64 chroot "$CHROOT" /bin/bash -l -c "su - user"
wait
while :; do
echo -n "Unmount chroot? [Y/n]: "
read conf
case "$conf" in
""|y|Y)
um
break
;;
"n")
break
;;
esac
done
Try running some Termux:API command and then run logcat
to collect Android logs. Post logs there.
Copy /plat_property_contexts and /property_contexts (whatever exists) to the root directory of chroot image.
Here is my chroot script:
#!/system/xbin/bash
Probably a good idea to use termux's bash as well
Try running some Termux:API command and then run
logcat
to collect Android logs. Post logs there.
Thanks for this suggestion. I do get an error in logcat when I do this.
chroot:
root@localhost:/# /data/data/com.termux/files/usr/bin/termux-clipboard-get
Android:
--------- beginning of main 01-14 12:49:03.123 8297 8297 E com.termux.api: Not starting debugger since process cannot load the jdwp agent. 01-14 12:49:03.254 8297 8315 E termux-api: Error in ResultReturner 01-14 12:49:03.254 8297 8315 E termux-api: java.io.IOException: Permission denied 01-14 12:49:03.254 8297 8315 E termux-api: at android.net.LocalSocketImpl.connectLocal(Native Method) 01-14 12:49:03.254 8297 8315 E termux-api: at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:292) 01-14 12:49:03.254 8297 8315 E termux-api: at android.net.LocalSocket.connect(LocalSocket.java:145) 01-14 12:49:03.254 8297 8315 E termux-api: at com.termux.api.util.b.b(Unknown Source:23) 01-14 12:49:03.254 8297 8315 E termux-api: at com.termux.api.util.a.run(Unknown Source:8) 01-14 12:49:03.254 8297 8315 E termux-api: at java.lang.Thread.run(Thread.java:764)
But only when using @mvasi90 's chroot script with all the Android 10 bits (/apex etc) commented out. My own chroot script doesn't even show anything in logcat, I'll need to compare them to figure out what is different that causes this
Interestingly, using @mvasi90's script, some of the commands are "half-working" for me now, like termux-vibrate
(ie, my phone actually vibrates). But all of them still hang at the cli even after they've completed the intended action. termux-tts-speak
and termux-toast
are still not working. Strange that vibrate works then
chroot:
root@localhost:/# /data/data/com.termux/files/usr/bin/termux-vibrate
Android:
01-14 13:08:42.920 8297 10554 E termux-api: Error in ResultReturner 01-14 13:08:42.920 8297 10554 E termux-api: java.io.IOException: Permission denied 01-14 13:08:42.920 8297 10554 E termux-api: at android.net.LocalSocketImpl.connectLocal(Native Method) 01-14 13:08:42.920 8297 10554 E termux-api: at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:292) 01-14 13:08:42.920 8297 10554 E termux-api: at android.net.LocalSocket.connect(LocalSocket.java:145) 01-14 13:08:42.920 8297 10554 E termux-api: at com.termux.api.util.b.b(Unknown Source:23) 01-14 13:08:42.920 8297 10554 E termux-api: at com.termux.api.util.a.run(Unknown Source:8) 01-14 13:08:42.920 8297 10554 E termux-api: at com.termux.api.util.b.d(Unknown Source:30) 01-14 13:08:42.920 8297 10554 E termux-api: at com.termux.api.TextToSpeechAPI$TextToSpeechService.onHandleIntent(Unknown Source:153) 01-14 13:08:42.920 8297 10554 E termux-api: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:76) 01-14 13:08:42.920 8297 10554 E termux-api: at android.os.Handler.dispatchMessage(Handler.java:106) 01-14 13:08:42.920 8297 10554 E termux-api: at android.os.Looper.loop(Looper.java:214) 01-14 13:08:42.920 8297 10554 E termux-api: at android.os.HandlerThread.run(HandlerThread.java:65)
EDIT: Ok great news. I've got mine fully working now, with a combination of setenforce permissive
and @mvasi90's chroot script.
I'm not sure if it's the best way to deal with the permissions problem? but it works and I don't mind permissive kernel, so this is good enough for me
root@localhost:/# /data/data/com.termux/files/usr/bin/termux-location { "latitude": -xx.145742379400737, "longitude": xx.843404778108514, "altitude": xxxx.4181594237032, "accuracy": 12.0, "vertical_accuracy": 0.0, "bearing": xxx.4746856689453, "speed": 0.11394570022821426, "elapsedMs": 14, "provider": "gps" } root@localhost:/# /data/data/com.termux/files/usr/bin/termux-vibrate root@localhost:/# /data/data/com.termux/files/usr/bin/termux-toast test root@localhost:/#
No problem anymore... ! Good luck @mvasi90 hope you're also one step closer to finding a solution. I see your script doesn't have setenforce permissive
, so it could maybe be the solution for your termux commands hanging as well.
@Grimler91 Probably a good idea to use termux's bash as well
Using the termux bash, same result.
#!/data/data/com.termux/files/usr/bin/bash
@xeffyr, I don't have the files: /plat_property_contexts
and /property_contexts
.
This is my logcat output when invoking termux-clipboard-get
, same as @fragtion
--------- beginning of main
01-14 15:24:16.892 8689 8689 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10186 <<<<<<
01-14 15:24:16.900 8689 8689 I AndroidRuntime: Using default boot image
01-14 15:24:16.900 8689 8689 I AndroidRuntime: Leaving lock profiling enabled
01-14 15:24:16.901 8689 8689 E cutils-trace: Error opening trace file: No such file or directory (2)
01-14 15:24:16.902 8689 8689 I app_process: Core platform API reporting enabled, enforcing=false
01-14 15:24:16.972 8689 8689 D app_process: Time zone APEX ICU file found: /apex/com.android.tzdata/etc/icu/icu_tzdata.dat
01-14 15:24:16.972 8689 8689 D app_process: I18n APEX ICU file found: /apex/com.android.i18n/etc/icu/icudt66l.dat
01-14 15:24:16.998 8689 8689 W app_process: JNI RegisterNativeMethods: attempt to register 0 native methods for android.media.AudioAttributes
01-14 15:24:17.004 8689 8689 D AndroidRuntime: Calling main entry com.termux.termuxam.Am
01-14 15:24:17.035 7410 8703 E termux-api: Error in ResultReturner
01-14 15:24:17.035 7410 8703 E termux-api: java.io.IOException: Permission denied
01-14 15:24:17.035 7410 8703 E termux-api: at android.net.LocalSocketImpl.connectLocal(Native Method)
01-14 15:24:17.035 7410 8703 E termux-api: at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:262)
01-14 15:24:17.035 7410 8703 E termux-api: at android.net.LocalSocket.connect(LocalSocket.java:148)
01-14 15:24:17.035 7410 8703 E termux-api: at com.termux.api.util.ResultReturner.lambda$returnData$0(ResultReturner.java:122)
01-14 15:24:17.035 7410 8703 E termux-api: at com.termux.api.util.-$$Lambda$ResultReturner$oCU8JqHW5HLMrNZa40ThjAWcwzo.run(Unknown Source:8)
01-14 15:24:17.035 7410 8703 E termux-api: at java.lang.Thread.run(Thread.java:923)
01-14 15:24:17.039 8689 8689 D AndroidRuntime: Shutting down VM
01-14 15:24:18.789 8638 8638 W kworker/u16:2: type=1400 audit(0.0:8326): avc: denied { kill } for capability=5 scontext=u:r:kernel:s0 tcontext=u:r:kernel:s0 tclass=capability permissive=0
01-14 15:24:19.352 0 0 W chan_tcs_write: 54 callbacks suppressed
01-14 15:24:19.353 0 0 E msm_bus_device 16e0000.ad-hoc-bus: TCS Busy, retrying RPMH message send
01-14 15:24:19.581 1853 2069 D InputDispatcher: Waiting to send key to Window{db46df2 u0 com.termux/com.termux.app.TermuxActivity} because there are unprocessed events that may cause focus to change
@fragtion Good luck @mvasi90 hope you're also one step closer to finding a solution. I see your script doesn't have setenforce permissive, so it could maybe be the solution for your termux commands hanging as well.
Thank you @fragtion. Please never do that. Disabling the security kernel module SeLinux
is very dangerous. Your device is vulnerable to any known or unknown (0-day) exploits.
The correct way to allow it without disabling the SeLinux
, is something like supolicy --live 'allow <source> <target> < class> <permission>'
The problem in this case is that no related audit log (avc) is writted in logcat/dmesg. But yes, disabling SeLinux
it works.
How to inject policies without disabling SeLinux
?
For example, this a unrelated audit log:
avc: denied { ioctl } for comm="screen" path="/dev/pts/0" dev="devpts" ino=1 ioctlcmd=0x540a scontext=u:r:untrusted_app_27:s0:c186,c256,c512,c768 tcontext=u:object_r:untrusted_app_all_devpts:s0:c186,c256 tclass=chr_file ... app=com.termux.api
You can allow it by running:
supolicy --live 'allow untrusted_app_27 untrusted_app_all_devpts chr_file ioctl'
Note: You can specify more than one permission { ioctl, read, write }. Or the * for all permissions.
Selinux context can be checked with:
cat /proc/self/attr/current
Selinux policies for termux-api
# Termux selinux policies
supolicy --live 'allow untrusted_app_27 device_config_runtime_native_boot_prop file read'
supolicy --live 'allow untrusted_app_27 device_config_runtime_native_boot_prop file open'
supolicy --live 'allow untrusted_app_27 device_config_runtime_native_boot_prop file getattr'
supolicy --live 'allow untrusted_app_27 untrusted_app_27 file lock'
supolicy --live 'allow untrusted_app_27 untrusted_app_27 fifo_file read'
supolicy --live 'allow untrusted_app_27 untrusted_app_27 fifo_file create'
supolicy --live 'allow untrusted_app_27 system_file file lock'
supolicy --live 'allowxperm untrusted_app_27 untrusted_app_27 fifo_file ioctl 0x540f-0x5413'
Same problem here. Details for my case:
I’ve installed the most recent
• Termux (termux-app_v0.118.0+64fe832-apt-android-7-github-debug_arm64-v8a.zip),
• Termux::API (termux-api_v0.50.1+60f15b6-github-debug.zip) and
• termux-api (from pkg upgrade && pkg install termux-api
)
packages five minutes ago, and the termux api commands (e.g. termux-torch on
or termux-call-log
) just hang here too.
This is Android 11 (DokeOS 11, Blackview BV8800, up-to-date)
Termux and Termux:API have been given all permissions, and power saving measures are disabled.
My logcat
output while calling termux-torch on
, waiting a few seconds, and then pressing Ctrl-C
as it won’t exit:
--------- beginning of main
09-11 17:05:41.764 9107 9107 V ViewRootImpl[TermuxActivity]: [ANR Warning]Input routeing takes more than 6000ms since 1970-01-01 01:00:00.000, this = com.mediatek.view.impl.ViewDebugManagerImpl@7e7381f
09-11 17:05:41.764 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$SyntheticInputStage@16c930c at 2023-09-11 17:05:41.764
09-11 17:05:41.763 11571 11571 W bash : type=1400 audit(0.0:706040): avc: granted { execute } for name="termux-torch" dev="dm-11" ino=83141 scontext=u:r:untrusted_app_27:s0:c224,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c224,c256,c512,c768 tclass=file app=com.termux.api
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$EarlyPostImeInputStage@370f799 at 2023-09-11 17:05:41.764
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$ViewPostImeInputStage@2f5ae3f at 2023-09-11 17:05:41.764
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$NativePostImeInputStage@be03a5e at 2023-09-11 17:05:41.764
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: [ANR Warning]Input routeing takes more than 6000ms since 1970-01-01 01:00:00.000, this = com.mediatek.view.impl.ViewDebugManagerImpl@7e7381f
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$SyntheticInputStage@16c930c at 2023-09-11 17:05:41.765
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$EarlyPostImeInputStage@370f799 at 2023-09-11 17:05:41.765
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$ViewPostImeInputStage@2f5ae3f at 2023-09-11 17:05:41.765
09-11 17:05:41.765 9107 9107 V ViewRootImpl[TermuxActivity]: Input event delivered to android.view.ViewRootImpl$NativePostImeInputStage@be03a5e at 2023-09-11 17:05:41.765
09-11 17:05:41.763 11571 11571 W bash : type=1400 audit(0.0:706041): avc: granted { execute } for name="termux-torch" dev="dm-11" ino=83141 scontext=u:r:untrusted_app_27:s0:c224,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c224,c256,c512,c768 tclass=file app=com.termux.api
09-11 17:05:41.933 11573 11573 D AVStageFactory: createInstance(64bit): createVendorAVFactory success!
09-11 17:05:41.934 11573 11573 D AVStageUtils: createInstance(64bit): createVendorAVUtils success!
09-11 17:05:41.934 11573 11573 D AVStageFactory: createInstance(64bit): createVendorAVFactory success!
09-11 17:05:41.939 11573 11573 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10224 <<<<<<
09-11 17:05:41.944 11573 11573 E libc : Access denied finding property "persist.device_config.runtime_native_boot.profilebootclasspath"
09-11 17:05:41.944 11573 11573 E libc : Access denied finding property "persist.device_config.runtime_native_boot.enable_apex_image"
09-11 17:05:41.944 11573 11573 I AndroidRuntime: Using default boot image
09-11 17:05:41.944 11573 11573 E libc : Access denied finding property "persist.device_config.runtime_native_boot.disable_lock_profiling"
09-11 17:05:41.944 11573 11573 I AndroidRuntime: Leaving lock profiling enabled
09-11 17:05:41.945 11573 11573 E libc : Access denied finding property "persist.device_config.runtime_native_boot.enable_generational_cc"
09-11 17:05:42.053 11573 11573 D app_process: Time zone APEX ICU file found: /apex/com.android.tzdata/etc/icu/icu_tzdata.dat
09-11 17:05:42.053 11573 11573 D app_process: I18n APEX ICU file found: /apex/com.android.i18n/etc/icu/icudt66l.dat
09-11 17:05:42.076 11573 11573 W app_process: JNI RegisterNativeMethods: attempt to register 0 native methods for android.media.AudioAttributes
09-11 17:05:42.080 11573 11573 D AndroidRuntime: Calling main entry com.termux.termuxam.Am
09-11 17:05:42.082 11573 11573 W System : ClassLoader referenced unknown path: /system/framework/mediatek-cta.jar
09-11 17:05:42.083 11573 11573 W CtaManagerFactory: CtaManagerFactoryImpl not found
09-11 17:05:42.099 11573 11573 I app_process: System.exit called, status: 0
09-11 17:05:42.099 11573 11573 I AndroidRuntime: VM exiting with result code 0.
(This ViewRootImpl[TermuxActivity]
seems to happen for almost every input, but I guess it’s unrelated and due to this being a debug version?)
I’m quite ill right now, and it’s extreme hot and humid, so I’m unable to follow the thread, but hope this is useful, and helps solve the problem…