1 ps -AZ
可以看到对应进程的sepolicy domain信息
如下面的 platform_app gmscore_app priv_app mediashell_app
u:r:platform_app:s0:c512,c768 u0_a66 954 383 1109868 51060 do_epoll_wait 0 S com.android.systemuiu:r:gmscore_app:s0:c512,c768 u0_a41 1260 383 1251484 106244 do_epoll_wait 0 S com.google.android.gms.persistentu:r:priv_app:s0:c512,c768 u0_a39 1698 383 1331920 51540 do_epoll_wait 0 S com.google.android.katniss:searchu:r:mediashell_app:s0:c34,c256,c512,c768 u0_a34 2308 383 1220064 50232 do_epoll_wait 0 S com.google.android.apps.mediashell
2 哪里指定这些进程的sepolicy domain信息呢
是android aosp code中的有指定:
system/sepolicy/private/seapp_contexts
user=system seinfo=platform domain=system_app type=system_app_data_fileuser=_app seinfo=app_zygote domain=app_zygote levelFrom=user
user=_app seinfo=media domain=mediaprovider type=app_data_file levelFrom=user
user=_app seinfo=platform domain=platform_app type=app_data_file levelFrom=user
user=_app isEphemeralApp=true domain=ephemeral_app type=app_data_file levelFrom=all
user=_app isPrivApp=true domain=priv_app type=privapp_data_file levelFrom=user
user=_app isPrivApp=true name=com.google.android.permissioncontroller domain=permissioncontroller_app type=privapp_data_file levelFrom=all
user=_app seinfo=media isPrivApp=true name=com.android.providers.media.module domain=mediaprovider_app type=privapp_data_file levelFrom=all
user=_app isPrivApp=true name=com.google.android.providers.media.module domain=mediaprovider_app type=privapp_data_file levelFrom=all
user=_app seinfo=platform isPrivApp=true name=com.android.permissioncontroller domain=permissioncontroller_app type=privapp_data_file levelFrom=all
user=_app isPrivApp=true name=com.android.vzwomatrigger domain=vzwomatrigger_app type=privapp_data_file levelFrom=all
user=_app isPrivApp=true name=com.google.android.gms domain=gmscore_app type=privapp_data_file levelFrom=user
user=_app isPrivApp=true name=com.google.android.gms.* domain=gmscore_app type=privapp_data_file levelFrom=user
user=_app isPrivApp=true name=com.google.android.gms:* domain=gmscore_app type=privapp_data_file levelFrom=user
user=_app isPrivApp=true name=com.google.android.gsf domain=gmscore_app type=privapp_data_file levelFrom=user
user=_app minTargetSdkVersion=30 domain=untrusted_app type=app_data_file levelFrom=all
user=_app minTargetSdkVersion=29 domain=untrusted_app_29 type=app_data_file levelFrom=all
user=_app minTargetSdkVersion=28 domain=untrusted_app_27 type=app_data_file levelFrom=all
user=_app minTargetSdkVersion=26 domain=untrusted_app_27 type=app_data_file levelFrom=user
user=_app domain=untrusted_app_25 type=app_data_file levelFrom=user
user=_app minTargetSdkVersion=28 fromRunAs=true domain=runas_app levelFrom=all
user=_app fromRunAs=true domain=runas_app levelFrom=user
user:指apk process的userid,如system app等, ps -AZ的第二列可以看出来
seinfo 可能与apk签名有关系(certificate),如 platform、media 等
isPrivApp: 是指apk存放的路径,是否在priv-app下,android.bp中指定
domain: 分配给apk process的selinux domain信息
type:是该apk process 创建的文件的selinux 信息
具体几个常见的domain:
system_app: userid是system,且是platform签名
正常apk可以在androidManifest.xml中指定sharedUserId
platform_app :非system userid,正常apk userid, 具有platform签名
priv_app : 非system userid,正常apk userid, 无platform签名,在priv-app下
上述domain信息都有自己对应的sepolicy权限设置,可以具体参考source code中定义
system/sepolicy/private/gmscore_app.te
system/sepolicy/public/gmscore_app.te
system/sepolicy/private/priv_app.te
system/sepolicy/public/priv_app.te
system/sepolicy/private/platform_app.te
system/sepolicy/public/platform_app.te
system/sepolicy/private/system_app.te
system/sepolicy/public/system_app.te