spamassassin.te 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. policy_module(spamassassin, 2.9.4)
  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. ########################################
  71. #
  72. # Standalone local policy
  73. #
  74. allow spamassassin_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
  75. allow spamassassin_t self:fd use;
  76. allow spamassassin_t self:fifo_file rw_fifo_file_perms;
  77. allow spamassassin_t self:unix_dgram_socket sendto;
  78. allow spamassassin_t self:unix_stream_socket { accept connectto listen };
  79. manage_dirs_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  80. manage_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  81. manage_lnk_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  82. manage_fifo_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  83. manage_sock_files_pattern(spamassassin_t, spamassassin_home_t, spamassassin_home_t)
  84. userdom_user_home_dir_filetrans(spamassassin_t, spamassassin_home_t, dir, ".spamassassin")
  85. manage_dirs_pattern(spamassassin_t, spamassassin_tmp_t, spamassassin_tmp_t)
  86. manage_files_pattern(spamassassin_t, spamassassin_tmp_t, spamassassin_tmp_t)
  87. files_tmp_filetrans(spamassassin_t, spamassassin_tmp_t, { file dir })
  88. kernel_read_kernel_sysctls(spamassassin_t)
  89. dev_read_urand(spamassassin_t)
  90. fs_getattr_all_fs(spamassassin_t)
  91. fs_search_auto_mountpoints(spamassassin_t)
  92. domain_use_interactive_fds(spamassassin_t)
  93. files_read_etc_files(spamassassin_t)
  94. files_read_etc_runtime_files(spamassassin_t)
  95. files_list_home(spamassassin_t)
  96. files_read_usr_files(spamassassin_t)
  97. files_dontaudit_search_var(spamassassin_t)
  98. logging_send_syslog_msg(spamassassin_t)
  99. miscfiles_read_localization(spamassassin_t)
  100. sysnet_dns_name_resolve(spamassassin_t)
  101. tunable_policy(`spamassassin_can_network',`
  102. allow spamassassin_t self:tcp_socket { accept listen };
  103. corenet_all_recvfrom_unlabeled(spamassassin_t)
  104. corenet_all_recvfrom_netlabel(spamassassin_t)
  105. corenet_tcp_sendrecv_generic_if(spamassassin_t)
  106. corenet_tcp_sendrecv_generic_node(spamassassin_t)
  107. corenet_tcp_sendrecv_all_ports(spamassassin_t)
  108. corenet_tcp_connect_all_ports(spamassassin_t)
  109. corenet_sendrecv_all_client_packets(spamassassin_t)
  110. ')
  111. tunable_policy(`use_nfs_home_dirs',`
  112. fs_manage_nfs_dirs(spamassassin_t)
  113. fs_manage_nfs_files(spamassassin_t)
  114. fs_manage_nfs_symlinks(spamassassin_t)
  115. ')
  116. tunable_policy(`use_samba_home_dirs',`
  117. fs_manage_cifs_dirs(spamassassin_t)
  118. fs_manage_cifs_files(spamassassin_t)
  119. fs_manage_cifs_symlinks(spamassassin_t)
  120. ')
  121. optional_policy(`
  122. tunable_policy(`spamassassin_can_network && allow_ypbind',`
  123. nis_use_ypbind_uncond(spamassassin_t)
  124. ')
  125. ')
  126. optional_policy(`
  127. mta_read_config(spamassassin_t)
  128. sendmail_stub(spamassassin_t)
  129. ')
  130. ########################################
  131. #
  132. # Client local policy
  133. #
  134. allow spamc_t self:capability dac_override;
  135. allow spamc_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
  136. allow spamc_t self:fd use;
  137. allow spamc_t self:fifo_file rw_fifo_file_perms;
  138. allow spamc_t self:unix_dgram_socket sendto;
  139. allow spamc_t self:unix_stream_socket { accept connectto listen };
  140. allow spamc_t self:tcp_socket { accept listen };
  141. manage_dirs_pattern(spamc_t, spamc_tmp_t, spamc_tmp_t)
  142. manage_files_pattern(spamc_t, spamc_tmp_t, spamc_tmp_t)
  143. files_tmp_filetrans(spamc_t, spamc_tmp_t, { file dir })
  144. manage_dirs_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  145. manage_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  146. manage_lnk_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  147. manage_fifo_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  148. manage_sock_files_pattern(spamc_t, spamassassin_home_t, spamassassin_home_t)
  149. userdom_user_home_dir_filetrans(spamc_t, spamassassin_home_t, dir, ".spamassassin")
  150. list_dirs_pattern(spamc_t, spamd_var_lib_t, spamd_var_lib_t)
  151. read_files_pattern(spamc_t, spamd_var_lib_t, spamd_var_lib_t)
  152. stream_connect_pattern(spamc_t, { spamd_var_run_t spamd_tmp_t }, { spamd_var_run_t spamd_tmp_t }, spamd_t)
  153. kernel_read_kernel_sysctls(spamc_t)
  154. kernel_read_system_state(spamc_t)
  155. corenet_all_recvfrom_unlabeled(spamc_t)
  156. corenet_all_recvfrom_netlabel(spamc_t)
  157. corenet_tcp_sendrecv_generic_if(spamc_t)
  158. corenet_tcp_sendrecv_generic_node(spamc_t)
  159. corenet_tcp_sendrecv_all_ports(spamc_t)
  160. corenet_sendrecv_all_client_packets(spamc_t)
  161. corenet_tcp_connect_all_ports(spamc_t)
  162. corecmd_exec_bin(spamc_t)
  163. domain_use_interactive_fds(spamc_t)
  164. fs_getattr_all_fs(spamc_t)
  165. fs_search_auto_mountpoints(spamc_t)
  166. files_read_etc_runtime_files(spamc_t)
  167. files_read_usr_files(spamc_t)
  168. files_dontaudit_search_var(spamc_t)
  169. files_list_home(spamc_t)
  170. files_list_var_lib(spamc_t)
  171. auth_use_nsswitch(spamc_t)
  172. logging_send_syslog_msg(spamc_t)
  173. miscfiles_read_localization(spamc_t)
  174. dovecot_domtrans_deliver(spamc_t)
  175. search_dirs_pattern(spamc_t, etc_mail_t, etc_mail_t)
  176. search_dirs_pattern(spamc_t, spamd_etc_t, spamd_etc_t)
  177. tunable_policy(`use_nfs_home_dirs',`
  178. fs_manage_nfs_dirs(spamc_t)
  179. fs_manage_nfs_files(spamc_t)
  180. fs_manage_nfs_symlinks(spamc_t)
  181. ')
  182. tunable_policy(`use_samba_home_dirs',`
  183. fs_manage_cifs_dirs(spamc_t)
  184. fs_manage_cifs_files(spamc_t)
  185. fs_manage_cifs_symlinks(spamc_t)
  186. ')
  187. optional_policy(`
  188. abrt_stream_connect(spamc_t)
  189. ')
  190. optional_policy(`
  191. amavis_manage_spool_files(spamc_t)
  192. ')
  193. optional_policy(`
  194. evolution_stream_connect(spamc_t)
  195. ')
  196. optional_policy(`
  197. milter_manage_spamass_state(spamc_t)
  198. ')
  199. optional_policy(`
  200. mta_send_mail(spamc_t)
  201. mta_read_config(spamc_t)
  202. mta_read_queue(spamc_t)
  203. sendmail_rw_pipes(spamc_t)
  204. sendmail_stub(spamc_t)
  205. ')
  206. optional_policy(`
  207. postfix_domtrans_postdrop(spamc_t)
  208. postfix_search_spool(spamc_t)
  209. postfix_rw_local_pipes(spamc_t)
  210. postfix_rw_inherited_master_pipes(spamc_t)
  211. ')
  212. ########################################
  213. #
  214. # Daemon local policy
  215. #
  216. allow spamd_t self:capability { kill setuid setgid dac_override sys_tty_config };
  217. dontaudit spamd_t self:capability sys_tty_config;
  218. allow spamd_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
  219. allow spamd_t self:fd use;
  220. allow spamd_t self:fifo_file rw_fifo_file_perms;
  221. allow spamd_t self:unix_dgram_socket sendto;
  222. allow spamd_t self:unix_stream_socket { accept connectto listen };
  223. allow spamd_t self:tcp_socket { accept listen };
  224. manage_dirs_pattern(spamd_t, spamd_home_t, spamd_home_t)
  225. manage_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  226. manage_lnk_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  227. manage_fifo_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  228. manage_sock_files_pattern(spamd_t, spamd_home_t, spamd_home_t)
  229. userdom_user_home_dir_filetrans(spamd_t, spamd_home_t, dir, ".spamd")
  230. manage_dirs_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  231. manage_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  232. manage_lnk_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  233. manage_fifo_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  234. manage_sock_files_pattern(spamd_t, spamassassin_home_t, spamassassin_home_t)
  235. userdom_user_home_dir_filetrans(spamd_t, spamassassin_home_t, dir, ".spamassassin")
  236. manage_dirs_pattern(spamd_t, spamd_compiled_t, spamd_compiled_t)
  237. manage_files_pattern(spamd_t, spamd_compiled_t, spamd_compiled_t)
  238. allow spamd_t spamd_log_t:file { append_file_perms create_file_perms setattr_file_perms };
  239. logging_log_filetrans(spamd_t, spamd_log_t, file)
  240. manage_dirs_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
  241. manage_files_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
  242. manage_sock_files_pattern(spamd_t, spamd_spool_t, spamd_spool_t)
  243. files_spool_filetrans(spamd_t, spamd_spool_t, { file dir })
  244. manage_dirs_pattern(spamd_t, spamd_tmp_t, spamd_tmp_t)
  245. manage_files_pattern(spamd_t, spamd_tmp_t, spamd_tmp_t)
  246. files_tmp_filetrans(spamd_t, spamd_tmp_t, { file dir })
  247. allow spamd_t spamd_var_lib_t:dir list_dir_perms;
  248. manage_files_pattern(spamd_t, spamd_var_lib_t, spamd_var_lib_t)
  249. manage_lnk_files_pattern(spamd_t, spamd_var_lib_t, spamd_var_lib_t)
  250. manage_dirs_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
  251. manage_files_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
  252. manage_sock_files_pattern(spamd_t, spamd_var_run_t, spamd_var_run_t)
  253. files_pid_filetrans(spamd_t, spamd_var_run_t, { file dir })
  254. can_exec(spamd_t, { spamd_exec_t spamd_compiled_t })
  255. kernel_read_all_sysctls(spamd_t)
  256. kernel_read_system_state(spamd_t)
  257. corenet_all_recvfrom_unlabeled(spamd_t)
  258. corenet_all_recvfrom_netlabel(spamd_t)
  259. corenet_tcp_sendrecv_generic_if(spamd_t)
  260. corenet_udp_sendrecv_generic_if(spamd_t)
  261. corenet_tcp_sendrecv_generic_node(spamd_t)
  262. corenet_udp_sendrecv_generic_node(spamd_t)
  263. corenet_tcp_sendrecv_all_ports(spamd_t)
  264. corenet_udp_sendrecv_all_ports(spamd_t)
  265. corenet_tcp_bind_generic_node(spamd_t)
  266. corenet_udp_bind_generic_node(spamd_t)
  267. corenet_sendrecv_spamd_server_packets(spamd_t)
  268. corenet_tcp_bind_spamd_port(spamd_t)
  269. corenet_sendrecv_razor_client_packets(spamd_t)
  270. corenet_tcp_connect_razor_port(spamd_t)
  271. corenet_sendrecv_smtp_client_packets(spamd_t)
  272. corenet_tcp_connect_smtp_port(spamd_t)
  273. corenet_sendrecv_generic_server_packets(spamd_t)
  274. corenet_udp_bind_generic_port(spamd_t)
  275. corenet_sendrecv_imaze_server_packets(spamd_t)
  276. corenet_udp_bind_imaze_port(spamd_t)
  277. corenet_dontaudit_udp_bind_all_ports(spamd_t)
  278. corecmd_exec_bin(spamd_t)
  279. dev_read_sysfs(spamd_t)
  280. dev_read_urand(spamd_t)
  281. domain_use_interactive_fds(spamd_t)
  282. files_read_usr_files(spamd_t)
  283. files_read_etc_runtime_files(spamd_t)
  284. fs_getattr_all_fs(spamd_t)
  285. fs_search_auto_mountpoints(spamd_t)
  286. auth_use_nsswitch(spamd_t)
  287. auth_dontaudit_read_shadow(spamd_t)
  288. init_dontaudit_rw_utmp(spamd_t)
  289. libs_use_ld_so(spamd_t)
  290. libs_use_shared_libs(spamd_t)
  291. logging_send_syslog_msg(spamd_t)
  292. miscfiles_read_localization(spamd_t)
  293. sysnet_use_ldap(spamd_t)
  294. userdom_use_unpriv_users_fds(spamd_t)
  295. tunable_policy(`spamd_enable_home_dirs',`
  296. userdom_manage_user_home_content_dirs(spamd_t)
  297. userdom_manage_user_home_content_files(spamd_t)
  298. userdom_manage_user_home_content_symlinks(spamd_t)
  299. ')
  300. tunable_policy(`use_nfs_home_dirs',`
  301. fs_manage_nfs_dirs(spamd_t)
  302. fs_manage_nfs_files(spamd_t)
  303. fs_manage_nfs_symlinks(spamd_t)
  304. ')
  305. tunable_policy(`use_samba_home_dirs',`
  306. fs_manage_cifs_dirs(spamd_t)
  307. fs_manage_cifs_files(spamd_t)
  308. fs_manage_cifs_symlinks(spamd_t)
  309. ')
  310. optional_policy(`
  311. amavis_manage_lib_files(spamd_t)
  312. ')
  313. optional_policy(`
  314. clamav_stream_connect(spamd_t)
  315. ')
  316. optional_policy(`
  317. cron_system_entry(spamd_t, spamd_exec_t)
  318. ')
  319. optional_policy(`
  320. daemontools_service_domain(spamd_t, spamd_exec_t)
  321. ')
  322. optional_policy(`
  323. dcc_domtrans_cdcc(spamd_t)
  324. dcc_domtrans_client(spamd_t)
  325. dcc_signal_client(spamd_t)
  326. dcc_stream_connect_dccifd(spamd_t)
  327. ')
  328. optional_policy(`
  329. evolution_home_filetrans(spamd_t, spamd_tmp_t, { file sock_file })
  330. ')
  331. optional_policy(`
  332. exim_manage_spool_dirs(spamd_t)
  333. exim_manage_spool_files(spamd_t)
  334. ')
  335. optional_policy(`
  336. milter_manage_spamass_state(spamd_t)
  337. ')
  338. optional_policy(`
  339. mysql_stream_connect(spamd_t)
  340. mysql_tcp_connect(spamd_t)
  341. ')
  342. optional_policy(`
  343. postfix_read_config(spamd_t)
  344. ')
  345. optional_policy(`
  346. postgresql_stream_connect(spamd_t)
  347. postgresql_tcp_connect(spamd_t)
  348. ')
  349. optional_policy(`
  350. pyzor_domtrans(spamd_t)
  351. pyzor_signal(spamd_t)
  352. ')
  353. optional_policy(`
  354. razor_domtrans(spamd_t)
  355. razor_read_lib_files(spamd_t)
  356. razor_manage_home_content(spamd_t)
  357. ')
  358. optional_policy(`
  359. seutil_sigchld_newrole(spamd_t)
  360. ')
  361. optional_policy(`
  362. sendmail_stub(spamd_t)
  363. mta_read_config(spamd_t)
  364. mta_send_mail(spamd_t)
  365. ')
  366. optional_policy(`
  367. udev_read_db(spamd_t)
  368. ')
  369. ########################################
  370. #
  371. # Update local policy
  372. #
  373. allow spamd_update_t self:capability dac_override;
  374. allow spamd_update_t self:fifo_file manage_fifo_file_perms;
  375. allow spamd_update_t self:unix_stream_socket create_stream_socket_perms;
  376. manage_dirs_pattern(spamd_update_t, spamd_tmp_t, spamd_tmp_t)
  377. manage_files_pattern(spamd_update_t, spamd_tmp_t, spamd_tmp_t)
  378. files_tmp_filetrans(spamd_update_t, spamd_tmp_t, { file dir })
  379. manage_dirs_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
  380. manage_files_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
  381. manage_lnk_files_pattern(spamd_update_t, spamd_var_lib_t, spamd_var_lib_t)
  382. kernel_read_system_state(spamd_update_t)
  383. corenet_all_recvfrom_unlabeled(spamd_update_t)
  384. corenet_all_recvfrom_netlabel(spamd_update_t)
  385. corenet_tcp_sendrecv_generic_if(spamd_update_t)
  386. corenet_tcp_sendrecv_generic_node(spamd_update_t)
  387. corenet_tcp_sendrecv_all_ports(spamd_update_t)
  388. corenet_sendrecv_http_client_packets(spamd_update_t)
  389. corenet_tcp_connect_http_port(spamd_update_t)
  390. corenet_tcp_sendrecv_http_port(spamd_update_t)
  391. corecmd_exec_bin(spamd_update_t)
  392. corecmd_exec_shell(spamd_update_t)
  393. dev_read_urand(spamd_update_t)
  394. domain_use_interactive_fds(spamd_update_t)
  395. files_read_usr_files(spamd_update_t)
  396. auth_use_nsswitch(spamd_update_t)
  397. auth_dontaudit_read_shadow(spamd_update_t)
  398. miscfiles_read_localization(spamd_update_t)
  399. userdom_use_user_terminals(spamd_update_t)
  400. optional_policy(`
  401. cron_system_entry(spamd_update_t, spamd_update_exec_t)
  402. ')
  403. # probably want a solution same as httpd_use_gpg since this will
  404. # give spamd_update a path to users gpg keys
  405. # optional_policy(`
  406. # gpg_domtrans(spamd_update_t)
  407. # ')
  408. optional_policy(`
  409. mta_read_config(spamd_update_t)
  410. ')