zoukankan      html  css  js  c++  java
  • 文件开放权限

    转载:https://www.jianshu.com/p/058970ae46fd

    SEAndroid 为Sys设备节点开放访问(读或写)权限方法(如:sys/class/leds/red_aux/brightness)

    1.APP层写节点之前,必须确保当前应用程序能够有权限去读写

    否则是无法正常写入的,如果应用没有权限写设备节点,首先进入源码目录中system/core/rootdir/init.rc;
    修改内容如下:

           //开放节点让系统进程可以访问
         chown system system /sys/class/leds/red_aux/brightness
           //修改设备节点可读可写
         chmod 0666 /sys/class/leds/red_aux/brightness
    

    2.修改file.te

    进入/device/XXX/sepolicy/common
    找到file.te文件,加入以下的类型声明:
    定义selinux type

    # leds file
    type sysfs_ledred_leds, fs_type, sysfs_type;
    

    3.修改file_contexts

    进入/device/XXX/sepolicy/common
    找到修改file_contexts文件
    绑定sysfs_ledred_leds到对应的实际节点,加入以下声明:

    /sys/devices/soc/75b5000.i2c/i2c-7/7-0045/leds/red_aux/brightness u:object_r:sysfs_ledred_leds:s0
    

    4.修改sysetem_app.te文件

    找到修改sysetem_app.te文件
    加入以下权限声明:

    allow system_app sysfs_ledred_leds:file rw_file_perms;
    

    //rw_file_perms代表读写权限,该话的意思事允许system_app进程能够拥有对sysfs_ledred_leds的这个字符设备的读写权限;如果system_server 则表示是system_server进程

    allow system_app sysfs_ledred_leds:file { create open read setattr write };
    

    注意:以上的sysfs_ledred_leds必须与file.te文件中声明的文件类型、名称必须一致。

    5.APP

    APP 配置为系统APP
    在AndroidMainefest.xml中配置
    android:sharedUserId=”android.uid.system”;

    write_init("/sys/class/leds/red_aux/brightness", 255);
    

    6.kernel 中sysfs 读写权限

    S_IWUGO 全部用户读写

    S_IWUSR 用户读写

  • 相关阅读:
    将vue文件script代码抽取到单独的js文件
    git pull 提示错误:Your local changes to the following files would be overwritten by merge
    vue和uniapp 配置项目基础路径
    XAMPP Access forbidden! Access to the requested directory is only available from the local network.
    postman与newman集成
    postman生成代码段
    Curl命令
    POST方法的Content-type类型
    Selenium Grid 并行的Web测试
    pytorch转ONNX以及TnesorRT的坑
  • 原文地址:https://www.cnblogs.com/hellokitty2/p/13325051.html
Copyright © 2011-2022 走看看