Android P SELinux权限获取
常见权限报错及解决
报错log基本样式:
avc: denied {
Permission } for pid=597 comm="cnss_diag" name="0" dev="mmcblk0p53"
ino=1305607 scontext=u:r:Source_Type:s0 tcontext=u:object_r:TargetType:s0 tclass=Class permissive=0
Permission:执行操作所缺失的权限,如{
read search open getattr execute}等等。
Source_Type: 一个进程或一组进程的标签(Domain),可以理解为用户。
TargetType: 被Source_Type操作的对象或对象组的标签。
Class:TargetType的类型,如{
file dir lnk_file chr_file}等等。
赋予权限的基本语法:
allow Source_Type TargetType:Class {
Permission };
#Permission可以添加多个
报错例子:
selinux: avc: denied {
set } for property=vold.decrypt pid=7192 uid=2000 gid=2000 scontext=u:r:shell:s0
tcontext=u:object_r:exported_vold_prop:s0 tclass=property_service permissive=0\x0a
如上报错在相应的Source_Type.te文件中添加相应权限赋予语句即可解决。
在android/device/qcom/sepolicy/vendor/common/shell.te中添加:
allow shell exported_vold_prop:property_service {
set