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