shell.te 3.23 KB
Newer Older
1
# Domain for shell processes spawned by ADB or console service.
Stephen Smalley's avatar
Stephen Smalley committed
2
type shell, domain, mlstrustedsubject;
3
type shell_exec, exec_type, file_type;
Stephen Smalley's avatar
Stephen Smalley committed
4

Stephen Smalley's avatar
Stephen Smalley committed
5 6 7
# Create and use network sockets.
net_domain(shell)

Stephen Smalley's avatar
Stephen Smalley committed
8
# Run app_process.
9
# XXX Transition into its own domain?
Stephen Smalley's avatar
Stephen Smalley committed
10
app_domain(shell)
11

Mark Salyzyn's avatar
Mark Salyzyn committed
12
# logcat
Mark Salyzyn's avatar
Mark Salyzyn committed
13 14
read_logd(shell)
control_logd(shell)
Mark Salyzyn's avatar
Mark Salyzyn committed
15 16 17
# logcat -L (directly, or via dumpstate)
allow shell pstorefs:dir search;
allow shell pstorefs:file r_file_perms;
Mark Salyzyn's avatar
Mark Salyzyn committed
18
# logpersistd (nee logcatd) files
19 20 21 22
userdebug_or_eng(`
  allow shell misc_logd_file:dir r_dir_perms;
  allow shell misc_logd_file:file r_file_perms;
')
Mark Salyzyn's avatar
Mark Salyzyn committed
23

24 25 26 27
# read files in /data/anr
allow shell anr_data_file:dir r_dir_perms;
allow shell anr_data_file:file r_file_perms;

Stephen Smalley's avatar
Stephen Smalley committed
28 29 30 31
# Access /data/local/tmp.
allow shell shell_data_file:dir create_dir_perms;
allow shell shell_data_file:file create_file_perms;
allow shell shell_data_file:file rx_file_perms;
32
allow shell shell_data_file:lnk_file create_file_perms;
Stephen Smalley's avatar
Stephen Smalley committed
33 34 35 36 37 38 39

# adb bugreport
unix_socket_connect(shell, dumpstate, dumpstate)

allow shell devpts:chr_file rw_file_perms;
allow shell tty_device:chr_file rw_file_perms;
allow shell console_device:chr_file rw_file_perms;
40
allow shell input_device:dir r_dir_perms;
Stephen Smalley's avatar
Stephen Smalley committed
41 42
allow shell input_device:chr_file rw_file_perms;
allow shell system_file:file x_file_perms;
43
allow shell toolbox_exec:file rx_file_perms;
Stephen Smalley's avatar
Stephen Smalley committed
44 45 46 47 48 49
allow shell shell_exec:file rx_file_perms;
allow shell zygote_exec:file rx_file_perms;

r_dir_file(shell, apk_data_file)

# Set properties.
50 51 52 53
set_prop(shell, shell_prop)
set_prop(shell, ctl_dumpstate_prop)
set_prop(shell, debug_prop)
set_prop(shell, powerctl_prop)
Stephen Smalley's avatar
Stephen Smalley committed
54 55 56 57 58 59 60

# systrace support - allow atrace to run
# debugfs doesn't support labeling individual files, so we have
# to grant read access to all of /sys/kernel/debug.
# Directory read access and file write access is already granted
# in domain.te.
allow shell debugfs:file r_file_perms;
61 62 63 64 65 66 67 68
allow shell atrace_exec:file rx_file_perms;

userdebug_or_eng(`
  # "systrace --boot" support - allow boottrace service to run
  allow shell boottrace_data_file:dir rw_dir_perms;
  allow shell boottrace_data_file:file create_file_perms;
  set_prop(shell, persist_debug_prop)
')
Stephen Smalley's avatar
Stephen Smalley committed
69 70 71

# allow shell to run dmesg
allow shell kernel:system syslog_read;
72

dcashman's avatar
dcashman committed
73
# allow shell access to services
74
allow shell servicemanager:service_manager list;
75 76
# don't allow shell to access GateKeeper service
allow shell { service_manager_type -gatekeeper_service }:service_manager find;
dcashman's avatar
dcashman committed
77 78 79 80

# allow shell to look through /proc/ for ps, top
allow shell domain:dir { search open read getattr };
allow shell domain:{ file lnk_file } { open read getattr };
81

82 83 84
# allow shell to read /proc/pid/attr/current for ps -Z
allow shell domain:process getattr;

85 86 87 88 89
# enable shell domain to read/write files/dirs for bootchart data
# User will creates the start and stop file via adb shell
# and read other files created by init process under /data/bootchart
allow shell bootchart_data_file:dir rw_dir_perms;
allow shell bootchart_data_file:file create_file_perms;
90 91 92 93 94 95 96 97

# Do not allow shell to hard link to any files.
# In particular, if shell hard links to app data
# files, installd will not be able to guarantee the deletion
# of the linked to file. Hard links also contribute to security
# bugs, so we want to ensure the shell user never has this
# capability.
neverallow shell file_type:file link;