Skip to content

Commit d3edd6b

Browse files
committed
Allow cppreopts to work with selinux
Bug: 29278988 Change-Id: I199572377a6b5c33116c718a545159ddcf50df30
1 parent 0989a53 commit d3edd6b

8 files changed

+51
-1
lines changed

cppreopts.te

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# cppreopts
2+
#
3+
# This command copies preopted files from the system_b partition to the data
4+
# partition. This domain ensures that we are only copying into specific
5+
# directories.
6+
7+
type cppreopts, domain, mlstrustedsubject;
8+
type cppreopts_exec, exec_type, file_type;
9+
10+
# Technically not a daemon but we do want the transition from init domain to
11+
# cppreopts to occur.
12+
init_daemon_domain(cppreopts)
13+
14+
domain_auto_trans(cppreopts, preopt2cachename_exec, preopt2cachename);
15+
16+
# Allow cppreopts copy files into the dalvik-cache
17+
allow cppreopts dalvikcache_data_file:dir { add_name remove_name search write };
18+
allow cppreopts dalvikcache_data_file:file { create getattr open read rename write };
19+
20+
# Allow cppreopts to execute itself using #!/system/bin/sh
21+
allow cppreopts shell_exec:file rx_file_perms;
22+
23+
# Allow us to run find on /postinstall
24+
allow cppreopts system_file:dir { open read };
25+
26+
# Allow running the cp command using cppreopts permissions. Needed so we can
27+
# write into dalvik-cache
28+
allow cppreopts toolbox_exec:file rx_file_perms;

domain.te

+2
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ neverallow {
378378
-zygote
379379
-installd
380380
-postinstall_dexopt
381+
-cppreopts
381382
-dex2oat
382383
} dalvikcache_data_file:file no_w_file_perms;
383384

@@ -386,6 +387,7 @@ neverallow {
386387
-init
387388
-installd
388389
-postinstall_dexopt
390+
-cppreopts
389391
-dex2oat
390392
-zygote
391393
} dalvikcache_data_file:dir no_w_dir_perms;

file_contexts

+2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@
203203
/system/bin/update_verifier u:object_r:update_verifier_exec:s0
204204
/system/bin/logwrapper u:object_r:system_file:s0
205205
/system/bin/vdc u:object_r:vdc_exec:s0
206+
/system/bin/cppreopts.sh u:object_r:cppreopts_exec:s0
207+
/system/bin/preopt2cachename u:object_r:preopt2cachename_exec:s0
206208
/system/bin/install-recovery.sh u:object_r:install_recovery_exec:s0
207209
/system/bin/dex2oat u:object_r:dex2oat_exec:s0
208210
# patchoat executable has (essentially) the same requirements as dex2oat.

init.te

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ allow init self:capability sys_admin;
4444

4545
# Create and mount on directories in /.
4646
allow init rootfs:dir create_dir_perms;
47-
allow init { rootfs cache_file cgroup storage_file system_data_file system_file }:dir mounton;
47+
allow init { rootfs cache_file cgroup storage_file system_data_file system_file postinstall_mnt_dir }:dir mounton;
4848

4949
# Mount on /dev/usb-ffs/adb.
5050
allow init device:dir mounton;

preopt2cachename.te

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# preopt2cachename executable
2+
#
3+
# This executable translates names from the preopted versions the build system
4+
# creates to the names the runtime expects in the data directory.
5+
type preopt2cachename, domain;
6+
type preopt2cachename_exec, exec_type, file_type;
7+
8+
# Allow write to stdout.
9+
allow preopt2cachename cppreopts:fd use;
10+
allow preopt2cachename cppreopts:fifo_file { getattr read write };
11+
12+
# Allow write to logcat.
13+
allow preopt2cachename proc_net:file r_file_perms;

property.te

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type security_prop, property_type, core_property_type;
3131
type bluetooth_prop, property_type, core_property_type;
3232
type pan_result_prop, property_type, core_property_type;
3333
type powerctl_prop, property_type, core_property_type;
34+
type cppreopt_prop, property_type, core_property_type;
3435
type nfc_prop, property_type, core_property_type;
3536
type dalvik_prop, property_type, core_property_type;
3637
type config_prop, property_type, core_property_type;

property_contexts

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ ro.runtime. u:object_r:system_prop:s0
2121
hw. u:object_r:system_prop:s0
2222
ro.hw. u:object_r:system_prop:s0
2323
sys. u:object_r:system_prop:s0
24+
sys.cppreopt u:object_r:cppreopt_prop:s0
2425
sys.powerctl u:object_r:powerctl_prop:s0
2526
sys.usb.ffs. u:object_r:ffs_prop:s0
2627
service. u:object_r:system_prop:s0

system_server.te

+3
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ userdebug_or_eng(`set_prop(system_server, wifi_log_prop)')
347347
set_prop(system_server, ctl_default_prop)
348348
set_prop(system_server, ctl_bugreport_prop)
349349

350+
# cppreopt property
351+
set_prop(system_server, cppreopt_prop)
352+
350353
# Create a socket for receiving info from wpa.
351354
type_transition system_server wifi_data_file:sock_file system_wpa_socket;
352355
type_transition system_server wpa_socket:sock_file system_wpa_socket;

0 commit comments

Comments
 (0)