selinux权限问题【转】
本文转载自: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权限问题【转】的更多相关文章
- apache 访问权限出错,apache selinux 权限问题, (13) Permission Denied
今天在使用 httpd 做文件服务器的时候,发现 png 图像没有打开,但是原本www/html 文件夹内部的文件就可以打开.后来猜测是selinux 的问题,之前一直想写一篇关于selinux 的博 ...
- SELinux 权限设置
SELinux 权限设置 一.SELinux简介 SELinux全称是Security Enhanced Linux,由美国国家安全部(National Security Agency)领导开发的GP ...
- centos 6.4 samba 权限 selinux权限配置
http://www.cnblogs.com/xiaoluo501395377/archive/2013/05/26/3100444.html(参考) SELINUX 策略 配置好samba后, 输入 ...
- Android 系统添加SELinux权限
本文为博主原创文章,转载请注明出处:https://i.cnblogs.com/EditPosts.aspx?postid=11185476 CPU:RK3288 系统:Android 5.1 SEL ...
- 快速解决Android中的selinux权限问题【转】
本文转载自:http://blog.csdn.net/mike8825/article/details/49428417 版权声明:本文为博主原创文章,未经博主允许不得转载. 关于selinux的详细 ...
- Android 6.0出现的init: cannot execve(‘XXX’):Permission denied问题:禁止SELINUX的权限设置
最近在开发MTK的相关项目,需要将一些可执行文件添加到init.rc文件里去,但是开机后发现,这个bin文件没有权限不能执行,于是我就在init.rc中对相应的bin文件增加了权限.后来发现,改了也没 ...
- 库会因为权限问题无法打开——selinux开启严格模式
第三方库会因为提高selinux权限等级而无法打开,若使用setenforce 0可以打开则可确认.需要增加相应权限.修改te权限. 查看SELinux状态: 1./usr/sbin/sestatus ...
- root权限后,不要忘了还有selinux
下面的例子运行在中兴android 5.0手机上. 当我们使用root权限的python去创建socket监听端口8088时,selinux向kmsg输出了下面的记录 python-android5 ...
- CentOS6.5 服务器+apache5.3绑定多个域名+SELinux设置
下面简单的介绍了如何通过设置Apache的http.conf文件,进行多个域名以及其相关的二级域名的绑定(假设我们要绑定的域名是minidx.com和ntt.cc,二级域名是blog.minidx.c ...
随机推荐
- LeetCode110.平衡二叉树
一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1. 示例 1: 给定二叉树 [3,9,20,null,null,15,7] 3 / \ 9 20 / \ 15 7 返回 true . 示例 ...
- C#会对于未赋值的变量/成员变量,给予一个初始值吗?
如果我有程序如下: C# code ? 1 2 3 4 5 6 7 public class My { public bool b; public ...
- C# JArray与JObject 的使用
STEP1.using Newtonsoft.Json.Linq; STEP2 如何获取json里的某个属性(节点)值,对其删改,新增 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 ...
- Lua之math
Lua之math函数: 转载请注明出处:http://www.cnblogs.com/jietian331/p/8032555.html abs 取绝对值 math.abs(-15) 15 acos ...
- PE结构图示
- 【转】robotFramework 与testlink集成
场景: robotframework 执行完用例之后,将执行结果报至testlink. 方案1: 通过TestLink-API-Python-client中的RF关键字 每条用例执行完成之后根据状态进 ...
- Linux 运维测试及第三应用及测试工具
一 .第三方应用及测试工具链接地址 https://pan.baidu.com/s/1rLQ5NCZvxcy93YQ4fGFaBQ 1.linux LSI系列raid卡监测工具 1)使用参数详解链接: ...
- 【Hadoop学习之二】Hadoop伪分布式安装
环境 虚拟机:VMware 10 Linux版本:CentOS-6.5-x86_64 客户端:Xshell4 FTP:Xftp4 jdk8 hadoop-3.1.1 伪分布式就 ...
- Python数据类型深入学习之数字
一. 数字常量 1. 下面来看看Python的数字常量中都要哪些类型: 数字 常量 129,-89,0 一般整数 9999848499999L,4594646469l 长整型数(无限大小) 1.232 ...
- android排除报很多错方法 Execution failed for task ':app:compileDebugJavaWithJavac' in Android Studio
android排除报很多错方法1.回撤对应layout的xml改动2.回撤对应java的改动3.重命名文件后导致的资源不对应 Execution failed for task ':app:compi ...