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 | |
Ricardo Cerqueira | 7cd6983 | 2014-12-10 17:17:18 +0000 | [diff] [blame^] | 49 | # Translate user 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) |
| 51 | |
| 52 | allow suclient sudaemon:unix_stream_socket { connectto read write setopt ioctl }; |
| 53 | |
| 54 | allow suclient superuser_device:dir { create rw_dir_perms setattr unlink }; |
| 55 | allow suclient superuser_device:sock_file { create setattr unlink write }; |
| 56 | allow suclient untrusted_app_devpts:chr_file { read write ioctl }; |
Chirayu Desai | 9e0dba3 | 2014-11-27 21:00:01 +0530 | [diff] [blame] | 57 | # For Settings control of access |
Ricardo Cerqueira | 09159ac | 2014-11-26 21:34:15 +0000 | [diff] [blame] | 58 | allow system_app superuser_device:sock_file { read write create setattr unlink getattr }; |
| 59 | allow system_app sudaemon:unix_stream_socket { connectto read write setopt ioctl }; |
| 60 | allow system_app superuser_device:dir { create rw_dir_perms setattr unlink }; |
Ricardo Cerqueira | 09159ac | 2014-11-26 21:34:15 +0000 | [diff] [blame] | 61 | ') |