Selinux 配置

SOC: Rk3399, Platform: Android 8.0.

一: 文件不可写,未获取到write属性。

在打印错误log中获取主要信息 denied -->需要获取的权限,name-->需要获取权限的文件,scontext-->需要配置的文件,tcontext-->文件所在路径,tclass-->文件类型。

type=1400 audit(0.0:49): avc: denied { write } for name="dwc3_mode" dev="sysfs" ino=20703 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs_usb0:s0 tclass=file permissive=0

  • 分析
    • 缺少的权限:{write/read}
    • 谁缺少权限:scontext=u:r:system_app:s0
    • 哪个文件的权限:tcontext=u:object_r:sysfs_usb0:s0
    • 文件的类型:tclass=file
  • 解决
    • allow system_app sysfs_usb0:file {open read write };
    • 公式:allow + scontext + tcontext + “:” + file + permission

 

SELinux 的三种模式:

  • enforcing:强制模式,代表 SELinux 运作中,且已经正确的开始限制 domain/type 了;
  • permissive:宽容模式:代表 SELinux 运作中,不过仅会有警告讯息并不会实际限制 domain/type 的存取。这种模式可以运来作为 SELinux 的 debug 之用;
  • disabled:关闭,SELinux 并没有实际运作。

模式切换

1)getenforce

得到当前的SELinux

[root@python bin]# getenforce

Permissive

2)setenforce

更改当前的SELINUX值 ,后面可以跟 enforcing,permissive 或者 1, 0。

[root@python bin]# setenforce permissive

3)sestatus

显示当前的 SELinux的信息

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Brave & Real

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

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

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

打赏作者

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

抵扣说明:

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

余额充值