【发布时间】:2021-05-17 14:05:59
【问题描述】:
我正在尝试使用 JNI 作为 open("/dev/diag", O_RDWR | O_LARGEFILE | O_NONBLOCK); 打开 /dev/diag,但返回 errno: 13 Permission denied。
应该做些什么来完成这项工作?
使用命令ls -l /dev/diag 检查/dev/diag 的所有权时,它返回crw-rw-rw- system qcom_diag 244, 0 2015-01-14 01:47 diag
当尝试使用命令id 时,我得到uid=0(root) gid=0(root) groups=0(root) context=u:r:init:s0
所以我认为问题与所有权有关?
更新:基于@HamidShatu 的回答
我尝试将 SELinux 设置为宽容,但没有成功。
我尝试了命令su 0 setenforce 0,如果立即使用getenforce 命令进行检查,它会返回OK,同时仍然是Enforcing。
我什至尝试更改 prop.build:这个文件不存在,而是 prop.build.bak 这样做了,所以我复制了它,将 SELinux 修改为 0 而不是 1,并在没有 .bak 扩展名的情况下推送它。即使我检查了修改 SELinux 设置为 0 的 prop.build 的外部应用程序,但是使用 getenforce 命令检查时它仍然返回 Enforcing
这里是 dmesg 的摘录:
[18177.676603] [0: servicemanager: 743] avc: received setenforce notice (enforcing=1)
[18182.768070] [1: servicemanager: 743] avc: received setenforce notice (enforcing=1)
[18183.231867] [0: init: 1] avc: received setenforce notice (enforcing=1)
[18183.232006] [0: init: 1] avc: received setenforce notice (enforcing=1)
我什至尝试通过添加到 Manifest 使应用程序作为系统应用程序运行:<application--> android:sharedUserId="android.uid.system"
提示:我正在使用可以成功访问 /dev/diag 的 Play 商店中的应用程序。
【问题讨论】:
标签: java android android-ndk android-permissions root