Android 应用(7)——untrusted_app访问底层硬件_横山郡守
参考链接://blog.csdn.net/Sunxiaolin2016/article/details/91039775//blog.csdn.net/scottmvp/article/details/115871037背景:用户自行开发的app需要访问底层serial port。我们开发的app在SELinux(或SEAndroid)中分为主要三种类型(根据user不同,也有其他的domain类型):1)untrusted_app 第三方app,没有Android平台签名...
参考链接:
//blog.csdn.net/Sunxiaolin2016/article/details/91039775
//blog.csdn.net/scottmvp/article/details/115871037
背景图片:客户自愿搭建的app所需网页访问表层serial port。人们搭建的app在SELinux(或SEAndroid)中分发型有利于要3种的型(只能根据user与众不同,也存在某个的domain的型):
1)untrusted_app 第三方app,没有Android平台签名,没有system权限
2)platform_app 有android平台签名,没有system权限
3)system_app 有android平台签名和system权限
从上面划分,权限等级,理论上:untrusted_app < platform_app < system_app
APP的domain和type
查看seapp_contexts文件,APP的domain和type由user和seinfo两个参数决定。
Policy files
以 *.te 结尾的文件是 SELinux 政策源代码文件,用于定义域及其标签。
标签、规则和域
规则采用以下形式:allow domains types:classes permissions;,其中:
Domain - 一个进程或一组进程的标签。也称为域类型,因为它只是指进程的类型。
Type - 一个对象(例如,文件、套接字)或一组对象的标签。
Class - 要访问的对象(例如,文件、套接字)的类型。
Permission - 要执行的操作(例如,读取、写入)。
添加serial port对象的标签
“添加另一半(人们要控制的串口机器设备文件资料)的标贴:diff --git a/device/softwinner/common/sepolicy/vendor/file_contexts b/device/softwinner/common/sepolicy/vendor/file_contexts
index c2600e0..13b3f73 100755
--- a/device/softwinner/common/sepolicy/vendor/file_contexts
+++ b/device/softwinner/common/sepolicy/vendor/file_contexts
@@ -72,6 +72,7 @@
# Bluetooth
/dev/ttyS1 u:object_r:hci_attach_dev:s0
+/dev/ttyS5 u:object_r:ttyS5_device:s0
/dev/ttyBT0 u:object_r:hci_attach_dev:s0
/sys/class/rfkill/rfkill0/state u:object_r:sysfs_bluetooth_writable:s0
设定tag标签的方式:
diff --git a/device/softwinner/common/sepolicy/vendor/device.te b/device/softwinner/common/sepolicy/vendor/device.te
index 80d18c5..66f14a0 100755
--- a/device/softwinner/common/sepolicy/vendor/device.te
+++ b/device/softwinner/common/sepolicy/vendor/device.te
@@ -4,3 +4,4 @@ type zram_backing_device, dev_type;
type sunxi_soc_device, dev_type;
type deinterlace_device, dev_type;
type sst_storage_device, dev_type, fs_type;
+type ttyS5_device, dev_type, mlstrustedobject;
添加访问权限
调用untrusted_app对serial port的访问管理权限管理权限:diff --git a/device/softwinner/common/sepolicy/vendor/untrusted_app.te b/device/softwinner/common/sepolicy/vendor/untrusted_app.te
index fb078dd..43496eb 100755
--- a/device/softwinner/common/sepolicy/vendor/untrusted_app.te
+++ b/device/softwinner/common/sepolicy/vendor/untrusted_app.te
@@ -10,3 +10,6 @@ allow untrusted_app su_exec:file { execute read open getattr execute_no_trans };
allow untrusted_app untrusted_app:capability { setgid setuid };
allow untrusted_app selinuxfs:file { open read write };
allow untrusted_app kernel:security { setenforce };
+allow untrusted_app ttyS5_device:chr_file rw_file_perms;
+allow untrusted_app apexd_prop:file { getattr open read };
+allow untrusted_app proc_tty_drivers:file { execute read open getattr execute_no_trans };
解除neverallow限制
android同意的安全性方式标准配置会对多种的授权管理控制档次安装相对禁用左右的授权管理控制,untrusted_app的授权管理控制档次很低,同意更多授权管理控制都在neverallow,这就必须要 大家一键打開:diff --git a/system/sepolicy/prebuilts/api/29.0/private/app_neverallows.te b/system/sepolicy/prebuilts/api/29.0/private/app_neverallows.te
index c60bf83..58fdc3c 100755
--- a/system/sepolicy/prebuilts/api/29.0/private/app_neverallows.te
+++ b/system/sepolicy/prebuilts/api/29.0/private/app_neverallows.te
@@ -327,8 +327,8 @@ full_treble_only(`
# b/33214085 b/33814662 b/33791054 b/33211769
# //github.com/strazzere/anti-emulator/blob/master/AntiEmulator/src/diff/strazzere/anti/emulator/FindEmulator.java
# This will go away in a future Android release
-neverallow { all_untrusted_apps -untrusted_app_25 } proc_tty_drivers:file r_file_perms;
-neverallow all_untrusted_apps proc_tty_drivers:file ~r_file_perms;
+#neverallow { all_untrusted_apps -untrusted_app_25 } proc_tty_drivers:file r_file_perms;
+#neverallow all_untrusted_apps proc_tty_drivers:file ~r_file_perms;
皇冠新体育APP相关的文章
- 实验六Random库-皇冠新体育APP字符串之随机密码生成_白昼57_python生成随机密码random库
- 皇冠新体育APP:从“1L 小钢炮”到 “PC界变形金刚”??Tiny助力企业数智转型的十年进化之路_AI科技大本营
- 皇冠新体育APP:【知识点总结】模拟电子技术(模电)_NONO.97_模拟电子技术
- 皇冠新体育APP:Chemex v3.5-IT资产管理平台部署_x_idea_chemex部署
- 皇冠新体育APP:数字图像处理与皇冠新体育APP实现_吴记玛卡_数字图像处理与python实现
- JUC 并发编程学习笔记(总)_Java技术一点通
- 皇冠新体育APP:【牛客刷题--SQL篇】多表查询组合查询SQL25 查找山东大学或者性别为男生的信息_与自己作战
- 如何修改Tomcat默认端口号8080的方法_喜崽BugBQ_修改tomcat端口号为80
- 【Flutter】【widget】Table 表格widget_DO?OK:NOT
- 《皇冠新体育APP进阶系列》五:皇冠新体育APP中的进制转换_奋斗的西瓜瓜_python进制转换题
- idea2022版创建Servlet文件(详细完整版)_m0_56392863_idea怎么创建servlet文件
- 皇冠新体育APP:python文本相似度计算_菜鸟1号??_python实现文本相似度
- (附源码)基于Android的订餐app 毕业设计 190711_普通网友_手机订餐软件界面设计
- 【Flutter系列】第一期??初识Dart语言_我就学习一小会儿_flutter蓝色波浪线代表什么
- 项目-Holocubic透明桌面站(基于STM32)_李华_
- 皇冠新体育APP:了解 Flutter 开发者们的 IDE 使用情况_谷歌开发者