码迷,mamicode.com
首页 > 移动开发 > 详细

Android CTS测试Fail项修改总结(四)

时间:2015-06-11 19:27:39      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:cts

Android5.1上的测试

1、android.security.cts.SELinuxDomainTest# testInitDomain fail

打印的log

junit.framework.AssertionFailedError: Expected 1 process in SELinux domain "u:r:init:s0" Found 
"[
pid: "1" proctitle: "/init" label: "u:r:init:s0" vsize: 1327104, 
pid: "298" proctitle: "/system/bin/immvibed" label: "u:r:init:s0" vsize: 1765376
]" 
expected:<1> but was:<2> at junit.framework.Assert.fail(Assert.java:50) 
这个是典型的L 版本SELinux Test 问题.
android.security.cts.SELinuxDomainTest 有1项fail,
-- testInitDomain
junit.framework.AssertionFailedError: Expected 1 process in SELinux domain "u:r:init:s0" Found "[pid: "1" proctitle: "/init" label: "u:r:init:s0" vsize: 1327104, pid: "298" proctitle: "/system/bin/immvibed" label: "u:r:init:s0" vsize: 1765376]" expected:<1> but was:<2> at junit.framework.Assert.fail(Assert.java:50)

其关键原因是因为 Google 强调系统关键进程的SELinux Context 必须唯一, 系统关键进程包括如 init, vold, surfaceflinger, netd, servicemanager, drmserver 等等. 一旦发现有多个process 同时使用这些关键的domain 则SELinux Test fail.

为此要求,系统关键进程启动长时间运行的process, 必须进行domain 切换. 否则将无法通过Google CTS test.

典型情况就是通过init 启动某个 service, 而没有对这个service 进行domain 切换. 比如贵司这个问题中 suntrold_32 这个 service 没有进行domain 切换, 成而无法通过测试.

下面是一个简单的demo.
情景: 定义一个init 启动的service, demo_service, 对应的执行档是/system/bin/demo.
(1). 创建一个demo.te 在/device/mediatke/common/sepolicy 目录下, 然后在/device/mediatke/common/BoardConfig.mk 的BOARD_SEPOLICY_UNION 宏中新增 demo.te
(2). 定义demo 类型,init 启动service 时类型转换, demo.te 中
type demo, domain;
type demo_exec, exec_type, file_type;
init_daemon_domain(demo)
(3). 绑定执行档 file_context 类型
/system/bin/demo u:object_r:demo_exec:s0
(4). 根据demo 需要访问的文件以及设备, 定义其它的权限在demo.te 中.

典型情况就是通过init 启动某个 service, 而没有对这个service 进行domain 切换. 比如这个问题中immvibed 这个 service 没有进行domain 切换, 从而无法通过测试.只需按照demo修改即可.

Android CTS测试Fail项修改总结(四)

标签:cts

原文地址:http://blog.csdn.net/deng0zhaotai/article/details/46460033

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!