Android5.1/7.1 Selinux JNI访问新增/dev/xxx设备节点

1、以/dev/test节点为例,在device/init.rc增加
on boot
//android5.0以下到此即可访问,5.0以上设置2-4步
  chmod 777 /dev/test 

2、在extern/sepolicy/file_contexts 或/device/sepolicy/file_contexts增加
//设备名:test_device
/dev/test  u:object_r:test_device:s0 

3、在extern/sepolicy/device.te 增加
//类型:dev_type
//For Android5.1
type  test_device, dev_type;  
//For Android7.0以上版本:这一attribute包含了所有能越过MLS检查的客体type
type  test_device, dev_type,mlstrustedobject; 

4、允许系统app访问/dev/test,在extern/sepolicy/system_app.te增加
//访问设备的进程:system_app
allow system_app test_device:chr_file  rw_file_perms; 

5、编译烧写
# mmm /device/sepolicy
# make ramdisk 
6、测试
int fd = open("/dev/test",O_RDONLY);  

    

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

Android系统攻城狮

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

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

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

打赏作者

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

抵扣说明:

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

余额充值