installd.te 4.46 KB
Newer Older
Stephen Smalley's avatar
Stephen Smalley committed
1
# installer daemon
2
type installd, domain, domain_deprecated;
Stephen Smalley's avatar
Stephen Smalley committed
3 4 5
type installd_exec, exec_type, file_type;

init_daemon_domain(installd)
6 7
typeattribute installd mlstrustedsubject;
allow installd self:capability { chown dac_override fowner fsetid setgid setuid };
Jeff Sharkey's avatar
Jeff Sharkey committed
8 9

# Allow labeling of files under /data/app/com.example/oat/
10
allow installd dalvikcache_data_file:dir relabelto;
11
allow installd dalvikcache_data_file:file { relabelto link };
Jeff Sharkey's avatar
Jeff Sharkey committed
12 13

# Allow movement of APK files between volumes
14
allow installd apk_data_file:dir { create_dir_perms relabelfrom };
15
allow installd apk_data_file:file { create_file_perms relabelfrom link };
16
allow installd apk_data_file:lnk_file { create read unlink };
Jeff Sharkey's avatar
Jeff Sharkey committed
17

18
allow installd asec_apk_file:file r_file_perms;
19 20
allow installd apk_tmp_file:file { r_file_perms unlink };
allow installd apk_tmp_file:dir { relabelfrom create_dir_perms };
Jeff Sharkey's avatar
Jeff Sharkey committed
21 22
allow installd oemfs:dir r_dir_perms;
allow installd oemfs:file r_file_perms;
23
allow installd cgroup:dir create_dir_perms;
24
allow installd mnt_expand_file:dir { search getattr };
25 26 27 28
# Check validity of SELinux context before use.
selinux_check_context(installd)
# Read /seapp_contexts and /data/security/seapp_contexts
security_access_policy(installd)
29

30
# Search /data/app-asec and stat files in it.
31
allow installd asec_image_file:dir search;
32
allow installd asec_image_file:file getattr;
33

34 35 36 37 38 39 40 41 42
# Create /data/user and /data/user/0 if necessary.
# Also required to initially create /data/data subdirectories
# and lib symlinks before the setfilecon call.  May want to
# move symlink creation after setfilecon in installd.
allow installd system_data_file:dir create_dir_perms;
allow installd system_data_file:lnk_file { create setattr unlink };

# Upgrade /data/media for multi-user if necessary.
allow installd media_rw_data_file:dir create_dir_perms;
43
allow installd media_rw_data_file:file { getattr unlink };
44
# restorecon new /data/media directory.
45
allow installd system_data_file:dir relabelfrom;
46 47
allow installd media_rw_data_file:dir relabelto;

48 49 50 51 52 53
# Upgrade /data/misc/keychain for multi-user if necessary.
allow installd misc_user_data_file:dir create_dir_perms;
allow installd misc_user_data_file:file create_file_perms;
allow installd keychain_data_file:dir create_dir_perms;
allow installd keychain_data_file:file {r_file_perms unlink};

54
# Create /data/.layout_version.* file
55 56
type_transition installd system_data_file:file install_data_file;
allow installd install_data_file:file create_file_perms;
57 58 59 60 61 62 63 64 65

# Create files under /data/dalvik-cache.
allow installd dalvikcache_data_file:dir create_dir_perms;
allow installd dalvikcache_data_file:file create_file_perms;

# Create /data/dalvik-cache/profiles.
allow installd dalvikcache_profiles_data_file:dir rw_dir_perms;
allow installd dalvikcache_profiles_data_file:file create_file_perms;

66 67 68 69
# Create files under /data/resource-cache.
allow installd resourcecache_data_file:dir rw_dir_perms;
allow installd resourcecache_data_file:file create_file_perms;

70 71 72
# Run dex2oat in its own sandbox.
domain_auto_trans(installd, dex2oat_exec, dex2oat)

Stephen Smalley's avatar
Stephen Smalley committed
73 74 75
# Run idmap in its own sandbox.
domain_auto_trans(installd, idmap_exec, idmap)

76
# Upgrade from unlabeled userdata.
77 78 79 80 81
# Just need enough to remove and/or relabel it.
allow installd unlabeled:dir { getattr search relabelfrom rw_dir_perms rmdir };
allow installd unlabeled:notdevfile_class_set { getattr relabelfrom rename unlink setattr };
# Read pkg.apk file for input during dexopt.
allow installd unlabeled:file r_file_perms;
82 83

# Upgrade from before system_app_data_file was used for system UID apps.
84
# Just need enough to relabel it and to unlink removed package files.
85
# Directory access covered by earlier rule above.
86
allow installd system_data_file:notdevfile_class_set { getattr relabelfrom unlink };
87 88 89 90 91 92 93

# Manage /data/data subdirectories, including initially labeling them
# upon creation via setfilecon or running restorecon_recursive,
# setting owner/mode, creating symlinks within them, and deleting them
# upon package uninstall.
# Types extracted from seapp_contexts type= fields.
allow 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 };
94 95 96 97
allow 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 };

# Create and use pty created by android_fork_execvp().
allow installd devpts:chr_file rw_file_perms;
98 99 100

# execute toybox for app relocation
allow installd toolbox_exec:file rx_file_perms;