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

安卓添加设备节点权限和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};

相关文章:

  • 高空视角之大美遥感-基于Leaflet和天地图的壮美遥感影像实践
  • 基于随机函数链接神经网络(RVFL)的锂电池健康状态(SOH)预测
  • 通过远程桌面连接Windows实例提示“出现身份验证错误,无法连接到本地安全机构”错误怎么办?
  • VTK - 编译静态库(No DLL)
  • 【数据集】中国江北气候区100m逐日近地表气温数据
  • Vue 技术文档
  • 进程控制与调度下
  • React从基础入门到高级实战:React 生态与工具 - React 单元测试
  • [PyTest-案例]
  • 实验设计与分析(第6版,Montgomery)第5章析因设计引导5.7节思考题5.6 R语言解题
  • 【HT NOI周赛 T1,CF1801G】 信息密度 题解(AC自动机,字符串后缀结构)
  • GoC新阶段课程研发
  • 解构产品经理
  • [SC]SystemC语法小结(一)
  • mysql使用 过程函数 for in函数批量修改数据
  • 罗德里格斯公式动图演示
  • DeepSeek 赋能低空经济:无人机智能调度的破局之道
  • 如何在 Odoo 18 中创建 PDF 报告
  • react库:class-variance-authority
  • 气象大模型如何影响端午节旅行?精准预报助力安全出行
  • 南昌优化网站服务/南宁seo规则
  • 网站开发视频是存储的/武汉seo主管
  • 外贸网站建设软件/网站怎样被百度收录
  • 伴奏网站防盗是怎么做的/百度识图搜索图片来源
  • 公积金门户网站建设方案/百度云网盘资源搜索引擎入口
  • 网站建设公司特色/郑州seo排名优化