非初始化进程/文件的SElinux域转换(Android Natvie)
我正在编写Android原生程序并设置它们的SEPolicy 我想知道如何为非init程序设置进程上下文,域转换似乎不起作用 我编写了两个程序,并将构建的可执行文件放入/vendor/bin 一个程序,my_service作为init守护进程服务运行 而另一个,my_client是一个非init程序,必须手动执行 这两个程序使用活页夹IPC进行通信 但我在尝试为非init程序的我的客户机设置进程上下文时遇到问题非初始化进程/文件的SElinux域转换(Android Natvie),android,selinux,android-binder,seandroid,Android,Selinux,Android Binder,Seandroid,我正在编写Android原生程序并设置它们的SEPolicy 我想知道如何为非init程序设置进程上下文,域转换似乎不起作用 我编写了两个程序,并将构建的可执行文件放入/vendor/bin 一个程序,my_service作为init守护进程服务运行 而另一个,my_client是一个非init程序,必须手动执行 这两个程序使用活页夹IPC进行通信 但我在尝试为非init程序的我的客户机设置进程上下文时遇到问题 # In file_context /vendor/bin/my_client
# In file_context
/vendor/bin/my_client u:object_r:my_client_exec:s0
# In my_client.te
type my_client, domain;
type my_client_exec, exec_type, file_type, vendor_file_type;
init_daemon_domain(my_client)
对于my_服务,它的selinux上下文主要在2个文件中设置
# In init.rc
service my_service /vendor/bin/my_service
class main
console
seclabel u:r:my_service:s0
我检查了我的\u服务的文件上下文和流程上下文,它们被设置为我所期望的
对于my_client的SEPolicy,所有内容都与my_service类似,只是它不是init程序,因此未写入init.rc文件
# In file_context
/vendor/bin/my_client u:object_r:my_client_exec:s0
# In my_client.te
type my_client, domain;
type my_client_exec, exec_type, file_type, vendor_file_type;
init_daemon_domain(my_client)
但是,对于my_client,只有文件上下文设置为my_client\u exec
我尝试运行我的_客户端并查看了流程上下文:
> # Executing my_client manually
> /vendor/bin/my_client
> ps -AZ | grep my_client
> u:r:su:s0 root 5838 5514 5948 1688 0 0 R my_client
流程上下文是su,而我希望它是my_client
此外,我在te\u宏中获得了关于init\u守护进程\u域(XX)的信息
我认为它会进行域转换:当init运行带有XX_exec上下文的文件时,它会将其进程上下文传输到XX
因此,我将规则更改为:
# init_daemon_domain(my_client)
domain_auto_trans(su, my_client_exec, my_client);
但这违反了一些预先定义的政策
顺便说一句,这两个程序之间的绑定器IPC似乎工作正常 令人困惑的是,即使流程上下文不是“我的客户机”,以下规则仍然有效
binder_call(my_client, my_service)
binder_call(my_service, my_service)
有没有办法为非init程序进行域转换
或者我误解了关于SEPolicy的任何事情?因为我找到的所有资源都是关于为init程序设置SEPolicy的
# In file_context
/vendor/bin/my_client u:object_r:my_client_exec:s0
# In my_client.te
type my_client, domain;
type my_client_exec, exec_type, file_type, vendor_file_type;
init_daemon_domain(my_client)