1# installer daemon 2type installd, domain; 3type installd_exec, exec_type, file_type; 4 5init_daemon_domain(installd) 6typeattribute installd mlstrustedsubject; 7allow installd self:capability { chown dac_override fowner fsetid setgid setuid }; 8 9# Allow labeling of files under /data/app/com.example/oat/ 10allow installd dalvikcache_data_file:dir relabelto; 11allow installd dalvikcache_data_file:file { relabelto link }; 12 13# Allow movement of APK files between volumes 14allow installd apk_data_file:dir { create_dir_perms relabelfrom }; 15allow installd apk_data_file:file { create_file_perms relabelfrom link }; 16allow installd apk_data_file:lnk_file { create read unlink }; 17 18allow installd asec_apk_file:file r_file_perms; 19allow installd apk_tmp_file:file { r_file_perms unlink }; 20allow installd apk_tmp_file:dir { relabelfrom create_dir_perms }; 21allow installd oemfs:dir r_dir_perms; 22allow installd oemfs:file r_file_perms; 23allow installd system_file:file x_file_perms; 24allow installd cgroup:dir create_dir_perms; 25allow installd mnt_expand_file:dir { search getattr }; 26# Check validity of SELinux context before use. 27selinux_check_context(installd) 28# Read /seapp_contexts and /data/security/seapp_contexts 29security_access_policy(installd) 30 31# Search /data/app-asec and stat files in it. 32allow installd asec_image_file:dir search; 33allow installd asec_image_file:file getattr; 34 35# Create /data/user and /data/user/0 if necessary. 36# Also required to initially create /data/data subdirectories 37# and lib symlinks before the setfilecon call. May want to 38# move symlink creation after setfilecon in installd. 39allow installd system_data_file:dir create_dir_perms; 40allow installd system_data_file:lnk_file { create setattr unlink }; 41 42# Upgrade /data/media for multi-user if necessary. 43allow installd media_rw_data_file:dir create_dir_perms; 44allow installd media_rw_data_file:file { getattr unlink }; 45# restorecon new /data/media directory. 46allow installd system_data_file:dir relabelfrom; 47allow installd media_rw_data_file:dir relabelto; 48 49# Upgrade /data/misc/keychain for multi-user if necessary. 50allow installd misc_user_data_file:dir create_dir_perms; 51allow installd misc_user_data_file:file create_file_perms; 52allow installd keychain_data_file:dir create_dir_perms; 53allow installd keychain_data_file:file {r_file_perms unlink}; 54 55# Create /data/.layout_version.* file 56type_transition installd system_data_file:file install_data_file; 57allow installd install_data_file:file create_file_perms; 58 59# Create files under /data/dalvik-cache. 60allow installd dalvikcache_data_file:dir create_dir_perms; 61allow installd dalvikcache_data_file:file create_file_perms; 62 63# Create /data/dalvik-cache/profiles. 64allow installd dalvikcache_profiles_data_file:dir rw_dir_perms; 65allow installd dalvikcache_profiles_data_file:file create_file_perms; 66 67# Create files under /data/resource-cache. 68allow installd resourcecache_data_file:dir rw_dir_perms; 69allow installd resourcecache_data_file:file create_file_perms; 70 71# Run dex2oat in its own sandbox. 72domain_auto_trans(installd, dex2oat_exec, dex2oat) 73 74# Upgrade from unlabeled userdata. 75# Just need enough to remove and/or relabel it. 76allow installd unlabeled:dir { getattr search relabelfrom rw_dir_perms rmdir }; 77allow installd unlabeled:notdevfile_class_set { getattr relabelfrom rename unlink setattr }; 78# Read pkg.apk file for input during dexopt. 79allow installd unlabeled:file r_file_perms; 80 81# Upgrade from before system_app_data_file was used for system UID apps. 82# Just need enough to relabel it and to unlink removed package files. 83# Directory access covered by earlier rule above. 84allow installd system_data_file:notdevfile_class_set { getattr relabelfrom unlink }; 85 86# Manage /data/data subdirectories, including initially labeling them 87# upon creation via setfilecon or running restorecon_recursive, 88# setting owner/mode, creating symlinks within them, and deleting them 89# upon package uninstall. 90# Types extracted from seapp_contexts type= fields. 91allow installd { system_app_data_file bluetooth_data_file nfc_data_file radio_data_file shell_data_file app_data_file }:dir { create_dir_perms relabelfrom relabelto }; 92allow installd { system_app_data_file bluetooth_data_file nfc_data_file radio_data_file shell_data_file app_data_file }:notdevfile_class_set { create_file_perms relabelfrom relabelto }; 93 94# Create and use pty created by android_fork_execvp(). 95allow installd devpts:chr_file rw_file_perms; 96