LED节点访问增加selinux权限记录

由于工厂测试是直接读写取呼吸灯的文件节点,测试app没有selinux权限去读写该节点,需要增加selinux权限。

该工厂测试模块属于system app,所以对应的要加在system_app.te中

 

MTK FAQ:

https://online.mediatek.com/FAQ#/SW/FAQ11486

https://online.mediatek.com/FAQ#/SW/FAQ13635

 

一:根据FAQ11486和以下log:

在system_app.te中增加allow system_app sysfs_leds:dir search;

<36>[18068.630431]  (1)[334:logd.auditd]type=1400 audit(1548337628.189:14011): avc: denied { search } for pid=19546 comm="pri.factorytest" name="leds" dev="sysfs" ino=9315 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs_leds:s0 tclass=dir permissive=0

 

二:上一步后仍然无法写成功,但log不一样

根据FAQ13635 和以下log做修改

<36>[  229.420022]  (3)[335:logd.auditd]type=1400 audit(1548397141.547:3543): avc: denied { write } for pid=4583 comm="pri.factorytest" name="brightness" dev="sysfs" ino=13673 scontext=u:r:system_app:s0 tcontext=u:object_r:sysfs_leds:s0 tclass=file permissive=0

 

修改:

device/mediatek/sepolicy/basic/non_plat/system_app.te:

allow system_app sysfs_leds:dir search;
allow system_app sys_lcd_brightness_file:file {rw_file_perms open};

 

device/mediatek/sepolicy/basic/non_plat//basic/non_plat/file.te:

type sys_lcd_brightness_file, fs_type, sysfs_type;

 

device/mediatek/sepolicy/basic/non_plat//basic/non_plat/file_contexts:

/sys/devices/platform/leds-mt65xx/leds/green/brightness u:object_r:sys_lcd_brightness_file:s0

注意:该文件节点必须为真实节点,不能是连接

 

三、增加普通权限

在对应device/mediatek/mt6xxx/init.mt6xxx.rc

chmod 0664 /sys/class/leds/green/brightness

 

此处只已绿灯为例,红、黄灯也是一样处理

 

参考:https://blog.csdn.net/long375577908/article/details/79384527

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值