Android seLiunx权限问题(avc dennied)解决方法

安全增强型 Linux(Security-Enhanced Linux)简称 SELinux。原本是美国国安局联合一些公司设计的一个针对Linux的安全加强系统。Google在Android上强制引入这一套非常严格的权限管理机制,主要用于增强系统的安全性。然而,在开发中,我们经常会遇到由于SELinux造成的各种权限不足。本文旨在结合具体案例,讲解如何根据log来快速解决大部分的SELinux权限问题。

查看 SELinux 状态:
adb shell getenforce

设置SELinux状态:
adb shell setenforce 0
adb shell setenforce 1
(1) setenforce 0
设置SELinux 为permissve mode, 只审查权限, 但不限制, 即不会产生实质性影响,对违反selinux规则的行为只记录,不会阻止;
(2) setenforce 1
设置SELinux 为enforcing mode, 会强制性限制访问。

标志性log 格式
avc: denied { 操作权限 } for pid=7201 comm=“进程名” scontext=u:r:源类型:s0 tcontext=u:r:目标类型:s0 tclass=访问类别 permissive=0

实例
avc: denied { append } for pid=8317 comm=”RenderThread” name=”glsl_shader_log.txt” dev=”mmcblk0p35” ino=4077 scontext=u:r:system_app:s0 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0
解决方法:
赋予 system_app (系统app)对 文件(file)类型 system_data_file 有append的权限
1.找到 system_app.te 文件
2.文件中添加内容:
allow system_app system_data_file:file { append }

猜你喜欢

转载自blog.csdn.net/daokedream/article/details/114234255
今日推荐