bind.te 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. policy_module(bind, 1.14.6)
  2. ########################################
  3. #
  4. # Declarations
  5. #
  6. ## <desc>
  7. ## <p>
  8. ## Determine whether Bind can bind tcp socket to http ports.
  9. ## </p>
  10. ## </desc>
  11. gen_tunable(named_tcp_bind_http_port, false)
  12. ## <desc>
  13. ## <p>
  14. ## Determine whether Bind can write to master zone files.
  15. ## Generally this is used for dynamic DNS or zone transfers.
  16. ## </p>
  17. ## </desc>
  18. gen_tunable(named_write_master_zones, false)
  19. attribute_role ndc_roles;
  20. type dnssec_t;
  21. files_security_file(dnssec_t)
  22. files_mountpoint(dnssec_t)
  23. type named_t;
  24. type named_exec_t;
  25. init_daemon_domain(named_t, named_exec_t)
  26. type named_checkconf_exec_t;
  27. init_system_domain(named_t, named_checkconf_exec_t)
  28. type named_conf_t;
  29. files_type(named_conf_t)
  30. files_mountpoint(named_conf_t)
  31. # for secondary zone files
  32. type named_cache_t;
  33. files_type(named_cache_t)
  34. type named_initrc_exec_t;
  35. init_script_file(named_initrc_exec_t)
  36. type named_keytab_t;
  37. files_type(named_keytab_t)
  38. type named_unit_file_t;
  39. systemd_unit_file(named_unit_file_t)
  40. type named_log_t;
  41. logging_log_file(named_log_t)
  42. type named_tmp_t;
  43. files_tmp_file(named_tmp_t)
  44. type named_var_run_t;
  45. files_pid_file(named_var_run_t)
  46. init_daemon_run_dir(named_var_run_t, "named")
  47. # for primary zone files
  48. type named_zone_t;
  49. files_type(named_zone_t)
  50. type ndc_t;
  51. type ndc_exec_t;
  52. init_system_domain(ndc_t, ndc_exec_t)
  53. role ndc_roles types ndc_t;
  54. ########################################
  55. #
  56. # Local policy
  57. #
  58. allow named_t self:capability { chown dac_override fowner setgid setuid sys_chroot sys_nice sys_resource };
  59. dontaudit named_t self:capability sys_tty_config;
  60. allow named_t self:process { setsched getcap setcap setrlimit signal_perms };
  61. allow named_t self:fifo_file rw_fifo_file_perms;
  62. allow named_t self:unix_stream_socket { accept listen };
  63. allow named_t self:tcp_socket { accept listen };
  64. allow named_t dnssec_t:file read_file_perms;
  65. gen_require(`
  66. type var_lib_t;
  67. type initrc_t;
  68. ')
  69. type_transition initrc_t var_lib_t:file dnssec_t;
  70. allow named_t named_conf_t:dir list_dir_perms;
  71. read_files_pattern(named_t, named_conf_t, named_conf_t)
  72. read_lnk_files_pattern(named_t, named_conf_t, named_conf_t)
  73. manage_files_pattern(named_t, named_cache_t, named_cache_t)
  74. manage_lnk_files_pattern(named_t, named_cache_t, named_cache_t)
  75. allow named_t named_keytab_t:file read_file_perms;
  76. append_files_pattern(named_t, named_log_t, named_log_t)
  77. create_files_pattern(named_t, named_log_t, named_log_t)
  78. setattr_files_pattern(named_t, named_log_t, named_log_t)
  79. logging_log_filetrans(named_t, named_log_t, file)
  80. manage_dirs_pattern(named_t, named_tmp_t, named_tmp_t)
  81. manage_files_pattern(named_t, named_tmp_t, named_tmp_t)
  82. files_tmp_filetrans(named_t, named_tmp_t, { file dir })
  83. manage_dirs_pattern(named_t, named_var_run_t, named_var_run_t)
  84. manage_files_pattern(named_t, named_var_run_t, named_var_run_t)
  85. manage_sock_files_pattern(named_t, named_var_run_t, named_var_run_t)
  86. files_pid_filetrans(named_t, named_var_run_t, { dir file sock_file })
  87. can_exec(named_t, named_exec_t)
  88. allow named_t named_zone_t:dir list_dir_perms;
  89. read_files_pattern(named_t, named_zone_t, named_zone_t)
  90. read_lnk_files_pattern(named_t, named_zone_t, named_zone_t)
  91. kernel_read_kernel_sysctls(named_t)
  92. kernel_read_vm_sysctls(named_t)
  93. kernel_read_system_state(named_t)
  94. kernel_read_network_state(named_t)
  95. corecmd_search_bin(named_t)
  96. corenet_all_recvfrom_unlabeled(named_t)
  97. corenet_all_recvfrom_netlabel(named_t)
  98. corenet_tcp_sendrecv_generic_if(named_t)
  99. corenet_udp_sendrecv_generic_if(named_t)
  100. corenet_tcp_sendrecv_generic_node(named_t)
  101. corenet_udp_sendrecv_generic_node(named_t)
  102. corenet_tcp_bind_generic_node(named_t)
  103. corenet_udp_bind_generic_node(named_t)
  104. corenet_tcp_bind_all_unreserved_ports(named_t)
  105. corenet_sendrecv_all_server_packets(named_t)
  106. corenet_tcp_bind_dns_port(named_t)
  107. corenet_udp_bind_dns_port(named_t)
  108. corenet_tcp_sendrecv_dns_port(named_t)
  109. corenet_udp_sendrecv_dns_port(named_t)
  110. corenet_tcp_bind_rndc_port(named_t)
  111. corenet_tcp_sendrecv_rndc_port(named_t)
  112. corenet_dontaudit_udp_bind_all_reserved_ports(named_t)
  113. corenet_udp_bind_all_unreserved_ports(named_t)
  114. corenet_udp_sendrecv_all_ports(named_t)
  115. corenet_sendrecv_all_client_packets(named_t)
  116. corenet_tcp_connect_all_ports(named_t)
  117. corenet_tcp_sendrecv_all_ports(named_t)
  118. dev_read_sysfs(named_t)
  119. dev_read_rand(named_t)
  120. dev_read_urand(named_t)
  121. domain_use_interactive_fds(named_t)
  122. files_read_etc_runtime_files(named_t)
  123. fs_getattr_all_fs(named_t)
  124. fs_search_auto_mountpoints(named_t)
  125. auth_use_nsswitch(named_t)
  126. logging_send_syslog_msg(named_t)
  127. miscfiles_read_generic_certs(named_t)
  128. miscfiles_read_localization(named_t)
  129. userdom_dontaudit_use_unpriv_user_fds(named_t)
  130. userdom_dontaudit_search_user_home_dirs(named_t)
  131. tunable_policy(`named_tcp_bind_http_port',`
  132. corenet_sendrecv_http_server_packets(named_t)
  133. corenet_tcp_bind_http_port(named_t)
  134. corenet_tcp_sendrecv_http_port(named_t)
  135. ')
  136. tunable_policy(`named_write_master_zones',`
  137. manage_dirs_pattern(named_t, named_zone_t, named_zone_t)
  138. manage_files_pattern(named_t, named_zone_t, named_zone_t)
  139. manage_lnk_files_pattern(named_t, named_zone_t, named_zone_t)
  140. ')
  141. optional_policy(`
  142. dbus_system_domain(named_t, named_exec_t)
  143. init_dbus_chat_script(named_t)
  144. sysnet_dbus_chat_dhcpc(named_t)
  145. optional_policy(`
  146. networkmanager_dbus_chat(named_t)
  147. ')
  148. ')
  149. optional_policy(`
  150. kerberos_read_keytab(named_t)
  151. kerberos_use(named_t)
  152. ')
  153. optional_policy(`
  154. ldap_stream_connect(named_t)
  155. ')
  156. optional_policy(`
  157. networkmanager_rw_udp_sockets(named_t)
  158. networkmanager_rw_packet_sockets(named_t)
  159. networkmanager_rw_routing_sockets(named_t)
  160. ')
  161. optional_policy(`
  162. seutil_sigchld_newrole(named_t)
  163. ')
  164. optional_policy(`
  165. udev_read_db(named_t)
  166. ')
  167. ########################################
  168. #
  169. # NDC local policy
  170. #
  171. allow ndc_t self:capability { dac_override net_admin };
  172. allow ndc_t self:capability2 block_suspend;
  173. allow ndc_t self:process signal_perms;
  174. allow ndc_t self:fifo_file rw_fifo_file_perms;
  175. allow ndc_t self:unix_stream_socket { accept listen };
  176. allow ndc_t dnssec_t:file read_file_perms;
  177. allow ndc_t dnssec_t:lnk_file read_lnk_file_perms;
  178. stream_connect_pattern(ndc_t, named_var_run_t, named_var_run_t, named_t)
  179. allow ndc_t named_conf_t:file read_file_perms;
  180. allow ndc_t named_conf_t:lnk_file read_lnk_file_perms;
  181. allow ndc_t named_zone_t:dir search_dir_perms;
  182. kernel_read_kernel_sysctls(ndc_t)
  183. kernel_read_system_state(ndc_t)
  184. corenet_all_recvfrom_unlabeled(ndc_t)
  185. corenet_all_recvfrom_netlabel(ndc_t)
  186. corenet_tcp_sendrecv_generic_if(ndc_t)
  187. corenet_tcp_sendrecv_generic_node(ndc_t)
  188. corenet_tcp_sendrecv_all_ports(ndc_t)
  189. corenet_tcp_bind_generic_node(ndc_t)
  190. corenet_tcp_connect_rndc_port(ndc_t)
  191. corenet_sendrecv_rndc_client_packets(ndc_t)
  192. domain_use_interactive_fds(ndc_t)
  193. files_search_pids(ndc_t)
  194. fs_getattr_xattr_fs(ndc_t)
  195. term_dontaudit_use_console(ndc_t)
  196. auth_use_nsswitch(ndc_t)
  197. init_use_fds(ndc_t)
  198. init_use_script_ptys(ndc_t)
  199. logging_send_syslog_msg(ndc_t)
  200. miscfiles_read_localization(ndc_t)
  201. userdom_use_user_terminals(ndc_t)
  202. ifdef(`distro_redhat',`
  203. allow ndc_t named_conf_t:dir search_dir_perms;
  204. ')
  205. optional_policy(`
  206. ppp_dontaudit_use_fds(ndc_t)
  207. ')
  208. optional_policy(`
  209. connect_udev_udp_socket(ndc_t)
  210. ')