xref: /aosp_15_r20/system/sepolicy/private/runas.te (revision e4a36f4174b17bbab9dc043f4a65dc8d87377290)
1*e4a36f41SAndroid Build Coastguard Workertypeattribute runas coredomain;
2*e4a36f41SAndroid Build Coastguard Worker
3*e4a36f41SAndroid Build Coastguard Worker# ndk-gdb invokes adb shell run-as.
4*e4a36f41SAndroid Build Coastguard Workerdomain_auto_trans(shell, runas_exec, runas)
5*e4a36f41SAndroid Build Coastguard Worker
6*e4a36f41SAndroid Build Coastguard Workerallow runas adbd:fd use;
7*e4a36f41SAndroid Build Coastguard Workerallow runas adbd:process sigchld;
8*e4a36f41SAndroid Build Coastguard Workerallow runas adbd:unix_stream_socket { read write };
9*e4a36f41SAndroid Build Coastguard Workerallow runas shell:fd use;
10*e4a36f41SAndroid Build Coastguard Workerallow runas shell:fifo_file { read write };
11*e4a36f41SAndroid Build Coastguard Workerallow runas shell:unix_stream_socket { read write };
12*e4a36f41SAndroid Build Coastguard Workerallow runas devpts:chr_file { read write ioctl };
13*e4a36f41SAndroid Build Coastguard Workerallow runas shell_data_file:file { read write };
14*e4a36f41SAndroid Build Coastguard Worker
15*e4a36f41SAndroid Build Coastguard Worker# run-as reads package information.
16*e4a36f41SAndroid Build Coastguard Workerallow runas system_data_file:file r_file_perms;
17*e4a36f41SAndroid Build Coastguard Workerallow runas system_data_file:lnk_file getattr;
18*e4a36f41SAndroid Build Coastguard Workerallow runas packages_list_file:file r_file_perms;
19*e4a36f41SAndroid Build Coastguard Worker
20*e4a36f41SAndroid Build Coastguard Worker# The app's data dir may be accessed through a symlink.
21*e4a36f41SAndroid Build Coastguard Workerallow runas system_data_file:lnk_file read;
22*e4a36f41SAndroid Build Coastguard Worker
23*e4a36f41SAndroid Build Coastguard Worker# run-as checks and changes to the app data dir.
24*e4a36f41SAndroid Build Coastguard Workerdontaudit runas self:global_capability_class_set { dac_override dac_read_search };
25*e4a36f41SAndroid Build Coastguard Workerallow runas app_data_file:dir { getattr search };
26*e4a36f41SAndroid Build Coastguard Worker
27*e4a36f41SAndroid Build Coastguard Worker# run-as switches to the app UID/GID.
28*e4a36f41SAndroid Build Coastguard Workerallow runas self:global_capability_class_set { setuid setgid };
29*e4a36f41SAndroid Build Coastguard Worker
30*e4a36f41SAndroid Build Coastguard Worker# run-as switches to the app security context.
31*e4a36f41SAndroid Build Coastguard Workerselinux_check_context(runas) # validate context
32*e4a36f41SAndroid Build Coastguard Workerallow runas self:process setcurrent;
33*e4a36f41SAndroid Build Coastguard Workerallow runas non_system_app_set:process dyntransition; # setcon
34*e4a36f41SAndroid Build Coastguard Worker
35*e4a36f41SAndroid Build Coastguard Worker# runas/libselinux needs access to seapp_contexts_file to
36*e4a36f41SAndroid Build Coastguard Worker# determine which domain to transition to.
37*e4a36f41SAndroid Build Coastguard Workerallow runas seapp_contexts_file:file r_file_perms;
38*e4a36f41SAndroid Build Coastguard Worker
39*e4a36f41SAndroid Build Coastguard Worker###
40*e4a36f41SAndroid Build Coastguard Worker### neverallow rules
41*e4a36f41SAndroid Build Coastguard Worker###
42*e4a36f41SAndroid Build Coastguard Worker
43*e4a36f41SAndroid Build Coastguard Worker# run-as cannot have capabilities other than CAP_SETUID and CAP_SETGID
44*e4a36f41SAndroid Build Coastguard Workerneverallow runas self:global_capability_class_set ~{ setuid setgid };
45*e4a36f41SAndroid Build Coastguard Workerneverallow runas self:global_capability2_class_set *;
46