blob: c0836ec634e07d4b6a2fb71964106152e8f959be [file] [log] [blame]
Andreas Gampe6d5baca2019-02-26 13:13:28 -08001# Domain for the otapreopt executable, running under postinstall_dexopt
2#
3# Note: otapreopt is a driver for dex2oat, and reuses parts of installd. As such,
4# this is derived and adapted from installd.te.
5
6type postinstall_dexopt, domain, coredomain;
Alex Klyubinf5446eb2017-03-23 14:27:32 -07007
dcashmancc39f632016-07-22 13:13:11 -07008# Run dex2oat/patchoat in its own sandbox.
9# We have to manually transition, as we don't have an entrypoint.
Roland Levillainab9c0532019-01-19 12:42:11 +000010domain_auto_trans(postinstall_dexopt, dex2oat_exec, dex2oat)
Andreas Gampe6d5baca2019-02-26 13:13:28 -080011
12allow postinstall_dexopt self:global_capability_class_set { chown dac_override dac_read_search fowner fsetid setgid setuid };
13
14allow postinstall_dexopt postinstall_file:filesystem getattr;
15allow postinstall_dexopt postinstall_file:dir { getattr read search };
16allow postinstall_dexopt postinstall_file:lnk_file { getattr read };
17allow postinstall_dexopt proc_filesystems:file { getattr open read };
18allow postinstall_dexopt tmpfs:file read;
19
20# Allow access to /postinstall/apex.
21allow postinstall_dexopt postinstall_apex_mnt_dir:dir { getattr search };
22
23# Note: /data/ota is created by init (see system/core/rootdir/init.rc) to avoid giving access
24# here and having to relabel the directory.
25
26# Read app data (APKs) as input to dex2oat.
27r_dir_file(postinstall_dexopt, apk_data_file)
28# Read vendor app data (APKs) as input to dex2oat.
29r_dir_file(postinstall_dexopt, vendor_app_file)
30# Access to app oat directory.
31r_dir_file(postinstall_dexopt, dalvikcache_data_file)
32
33# Read profile data.
34allow postinstall_dexopt user_profile_data_file:dir { getattr search };
35allow postinstall_dexopt user_profile_data_file:file r_file_perms;
36# Suppress deletion denial (we do not want to update the profile).
37dontaudit postinstall_dexopt user_profile_data_file:file { write };
38
39# Write to /data/ota(/*). Create symlinks in /data/ota(/*)
40allow postinstall_dexopt ota_data_file:dir create_dir_perms;
41allow postinstall_dexopt ota_data_file:file create_file_perms;
42allow postinstall_dexopt ota_data_file:lnk_file create_file_perms;
43
44# Need to write .b files, which are dalvikcache_data_file, not ota_data_file.
45# TODO: See whether we can apply ota_data_file?
46allow postinstall_dexopt dalvikcache_data_file:dir rw_dir_perms;
47allow postinstall_dexopt dalvikcache_data_file:file create_file_perms;
48
49# Allow labeling of files under /data/app/com.example/oat/
50# TODO: Restrict to .b suffix?
51allow postinstall_dexopt dalvikcache_data_file:dir relabelto;
52allow postinstall_dexopt dalvikcache_data_file:file { relabelto link };
53
54# Check validity of SELinux context before use.
55selinux_check_context(postinstall_dexopt)
56selinux_check_access(postinstall_dexopt)
57
58
59# Postinstall wants to know about our child.
60allow postinstall_dexopt postinstall:process sigchld;
61
62# Allow otapreopt to use file descriptors from otapreopt_chroot.
63# TODO: Probably we can actually close file descriptors...
64allow postinstall_dexopt otapreopt_chroot:fd use;
Nicolas Geoffray40014752019-03-01 10:05:35 +000065
66# Allow postinstall_dexopt to access the runtime feature flag properties.
67get_prop(postinstall_dexopt, device_config_runtime_native_prop)
68get_prop(postinstall_dexopt, device_config_runtime_native_boot_prop)