blob: 6b1b2b8e1ccb6cf1f747da74393f8740993568f6 [file] [log] [blame]
Stephen Smalley2dd4e512012-01-04 12:33:27 -05001# installer daemon
2type installd, domain;
3type installd_exec, exec_type, file_type;
4
5init_daemon_domain(installd)
Nick Kralevich51946bc2013-07-01 17:08:11 -07006typeattribute installd mlstrustedsubject;
7allow installd self:capability { chown dac_override fowner fsetid setgid setuid };
Christopher Tate6f6c4252014-05-30 15:21:22 -07008allow installd apk_data_file:file rename;
9allow installd apk_data_file:dir create_dir_perms;
10allow installd apk_data_file:lnk_file { create read unlink };
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040011allow installd asec_apk_file:file r_file_perms;
Nick Kralevich51946bc2013-07-01 17:08:11 -070012allow installd apk_tmp_file:file r_file_perms;
Jeff Sharkey6838cd52014-04-25 13:59:52 -070013allow installd oemfs:dir r_dir_perms;
14allow installd oemfs:file r_file_perms;
Nick Kralevich51946bc2013-07-01 17:08:11 -070015allow installd system_file:file x_file_perms;
16allow installd cgroup:dir create_dir_perms;
Nick Kralevich51946bc2013-07-01 17:08:11 -070017# Check validity of SELinux context before use.
18selinux_check_context(installd)
19# Read /seapp_contexts and /data/security/seapp_contexts
20security_access_policy(installd)
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040021
Stephen Smalleyd2622fd2014-06-04 13:56:22 -040022# Search /data/app-asec and stat files in it.
Stephen Smalleyd30060a2014-05-14 08:29:00 -040023allow installd asec_image_file:dir search;
Stephen Smalleyd2622fd2014-06-04 13:56:22 -040024allow installd asec_image_file:file getattr;
Stephen Smalleyd30060a2014-05-14 08:29:00 -040025
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040026# Create /data/user and /data/user/0 if necessary.
27# Also required to initially create /data/data subdirectories
28# and lib symlinks before the setfilecon call. May want to
29# move symlink creation after setfilecon in installd.
30allow installd system_data_file:dir create_dir_perms;
31allow installd system_data_file:lnk_file { create setattr unlink };
32
33# Upgrade /data/media for multi-user if necessary.
34allow installd media_rw_data_file:dir create_dir_perms;
Stephen Smalleyd2622fd2014-06-04 13:56:22 -040035allow installd media_rw_data_file:file { getattr unlink };
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040036# restorecon new /data/media directory.
Stephen Smalley91a4f8d2014-05-07 13:10:02 -040037allow installd system_data_file:dir relabelfrom;
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040038allow installd media_rw_data_file:dir relabelto;
39
Robin Lee51bfecf2014-10-13 12:10:08 +010040# Upgrade /data/misc/keychain for multi-user if necessary.
41allow installd misc_user_data_file:dir create_dir_perms;
42allow installd misc_user_data_file:file create_file_perms;
43allow installd keychain_data_file:dir create_dir_perms;
44allow installd keychain_data_file:file {r_file_perms unlink};
45
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040046# Create /data/.layout_version.* file
Stephen Smalleybaf49bd2014-05-12 11:18:21 -040047type_transition installd system_data_file:file install_data_file;
48allow installd install_data_file:file create_file_perms;
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040049
50# Create files under /data/dalvik-cache.
51allow installd dalvikcache_data_file:dir create_dir_perms;
52allow installd dalvikcache_data_file:file create_file_perms;
53
54# Create /data/dalvik-cache/profiles.
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040055allow installd dalvikcache_profiles_data_file:dir rw_dir_perms;
56allow installd dalvikcache_profiles_data_file:file create_file_perms;
57
Nick Kralevichfad4d5f2014-06-16 14:19:31 -070058# Create files under /data/resource-cache.
59allow installd resourcecache_data_file:dir rw_dir_perms;
60allow installd resourcecache_data_file:file create_file_perms;
61
Ed Heyl8ee37b42014-07-14 23:32:08 -070062# Run dex2oat in its own sandbox.
63domain_auto_trans(installd, dex2oat_exec, dex2oat)
64# dex2oat needs LD_PRELOAD, passed down from init
65# https://android-review.googlesource.com/94851
66allow installd dex2oat:process noatsecure;
67
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040068# Upgrade from unlabeled userdata.
Stephen Smalleyf85c1fc2014-05-27 10:56:24 -040069# Just need enough to remove and/or relabel it.
70allow installd unlabeled:dir { getattr search relabelfrom rw_dir_perms rmdir };
71allow installd unlabeled:notdevfile_class_set { getattr relabelfrom rename unlink setattr };
72# Read pkg.apk file for input during dexopt.
73allow installd unlabeled:file r_file_perms;
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040074
75# Upgrade from before system_app_data_file was used for system UID apps.
Stephen Smalleybaf49bd2014-05-12 11:18:21 -040076# Just need enough to relabel it and to unlink removed package files.
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040077# Directory access covered by earlier rule above.
Stephen Smalleybaf49bd2014-05-12 11:18:21 -040078allow installd system_data_file:notdevfile_class_set { getattr relabelfrom unlink };
Stephen Smalley4ebbbcb2014-05-09 14:26:36 -040079
80# Manage /data/data subdirectories, including initially labeling them
81# upon creation via setfilecon or running restorecon_recursive,
82# setting owner/mode, creating symlinks within them, and deleting them
83# upon package uninstall.
84# Types extracted from seapp_contexts type= fields.
85allow 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 };
Stephen Smalley41e14c72014-05-12 08:41:14 -040086allow installd { system_app_data_file bluetooth_data_file nfc_data_file radio_data_file shell_data_file app_data_file }:lnk_file { create setattr getattr unlink rename relabelfrom relabelto };
Stephen Smalley89b9ff72014-06-11 09:09:25 -040087allow installd { system_app_data_file bluetooth_data_file nfc_data_file radio_data_file shell_data_file app_data_file }:{ file sock_file fifo_file } { getattr unlink rename relabelfrom relabelto setattr };