dovecot.te 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. policy_module(dovecot, 1.18.1)
  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 sys_resource };
  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. allow dovecot_auth_t dovecot_var_run_t:file manage_file_perms;
  95. allow dovecot_auth_t dovecot_var_run_t:fifo_file write_fifo_file_perms;
  96. manage_fifo_files_pattern(dovecot_t, dovecot_var_run_t, dovecot_var_run_t)
  97. files_pid_filetrans(dovecot_t, dovecot_var_run_t, { dir file fifo_file })
  98. read_files_pattern(dovecot_t, dovecot_usr_share_t, dovecot_usr_share_t)
  99. allow dovecot_t dovecot_usr_share_t:dir read;
  100. can_exec(dovecot_t, dovecot_exec_t)
  101. allow dovecot_t dovecot_auth_t:process signal;
  102. domtrans_pattern(dovecot_t, dovecot_auth_exec_t, dovecot_auth_t)
  103. files_list_usr(dovecot_t)
  104. files_read_usr_files(dovecot_t)
  105. corenet_all_recvfrom_unlabeled(dovecot_t)
  106. corenet_all_recvfrom_netlabel(dovecot_t)
  107. corenet_tcp_sendrecv_generic_if(dovecot_t)
  108. corenet_tcp_sendrecv_generic_node(dovecot_t)
  109. corenet_tcp_sendrecv_all_ports(dovecot_t)
  110. corenet_tcp_bind_generic_node(dovecot_t)
  111. corenet_sendrecv_mail_server_packets(dovecot_t)
  112. corenet_tcp_bind_mail_port(dovecot_t)
  113. corenet_sendrecv_pop_server_packets(dovecot_t)
  114. corenet_tcp_bind_pop_port(dovecot_t)
  115. corenet_sendrecv_sieve_server_packets(dovecot_t)
  116. corenet_tcp_bind_sieve_port(dovecot_t)
  117. corenet_sendrecv_all_client_packets(dovecot_t)
  118. corenet_tcp_connect_all_ports(dovecot_t)
  119. corenet_tcp_connect_postgresql_port(dovecot_t)
  120. domain_use_interactive_fds(dovecot_t)
  121. files_read_var_lib_files(dovecot_t)
  122. files_read_var_symlinks(dovecot_t)
  123. files_search_spool(dovecot_t)
  124. files_dontaudit_list_default(dovecot_t)
  125. files_dontaudit_search_all_dirs(dovecot_t)
  126. files_search_all_mountpoints(dovecot_t)
  127. fs_getattr_all_fs(dovecot_t)
  128. fs_getattr_all_dirs(dovecot_t)
  129. fs_search_auto_mountpoints(dovecot_t)
  130. fs_list_inotifyfs(dovecot_t)
  131. init_getattr_utmp(dovecot_t)
  132. auth_use_nsswitch(dovecot_t)
  133. miscfiles_read_generic_certs(dovecot_t)
  134. userdom_dontaudit_use_unpriv_user_fds(dovecot_t)
  135. userdom_use_user_terminals(dovecot_t)
  136. tunable_policy(`use_nfs_home_dirs',`
  137. fs_manage_nfs_dirs(dovecot_t)
  138. fs_manage_nfs_files(dovecot_t)
  139. fs_manage_nfs_symlinks(dovecot_t)
  140. ')
  141. tunable_policy(`use_samba_home_dirs',`
  142. fs_manage_cifs_dirs(dovecot_t)
  143. fs_manage_cifs_files(dovecot_t)
  144. fs_manage_cifs_symlinks(dovecot_t)
  145. ')
  146. optional_policy(`
  147. kerberos_manage_host_rcache(dovecot_t)
  148. kerberos_read_keytab(dovecot_t)
  149. kerberos_tmp_filetrans_host_rcache(dovecot_t, file, "imap_0")
  150. kerberos_use(dovecot_t)
  151. ')
  152. optional_policy(`
  153. mta_manage_spool(dovecot_t)
  154. mta_manage_mail_home_rw_content(dovecot_t)
  155. mta_home_filetrans_mail_home_rw(dovecot_t, dir, "Maildir")
  156. mta_home_filetrans_mail_home_rw(dovecot_t, dir, ".maildir")
  157. ')
  158. optional_policy(`
  159. postgresql_stream_connect(dovecot_t)
  160. ')
  161. optional_policy(`
  162. postfix_manage_private_sockets(dovecot_t)
  163. postfix_search_spool(dovecot_t)
  164. ')
  165. optional_policy(`
  166. sendmail_domtrans(dovecot_t)
  167. ')
  168. optional_policy(`
  169. seutil_sigchld_newrole(dovecot_t)
  170. ')
  171. optional_policy(`
  172. squid_dontaudit_search_cache(dovecot_t)
  173. ')
  174. optional_policy(`
  175. udev_read_db(dovecot_t)
  176. ')
  177. ########################################
  178. #
  179. # Auth local policy
  180. #
  181. allow dovecot_auth_t self:capability { chown dac_override ipc_lock setgid setuid sys_nice };
  182. allow dovecot_auth_t self:process { getsched setsched signal_perms getcap setcap };
  183. allow dovecot_auth_t self:unix_stream_socket { accept connectto listen };
  184. read_files_pattern(dovecot_auth_t, dovecot_passwd_t, dovecot_passwd_t)
  185. manage_dirs_pattern(dovecot_auth_t, dovecot_auth_tmp_t, dovecot_auth_tmp_t)
  186. manage_files_pattern(dovecot_auth_t, dovecot_auth_tmp_t, dovecot_auth_tmp_t)
  187. files_tmp_filetrans(dovecot_auth_t, dovecot_auth_tmp_t, { file dir })
  188. manage_files_pattern(dovecot_auth_t, dovecot_var_run_t, dovecot_var_run_t)
  189. read_files_pattern(dovecot_auth_t, dovecot_var_run_t, dovecot_var_run_t)
  190. allow dovecot_auth_t dovecot_var_run_t:dir list_dir_perms;
  191. manage_sock_files_pattern(dovecot_auth_t, dovecot_var_run_t, dovecot_var_run_t)
  192. allow dovecot_auth_t dovecot_t:unix_stream_socket { connectto rw_stream_socket_perms };
  193. selinux_get_enforce_mode(dovecot_auth_t)
  194. selinux_get_fs_mount(dovecot_auth_t)
  195. files_search_pids(dovecot_auth_t)
  196. files_read_usr_files(dovecot_auth_t)
  197. files_read_var_lib_files(dovecot_auth_t)
  198. auth_domtrans_chk_passwd(dovecot_auth_t)
  199. auth_use_nsswitch(dovecot_auth_t)
  200. init_rw_utmp(dovecot_auth_t)
  201. logging_send_audit_msgs(dovecot_auth_t)
  202. seutil_search_default_contexts(dovecot_auth_t)
  203. sysnet_use_ldap(dovecot_auth_t)
  204. optional_policy(`
  205. userdom_list_user_tmp(dovecot_auth_t)
  206. userdom_read_user_tmp_files(dovecot_auth_t)
  207. userdom_read_user_tmp_symlinks(dovecot_auth_t)
  208. ')
  209. optional_policy(`
  210. mysql_stream_connect(dovecot_auth_t)
  211. mysql_read_config(dovecot_auth_t)
  212. mysql_tcp_connect(dovecot_auth_t)
  213. ')
  214. optional_policy(`
  215. nis_authenticate(dovecot_auth_t)
  216. ')
  217. optional_policy(`
  218. postfix_manage_private_sockets(dovecot_auth_t)
  219. postfix_search_spool(dovecot_auth_t)
  220. ')
  221. ########################################
  222. #
  223. # Deliver local policy
  224. #
  225. allow dovecot_deliver_t dovecot_cert_t:dir search_dir_perms;
  226. append_files_pattern(dovecot_deliver_t, dovecot_var_log_t, dovecot_var_log_t)
  227. manage_dirs_pattern(dovecot_deliver_t, dovecot_deliver_tmp_t, dovecot_deliver_tmp_t)
  228. manage_files_pattern(dovecot_deliver_t, dovecot_deliver_tmp_t, dovecot_deliver_tmp_t)
  229. files_tmp_filetrans(dovecot_deliver_t, dovecot_deliver_tmp_t, { file dir })
  230. allow dovecot_deliver_t dovecot_var_run_t:dir list_dir_perms;
  231. allow dovecot_deliver_t dovecot_var_run_t:file read_file_perms;
  232. allow dovecot_deliver_t dovecot_var_run_t:sock_file read_sock_file_perms;
  233. list_dirs_pattern(dovecot_deliver_t, dovecot_usr_share_t, dovecot_usr_share_t)
  234. read_files_pattern(dovecot_deliver_t, dovecot_usr_share_t, dovecot_usr_share_t)
  235. stream_connect_pattern(dovecot_deliver_t, dovecot_var_run_t, dovecot_var_run_t, { dovecot_t dovecot_auth_t })
  236. can_exec(dovecot_deliver_t, dovecot_deliver_exec_t)
  237. allow dovecot_deliver_t dovecot_t:process signull;
  238. fs_getattr_all_fs(dovecot_deliver_t)
  239. auth_use_nsswitch(dovecot_deliver_t)
  240. logging_search_logs(dovecot_deliver_t)
  241. mta_manage_spool(dovecot_deliver_t)
  242. tunable_policy(`use_nfs_home_dirs',`
  243. fs_manage_nfs_dirs(dovecot_deliver_t)
  244. fs_manage_nfs_files(dovecot_deliver_t)
  245. fs_manage_nfs_symlinks(dovecot_deliver_t)
  246. ')
  247. tunable_policy(`use_samba_home_dirs',`
  248. fs_manage_cifs_dirs(dovecot_deliver_t)
  249. fs_manage_cifs_files(dovecot_deliver_t)
  250. fs_manage_cifs_symlinks(dovecot_deliver_t)
  251. ')
  252. optional_policy(`
  253. mta_mailserver_delivery(dovecot_deliver_t)
  254. mta_read_queue(dovecot_deliver_t)
  255. ')
  256. optional_policy(`
  257. postfix_use_fds_master(dovecot_deliver_t)
  258. ')
  259. optional_policy(`
  260. sendmail_domtrans(dovecot_deliver_t)
  261. ')