system app是否有访问/system目录的权限?

Does system app have permission to access /system directory?

我有一个使用平台密钥 签名 的应用程序,我想访问该文件,例如 /system/myfile.txt。系统应用程序是否有权在 /system/ 目录中 readwrite

任何应用或服务都不能写入/system,因为它是只读的。

您可以使用 sepolicy-check 工具检查 SELinux 策略。

. build/envsetup.sh
lunch
m sepolicy-check

# Check whether system_app can read system_file.
sepolicy-check -s system_app -t system_file -c file -p read -P $OUT/root/sepolicy; echo $?

# Check whether system_app can write system_file.
sepolicy-check -s system_app -t system_file -c file -p write -P $OUT/root/sepolicy; echo $?

read 检查打印 Match found! 消息和 returns 1write只检查returns0,说明没有找到allow规则。由于 SELinux 将只允许规则中明确允许的内容,因此系统应用程序禁止写入 /system