Ricardo Cerqueira | 09159ac | 2014-11-26 21:34:15 +0000 | [diff] [blame] | 1 | type superuser_device, file_type; |
| 2 | |
| 3 | ## Perms for the daemon |
| 4 | |
| 5 | type sudaemon, domain; |
| 6 | |
| 7 | userdebug_or_eng(` |
| 8 | domain_trans(init, su_exec, sudaemon) |
| 9 | # The userspace app uses /dev sockets to control per-app access |
| 10 | allow sudaemon superuser_device:dir { create rw_dir_perms setattr unlink }; |
| 11 | allow sudaemon superuser_device:sock_file { create setattr unlink write }; |
| 12 | |
| 13 | # sudaemon is also permissive to permit setenforce. |
| 14 | permissive sudaemon; |
| 15 | |
| 16 | # Add sudaemon to various domains |
| 17 | net_domain(sudaemon) |
| 18 | app_domain(sudaemon) |
| 19 | |
| 20 | dontaudit sudaemon self:capability_class_set *; |
| 21 | dontaudit sudaemon kernel:security *; |
| 22 | dontaudit sudaemon kernel:system *; |
| 23 | dontaudit sudaemon self:memprotect *; |
| 24 | dontaudit sudaemon domain:process *; |
| 25 | dontaudit sudaemon domain:fd *; |
| 26 | dontaudit sudaemon domain:dir *; |
| 27 | dontaudit sudaemon domain:lnk_file *; |
| 28 | dontaudit sudaemon domain:{ fifo_file file } *; |
| 29 | dontaudit sudaemon domain:socket_class_set *; |
| 30 | dontaudit sudaemon domain:ipc_class_set *; |
| 31 | dontaudit sudaemon domain:key *; |
| 32 | dontaudit sudaemon fs_type:filesystem *; |
| 33 | dontaudit sudaemon {fs_type dev_type file_type}:dir_file_class_set *; |
| 34 | dontaudit sudaemon node_type:node *; |
| 35 | dontaudit sudaemon node_type:{ tcp_socket udp_socket rawip_socket } *; |
| 36 | dontaudit sudaemon netif_type:netif *; |
| 37 | dontaudit sudaemon port_type:socket_class_set *; |
| 38 | dontaudit sudaemon port_type:{ tcp_socket dccp_socket } *; |
| 39 | dontaudit sudaemon domain:peer *; |
| 40 | dontaudit sudaemon domain:binder *; |
| 41 | dontaudit sudaemon property_type:property_service *; |
| 42 | ') |
| 43 | |
| 44 | ## Perms for the app |
| 45 | |
| 46 | userdebug_or_eng(` |
| 47 | typealias shell alias suclient; |
| 48 | |
Pawit Pornkitprasan | 04fd919 | 2014-12-06 11:37:45 +0700 | [diff] [blame] | 49 | # Translate user and platform apps to the shell domain when using su |
Ricardo Cerqueira | 09159ac | 2014-11-26 21:34:15 +0000 | [diff] [blame] | 50 | domain_auto_trans(untrusted_app, su_exec, suclient) |
Pawit Pornkitprasan | 04fd919 | 2014-12-06 11:37:45 +0700 | [diff] [blame] | 51 | domain_auto_trans(platform_app, su_exec, suclient) |
Ricardo Cerqueira | 09159ac | 2014-11-26 21:34:15 +0000 | [diff] [blame] | 52 | |
| 53 | allow suclient sudaemon:unix_stream_socket { connectto read write setopt ioctl }; |
| 54 | |
| 55 | allow suclient superuser_device:dir { create rw_dir_perms setattr unlink }; |
| 56 | allow suclient superuser_device:sock_file { create setattr unlink write }; |
| 57 | allow suclient untrusted_app_devpts:chr_file { read write ioctl }; |
Chirayu Desai | 9e0dba3 | 2014-11-27 21:00:01 +0530 | [diff] [blame] | 58 | # For Settings control of access |
Ricardo Cerqueira | 09159ac | 2014-11-26 21:34:15 +0000 | [diff] [blame] | 59 | allow system_app superuser_device:sock_file { read write create setattr unlink getattr }; |
| 60 | allow system_app sudaemon:unix_stream_socket { connectto read write setopt ioctl }; |
| 61 | allow system_app superuser_device:dir { create rw_dir_perms setattr unlink }; |
Pawit Pornkitprasan | 04fd919 | 2014-12-06 11:37:45 +0700 | [diff] [blame] | 62 | |
| 63 | ## From external/sepolicy/domain.te adjusted from sudaemon |
| 64 | # Same as adbd rules above, except allow su to do the same thing |
| 65 | allow domain sudaemon:unix_stream_socket connectto; |
| 66 | allow domain sudaemon:fd use; |
| 67 | allow domain sudaemon:unix_stream_socket { getattr getopt read write shutdown }; |
| 68 | binder_call(domain, sudaemon) |
| 69 | # Running something like "pm dump com.android.bluetooth" requires |
| 70 | # fifo writes |
| 71 | allow domain sudaemon:fifo_file { write getattr }; |
| 72 | # allow "gdbserver --attach" to work for su. |
| 73 | allow domain sudaemon:process sigchld; |
Ricardo Cerqueira | 09159ac | 2014-11-26 21:34:15 +0000 | [diff] [blame] | 74 | ') |