【问题标题】:How is SEAndroid process domain givenSEAndroid进程域是如何给出的
【发布时间】:2014-11-10 14:51:57
【问题描述】:

我一直在研究 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

稍后在 init.c 中由 setexeccon 设置为写入的上下文:

if (svc->seclabel) {
    if (is_selinux_enabled() > 0 && setexeccon(svc->seclabel) < 0) {
        ERROR("cannot setexeccon('%s'): %s\n", svc->seclabel, strerror(errno));
        _exit(127);
    }
}

在上面的示例中,域将是 adbd。

但是我没有找到当服务声明中没有 seclabel 令牌时会发生什么。 init.c 中发生的事情是它不会调用 setexeccon,意思是……保留父域?

致电:

ps -Z

在显示所有进程及其域的 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

但调用 ps -Z 显示:

u:r:servicemanager:s0          system    53    1     /system/bin/servicemanager

怎么了?!

【问题讨论】:

    标签: android android-source selinux


    【解决方案1】:

    好的,我看了代码,终于有了答案!

    在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
    

    这根据一些输入定义每个进程的安全设置(输出)。我们可以在这个例子的第一行看到:

    如果它是系统服务器,它的域将是 system_server

    或者在最后一行:

    _app 关键字代表每个没有关联规则的应用程序。所以默认情况下,应用程序域将是 untrusted_app 并且属于它的文件标签将是 app_data_file。

    在文件中可以找到更多关于文件语法的文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-15
      • 2012-07-08
      相关资源
      最近更新 更多