概述
SEAndroid是在Android 4.3版本中开始引入的基于SELinux的系统安全机制。
关于SELinux的一些基础已经在SELinux基础中总结了。
在平时工作中,遇到SEAndroid最多的,就是一些权限问题,因此,本文的主要目标,是如何查看SELinux权限拒绝信息、如何修改添加权限。
1.SEAndroid相关文件
1.system/sepolicy目录
该目录是SEAndroid的核心,该目录中的文件在编译后会包含 SELinux 内核安全政策,并涵盖上游 Android 操作系统。
一般来说,不能直接修改system/sepolicy
文件,而是添加或修改自己的设备专用政策文件,即在/device/xxx/xxx/sepolicy文件。
2.te文件
以.te结尾的文件是SEAndroid的政策文件,在文件位于/system/sepolicy中,用来定义域(domain)和标签.如在/system/sepolicy/public/init.te中:
# Create and mount on directories in /.
allow init rootfs:dir create_dir_perms;
allow init {
rootfs cache_file cgroup storage_file system_data_file system_file vendor_file postinstall_mnt_dir }:dir mounton;
allow init cgroup_bpf:dir {
create mounton };
...
# Init should not access sysfs node that are not explicitly labeled.
neverallow init sysfs:file {
open read write };
allow语句和neverallow语句用来定义规则,具体含义参见在SELinux中的说明.
1.一般情况下,不能修改/system/sepolicy下的.te文件,而是在/device/xxx/xxx/s