接上文,要copy到cache/recovery,发现有permission denied,如图:
怎么解决捏?
开启root权限:
- adb reboot bootloader
- fastboot oem root Qon
将selinux状态设置为permissive:
- adb shell setenforce 0
抓取log信息:
- adb logcat > xx.log
查看avc denied:
- Thread-2: type=1400 audit(0.0:4272): avc: denied { read } for name="cache" dev="dm-3" ino=16 scontext=u:r:system_app:s0 tcontext=u:object_r:cache_file:s0 tclass=lnk_file permissive=1
解析avc:
1.avc: denied { read } -->不被允许的操作即缺少read权限
2.scontext=u:r:system_app:s0 -->访问者
3.tcontext=u:object_r:cache_file:s0-->被访问者
4.tclass=lnk_file -->操作对象
然后在system_app.te中增加权限:
- allow system_app cache_file:lnk_file read;
因为我这边cache_file已经定义过了,所以可以直接用hh,但是如果有需要自己定义的type:
1.file_contexts中添加type
- /data/test(/.*)? u:object_r:test_data_file:s
2.file.te中对新增的type进行关联说明
- type test_data_file,file_type,data_file_type,core_data_file_type;
3.修改相关te allow权限(如SystemServer中访问新建目录文件)
- allow system_server test_data_file:file rw_file_perms;(表示读写所有权限)
补一条:
adb shell --> ls -lZ 可以查看文件的安全上下文:
(还在努力学习wa✊不当之处望指正!!)