I am using the free SSHelper
SSH server on my phone to get SSH access. However, the application is not behaving correctly under SELinux
when set to Enforcing
mode, but seem to be OK when using Permissive
mode. This is not surprising as it was developed under CyanogenMod, making the author unaware of these issues for later SELinux Enforcing stock AOS's.
The problem occurs when the App is trying to allocate a /dev/pts/N
pseudo-terminal, during SSH connection. This fails and the resulting shell is essentially useless for development. After having spent considerable time trying to track down this problem as documented HERE. Where I found the following "errors" in the /data/misc/audit/audit.log
file:
audit(1401291488.480:203): avc: denied { setattr } for pid=11441 comm="sshelper_sshd" name="0" dev="devpts" ino=3 scontext=u:r:untrusted_app:s0 tcontext=u:object_r:untrusted_app_devpts:s0 tclass=chr_file VE=SEPF_GT-I9195_4.2.2_0022_M
audit(1401291488.480:203): arch=40000028 syscall=15 per=840000 success=no exit=-13 a0=beffd438 a1=190 a2=27da a3=c0000000 items=1 ppid=8499 pid=11441 auid=4294967295 uid=10202 gid=10202 euid=10202 suid=10202 fsuid=10202 egid=10202 sgid=10202 fsgid=10202 tty=(none) ses=4294967295 comm="sshelper_sshd" exe="/data/data/com.arachnoid.sshelper/bin/sshelper_sshd" subj=u:r:untrusted_app:s0 key=(null)
audit(1401291488.480:203): cwd="/"
audit(1401291488.480:203): item=0 name="/dev/pts/0" inode=3 dev=00:09 mode=020600 ouid=10202 ogid=10202 rdev=88:00 obj=u:object_r:untrusted_app_devpts:s0
However, since I have no previous experience in SELinux and its mysterious protection mechanisms, and could really use some help. I don't even know if this is the real issue, just guessing. Checking the permissions of the above file gives:
# ls -alZ /data/data/com.arachnoid.sshelper/bin/sshelper_sshd
-rwxr-xr-x u0_a202 u0_a202 u:object_r:app_data_file:s0 sshelper_sshd
But this context
doesn't seem to correspond at all to what was shown in the log.
How can I fix these permissions to play well with SELinux when in Enforcing mode?
(Also, what tools and file are available in Android to fix this?)