spamassassin.te 15 KB

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