android6.0第三方app如何打开串口

来源:互联网 发布:淘宝店铺不存在的原因 编辑:程序博客网 时间:2024/05/08 06:58

折腾了一天,用audit2allow工具解析avc错误,把所有的权限都加上了,还是不行,一直有以下提示:

01-06 23:47:28.170  1932  1932 W port_api.sample: type=1400 audit(0.0:59): avc: denied { write } for name="ttyS0" dev="tmpfs" ino=4864 scontext=u:r:untrusted_app:s0:c512,c768 tcontext=u:object_r:serial_device:s0 tclass=chr_file permissive=0

无意中看到网上这篇文章,在device.te加入type serial_device, dev_type, mlstrustedobject;这一行,问题迎刃而解,原文如下,就不标记出处了,因为我是在一个满是成人弹幕广告的网站上搜到的,嘿嘿。

第三方签名APP,在SElinux下,如何获得对一个内核节点的访问权限

 

在android6.0中,出于安全考虑,不允许第三方签名的app被分配mlstrustedsubject:

在external/sepolicy/untrusted_app.te文件中:

# Do not allow untrusted_app to be assignedmlstrustedsubject.
# This would undermine the per-user isolation model being
# enforced via levelFrom=user in seapp_contexts and the mls
# constraints.  As there is no direct way tospecify a neverallow
# on attribute assignment, this relies on the fact that fork
# permission only makes sense within a domain (hence should
# never be granted to any other domain withinmlstrustedsubject)
# and untrusted_app is allowed fork permission to itself.
neverallow untrusted_app mlstrustedsubject:process fork;

所以在使用第三方签名app时,希望第三方签名app某个进程能够对内核节点进行操作,可按如下修改:

1.在device/sprd/scx20/common/sepolicy/file_contexts 文件中添加:
/dev/abc u:object_r:abc_device:s0 
2.在device/sprd/scx20/common/sepolicy/device.te 文件中添加:
type abc_device, dev_type, mlstrustedobject;

3.在device/sprd/scx20/common/sepolicy/untrusted_app.te 文件中添加:
allow untrusted_app adc_device:chr_fileoperate;

operate为赋予的权限。

注:

mlstrustedsubject:这一attribute包含了所有能越过MLS检查的主体domain。

mlstrustedobject:这一attribute包含了所有能越过MLS检查的客体type。

0 0