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

[Android 10] termux-api hangs on sshd #301

Open
comzine opened this issue Nov 10, 2019 · 10 comments
Open

[Android 10] termux-api hangs on sshd #301

comzine opened this issue Nov 10, 2019 · 10 comments

Comments

@comzine
Copy link

comzine commented Nov 10, 2019

Hello!

I have a Pixel 4 (Android 10 Q) with installed termux-api and apk Termux:API from Play Store.
Granting all permissions and disabled battery optimization for termux:api.
Running sshd in termux terminal.

Using termux-api (for example /data/data/com.termux/files/usr/libexec/termux-api BatteryStatus) works well when using termux directly on the phone, but via ssh it is hanging at:

11-10 12:50:10.015 20878 20878 W bash : type=1400 audit(0.0:11281): avc: granted { execute } for name="ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:10.015 20878 20878 W bash : type=1400 audit(0.0:11282): avc: granted { execute } for name="ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:10.015 20878 20878 W bash : type=1400 audit(0.0:11283): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/bin/ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:10.015 20878 20878 W ps : type=1400 audit(0.0:11284): avc: granted { execute } for path="/data/data/com.termux/files/usr/bin/ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:10.035 20878 20878 W ps : type=1400 audit(0.0:11285): avc: granted { execute } for path="/data/data/com.termux/files/usr/lib/libtermux-exec.so" dev="dm-4" ino=13421 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:10.035 20878 20878 W ps : type=1400 audit(0.0:11286): avc: granted { execute } for path="/data/data/com.termux/files/usr/lib/libprocps.so" dev="dm-4" ino=13422 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:10.039 20878 20878 W ps : type=1400 audit(0.0:11287): avc: denied { read } for name="osrelease" dev="proc" ino=195981 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:proc:s0 tclass=file permissive=0 11-10 12:50:10.039 20878 20878 W ps : type=1400 audit(0.0:11288): avc: denied { read } for name="pid_max" dev="proc" ino=195983 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:proc_pid_max:s0 tclass=file permissive=0 11-10 12:50:30.819 20884 20884 W bash : type=1400 audit(0.0:11292): avc: granted { execute } for name="ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:30.819 20884 20884 W bash : type=1400 audit(0.0:11293): avc: granted { execute } for name="ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:30.819 20884 20884 W bash : type=1400 audit(0.0:11294): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/bin/ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:30.819 20884 20884 W ps : type=1400 audit(0.0:11295): avc: granted { execute } for path="/data/data/com.termux/files/usr/bin/ps" dev="dm-4" ino=12791 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:50:30.822 20884 20884 W ps : type=1400 audit(0.0:11296): avc: granted { execute } for path="/data/data/com.termux/files/usr/lib/libtermux-exec.so" dev="dm-4" ino=13421 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20912 20912 W bash : type=1400 audit(0.0:11304): avc: granted { execute } for name="termux-api" dev="dm-4" ino=61722 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20912 20912 W bash : type=1400 audit(0.0:11305): avc: granted { execute } for name="termux-api" dev="dm-4" ino=61722 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20912 20912 W bash : type=1400 audit(0.0:11306): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/libexec/termux-api" dev="dm-4" ino=61722 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20912 20912 W termux-api: type=1400 audit(0.0:11307): avc: granted { execute } for path="/data/data/com.termux/files/usr/libexec/termux-api" dev="dm-4" ino=61722 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20913 20913 W bash : type=1400 audit(0.0:11309): avc: granted { execute } for name="logcat" dev="dm-4" ino=12728 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20914 20914 W bash : type=1400 audit(0.0:11308): avc: granted { execute } for name="coreutils" dev="dm-4" ino=12888 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20913 20913 W bash : type=1400 audit(0.0:11310): avc: granted { execute } for name="logcat" dev="dm-4" ino=12728 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20913 20913 W bash : type=1400 audit(0.0:11311): avc: granted { execute_no_trans } for path="/data/data/com.termux/files/usr/bin/logcat" dev="dm-4" ino=12728 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.452 20913 20913 W bash : type=1400 audit(0.0:11312): avc: granted { execute } for name="dash" dev="dm-4" ino=12795 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=file 11-10 12:52:14.534 20915 20915 D AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 10211 <<<<<<

@ghost
Copy link

ghost commented Nov 10, 2019

@ghost ghost transferred this issue from termux/termux-packages Nov 10, 2019
@ghost ghost added the bug report label Nov 10, 2019
@ghost ghost changed the title termux-api hangs on sshd [Android 10] termux-api hangs on sshd Nov 10, 2019
@ai212983
Copy link

Same problem here. Android 10, Pixel 4. Works fine on device, freezing via sshd.

@matthewgrossman
Copy link

My workaround for this has been to start a tmux session on the device, detach, and tmux a after SSHing in via my computer.

Android 10, Pixel 1 FWIW

@oelmekki
Copy link

oelmekki commented Feb 7, 2020

Thanks for the workaround, @matthewgrossman

For the record, if someone is scripting ssh commands, it may be possible with tmux send (although, it quickly becomes an escaping nightmare).

I had this command to send the X selection of my laptop to my phone:

xsel -o | ssh pixel termux-clipboard-set

Which stopped working with the same symptoms described in this issue.

With tmux, it can be done like this :

#!/usr/bin/env bash
#xsel -o | ssh pixel termux-clipboard-set

sel=$(xsel -o)
ssh pixel tmux send "'termux-clipboard-set $sel' Enter"

The Enter keyword is used to send \n and actually execute the command. pixel is my host, so it's to be replaced with yours, obviously.

I also used to have the reverse (ssh pixel termux-clipboard-get | xsel -i) to copy mobile selection to my laptop, but I haven't figured yet how to retrieve data from tmux. I guess I'll have to use tmp files.

@LalaDK
Copy link

LalaDK commented Feb 18, 2020

I'm also experiencing this issue on Samsung S10 Plus Android 10.

@heart5
Copy link

heart5 commented Mar 8, 2020

My workaround for this has been to start a tmux session on the device, detach, and tmux a after SSHing in via my computer.

Android 10, Pixel 1 FWIW

I run tmux on phone firstly, then login through ssh, but it cannot work for any termux-api command.

ghost pushed a commit to termux/termux-packages that referenced this issue Mar 8, 2020
@YggdrasiI
Copy link

Minimal example code for workaround with GNU screen.

  1. Start screen session directly on the phone.
screen -S termux
  1. Create wrapper script in ~/bin/ for desired command, e.g. termux-media-scan
#!/data/data/com.termux/files/usr/bin/bash
screen -S termux -p 0 -X stuff "termux-media-scan '$1'^M"

Note that the output will printed in the screen session, but not returned over ssh.

@ondrej-stanek-ozobot
Copy link

I reproduced the same issue on Samsung Galaxy S9 earlier. The command termux-contact-list didn't work over ssh, while it was working well when invoked from termux.

The good news is, that the issue was resolved recently on my device, probably by an automatic update. I am now running termux Version 0.95 and there is no issue anymore.

This is just a heads-up; you might want to try the latest termux. It might solve the problem for you as well.

@eladts
Copy link

eladts commented Sep 9, 2020

The issue was resolved on my Pixel 3a on Android 10, but once I upgraded to Android 11 it came back.

@lypanov
Copy link

lypanov commented Apr 21, 2021

termux-open has even weirder behavior. Failed the first 10+ times I tried it.. and then magically started working. termux-clipboard-get/set still broken alas and a core part of my use case for Termux.

Correction: -set works fine. I'll assume this is something about Android 10+ security model preventing random clipboard copies. Maybe termux api needs new more extensive permissions?

Harshiv-Patel pushed a commit to Harshiv-Patel/termux-packages that referenced this issue Aug 15, 2021
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

10 participants