SELinux audit2allow命令使用

解决方案:

首先将我们的报错avc日志拷出来做成一个avc.txt放在Ubuntu系统下面在终端中运行以下命令生成的avc.te文件就是我们的解决方法了。

audit2allow –i avc.txt >avc.te

avc.txt

avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0
avc: denied { create } for name="hsdi_tmp" scontext=u:r:system_app:s0 tcontext=u:object_r:protect_f_data_file:s0 tclass=dir permissive=0

运行audit2allow工具(external/selinux/prebuilts/bin/audit2allow)之后得到的avc.te文件

avc.te

#============= system_app ==============
allow system_app protect_f_data_file:dir create;

前面的#============= system_app ==============

就是在告诉你在那个文件里面,你可以找到你们系统真正起作用的system_app.te文件是那个目录的。然后在文件的末尾处添加里面的那句话

allow system_app protect_f_data_file:dir create;

注意 这个权限问题是要一个个慢慢来的,也就是说你这个权限加了 等会你运行进去还有可能出现其他的权限问题。这就需要大家要有耐心慢慢的去一个个加好。

有的时候权限明明加进去了却还是报相同的错误 这个时候你就得检查你是否加对地方了。

把你编译的这个文件拷贝出来

out/target/product/angler/obj/ETC/sepolicy.recovery_intermediates/policy_recovery.conf


版权声明:本文为q1183345443原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
THE END
< <上一篇
下一篇>>