当前位置: 首页 > web >正文

安卓添加设备节点权限和selinux访问权限

# 1 修改设备节点权限及配置属性设置节点值

## 1.1 修改设备节点权限

### 1.1.1 不会手动卸载的节点

在system/core/rootdir/init.rc中添加节点权限

在on boot下面添加

chown system system /sys/kernel/usb/host
chmod 0664 /sys/kernel/usb/host

### 1.1.2 支持热插拔的节点(设备移除后,节点会删除)

在system/core/rootdir/ueventd.rc中添加

/dev/ttyUSB*              0666   system     system

## 1.2 配置属性设置节点值

# on property:sys.boot_completed=1 表示开机完成
# persist.sys.oem.usb_host=*表示随便写入什么值
on property:sys.boot_completed=1 && property:persist.sys.oem.usb_host=*write /sys/kernel/usb/host ${persist.sys.oem.usb_host}

# 2 添加selinux访问权限

## 2.1 权限报错和添加方法

修改se权限 编译
avc: denied { write } for comm="init" name="disable_charging_screen" dev="sysfs" ino=86923 scontext=u:r:init:s0 tcontext=u:object_r:vendor_sysfs_oem:s0 tclass=file permissive=
缺少什么权限:     { read }权限,
谁缺少权限:        scontext=u:r:hal_secure_element_unisoc:s0 
对哪个文件缺少权限:tcontext=u:object_r:hwservicemanager_prop
什么类型的文件:  tclass=file 
完整的意思: hal_secure_element_unisoc进程对hwservicemanager_prop类型的file缺少read 权限。
allow  hal_secure_element_unisoc hwservicemanager_prop:file  read;
allow init vendor_sysfs_oem:file { open read getattr execute write};export SELINUX_IGNORE_NEVERALLOWS=truemake -j128 selinux_policy最后push目录system/etc/selinux(修改system/sepolicy下的权限) 或者 vendor/etc/selinux(修改device下的权限)到设备

## 2.2 权限添加的位置

# mtk平台添加权限的位置:
device/mediatek/sepolicy/basic/non_plat# 高通添加的位置:
device/qcom添加的权限内容:
file.te中添加:type oem_device, fs_type, sysfs_type;
file_contexts中添加:/sys/kernel/usb/host                                 u:object_r:oem_device:s0
init.te中添加:
allow init oem_device:file w_file_perms;
allow init oem_device:file {open write read };
allow init oem_device:fd {use};

http://www.xdnf.cn/news/9727.html

相关文章:

  • 如何通过数据分析优化项目决策
  • t009-线上代驾管理系统
  • kafka学习笔记(三、消费者Consumer使用教程——使用实例及及核心流程源码讲解)
  • 微服务测试困境?Parasoft SOAtest的自动化、虚拟化与智能分析来袭!
  • WPF-Prism学习笔记之 “导航功能和依赖注入“
  • React 微应用接入:qiankun 深度集成实战
  • 如何在 Ubuntu 24.04 服务器上安装 Apache Solr
  • AugmentFree:解除 AugmentCode 限制的终极方案 如何快速清理vscode和AugmentCode缓存—windows端
  • 安科瑞Acrelcloud-6200系统:智慧路灯安全用电监控平台架构解析
  • 【Linux网络编程】传输层协议TCP,UDP
  • Nginx详解(三):ngx_http_rewrite_module模块核心指令详解
  • A2A Samples: Hello World Agent
  • [Java恶补day9] 438.找到字符串中所有字母异位词
  • JavaSE核心知识点05实践项目(学生管理系统-控制台版)
  • 前向渲染和延迟渲染
  • 利用仿真软件学习一下RC无源滤波和有源滤波电路
  • 【部署】手搓一个dify可用的rerank模型接口服务
  • VSCode Agent 和 Cursor Agent 系统提示词对比
  • There is a chart instance already initialized on the dom. 柱状图初始化时报前面这个错误如何解决?
  • Python异常处理:优雅地应对程序运行时的“意外”
  • 三轴云台之不完全微分PID控制算法篇
  • 可视化数据大屏适配方案之Scale等比缩放
  • java上机测试错题回顾(3)
  • YOLOv11冻结训练+微调策略实战教程(含效果对比分析)
  • 运维三剑客——grep
  • 【动态规划】子数组系列(二)
  • GEO革命:重新定义AI时代的内容规则
  • 代码随想录算法训练营第五十二天
  • 【笔试训练4】Fibonacci数列|单词搜索|杨辉三角
  • 11、总账管理(GL)数字化转型:财务核心支柱,承担着业务系统复杂多变的重任