spamassassin.te 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. policy_module(spamassassin, 2.9.7)
  2. require {
  3. type etc_mail_t;
  4. }
  5. ########################################
  6. #
  7. # Declarations
  8. #
  9. ## <desc>
  10. ## <p>
  11. ## Determine whether spamassassin
  12. ## clients can use the network.
  13. ## </p>
  14. ## </desc>
  15. gen_tunable(spamassassin_can_network, false)
  16. ## <desc>
  17. ## <p>
  18. ## Determine whether spamd can manage
  19. ## generic user home content.
  20. ## </p>
  21. ## </desc>
  22. gen_tunable(spamd_enable_home_dirs, false)
  23. type spamd_update_t;
  24. type spamd_update_exec_t;
  25. init_system_domain(spamd_update_t, spamd_update_exec_t)
  26. type spamassassin_t;
  27. type spamassassin_exec_t;
  28. typealias spamassassin_t alias { user_spamassassin_t staff_spamassassin_t sysadm_spamassassin_t };
  29. typealias spamassassin_t alias { auditadm_spamassassin_t secadm_spamassassin_t };
  30. userdom_user_application_domain(spamassassin_t, spamassassin_exec_t)
  31. type spamassassin_home_t;
  32. typealias spamassassin_home_t alias { user_spamassassin_home_t staff_spamassassin_home_t sysadm_spamassassin_home_t };
  33. typealias spamassassin_home_t alias { auditadm_spamassassin_home_t secadm_spamassassin_home_t };
  34. userdom_user_home_content(spamassassin_home_t)
  35. type spamassassin_tmp_t;
  36. typealias spamassassin_tmp_t alias { user_spamassassin_tmp_t staff_spamassassin_tmp_t sysadm_spamassassin_tmp_t };
  37. typealias spamassassin_tmp_t alias { auditadm_spamassassin_tmp_t secadm_spamassassin_tmp_t };
  38. userdom_user_tmp_file(spamassassin_tmp_t)
  39. type spamc_t;
  40. type spamc_exec_t;
  41. typealias spamc_t alias { user_spamc_t staff_spamc_t sysadm_spamc_t };
  42. typealias spamc_t alias { auditadm_spamc_t secadm_spamc_t };
  43. userdom_user_application_domain(spamc_t, spamc_exec_t)
  44. role system_r types spamc_t;
  45. type spamc_tmp_t;
  46. typealias spamc_tmp_t alias { user_spamc_tmp_t staff_spamc_tmp_t sysadm_spamc_tmp_t };
  47. typealias spamc_tmp_t alias { auditadm_spamc_tmp_t secadm_spamc_tmp_t };
  48. userdom_user_tmp_file(spamc_tmp_t)
  49. type spamd_t;
  50. type spamd_exec_t;
  51. init_daemon_domain(spamd_t, spamd_exec_t)
  52. type spamd_compiled_t;
  53. files_type(spamd_compiled_t)
  54. type spamd_etc_t;
  55. files_config_file(spamd_etc_t)
  56. type spamd_home_t;
  57. userdom_user_home_content(spamd_home_t)
  58. type spamd_initrc_exec_t;
  59. init_script_file(spamd_initrc_exec_t)
  60. type spamd_log_t;
  61. logging_log_file(spamd_log_t)
  62. type spamd_spool_t;
  63. files_type(spamd_spool_t)
  64. type spamd_tmp_t;
  65. files_tmp_file(spamd_tmp_t)
  66. type spamd_var_lib_t;
  67. files_type(spamd_var_lib_t)
  68. type spamd_var_run_t;
  69. files_pid_file(spamd_var_run_t)
  70. type spamd_unit_t;
  71. init_unit_file(spamd_unit_t)
  72. ########################################
  73. #
  74. # Standalone local policy
  75. #
  76. allow spamassassin_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
  77. allow spamassassin_t self:fd use;
  78. allow spamassassin_t self:fifo_file rw_fifo_file_perms;
  79. allow spamassassin_t self:unix_dgram_socket sendto;
  80. allow spamassassin_t self:unix_stream_socket { accept connectto listen };
  81. manage_dirs_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  82. manage_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  83. manage_lnk_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  84. manage_fifo_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  85. manage_sock_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  86. userdom_user_home_dir_filetrans(spamassassin_t, spamassassin_home_t, dir, ".spamassassin")
  87. manage_dirs_pattern(spamassassin_t, spamassassin_tmp_t, spamassassin_tmp_t)
  88. manage_files_pattern(spamassassin_t, spamassassin_tmp_t, spamassassin_tmp_t)
  89. files_tmp_filetrans(spamassassin_t, spamassassin_tmp_t, { file dir })
  90. kernel_read_kernel_sysctls(spamassassin_t)
  91. dev_read_urand(spamassassin_t)
  92. fs_getattr_all_fs(spamassassin_t)
  93. fs_search_auto_mountpoints(spamassassin_t)
  94. domain_use_interactive_fds(spamassassin_t)
  95. files_read_etc_files(spamassassin_t)
  96. files_read_etc_runtime_files(spamassassin_t)
  97. files_list_home(spamassassin_t)
  98. files_read_usr_files(spamassassin_t)
  99. files_dontaudit_search_var(spamassassin_t)
  100. logging_send_syslog_msg(spamassassin_t)
  101. miscfiles_read_localization(spamassassin_t)
  102. sysnet_dns_name_resolve(spamassassin_t)
  103. tunable_policy(`spamassassin_can_network',`
  104. allow spamassassin_t self:tcp_socket { accept listen };
  105. corenet_all_recvfrom_unlabeled(spamassassin_t)
  106. corenet_all_recvfrom_netlabel(spamassassin_t)
  107. corenet_tcp_sendrecv_generic_if(spamassassin_t)
  108. corenet_tcp_sendrecv_generic_node(spamassassin_t)
  109. corenet_tcp_sendrecv_all_ports(spamassassin_t)
  110. corenet_tcp_connect_all_ports(spamassassin_t)
  111. corenet_sendrecv_all_client_packets(spamassassin_t)
  112. ')
  113. tunable_policy(`use_nfs_home_dirs',`
  114. fs_manage_nfs_dirs(spamassassin_t)
  115. fs_manage_nfs_files(spamassassin_t)
  116. fs_manage_nfs_symlinks(spamassassin_t)
  117. ')
  118. tunable_policy(`use_samba_home_dirs',`
  119. fs_manage_cifs_dirs(spamassassin_t)
  120. fs_manage_cifs_files(spamassassin_t)
  121. fs_manage_cifs_symlinks(spamassassin_t)
  122. ')
  123. optional_policy(`
  124. tunable_policy(`spamassassin_can_network && allow_ypbind',`
  125. nis_use_ypbind_uncond(spamassassin_t)
  126. ')
  127. ')
  128. optional_policy(`
  129. mta_read_config(spamassassin_t)
  130. sendmail_stub(spamassassin_t)
  131. ')
  132. ########################################
  133. #
  134. # Client local policy
  135. #
  136. allow spamc_t self:capability dac_override;
  137. allow spamc_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
  138. allow spamc_t self:fd use;
  139. allow spamc_t self:fifo_file rw_fifo_file_perms;
  140. allow spamc_t self:unix_dgram_socket sendto;
  141. allow spamc_t self:unix_stream_socket { accept connectto listen };
  142. allow spamc_t self:tcp_socket { accept listen };
  143. manage_dirs_pattern(spamc_t, spamc_tmp_t, spamc_tmp_t)
  144. manage_files_pattern(spamc_t, spamc_tmp_t, spamc_tmp_t)
  145. files_tmp_filetrans(spamc_t, spamc_tmp_t, { file dir })
  146. manage_dirs_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  147. manage_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  148. manage_lnk_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  149. manage_fifo_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  150. manage_sock_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  151. userdom_user_home_dir_filetrans(spamc_t, spamassassin_home_t, dir, ".spamassassin")
  152. list_dirs_pattern(spamc_t, spamd_var_lib_t, spamd_var_lib_t)
  153. read_files_pattern(spamc_t, spamd_var_lib_t, spamd_var_lib_t)
  154. stream_connect_pattern(spamc_t, { spamd_var_run_t spamd_tmp_t }, { spamd_var_run_t spamd_tmp_t }, spamd_t)
  155. kernel_read_kernel_sysctls(spamc_t)
  156. kernel_read_system_state(spamc_t)
  157. corenet_all_recvfrom_unlabeled(spamc_t)
  158. corenet_all_recvfrom_netlabel(spamc_t)
  159. corenet_tcp_sendrecv_generic_if(spamc_t)
  160. corenet_tcp_sendrecv_generic_node(spamc_t)
  161. corenet_tcp_sendrecv_all_ports(spamc_t)
  162. corenet_sendrecv_all_client_packets(spamc_t)
  163. corenet_tcp_connect_all_ports(spamc_t)
  164. corecmd_exec_bin(spamc_t)
  165. domain_use_interactive_fds(spamc_t)
  166. fs_getattr_all_fs(spamc_t)
  167. fs_search_auto_mountpoints(spamc_t)
  168. files_read_etc_runtime_files(spamc_t)
  169. files_read_usr_files(spamc_t)
  170. files_dontaudit_search_var(spamc_t)
  171. files_list_home(spamc_t)
  172. files_list_var_lib(spamc_t)
  173. auth_use_nsswitch(spamc_t)
  174. logging_send_syslog_msg(spamc_t)
  175. miscfiles_read_localization(spamc_t)
  176. dovecot_domtrans_deliver(spamc_t)
  177. search_dirs_pattern(spamc_t, etc_mail_t, etc_mail_t)
  178. search_dirs_pattern(spamc_t, spamd_etc_t, spamd_etc_t)
  179. tunable_policy(`use_nfs_home_dirs',`
  180. fs_manage_nfs_dirs(spamc_t)
  181. fs_manage_nfs_files(spamc_t)
  182. fs_manage_nfs_symlinks(spamc_t)
  183. ')
  184. tunable_policy(`use_samba_home_dirs',`
  185. fs_manage_cifs_dirs(spamc_t)
  186. fs_manage_cifs_files(spamc_t)
  187. fs_manage_cifs_symlinks(spamc_t)
  188. ')
  189. optional_policy(`
  190. abrt_stream_connect(spamc_t)
  191. ')
  192. optional_policy(`
  193. amavis_manage_spool_files(spamc_t)
  194. ')
  195. optional_policy(`
  196. evolution_stream_connect(spamc_t)
  197. ')
  198. optional_policy(`
  199. milter_manage_spamass_state(spamc_t)
  200. ')
  201. optional_policy(`
  202. mta_send_mail(spamc_t)
  203. mta_read_config(spamc_t)
  204. mta_read_queue(spamc_t)
  205. sendmail_rw_pipes(spamc_t)
  206. sendmail_stub(spamc_t)
  207. ')
  208. optional_policy(`
  209. postfix_domtrans_postdrop(spamc_t)
  210. postfix_search_spool(spamc_t)
  211. postfix_rw_local_pipes(spamc_t)
  212. postfix_rw_inherited_master_pipes(spamc_t)
  213. ')
  214. ########################################
  215. #
  216. # Daemon local policy
  217. #
  218. allow spamd_t self:capability { kill setuid setgid dac_override sys_tty_config };
  219. dontaudit spamd_t self:capability sys_tty_config;
  220. allow spamd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
  221. allow spamd_t self:fd use;
  222. allow spamd_t self:fifo_file rw_fifo_file_perms;
  223. allow spamd_t self:unix_dgram_socket sendto;
  224. allow spamd_t self:unix_stream_socket { accept connectto listen };
  225. allow spamd_t self:tcp_socket { accept listen };
  226. manage_dirs_pattern(spamd_t, spamd_home_t, spamd_home_t)
  227. manage_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  228. manage_lnk_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  229. manage_fifo_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  230. manage_sock_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  231. userdom_user_home_dir_filetrans(spamd_t, spamd_home_t, dir, ".spamd")
  232. manage_dirs_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  233. manage_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  234. manage_lnk_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  235. manage_fifo_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  236. manage_sock_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  237. userdom_user_home_dir_filetrans(spamd_t, spamassassin_home_t, dir, ".spamassassin")
  238. manage_dirs_pattern(spamd_t, spamd_compiled_t, spamd_compiled_t)
  239. manage_files_pattern(spamd_t, spamd_compiled_t, spamd_compiled_t)
  240. allow spamd_t spamd_log_t:file { append_file_perms create_file_perms setattr_file_perms };
  241. logging_log_filetrans(spamd_t, spamd_log_t, file)
  242. manage_dirs_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
  243. manage_files_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
  244. manage_sock_files_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
  245. files_spool_filetrans(spamd_t, spamd_spool_t, { file dir })
  246. manage_dirs_pattern(spamd_t, spamd_tmp_t, spamd_tmp_t)
  247. manage_files_pattern(spamd_t, spamd_tmp_t, spamd_tmp_t)
  248. files_tmp_filetrans(spamd_t, spamd_tmp_t, { file dir })
  249. allow spamd_t spamd_var_lib_t:dir list_dir_perms;
  250. manage_files_pattern(spamd_t, spamd_var_lib_t, spamd_var_lib_t)
  251. manage_lnk_files_pattern(spamd_t, spamd_var_lib_t, spamd_var_lib_t)
  252. manage_dirs_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
  253. manage_files_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
  254. manage_sock_files_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
  255. files_pid_filetrans(spamd_t, spamd_var_run_t, { file dir })
  256. list_dirs_pattern(spamd_t, spamd_etc_t, spamd_etc_t)
  257. read_files_pattern(spamd_t, spamd_etc_t, spamd_etc_t)
  258. search_dirs_pattern(spamd_t, etc_mail_t, etc_mail_t)
  259. can_exec(spamd_t, { spamd_exec_t spamd_compiled_t })
  260. kernel_read_all_sysctls(spamd_t)
  261. kernel_read_system_state(spamd_t)
  262. corecmd_exec_shell(spamd_t)
  263. corenet_all_recvfrom_unlabeled(spamd_t)
  264. corenet_all_recvfrom_netlabel(spamd_t)
  265. corenet_tcp_sendrecv_generic_if(spamd_t)
  266. corenet_udp_sendrecv_generic_if(spamd_t)
  267. corenet_tcp_sendrecv_generic_node(spamd_t)
  268. corenet_udp_sendrecv_generic_node(spamd_t)
  269. corenet_tcp_sendrecv_all_ports(spamd_t)
  270. corenet_udp_sendrecv_all_ports(spamd_t)
  271. corenet_tcp_bind_generic_node(spamd_t)
  272. corenet_udp_bind_generic_node(spamd_t)
  273. corenet_sendrecv_spamd_server_packets(spamd_t)
  274. corenet_tcp_bind_spamd_port(spamd_t)
  275. corenet_sendrecv_razor_client_packets(spamd_t)
  276. corenet_tcp_connect_razor_port(spamd_t)
  277. corenet_sendrecv_smtp_client_packets(spamd_t)
  278. corenet_tcp_connect_smtp_port(spamd_t)
  279. corenet_sendrecv_generic_server_packets(spamd_t)
  280. corenet_udp_bind_generic_port(spamd_t)
  281. corenet_sendrecv_imaze_server_packets(spamd_t)
  282. corenet_udp_bind_imaze_port(spamd_t)
  283. corenet_dontaudit_udp_bind_all_ports(spamd_t)
  284. corecmd_exec_bin(spamd_t)
  285. dev_read_sysfs(spamd_t)
  286. dev_read_urand(spamd_t)
  287. domain_use_interactive_fds(spamd_t)
  288. files_read_usr_files(spamd_t)
  289. files_read_etc_runtime_files(spamd_t)
  290. files_read_etc_files(spamd_t)
  291. fs_getattr_all_fs(spamd_t)
  292. fs_search_auto_mountpoints(spamd_t)
  293. auth_use_nsswitch(spamd_t)
  294. auth_dontaudit_read_shadow(spamd_t)
  295. init_dontaudit_rw_utmp(spamd_t)
  296. libs_use_ld_so(spamd_t)
  297. libs_use_shared_libs(spamd_t)
  298. logging_send_syslog_msg(spamd_t)
  299. miscfiles_read_localization(spamd_t)
  300. sysnet_use_ldap(spamd_t)
  301. userdom_use_unpriv_users_fds(spamd_t)
  302. tunable_policy(`spamd_enable_home_dirs',`
  303. userdom_manage_user_home_content_dirs(spamd_t)
  304. userdom_manage_user_home_content_files(spamd_t)
  305. userdom_manage_user_home_content_symlinks(spamd_t)
  306. ')
  307. tunable_policy(`use_nfs_home_dirs',`
  308. fs_manage_nfs_dirs(spamd_t)
  309. fs_manage_nfs_files(spamd_t)
  310. fs_manage_nfs_symlinks(spamd_t)
  311. ')
  312. tunable_policy(`use_samba_home_dirs',`
  313. fs_manage_cifs_dirs(spamd_t)
  314. fs_manage_cifs_files(spamd_t)
  315. fs_manage_cifs_symlinks(spamd_t)
  316. ')
  317. optional_policy(`
  318. amavis_manage_lib_files(spamd_t)
  319. ')
  320. optional_policy(`
  321. clamav_stream_connect(spamd_t)
  322. ')
  323. optional_policy(`
  324. cron_system_entry(spamd_t, spamd_exec_t)
  325. ')
  326. optional_policy(`
  327. daemontools_service_domain(spamd_t, spamd_exec_t)
  328. ')
  329. optional_policy(`
  330. dcc_domtrans_cdcc(spamd_t)
  331. dcc_domtrans_client(spamd_t)
  332. dcc_signal_client(spamd_t)
  333. dcc_stream_connect_dccifd(spamd_t)
  334. ')
  335. optional_policy(`
  336. evolution_home_filetrans(spamd_t, spamd_tmp_t, { file sock_file })
  337. ')
  338. optional_policy(`
  339. exim_manage_spool_dirs(spamd_t)
  340. exim_manage_spool_files(spamd_t)
  341. ')
  342. optional_policy(`
  343. milter_manage_spamass_state(spamd_t)
  344. ')
  345. optional_policy(`
  346. mysql_stream_connect(spamd_t)
  347. mysql_tcp_connect(spamd_t)
  348. ')
  349. optional_policy(`
  350. postfix_read_config(spamd_t)
  351. ')
  352. optional_policy(`
  353. postgresql_stream_connect(spamd_t)
  354. postgresql_tcp_connect(spamd_t)
  355. ')
  356. optional_policy(`
  357. pyzor_domtrans(spamd_t)
  358. pyzor_signal(spamd_t)
  359. ')
  360. optional_policy(`
  361. razor_domtrans(spamd_t)
  362. razor_read_lib_files(spamd_t)
  363. razor_manage_home_content(spamd_t)
  364. ')
  365. optional_policy(`
  366. seutil_sigchld_newrole(spamd_t)
  367. ')
  368. optional_policy(`
  369. sendmail_stub(spamd_t)
  370. mta_read_config(spamd_t)
  371. mta_send_mail(spamd_t)
  372. ')
  373. optional_policy(`
  374. udev_read_db(spamd_t)
  375. ')
  376. ########################################
  377. #
  378. # Update local policy
  379. #
  380. allow spamd_update_t self:capability dac_override;
  381. allow spamd_update_t self:fifo_file manage_fifo_file_perms;
  382. allow spamd_update_t self:unix_stream_socket create_stream_socket_perms;
  383. manage_dirs_pattern(spamd_update_t, spamd_tmp_t, spamd_tmp_t)
  384. manage_files_pattern(spamd_update_t, spamd_tmp_t, spamd_tmp_t)
  385. files_tmp_filetrans(spamd_update_t, spamd_tmp_t, { file dir })
  386. manage_dirs_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
  387. manage_files_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
  388. manage_lnk_files_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
  389. kernel_read_system_state(spamd_update_t)
  390. corenet_all_recvfrom_unlabeled(spamd_update_t)
  391. corenet_all_recvfrom_netlabel(spamd_update_t)
  392. corenet_tcp_sendrecv_generic_if(spamd_update_t)
  393. corenet_tcp_sendrecv_generic_node(spamd_update_t)
  394. corenet_tcp_sendrecv_all_ports(spamd_update_t)
  395. corenet_sendrecv_http_client_packets(spamd_update_t)
  396. corenet_tcp_connect_http_port(spamd_update_t)
  397. corenet_tcp_sendrecv_http_port(spamd_update_t)
  398. corecmd_exec_bin(spamd_update_t)
  399. corecmd_exec_shell(spamd_update_t)
  400. dev_read_urand(spamd_update_t)
  401. domain_use_interactive_fds(spamd_update_t)
  402. files_read_usr_files(spamd_update_t)
  403. auth_use_nsswitch(spamd_update_t)
  404. auth_dontaudit_read_shadow(spamd_update_t)
  405. miscfiles_read_localization(spamd_update_t)
  406. userdom_use_user_terminals(spamd_update_t)
  407. optional_policy(`
  408. cron_system_entry(spamd_update_t, spamd_update_exec_t)
  409. ')
  410. # probably want a solution same as httpd_use_gpg since this will
  411. # give spamd_update a path to users gpg keys
  412. # optional_policy(`
  413. # gpg_domtrans(spamd_update_t)
  414. # ')
  415. optional_policy(`
  416. mta_read_config(spamd_update_t)
  417. ')