Android SELinux 中是否可以使用包名作为域名?

Is it possible to use the package name as the domain name in Android SELinux?

Android SELinux(或者你可以说 SEAndroid)定义了很多域,包括 system_app、platform_app、isolated_app 等

每个域都有不同的含义,例如system_app包括共享系统uid的所有应用程序,platform_app包括签署平台密钥的所有应用程序。

所有 SE 文件都位于 external/sepolicy,我可以从这些文件修改规则。

是否可以定义一个指向指定包名称的新域(例如,com.google.android.music)?

我没有找到任何相关的文档或示例,所以我不确定该怎么做。

如有任何建议或意见,我将不胜感激。

谢谢。

经过长时间的研究,我找到了一种为指定包定义新域的方法

seapp_contexts

中定义一个新域

像这样,

user=_app domain=googlemusic seinfo=platform name=com.google.android.music type=app_data_file

然后定义新域的权限googlemusic

创建一个名为 googlemusic.te

的 te 文件

type googlemusic_app,domain

app_domain(googlemusic)

#more permissions

只是为了更新@alec.tu Android 12 的回答 - 在 googlemusic.te 文件中,前两行应该是:

typeattribute googlemusic_app coredomain;
app_domain(googlemusic_app)

还有另一个新文件 - system/sepolicy/public/googlemusic_app.te 应使用以下内容创建:

type googlemusic_app, domain;