Selinux Error while expanding policy libsepol.check_assertions: 2 neverallow failures occurred

Selinux Error while expanding policy libsepol.check_assertions: 2 neverallow failures occurred

添加selinux 权限报以上的错误。

错误缘由

今天在完善一个功能,即将U盘中的文件拷贝到系统的data 目录下。始终拷贝不过去。然后看log,发现了一顿avc的log。这才知道是selinux的锅。log 如下:

type=1400 audit(0.0:257): avc: denied { write } for comm=73656E6420636F6D6D616E6420706F name="terminalplayer-res" dev="mmcblk0p44" ino=128314 scontext=u:r:system_app:s0 tcontext=u:object_r:system_data_file:s0 tclass=dir permissive=0
type=1400 audit(0.0:258): avc: denied { open } for comm=73656E6420636F6D6D616E6420706F path=2F646174612F7465726D696E616C706C617965722D7265732FE5B091E5A5B3E697B6E4BBA34F684D5646756C6C4844313038302E617669 dev="mmcblk0p44" ino=128319 scontext=u:r:system_app:s0 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0
PlaysourceManageModel:  onOperateInfo:源文件异常,请检查U盘。java.io.FileNotFoundException: /data/terminalplayer-res/[ 196 ]mkv_AVC+AAC(LC)(y-Subtitle)_1280×720.ass (Permission denied)
type=1400 audit(0.0:259): avc: denied { open } for comm=73656E6420636F6D6D616E6420706F path=2F646174612F7465726D696E616C706C617965722D7265732F5B20303932205D6D6B765F4D504547342B4143335F373230C3973430302E6D6B76 dev="mmcblk0p44" ino=128318 scontext=u:r:system_app:s0 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=0
Search "error" (202 hits in 1 file)

为了进一步确认是否是selinux权限的问题。我在串口输入了:setenforce 0 然后再去执行拷贝的动作,果然,可以了。

那么既然是这样的话,那就好办了,selinux 缺什么补什么就完事了。
具体可以参考我的这篇博客

这里根据规则直接在system.te 文件中加了下面两句话:

allow system_app system_data_file:dir { read open add_name write create remove_name setattr search };
allow system_app system_data_file:file { open lock create read write rename setattr unlink};

然后开始编译验证。结果,悲剧了,编译报错。谢天谢地,幸好我保存了log。我在编译生成的log 中发现了如下的报错:

[19:27:57]libsepol.report_failure: neverallow on line 458 of system/sepolicy/public/app.te (or line 8377 of policy.conf) violated by allow system_app system_data_file:dir { write create };
[19:27:57]libsepol.report_failure: neverallow on line 458 of system/sepolicy/public/app.te (or line 8377 of policy.conf) violated by allow system_app system_data_file:file { write create unlink };
[19:27:57]libsepol.check_assertions: 2 neverallow failures occurred
[19:27:57]Error while expanding policy
解决

从上面的报错可以看出,是因为app.te 这个文件里面不允许这样做,于是打开app.te,发现了如下字段:
在这里插入图片描述

原来这里定义了不允许的权限。所以,改下这里就好了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

假装多好123

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值