blob: 4b4093dc22e3789954c8a0352f8118ee2dc197de [file] [log] [blame]
Stephen Smalleyb3cb9692014-02-21 13:45:29 -05001# Domain for shell processes spawned by ADB or console service.
Stephen Smalley42fb8242014-06-11 07:10:09 -04002type shell, domain, mlstrustedsubject;
Stephen Smalley01301542013-09-27 10:38:14 -04003type shell_exec, exec_type, file_type;
Stephen Smalley2dd4e512012-01-04 12:33:27 -05004
Stephen Smalley396015c2014-01-07 12:47:10 -05005# Create and use network sockets.
6net_domain(shell)
7
Stephen Smalley2dd4e512012-01-04 12:33:27 -05008# Run app_process.
Stephen Smalley712ca0a2013-10-23 13:25:53 -04009# XXX Transition into its own domain?
Stephen Smalley2dd4e512012-01-04 12:33:27 -050010app_domain(shell)
Stephen Smalleyd99e6d52013-12-02 14:18:11 -050011
Mark Salyzyn34d32ea2014-12-15 12:01:35 -080012# logcat
Mark Salyzynad5315d2014-03-17 13:00:38 -070013read_logd(shell)
14control_logd(shell)
Mark Salyzyn34d32ea2014-12-15 12:01:35 -080015# logcat -L (directly, or via dumpstate)
16allow shell pstorefs:dir search;
17allow shell pstorefs:file r_file_perms;
Mark Salyzyn7e0838a2015-05-26 15:12:45 -070018# logpersistd (nee logcatd) files
19allow shell misc_logd_file:dir r_dir_perms;
20allow shell misc_logd_file:file r_file_perms;
Mark Salyzynad5315d2014-03-17 13:00:38 -070021
Nick Kralevich4fd4a202014-06-05 13:27:44 -070022# read files in /data/anr
23allow shell anr_data_file:dir r_dir_perms;
24allow shell anr_data_file:file r_file_perms;
25
Stephen Smalley42fb8242014-06-11 07:10:09 -040026# Access /data/local/tmp.
27allow shell shell_data_file:dir create_dir_perms;
28allow shell shell_data_file:file create_file_perms;
29allow shell shell_data_file:file rx_file_perms;
Brian Carlstromfc6214b2014-12-09 23:49:31 -080030allow shell shell_data_file:lnk_file create_file_perms;
Stephen Smalley42fb8242014-06-11 07:10:09 -040031
32# adb bugreport
33unix_socket_connect(shell, dumpstate, dumpstate)
34
Stephen Smalley42fb8242014-06-11 07:10:09 -040035allow shell devpts:chr_file rw_file_perms;
36allow shell tty_device:chr_file rw_file_perms;
37allow shell console_device:chr_file rw_file_perms;
Stephen Smalleya2e4e262014-06-11 12:09:15 -040038allow shell input_device:dir r_dir_perms;
Stephen Smalley42fb8242014-06-11 07:10:09 -040039allow shell input_device:chr_file rw_file_perms;
40allow shell system_file:file x_file_perms;
41allow shell shell_exec:file rx_file_perms;
42allow shell zygote_exec:file rx_file_perms;
43
44r_dir_file(shell, apk_data_file)
45
46# Set properties.
William Roberts2f5a6a92015-05-04 18:22:45 -070047set_prop(shell, shell_prop)
48set_prop(shell, ctl_dumpstate_prop)
49set_prop(shell, debug_prop)
50set_prop(shell, powerctl_prop)
Stephen Smalley42fb8242014-06-11 07:10:09 -040051
52# systrace support - allow atrace to run
53# debugfs doesn't support labeling individual files, so we have
54# to grant read access to all of /sys/kernel/debug.
55# Directory read access and file write access is already granted
56# in domain.te.
57allow shell debugfs:file r_file_perms;
58
59# allow shell to run dmesg
60allow shell kernel:system syslog_read;
dcashman0780f302014-12-30 15:21:50 -080061
dcashman5fef2de2015-01-23 15:55:42 -080062# allow shell access to services
dcashman0780f302014-12-30 15:21:50 -080063allow shell servicemanager:service_manager list;
Andres Moralese2079862015-04-03 16:46:33 -070064# don't allow shell to access GateKeeper service
65allow shell { service_manager_type -gatekeeper_service }:service_manager find;
dcashman25fef2e2015-01-16 13:39:59 -080066
67# allow shell to look through /proc/ for ps, top
68allow shell domain:dir { search open read getattr };
69allow shell domain:{ file lnk_file } { open read getattr };
Yongqin Liucc38e6d2014-12-05 13:40:22 +080070
Stephen Smalleyd5892b42015-03-16 11:43:22 -040071# allow shell to read /proc/pid/attr/current for ps -Z
72allow shell domain:process getattr;
73
Yongqin Liucc38e6d2014-12-05 13:40:22 +080074# enable shell domain to read/write files/dirs for bootchart data
75# User will creates the start and stop file via adb shell
76# and read other files created by init process under /data/bootchart
77allow shell bootchart_data_file:dir rw_dir_perms;
78allow shell bootchart_data_file:file create_file_perms;
Nick Kraleviche0c8da22015-04-16 08:43:10 -070079
Jeff Vander Stoepc47a11b2016-01-05 13:16:34 -080080# only allow unprivileged socket ioctl commands
81allow shell self:{ rawip_socket tcp_socket udp_socket } unpriv_sock_ioctls;
82
Nick Kraleviche0c8da22015-04-16 08:43:10 -070083# Do not allow shell to hard link to any files.
84# In particular, if shell hard links to app data
85# files, installd will not be able to guarantee the deletion
86# of the linked to file. Hard links also contribute to security
87# bugs, so we want to ensure the shell user never has this
88# capability.
89neverallow shell file_type:file link;