Android关闭SLinux

调试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 = 0xff;
            if (read(fd, &v, 1) < 0)
                PLOG(ERROR) << "Failed to read /mboot/selinux";
            close(fd);
            LOG(WARNING) << "/mboot/selinux is " << v;
            return v == '1';
        }
    }
    + return false; //add to close selinux
    if (ALLOW_PERMISSIVE_SELINUX) {
        return StatusFromCmdline() == SELINUX_ENFORCING;
    }
    return true;
}

Android 9:

/system/core/init/selinux.cpp
 
bool IsEnforcing() {
+ return false; //add to close selinux
  if (ALLOW_PERMISSIVE_SELINUX) {
    return StatusFromCmdline() == SELINUX_ENFORCING;
   }
  return true;
}

相关推荐

  1. Android关闭SLinux

    2024-07-11 00:12:04       9 阅读
  2. SELinux 关闭修改

    2024-07-11 00:12:04       58 阅读
  3. AndroidSELinux详解

    2024-07-11 00:12:04       14 阅读
  4. Android Selinux详解[一]---整体介绍

    2024-07-11 00:12:04       22 阅读

最近更新

  1. pip简介与工作原理

    2024-07-11 00:12:04       0 阅读
  2. 【Ubuntu】Ubuntu20修改MAC地址

    2024-07-11 00:12:04       0 阅读
  3. 一文带你了解提升私域成交的四大关键因素

    2024-07-11 00:12:04       0 阅读
  4. CH02_XAML

    CH02_XAML

    2024-07-11 00:12:04      0 阅读
  5. Underlay和Fabric

    2024-07-11 00:12:04       0 阅读
  6. uniapp使用WebSocket发消息缓慢问题

    2024-07-11 00:12:04       0 阅读

热门阅读

  1. 小白学webgl合集-Three.js加载器

    2024-07-11 00:12:04       5 阅读
  2. 【AI工具】— 文心一言

    2024-07-11 00:12:04       8 阅读
  3. AWS IoT Core 权限管理指南

    2024-07-11 00:12:04       7 阅读
  4. 选择结构作业题(五.2)

    2024-07-11 00:12:04       8 阅读
  5. Vue 3 组件通信全解:从基础到高级技巧

    2024-07-11 00:12:04       7 阅读
  6. android gradle开发基础

    2024-07-11 00:12:04       6 阅读