您的位置:首页 > 移动开发 > Android开发

Android 5.x 权限问题解决方法

2018-02-02 10:24 447 查看
1.从android5.x开始,引入严格的selinux权限管理机制,经常会遇到各种avc denied的Log。  

 # adb shell cat /proc/kmsg | grep avc

 # adb shell dmesg | grep avc 

 # adb logcat | grep avc

解决原则是:缺什么补什么,一步一步补到没有avc denied为止。   

2.Log解决:

 audit(0.0:67): avc: denied { write }for path="/dev/block/vold/93:96" dev="tmpfs" ino=1263 scontext=u:r:kernel:s0 tcontext=u:object_r:block_device:s0tclass=blk_file permissive=0  

分析过程: 

缺少什么权限:           { write }权限, 

谁缺少权限:             scontext=u:r:kernel:s0, 

对哪个文件缺少权限:tcontext=u:object_r:block_device 

什么类型的文件:        tclass=blk_file  

解决方法:kernel.te 

# allow kernel block_device:blk_file write; 

3.万能套用公式:  

                       scontext(进程名)  tcontext(安全上下文)      tclass(访问类型)    avc denied(访问权限)

             allow     kernel           block_device       :    blk_file          write

重新编译:make bootimage,重新烧写boot.img固件.  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息