use*_*844 3 android selinux android-source
我一直在寻找SEAndroid,并且一直在尝试了解过程域是如何给出的。
到目前为止,我得到的是init.rc文件中的某些服务声明下,有一个称为seclabel的令牌:
service adbd /sbin/adbd --root_seclabel=u:r:su:s0
class core
socket adbd stream 660 system system
disabled
seclabel u:r:adbd:s0
Run Code Online (Sandbox Code Playgroud)
setexeccon将稍后在init.c中设置为所写的上下文:
if (svc->seclabel) {
if (is_selinux_enabled() > 0 && setexeccon(svc->seclabel) < 0) {
ERROR("cannot setexeccon('%s'): %s\n", svc->seclabel, strerror(errno));
_exit(127);
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的示例中,域将为adbd。
但是我没有发现服务声明中没有seclabel令牌时会发生什么。init.c中发生的事情是它不会调用setexeccon,这意味着..保留父域?
致电至:
ps -Z
Run Code Online (Sandbox Code Playgroud)
在adb shell中,它显示了所有进程及其域,否则显示。
For example, the servicemanager in init.rc:
class core
user system
group system
critical
onrestart restart healthd
onrestart restart zygote
onrestart restart media
onrestart restart surfaceflinger
onrestart restart drm
Run Code Online (Sandbox Code Playgroud)
但是调用ps -Z显示:
u:r:servicemanager:s0 system 53 1 /system/bin/servicemanager
Run Code Online (Sandbox Code Playgroud)
这是怎么回事?!
好的,我查看了代码,终于得到了答案!
在android映像的根文件系统上找到的/ external / sepolicy / seapp_contexts文件包含以下内容:
isSystemServer=true domain=system_server
user=system domain=system_app type=system_app_data_file
user=bluetooth domain=bluetooth type=bluetooth_data_file
user=nfc domain=nfc type=nfc_data_file
user=radio domain=radio type=radio_data_file
user=shared_relro domain=shared_relro
user=shell domain=shell type=shell_data_file
user=_isolated domain=isolated_app levelFrom=user
user=_app seinfo=platform domain=platform_app type=app_data_file levelFrom=user
user=_app domain=untrusted_app type=app_data_file levelFrom=user
Run Code Online (Sandbox Code Playgroud)
这根据一些输入来定义每个过程的安全设置(输出)。我们可以在第一行的示例中看到:
如果是系统服务器,则其域将是system_server
或在最后一行:
_app关键字代表没有关联规则的每个应用。因此,默认情况下,应用程序域将是untrusted_app,属于它的文件的标签将是app_data_file。
在文件内部可以找到有关文件语法的更多文档。