方法1: adb在線修改seLinux
Enforcing
(表示已打開),Permissive
(表示已關閉)
getenforce; //獲取當前seLinux狀態
setenforce 1; //打開seLinux
setenforce 0; //關閉seLinux
方法2: 從kernel中徹底關閉
修改LINUX/android/kernel/arch/arm64/configs/xxx_defconfig
文件(xxx一般爲手機產品名),
去掉CONFIG_SECURITY_SELINUX=y
的配置項
方法3: sepolicy中添加權限
-
修改依據,通過指令
cat /proc/kmsg | grep denied
,或者kernel的Log中定位到標誌性log。 - 修改步驟
-
找相應的源類型.te文件,此文件可能的存放路徑 (其中源類型見下方的標誌性log格式) :
LINUX/android/external/sepolicy LINUX/android/device/qcom/sepolicy/common
-
標誌性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};
-