1、system_server进程又是由Zygote孵化出来的,于是我们在frameworks/base/core/java/com/android/internal/os/ZygoteInit.java看到startSystemServer方法,这是启动system_server进程的
在system/core/include/private/android_filesystem_config.h可以找到关于sdcard_rw的定义:
#define AID_SDCARD_RW 1015 /* external storage write access */
最后,我们在–setgroups字符串后面加上1015
2、Selinux 查看安全上下文
- 文件安全上下文 adb shell ls -Z
- 进程的安全上下文 adb shell ps -Z
selinux参考
https://blog.csdn.net/aihua53/article/details/51198652
https://blog.csdn.net/tkwxty/article/details/98213671
https://blog.csdn.net/chenjinlong126/article/details/80558022
https://blog.csdn.net/huangyabin001/article/details/79264222
3、开启system_server selinux的权限
修改external/sepolicy/system_server.te
-
修改Neverallow rules
allow system_server sdcard_type:dir { open read write };
allow system_server sdcard_type:file rw_file_perms;
添加
allow system_server self:unix_stream_socket { read write getattr create ioctl};
allow system_server fuse:dir { open search write read rename create rmdir getattr add_name setattr};
allow system_server fuse:file { open read write open execute getattr create ioctl setattr};
allow system_server shell_exec:file { execute read open execute_no_trans}; -
还会有一些和allow冲突的需要删除掉。
网友评论