Android SELinux 添加权限后不生效
Android 12上需要对一个节点进行写操作,但是添加了Selinux以后还是报错
allow platform_app yft_temperature_file:file { write read getattr open };
加了权限还是一直报avc
01-26 09:40:55.556 7891 7891 W yft.factorymode: type=1400 audit(0.0:361): avc: denied { write } for name="chip_power" dev="sysfs" ino=42191 scontext=u:r:platform_app:s0:c512,c768 tcontext=u:object_r:yft_temperature_file:s0 tclass=file permissive=0 app=com.yft.factorymode
参考
Android SELinux 权限问题(二)—添加权限后不生效_it_rensheng的博客-CSDN博客_selinux 权限加不上
发现需要确实是Android 12 platform_app 缺少mlstrustedobject
但是因为要过cts,不能直接修改platform_app的type
修改yft_temperature_file即可
-type yft_temperature_file, fs_type, sysfs_type;
+type yft_temperature_file, fs_type, sysfs_type, mlstrustedobject;
修改后编译生效