Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1291991
  • 博文数量: 478
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 4833
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-28 11:12
文章分类

全部博文(478)

文章存档

2019年(1)

2018年(27)

2017年(21)

2016年(171)

2015年(258)

我的朋友

分类: Android平台

2016-07-25 12:39:56

[FAQ15571][SELinux] Android M 版本后进程无法访问直接访问data 目录的说明
2015-11-18
平台...
软件分支
FAQs 14 of 24

内容

[Description]
[SELinux] Android M 版本后进程无法访问直接访问data 目录的说明
 
[Keyword]
SELinux, data, 拒绝, permission denied, 安全 , security

[Version]
android >= 6.0
 
[Solution]
Google 在android M 版本后, 通过SELinux 的neverallow 语法强制性限制了普通进程访问data 目录的权限. 严禁除init system_server installd system_app 之外的其他进程直接操作/data 目录比如在data 目录下面创建文件,写文件,重命名文件等等.

有很多客户都会在data 目录下创建文件, 保存资讯, 在M 版本上这个操作会被SELinux 直接拦截下来,并且没法直接添加访问system_data_file 的权限, 需要按下面的流程操作。
(1).  在init.rc 或者 其他的init.xxx.rc 的on post-fs-data 段 添加:
mkdir /data/xxxx 0770 root system

(2). 在/device/mediatek/common/sepolicy/file.te 里面添加:
type xxxx_data_file, file_type, data_file_type;

(3). /device/mediatek/common/sepolicy/file_contexts 里面添加:
/data/xxxx(/.*)? u:object_r:xxxx_data_file:s0

(4). 给你的进程添加权限, 比如你的进程的SELinux domain 是 yyyy
allow yyyy xxxx_data_file:dir create dir_perms;
allow yyyy xxxx_data_file:file create_file_perms;

这样你才能绕过Google 的设置. 这个xxxx 目录随你定义.
阅读(2018) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~