调试Android的时候有时需要关闭Selinux验证问题。总结下关闭SELinux的方法。
adb shell getenforce 查看当前 Selinux 状态是 permissive(关闭)还是 enforce(打开)的
adb shell setenforce 0 开Selinux:设置成模式permissive
adb shell setenforce 1 关Selinux:设置成模式enforce
代码:
diff --git a/alps/system/core/init/selinux.cpp b/alps/system/core/init/selinux.cpp
index ce8348e..1b87d60 100644
--- a/alps/system/core/init/selinux.cpp
+++ b/alps/system/core/init/selinux.cpp
@@ -104,6 +104,8 @@ EnforcingStatus StatusFromCmdline() {
}
bool IsEnforcing() {
+ return false;
+
if (ALLOW_PERMISSIVE_SELINUX) {
return StatusFromCmdline() == SELINUX_ENFORCING;
}
Android 10:
bool IsEnforcing() {
{
int fd(open("/mboot/selinux", O_RDONLY | O_CLOEXEC | O_BINARY));
if (fd != -1) {
char v