dovecot.te 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. policy_module(dovecot, 1.17.8)
  2. ########################################
  3. #
  4. # Declarations
  5. #
  6. attribute dovecot_domain;
  7. type dovecot_t, dovecot_domain;
  8. type dovecot_exec_t;
  9. init_daemon_domain(dovecot_t, dovecot_exec_t)
  10. type dovecot_auth_t, dovecot_domain;
  11. type dovecot_auth_exec_t;
  12. domain_type(dovecot_auth_t)
  13. domain_entry_file(dovecot_auth_t, dovecot_auth_exec_t)
  14. role system_r types dovecot_auth_t;
  15. type dovecot_auth_tmp_t;
  16. files_tmp_file(dovecot_auth_tmp_t)
  17. type dovecot_cert_t;
  18. miscfiles_cert_type(dovecot_cert_t)
  19. type dovecot_deliver_t, dovecot_domain;
  20. type dovecot_deliver_exec_t;
  21. domain_type(dovecot_deliver_t)
  22. domain_entry_file(dovecot_deliver_t, dovecot_deliver_exec_t)
  23. role system_r types dovecot_deliver_t;
  24. type dovecot_deliver_tmp_t;
  25. files_tmp_file(dovecot_deliver_tmp_t)
  26. type dovecot_etc_t;
  27. files_config_file(dovecot_etc_t)
  28. type dovecot_initrc_exec_t;
  29. init_script_file(dovecot_initrc_exec_t)
  30. type dovecot_keytab_t;
  31. files_type(dovecot_keytab_t)
  32. type dovecot_passwd_t;
  33. files_type(dovecot_passwd_t)
  34. type dovecot_spool_t;
  35. files_type(dovecot_spool_t)
  36. type dovecot_tmp_t;
  37. files_tmp_file(dovecot_tmp_t)
  38. type dovecot_var_lib_t;
  39. files_type(dovecot_var_lib_t)
  40. type dovecot_var_log_t;
  41. logging_log_file(dovecot_var_log_t)
  42. type dovecot_var_run_t;
  43. files_pid_file(dovecot_var_run_t)
  44. type dovecot_usr_share_t;
  45. files_type(dovecot_usr_share_t)
  46. ########################################
  47. #
  48. # Common local policy
  49. #
  50. allow dovecot_domain self:capability2 block_suspend;
  51. allow dovecot_domain self:fifo_file rw_fifo_file_perms;
  52. allow dovecot_domain dovecot_etc_t:dir list_dir_perms;
  53. allow dovecot_domain dovecot_etc_t:file read_file_perms;
  54. allow dovecot_domain dovecot_etc_t:lnk_file read_lnk_file_perms;
  55. kernel_read_all_sysctls(dovecot_domain)
  56. kernel_read_system_state(dovecot_domain)
  57. corecmd_exec_bin(dovecot_domain)
  58. corecmd_exec_shell(dovecot_domain)
  59. dev_read_sysfs(dovecot_domain)
  60. dev_read_rand(dovecot_domain)
  61. dev_read_urand(dovecot_domain)
  62. files_read_etc_runtime_files(dovecot_domain)
  63. logging_send_syslog_msg(dovecot_domain)
  64. miscfiles_read_localization(dovecot_domain)
  65. ########################################
  66. #
  67. # Local policy
  68. #
  69. allow dovecot_t self:capability { dac_override dac_read_search chown fsetid kill setgid setuid sys_chroot };
  70. dontaudit dovecot_t self:capability sys_tty_config;
  71. allow dovecot_t self:process { setrlimit signal_perms getcap setcap setsched };
  72. allow dovecot_t self:tcp_socket { accept listen };
  73. allow dovecot_t self:unix_stream_socket { accept connectto listen };
  74. allow dovecot_t dovecot_cert_t:dir list_dir_perms;
  75. allow dovecot_t dovecot_cert_t:file read_file_perms;
  76. allow dovecot_t dovecot_cert_t:lnk_file read_lnk_file_perms;
  77. allow dovecot_t dovecot_keytab_t:file read_file_perms;
  78. manage_dirs_pattern(dovecot_t, dovecot_tmp_t, dovecot_tmp_t)
  79. manage_files_pattern(dovecot_t, dovecot_tmp_t, dovecot_tmp_t)
  80. files_tmp_filetrans(dovecot_t, dovecot_tmp_t, { file dir })
  81. manage_files_pattern(dovecot_t, dovecot_var_lib_t, dovecot_var_lib_t)
  82. manage_dirs_pattern(dovecot_t, dovecot_var_log_t, dovecot_var_log_t)
  83. append_files_pattern(dovecot_t, dovecot_var_log_t, dovecot_var_log_t)
  84. create_files_pattern(dovecot_t, dovecot_var_log_t, dovecot_var_log_t)
  85. setattr_files_pattern(dovecot_t, dovecot_var_log_t, dovecot_var_log_t)
  86. logging_log_filetrans(dovecot_t, dovecot_var_log_t, { file dir })
  87. manage_dirs_pattern(dovecot_t, dovecot_spool_t, dovecot_spool_t)
  88. manage_files_pattern(dovecot_t, dovecot_spool_t, dovecot_spool_t)
  89. manage_lnk_files_pattern(dovecot_t, dovecot_spool_t, dovecot_spool_t)
  90. manage_dirs_pattern(dovecot_t, dovecot_var_run_t, dovecot_var_run_t)
  91. manage_files_pattern(dovecot_t, dovecot_var_run_t, dovecot_var_run_t)
  92. manage_lnk_files_pattern(dovecot_t, dovecot_var_run_t, dovecot_var_run_t)
  93. manage_sock_files_pattern(dovecot_t, dovecot_var_run_t, dovecot_var_run_t)
  94. manage_fifo_files_pattern(dovecot_t, dovecot_var_run_t, dovecot_var_run_t)
  95. files_pid_filetrans(dovecot_t, dovecot_var_run_t, { dir file fifo_file })
  96. read_files_pattern(dovecot_t, dovecot_usr_share_t, dovecot_usr_share_t)
  97. allow dovecot_t dovecot_usr_share_t:dir read;
  98. can_exec(dovecot_t, dovecot_exec_t)
  99. allow dovecot_t dovecot_auth_t:process signal;
  100. domtrans_pattern(dovecot_t, dovecot_auth_exec_t, dovecot_auth_t)
  101. corenet_all_recvfrom_unlabeled(dovecot_t)
  102. corenet_all_recvfrom_netlabel(dovecot_t)
  103. corenet_tcp_sendrecv_generic_if(dovecot_t)
  104. corenet_tcp_sendrecv_generic_node(dovecot_t)
  105. corenet_tcp_sendrecv_all_ports(dovecot_t)
  106. corenet_tcp_bind_generic_node(dovecot_t)
  107. corenet_sendrecv_mail_server_packets(dovecot_t)
  108. corenet_tcp_bind_mail_port(dovecot_t)
  109. corenet_sendrecv_pop_server_packets(dovecot_t)
  110. corenet_tcp_bind_pop_port(dovecot_t)
  111. corenet_sendrecv_sieve_server_packets(dovecot_t)
  112. corenet_tcp_bind_sieve_port(dovecot_t)
  113. corenet_sendrecv_all_client_packets(dovecot_t)
  114. corenet_tcp_connect_all_ports(dovecot_t)
  115. corenet_tcp_connect_postgresql_port(dovecot_t)
  116. domain_use_interactive_fds(dovecot_t)
  117. files_read_var_lib_files(dovecot_t)
  118. files_read_var_symlinks(dovecot_t)
  119. files_search_spool(dovecot_t)
  120. files_dontaudit_list_default(dovecot_t)
  121. files_dontaudit_search_all_dirs(dovecot_t)
  122. files_search_all_mountpoints(dovecot_t)
  123. fs_getattr_all_fs(dovecot_t)
  124. fs_getattr_all_dirs(dovecot_t)
  125. fs_search_auto_mountpoints(dovecot_t)
  126. fs_list_inotifyfs(dovecot_t)
  127. init_getattr_utmp(dovecot_t)
  128. auth_use_nsswitch(dovecot_t)
  129. miscfiles_read_generic_certs(dovecot_t)
  130. userdom_dontaudit_use_unpriv_user_fds(dovecot_t)
  131. userdom_use_user_terminals(dovecot_t)
  132. tunable_policy(`use_nfs_home_dirs',`
  133. fs_manage_nfs_dirs(dovecot_t)
  134. fs_manage_nfs_files(dovecot_t)
  135. fs_manage_nfs_symlinks(dovecot_t)
  136. ')
  137. tunable_policy(`use_samba_home_dirs',`
  138. fs_manage_cifs_dirs(dovecot_t)
  139. fs_manage_cifs_files(dovecot_t)
  140. fs_manage_cifs_symlinks(dovecot_t)
  141. ')
  142. optional_policy(`
  143. kerberos_manage_host_rcache(dovecot_t)
  144. kerberos_read_keytab(dovecot_t)
  145. kerberos_tmp_filetrans_host_rcache(dovecot_t, file, "imap_0")
  146. kerberos_use(dovecot_t)
  147. ')
  148. optional_policy(`
  149. mta_manage_spool(dovecot_t)
  150. mta_manage_mail_home_rw_content(dovecot_t)
  151. mta_home_filetrans_mail_home_rw(dovecot_t, dir, "Maildir")
  152. mta_home_filetrans_mail_home_rw(dovecot_t, dir, ".maildir")
  153. ')
  154. optional_policy(`
  155. postgresql_stream_connect(dovecot_t)
  156. ')
  157. optional_policy(`
  158. postfix_manage_private_sockets(dovecot_t)
  159. postfix_search_spool(dovecot_t)
  160. ')
  161. optional_policy(`
  162. sendmail_domtrans(dovecot_t)
  163. ')
  164. optional_policy(`
  165. seutil_sigchld_newrole(dovecot_t)
  166. ')
  167. optional_policy(`
  168. squid_dontaudit_search_cache(dovecot_t)
  169. ')
  170. optional_policy(`
  171. udev_read_db(dovecot_t)
  172. ')
  173. ########################################
  174. #
  175. # Auth local policy
  176. #
  177. allow dovecot_auth_t self:capability { chown dac_override ipc_lock setgid setuid sys_nice };
  178. allow dovecot_auth_t self:process { getsched setsched signal_perms getcap setcap };
  179. allow dovecot_auth_t self:unix_stream_socket { accept connectto listen };
  180. read_files_pattern(dovecot_auth_t, dovecot_passwd_t, dovecot_passwd_t)
  181. manage_dirs_pattern(dovecot_auth_t, dovecot_auth_tmp_t, dovecot_auth_tmp_t)
  182. manage_files_pattern(dovecot_auth_t, dovecot_auth_tmp_t, dovecot_auth_tmp_t)
  183. files_tmp_filetrans(dovecot_auth_t, dovecot_auth_tmp_t, { file dir })
  184. manage_files_pattern(dovecot_auth_t, dovecot_var_run_t, dovecot_var_run_t)
  185. read_files_pattern(dovecot_auth_t, dovecot_var_run_t, dovecot_var_run_t)
  186. allow dovecot_auth_t dovecot_var_run_t:dir list_dir_perms;
  187. manage_sock_files_pattern(dovecot_auth_t, dovecot_var_run_t, dovecot_var_run_t)
  188. allow dovecot_auth_t dovecot_t:unix_stream_socket { connectto rw_stream_socket_perms };
  189. files_search_pids(dovecot_auth_t)
  190. files_read_usr_files(dovecot_auth_t)
  191. files_read_var_lib_files(dovecot_auth_t)
  192. auth_domtrans_chk_passwd(dovecot_auth_t)
  193. auth_use_nsswitch(dovecot_auth_t)
  194. init_rw_utmp(dovecot_auth_t)
  195. logging_send_audit_msgs(dovecot_auth_t)
  196. seutil_dontaudit_search_config(dovecot_auth_t)
  197. sysnet_use_ldap(dovecot_auth_t)
  198. optional_policy(`
  199. userdom_list_user_tmp(dovecot_auth_t)
  200. userdom_read_user_tmp_files(dovecot_auth_t)
  201. userdom_read_user_tmp_symlinks(dovecot_auth_t)
  202. ')
  203. optional_policy(`
  204. mysql_stream_connect(dovecot_auth_t)
  205. mysql_read_config(dovecot_auth_t)
  206. mysql_tcp_connect(dovecot_auth_t)
  207. ')
  208. optional_policy(`
  209. nis_authenticate(dovecot_auth_t)
  210. ')
  211. optional_policy(`
  212. postfix_manage_private_sockets(dovecot_auth_t)
  213. postfix_search_spool(dovecot_auth_t)
  214. ')
  215. ########################################
  216. #
  217. # Deliver local policy
  218. #
  219. allow dovecot_deliver_t dovecot_cert_t:dir search_dir_perms;
  220. append_files_pattern(dovecot_deliver_t, dovecot_var_log_t, dovecot_var_log_t)
  221. manage_dirs_pattern(dovecot_deliver_t, dovecot_deliver_tmp_t, dovecot_deliver_tmp_t)
  222. manage_files_pattern(dovecot_deliver_t, dovecot_deliver_tmp_t, dovecot_deliver_tmp_t)
  223. files_tmp_filetrans(dovecot_deliver_t, dovecot_deliver_tmp_t, { file dir })
  224. allow dovecot_deliver_t dovecot_var_run_t:dir list_dir_perms;
  225. allow dovecot_deliver_t dovecot_var_run_t:file read_file_perms;
  226. allow dovecot_deliver_t dovecot_var_run_t:sock_file read_sock_file_perms;
  227. list_dirs_pattern(dovecot_deliver_t, dovecot_usr_share_t, dovecot_usr_share_t)
  228. read_files_pattern(dovecot_deliver_t, dovecot_usr_share_t, dovecot_usr_share_t)
  229. stream_connect_pattern(dovecot_deliver_t, dovecot_var_run_t, dovecot_var_run_t, { dovecot_t dovecot_auth_t })
  230. can_exec(dovecot_deliver_t, dovecot_deliver_exec_t)
  231. allow dovecot_deliver_t dovecot_t:process signull;
  232. fs_getattr_all_fs(dovecot_deliver_t)
  233. auth_use_nsswitch(dovecot_deliver_t)
  234. logging_search_logs(dovecot_deliver_t)
  235. mta_manage_spool(dovecot_deliver_t)
  236. tunable_policy(`use_nfs_home_dirs',`
  237. fs_manage_nfs_dirs(dovecot_deliver_t)
  238. fs_manage_nfs_files(dovecot_deliver_t)
  239. fs_manage_nfs_symlinks(dovecot_deliver_t)
  240. ')
  241. tunable_policy(`use_samba_home_dirs',`
  242. fs_manage_cifs_dirs(dovecot_deliver_t)
  243. fs_manage_cifs_files(dovecot_deliver_t)
  244. fs_manage_cifs_symlinks(dovecot_deliver_t)
  245. ')
  246. optional_policy(`
  247. mta_mailserver_delivery(dovecot_deliver_t)
  248. mta_read_queue(dovecot_deliver_t)
  249. ')
  250. optional_policy(`
  251. postfix_use_fds_master(dovecot_deliver_t)
  252. ')
  253. optional_policy(`
  254. sendmail_domtrans(dovecot_deliver_t)
  255. ')