2014-02-21 19:45:29 +01:00
|
|
|
# Domain for shell processes spawned by ADB or console service.
|
2015-11-28 04:18:17 +01:00
|
|
|
type shell, domain, mlstrustedsubject;
|
2013-09-27 16:38:14 +02:00
|
|
|
type shell_exec, exec_type, file_type;
|
2012-01-04 18:33:27 +01:00
|
|
|
|
2014-01-07 18:47:10 +01:00
|
|
|
# Create and use network sockets.
|
|
|
|
net_domain(shell)
|
|
|
|
|
2012-01-04 18:33:27 +01:00
|
|
|
# Run app_process.
|
2013-10-23 19:25:53 +02:00
|
|
|
# XXX Transition into its own domain?
|
2012-01-04 18:33:27 +01:00
|
|
|
app_domain(shell)
|
2013-12-02 20:18:11 +01:00
|
|
|
|
2014-12-15 21:01:35 +01:00
|
|
|
# logcat
|
2014-03-17 21:00:38 +01:00
|
|
|
read_logd(shell)
|
|
|
|
control_logd(shell)
|
2014-12-15 21:01:35 +01:00
|
|
|
# logcat -L (directly, or via dumpstate)
|
|
|
|
allow shell pstorefs:dir search;
|
|
|
|
allow shell pstorefs:file r_file_perms;
|
2015-05-27 00:12:45 +02:00
|
|
|
# logpersistd (nee logcatd) files
|
2015-09-22 01:22:21 +02:00
|
|
|
userdebug_or_eng(`
|
|
|
|
allow shell misc_logd_file:dir r_dir_perms;
|
|
|
|
allow shell misc_logd_file:file r_file_perms;
|
|
|
|
')
|
2014-03-17 21:00:38 +01:00
|
|
|
|
2015-11-28 04:18:17 +01:00
|
|
|
# interact with adb
|
|
|
|
allow shell adbd:fd use;
|
|
|
|
allow shell adbd:unix_stream_socket { read write ioctl getattr };
|
|
|
|
|
2015-12-02 01:28:28 +01:00
|
|
|
# Root fs.
|
|
|
|
allow shell rootfs:dir r_dir_perms;
|
|
|
|
|
2014-06-05 22:27:44 +02:00
|
|
|
# read files in /data/anr
|
|
|
|
allow shell anr_data_file:dir r_dir_perms;
|
|
|
|
allow shell anr_data_file:file r_file_perms;
|
|
|
|
|
2014-06-11 13:10:09 +02:00
|
|
|
# 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;
|
2014-12-10 08:49:31 +01:00
|
|
|
allow shell shell_data_file:lnk_file create_file_perms;
|
2014-06-11 13:10:09 +02:00
|
|
|
|
2015-10-29 00:45:58 +01:00
|
|
|
# Read/execute files in /data/nativetest
|
|
|
|
userdebug_or_eng(`
|
|
|
|
allow shell nativetest_data_file:dir r_dir_perms;
|
|
|
|
allow shell nativetest_data_file:file rx_file_perms;
|
|
|
|
')
|
|
|
|
|
2014-06-11 13:10:09 +02:00
|
|
|
# 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;
|
2014-06-11 18:09:15 +02:00
|
|
|
allow shell input_device:dir r_dir_perms;
|
2014-06-11 13:10:09 +02:00
|
|
|
allow shell input_device:chr_file rw_file_perms;
|
2015-12-04 18:05:02 +01:00
|
|
|
r_dir_file(shell, system_file)
|
2014-06-11 13:10:09 +02:00
|
|
|
allow shell system_file:file x_file_perms;
|
2015-08-25 17:38:29 +02:00
|
|
|
allow shell toolbox_exec:file rx_file_perms;
|
2014-06-11 13:10:09 +02:00
|
|
|
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.
|
2015-05-05 03:22:45 +02:00
|
|
|
set_prop(shell, shell_prop)
|
2015-12-02 03:03:05 +01:00
|
|
|
set_prop(shell, ctl_bugreport_prop)
|
2015-05-05 03:22:45 +02:00
|
|
|
set_prop(shell, ctl_dumpstate_prop)
|
2015-12-02 03:03:05 +01:00
|
|
|
set_prop(shell, dumpstate_prop)
|
2015-05-05 03:22:45 +02:00
|
|
|
set_prop(shell, debug_prop)
|
|
|
|
set_prop(shell, powerctl_prop)
|
2014-06-11 13:10:09 +02:00
|
|
|
|
|
|
|
# systrace support - allow atrace to run
|
2015-12-14 22:57:26 +01:00
|
|
|
allow shell debugfs_tracing:dir r_dir_perms;
|
|
|
|
allow shell debugfs_tracing:file rw_file_perms;
|
2015-12-16 21:50:06 +01:00
|
|
|
allow shell debugfs_trace_marker:file getattr;
|
2015-06-24 08:24:17 +02:00
|
|
|
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)
|
|
|
|
')
|
2014-06-11 13:10:09 +02:00
|
|
|
|
|
|
|
# allow shell to run dmesg
|
|
|
|
allow shell kernel:system syslog_read;
|
2014-12-31 00:21:50 +01:00
|
|
|
|
2015-01-24 00:55:42 +01:00
|
|
|
# allow shell access to services
|
2014-12-31 00:21:50 +01:00
|
|
|
allow shell servicemanager:service_manager list;
|
2015-04-04 01:46:33 +02:00
|
|
|
# don't allow shell to access GateKeeper service
|
|
|
|
allow shell { service_manager_type -gatekeeper_service }:service_manager find;
|
2015-01-16 22:39:59 +01:00
|
|
|
|
2015-12-08 16:07:42 +01:00
|
|
|
# allow shell to look through /proc/ for ps, top, netstat
|
2015-11-28 04:18:17 +01:00
|
|
|
r_dir_file(shell, proc)
|
2015-12-08 16:07:42 +01:00
|
|
|
r_dir_file(shell, proc_net)
|
2015-11-28 04:18:17 +01:00
|
|
|
r_dir_file(shell, cgroup)
|
2015-01-16 22:39:59 +01:00
|
|
|
allow shell domain:dir { search open read getattr };
|
|
|
|
allow shell domain:{ file lnk_file } { open read getattr };
|
2014-12-05 06:40:22 +01:00
|
|
|
|
2015-12-23 01:41:27 +01:00
|
|
|
# statvfs() of /proc and other labeled filesystems
|
|
|
|
# (yaffs2, jffs2, ext2, ext3, ext4, xfs, btrfs, f2fs, squashfs)
|
|
|
|
allow shell { proc labeledfs }:filesystem getattr;
|
|
|
|
|
|
|
|
# stat() of /dev
|
|
|
|
allow shell device:dir getattr;
|
|
|
|
|
2015-03-16 16:43:22 +01:00
|
|
|
# allow shell to read /proc/pid/attr/current for ps -Z
|
|
|
|
allow shell domain:process getattr;
|
|
|
|
|
2015-12-03 22:28:14 +01:00
|
|
|
# Allow pulling the SELinux policy for CTS purposes
|
|
|
|
allow shell selinuxfs:dir r_dir_perms;
|
|
|
|
allow shell selinuxfs:file r_file_perms;
|
|
|
|
|
2014-12-05 06:40:22 +01:00
|
|
|
# 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;
|
2015-04-16 17:43:10 +02:00
|
|
|
|
2015-10-15 22:35:01 +02:00
|
|
|
# Make sure strace works for the non-privileged shell user
|
|
|
|
allow shell self:process ptrace;
|
|
|
|
|
2016-01-05 23:32:54 +01:00
|
|
|
# allow shell to get battery info
|
|
|
|
allow shell sysfs_batteryinfo:file r_file_perms;
|
2016-01-13 18:02:36 +01:00
|
|
|
allow shell sysfs:dir r_dir_perms;
|
2015-12-22 18:40:03 +01:00
|
|
|
|
|
|
|
# Allow access to ion memory allocation device.
|
|
|
|
allow shell ion_device:chr_file rw_file_perms;
|
|
|
|
|
|
|
|
###
|
|
|
|
### Neverallow rules
|
|
|
|
###
|
|
|
|
|
2015-04-16 17:43:10 +02:00
|
|
|
# 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;
|