clamav.if 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. ## <summary>ClamAV Virus Scanner.</summary>
  2. ########################################
  3. ## <summary>
  4. ## Execute a domain transition to run clamd.
  5. ## </summary>
  6. ## <param name="domain">
  7. ## <summary>
  8. ## Domain allowed to transition.
  9. ## </summary>
  10. ## </param>
  11. #
  12. interface(`clamav_domtrans',`
  13. gen_require(`
  14. type clamd_t, clamd_exec_t;
  15. ')
  16. corecmd_search_bin($1)
  17. domtrans_pattern($1, clamd_exec_t, clamd_t)
  18. ')
  19. ########################################
  20. ## <summary>
  21. ## Connect to clamd using a unix
  22. ## domain stream socket.
  23. ## </summary>
  24. ## <param name="domain">
  25. ## <summary>
  26. ## Domain allowed access.
  27. ## </summary>
  28. ## </param>
  29. #
  30. interface(`clamav_stream_connect',`
  31. gen_require(`
  32. type clamd_t, clamd_var_run_t;
  33. ')
  34. files_search_pids($1)
  35. stream_connect_pattern($1, clamd_var_run_t, clamd_var_run_t, clamd_t)
  36. ')
  37. ########################################
  38. ## <summary>
  39. ## Append clamav log files.
  40. ## </summary>
  41. ## <param name="domain">
  42. ## <summary>
  43. ## Domain allowed access.
  44. ## </summary>
  45. ## </param>
  46. #
  47. interface(`clamav_append_log',`
  48. gen_require(`
  49. type clamd_var_log_t;
  50. ')
  51. logging_search_logs($1)
  52. allow $1 clamd_var_log_t:dir list_dir_perms;
  53. append_files_pattern($1, clamd_var_log_t, clamd_var_log_t)
  54. ')
  55. ########################################
  56. ## <summary>
  57. ## Create, read, write, and delete
  58. ## clamav pid content.
  59. ## </summary>
  60. ## <param name="domain">
  61. ## <summary>
  62. ## Domain allowed access.
  63. ## </summary>
  64. ## </param>
  65. #
  66. interface(`clamav_manage_pid_content',`
  67. gen_require(`
  68. type clamd_var_run_t;
  69. ')
  70. files_search_pids($1)
  71. manage_dirs_pattern($1, clamd_var_run_t, clamd_var_run_t)
  72. manage_files_pattern($1, clamd_var_run_t, clamd_var_run_t)
  73. ')
  74. ########################################
  75. ## <summary>
  76. ## Read clamav configuration files.
  77. ## </summary>
  78. ## <param name="domain">
  79. ## <summary>
  80. ## Domain allowed access.
  81. ## </summary>
  82. ## </param>
  83. #
  84. interface(`clamav_read_config',`
  85. gen_require(`
  86. type clamd_etc_t;
  87. ')
  88. files_search_etc($1)
  89. allow $1 clamd_etc_t:file read_file_perms;
  90. ')
  91. ########################################
  92. ## <summary>
  93. ## Search clamav library directories.
  94. ## </summary>
  95. ## <param name="domain">
  96. ## <summary>
  97. ## Domain allowed access.
  98. ## </summary>
  99. ## </param>
  100. #
  101. interface(`clamav_search_lib',`
  102. gen_require(`
  103. type clamd_var_lib_t;
  104. ')
  105. files_search_var_lib($1)
  106. allow $1 clamd_var_lib_t:dir search_dir_perms;
  107. ')
  108. ########################################
  109. ## <summary>
  110. ## Execute a domain transition to run clamscan.
  111. ## </summary>
  112. ## <param name="domain">
  113. ## <summary>
  114. ## Domain allowed to transition.
  115. ## </summary>
  116. ## </param>
  117. #
  118. interface(`clamav_domtrans_clamscan',`
  119. gen_require(`
  120. type clamscan_t, clamscan_exec_t;
  121. ')
  122. corecmd_search_bin($1)
  123. domtrans_pattern($1, clamscan_exec_t, clamscan_t)
  124. ')
  125. ########################################
  126. ## <summary>
  127. ## Execute clamscan in the caller domain.
  128. ## </summary>
  129. ## <param name="domain">
  130. ## <summary>
  131. ## Domain allowed access.
  132. ## </summary>
  133. ## </param>
  134. #
  135. interface(`clamav_exec_clamscan',`
  136. gen_require(`
  137. type clamscan_exec_t;
  138. ')
  139. corecmd_search_bin($1)
  140. can_exec($1, clamscan_exec_t)
  141. ')
  142. #######################################
  143. ## <summary>
  144. ## Read clamd process state files.
  145. ## </summary>
  146. ## <param name="domain">
  147. ## <summary>
  148. ## Domain allowed access.
  149. ## </summary>
  150. ## </param>
  151. #
  152. interface(`clamav_read_state_clamd',`
  153. gen_require(`
  154. type clamd_t;
  155. ')
  156. kernel_search_proc($1)
  157. allow $1 clamd_t:dir list_dir_perms;
  158. read_files_pattern($1, clamd_t, clamd_t)
  159. read_lnk_files_pattern($1, clamd_t, clamd_t)
  160. ')
  161. ########################################
  162. ## <summary>
  163. ## All of the rules required to
  164. ## administrate an clamav environment.
  165. ## </summary>
  166. ## <param name="domain">
  167. ## <summary>
  168. ## Domain allowed access.
  169. ## </summary>
  170. ## </param>
  171. ## <param name="role">
  172. ## <summary>
  173. ## Role allowed access.
  174. ## </summary>
  175. ## </param>
  176. ## <rolecap/>
  177. #
  178. interface(`clamav_admin',`
  179. gen_require(`
  180. type clamd_t, clamd_etc_t, clamd_tmp_t;
  181. type clamd_var_log_t, clamd_var_lib_t, clamd_initrc_exec_t;
  182. type clamd_var_run_t, clamscan_t, clamscan_tmp_t;
  183. type freshclam_t, freshclam_var_log_t;
  184. ')
  185. allow $1 { clamd_t clamscan_t freshclam_t }:process { ptrace signal_perms };
  186. ps_process_pattern($1, { clamd_t clamscan_t freshclam_t })
  187. init_labeled_script_domtrans($1, clamd_initrc_exec_t)
  188. domain_system_change_exemption($1)
  189. role_transition $2 clamd_initrc_exec_t system_r;
  190. allow $2 system_r;
  191. files_list_etc($1)
  192. admin_pattern($1, clamd_etc_t)
  193. files_list_var_lib($1)
  194. admin_pattern($1, clamd_var_lib_t)
  195. logging_list_logs($1)
  196. admin_pattern($1, { clamd_var_log_t freshclam_var_log_t })
  197. files_list_pids($1)
  198. admin_pattern($1, clamd_var_run_t)
  199. files_list_tmp($1)
  200. admin_pattern($1, { clamd_tmp_t clamscan_tmp_t })
  201. ')