本文转载自:https://blog.csdn.net/u011386173/article/details/83339770

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011386173/article/details/83339770
adb修改selinux

Enforcing(表示已打开),Permissive(表示已关闭)
    getenforce; //获取当前selinux状态
    setenforce 1; //打开selinux
    setenforce 0; //关闭selinux

从kernel中彻底关闭

修改/linux/android/kernel/arch/arm64/configs/xxx_defconfig文件(xxx一般为产品名),去掉CONFIG_SECURITY_SELINUX = y的设置项

sepolicy中添加权限

修改依据,通过指令cat /proc/kmsg | grep denied,或Kernel 的log中定位到的标志性log
    修改步骤
        找相应的源类型.te文件,此文件可能存放的路径:
            linux/android/external/sepolicy
            linux/android/device/qcom/sepolicy/common
            device/xxx/sepolicy(与device相关)
        标志性log

avc: denied  { 操作权限  }  for pid=7201  comm=“进程名”  scontext=u:r:源类型:s0  tcontext=u:r:目标类型:s0  tclass=访问类型 permissive=0

·在相应源类型.te文件,添加如下格式的一行语句(结尾有分号)

格式:allow  源类型 目标类型:访问类型 {操作权限};

实例

kernel log:

avc: denied {getattr read} for pid=7201 comm="xxx.xxx" scontext=u:r:system_app:s0 tcontext=u:r:shell_data_file:s0 tclass=dir permissive=0

修改方案:

在system_app.te文件中,添加下面语句:
    allow system_app shell_data_file:dir{getattr read};

修改Sepolicy后出现“Error While Expanding policy”

在系统添加某个*.te或在te文件中添加某个selinux权限后,build会出现如下error:

genfscon proc /driver/thermal u:object_r:proc_thermal:s0
    libsepol.report_failure: neverallow on line 429 of system/sepolicy/private/app.te (or line 21317 of policy.conf) violated by allow system_app system_file:file { write };
    libsepol.report_failure: neverallow on line 406 of system/sepolicy/public/domain.te (or line 8484 of policy.conf) violated by allow system_app system_file:file { write };
    libsepol.check_assertions: 2 neverallow failures occurred
    Error while expanding policy

这是因为在/system/sepolicy/private/app.te和system/sepolicy/public/domain.te文件中添加了一些neverallow rules,导致编译检查的时候出现错误。

neverallow appdomain system_file:dir_file_class_set {create write setattr relabelfrom relabelto append unlink link rename};

只需要在上面的规则中去掉添加的allow xx system_file:file { write };中的xx,具体方式是在nerverallow中用{}里用-xx排除某个,即不需要有此规则:

neverallow {appdomain -system_app} system_file:dir_file_class_set {create write setattr relabelfrom relabelto append unlink link rename};

selinux权限问题【转】的更多相关文章

  1. apache 访问权限出错,apache selinux 权限问题, (13) Permission Denied

    今天在使用 httpd 做文件服务器的时候,发现 png 图像没有打开,但是原本www/html 文件夹内部的文件就可以打开.后来猜测是selinux 的问题,之前一直想写一篇关于selinux 的博 ...

  2. SELinux 权限设置

    SELinux 权限设置 一.SELinux简介 SELinux全称是Security Enhanced Linux,由美国国家安全部(National Security Agency)领导开发的GP ...

  3. centos 6.4 samba 权限 selinux权限配置

    http://www.cnblogs.com/xiaoluo501395377/archive/2013/05/26/3100444.html(参考) SELINUX 策略 配置好samba后, 输入 ...

  4. Android 系统添加SELinux权限

    本文为博主原创文章,转载请注明出处:https://i.cnblogs.com/EditPosts.aspx?postid=11185476 CPU:RK3288 系统:Android 5.1 SEL ...

  5. 快速解决Android中的selinux权限问题【转】

    本文转载自:http://blog.csdn.net/mike8825/article/details/49428417 版权声明:本文为博主原创文章,未经博主允许不得转载. 关于selinux的详细 ...

  6. Android 6.0出现的init: cannot execve(‘XXX’):Permission denied问题:禁止SELINUX的权限设置

    最近在开发MTK的相关项目,需要将一些可执行文件添加到init.rc文件里去,但是开机后发现,这个bin文件没有权限不能执行,于是我就在init.rc中对相应的bin文件增加了权限.后来发现,改了也没 ...

  7. 库会因为权限问题无法打开——selinux开启严格模式

    第三方库会因为提高selinux权限等级而无法打开,若使用setenforce 0可以打开则可确认.需要增加相应权限.修改te权限. 查看SELinux状态: 1./usr/sbin/sestatus ...

  8. root权限后,不要忘了还有selinux

    下面的例子运行在中兴android 5.0手机上. 当我们使用root权限的python去创建socket监听端口8088时,selinux向kmsg输出了下面的记录 python-android5 ...

  9. CentOS6.5 服务器+apache5.3绑定多个域名+SELinux设置

    下面简单的介绍了如何通过设置Apache的http.conf文件,进行多个域名以及其相关的二级域名的绑定(假设我们要绑定的域名是minidx.com和ntt.cc,二级域名是blog.minidx.c ...

随机推荐

  1. beego 初体验 - orm

    goland Terminal运行命令: go get github.com/astaxie/beego/orm 安装go mysql驱动: go get github.com/go-sql-driv ...

  2. VS编译后直接复制DLL库文件到其他目录下

    项目目录:SourceCode\公共组件\KApiClient\ 要复制的目的目录: SourceCode\公共组件\DllLibrary\ApiClient 则在项目 KApiClient下添加如下 ...

  3. <2>基本表达式和语句

    1.基本表达式 1: =, +, -, *, /, 赋值,加减剩除; lua 没有 c/c++的缩写表达式 += -= *=, ++, --; 2: () 改变运算的优先级; 3: 字符串对象加法.. ...

  4. windows启动项管理

    在运行框中输入 msconfig 选择启动栏 会跳转到任务管理器,可以管理启动项,可以看到我的启动项里有nc病毒 ,点击禁用即可.

  5. linux常见运维题

    linux运维题 一.填空题 1. 在Linux 系统 中,以文件方式访问设备 . (linux下一切都是文件) 2. Linux 内核引导时,从文件/etc/fstab中读取要加载的文件系统 . ( ...

  6. META标签之关键词、网页描述设置帮助SEO网站优化(转)

      ASP.NET 4.0 Web Forms针对SEO改进措施中有一个是在Page类中加了2个新属性:MetaKeywords 和MetaDescription,它们使得在后台代码类中用编程的手法设 ...

  7. Yii2缓存依赖

  8. python_super注意事项

    class room: def __init__(self,area=120,usedfor='sleep'): self.area = area self.usedfor = usedfor def ...

  9. ExtJS5入门

    https://www.cnblogs.com/xiaoliu66007/p/7988060.html

  10. 使用commons-compress解压GBK格式winzip文件到UTF8,以及错误使用ZipArchiveInputStream读出来数据全是空的解决办法

    先上正确方法: 正确方式应该为,先创建一个ZipFile,然后对其entries做遍历,每一个entry其实就是一个文件或者文件夹,检测到文件夹的时候创建文件夹,其他情况创建文件,其中使用zipFil ...