Android 系统调试(1) 禁止SeLinux

有时候调试需要关闭SElinux , 下面方式可以临时或永久关闭SELinux 方式一:  adb shell "echo 0 > /sys/fs/seli

有时候调试需要关闭SElinux , 下面方式可以临时或永久关闭SELinux

方式一: 

adb shell "echo 0 > /sys/fs/selinux/enforce" //设置SELinux 成为permissive模式
adb shell "echo 1 > /sys/fs/selinux/enforce" //设置SELinux 成为enforcing模式 

方式二: 

adb shell setenforce 1 //设置SELinux 成为enforcing模式 
adb shell setenforce 0 //设置SELinux 成为permissive模式 

方式三: 

diff --git a/system/core/init/selinux.cpp b/system/core/init/selinux.cpp
index 438ba7a..8282d83 100755
--- a/system/core/init/selinux.cpp
+++ b/system/core/init/selinux.cpp
@@ -106,7 +106,8 @@ EnforcingStatus StatusFromCmdline() {bool IsEnforcing() {//return false;//add by hxqif (ALLOW_PERMISSIVE_SELINUX) {
-        return StatusFromCmdline() == SELINUX_ENFORCING;
+        //return StatusFromCmdline() == SELINUX_ENFORCING;
+        return StatusFromCmdline() == SELINUX_PERMISSIVE;}return true;}
--- a/system/core/init/service.cpp
+++ b/system/core/init/service.cpp
@@ -86,7 +86,9 @@ static Result ComputeContextFromExecutable(const std::string& servifree(new_con);}if (rc == 0 && computed_context == mycon.get()) {
-        return Error() << "File " << service_path << "(labeled \"" << filecon.get()
+        //return Error() << "File " << service_path << "(labeled \"" << filecon.get()
+               std::ostringstream file_label_err;
+               file_label_err << "File " << service_path << "(labeled \"" << filecon.get()<< "\") has incorrect label or no domain transition from " << mycon.get()<< " to another SELinux domain defined. Have you configured your ""service correctly? https://source.android.com/security/selinux/"