bind.te 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. policy_module(bind, 1.14.1)
  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. allow named_t named_conf_t:dir list_dir_perms;
  66. read_files_pattern(named_t, named_conf_t, named_conf_t)
  67. read_lnk_files_pattern(named_t, named_conf_t, named_conf_t)
  68. manage_files_pattern(named_t, named_cache_t, named_cache_t)
  69. manage_lnk_files_pattern(named_t, named_cache_t, named_cache_t)
  70. allow named_t named_keytab_t:file read_file_perms;
  71. append_files_pattern(named_t, named_log_t, named_log_t)
  72. create_files_pattern(named_t, named_log_t, named_log_t)
  73. setattr_files_pattern(named_t, named_log_t, named_log_t)
  74. logging_log_filetrans(named_t, named_log_t, file)
  75. manage_dirs_pattern(named_t, named_tmp_t, named_tmp_t)
  76. manage_files_pattern(named_t, named_tmp_t, named_tmp_t)
  77. files_tmp_filetrans(named_t, named_tmp_t, { file dir })
  78. manage_dirs_pattern(named_t, named_var_run_t, named_var_run_t)
  79. manage_files_pattern(named_t, named_var_run_t, named_var_run_t)
  80. manage_sock_files_pattern(named_t, named_var_run_t, named_var_run_t)
  81. files_pid_filetrans(named_t, named_var_run_t, { dir file sock_file })
  82. can_exec(named_t, named_exec_t)
  83. allow named_t named_zone_t:dir list_dir_perms;
  84. read_files_pattern(named_t, named_zone_t, named_zone_t)
  85. read_lnk_files_pattern(named_t, named_zone_t, named_zone_t)
  86. kernel_read_kernel_sysctls(named_t)
  87. kernel_read_vm_sysctls(named_t)
  88. kernel_read_system_state(named_t)
  89. kernel_read_network_state(named_t)
  90. corecmd_search_bin(named_t)
  91. corenet_all_recvfrom_unlabeled(named_t)
  92. corenet_all_recvfrom_netlabel(named_t)
  93. corenet_tcp_sendrecv_generic_if(named_t)
  94. corenet_udp_sendrecv_generic_if(named_t)
  95. corenet_tcp_sendrecv_generic_node(named_t)
  96. corenet_udp_sendrecv_generic_node(named_t)
  97. corenet_tcp_bind_generic_node(named_t)
  98. corenet_udp_bind_generic_node(named_t)
  99. corenet_sendrecv_all_server_packets(named_t)
  100. corenet_tcp_bind_dns_port(named_t)
  101. corenet_udp_bind_dns_port(named_t)
  102. corenet_tcp_sendrecv_dns_port(named_t)
  103. corenet_udp_sendrecv_dns_port(named_t)
  104. corenet_tcp_bind_rndc_port(named_t)
  105. corenet_tcp_sendrecv_rndc_port(named_t)
  106. corenet_dontaudit_udp_bind_all_reserved_ports(named_t)
  107. corenet_udp_bind_all_unreserved_ports(named_t)
  108. corenet_udp_sendrecv_all_ports(named_t)
  109. corenet_sendrecv_all_client_packets(named_t)
  110. corenet_tcp_connect_all_ports(named_t)
  111. corenet_tcp_sendrecv_all_ports(named_t)
  112. dev_read_sysfs(named_t)
  113. dev_read_rand(named_t)
  114. dev_read_urand(named_t)
  115. domain_use_interactive_fds(named_t)
  116. files_read_etc_runtime_files(named_t)
  117. fs_getattr_all_fs(named_t)
  118. fs_search_auto_mountpoints(named_t)
  119. auth_use_nsswitch(named_t)
  120. logging_send_syslog_msg(named_t)
  121. miscfiles_read_generic_certs(named_t)
  122. miscfiles_read_localization(named_t)
  123. userdom_dontaudit_use_unpriv_user_fds(named_t)
  124. userdom_dontaudit_search_user_home_dirs(named_t)
  125. tunable_policy(`named_tcp_bind_http_port',`
  126. corenet_sendrecv_http_server_packets(named_t)
  127. corenet_tcp_bind_http_port(named_t)
  128. corenet_tcp_sendrecv_http_port(named_t)
  129. ')
  130. tunable_policy(`named_write_master_zones',`
  131. manage_dirs_pattern(named_t, named_zone_t, named_zone_t)
  132. manage_files_pattern(named_t, named_zone_t, named_zone_t)
  133. manage_lnk_files_pattern(named_t, named_zone_t, named_zone_t)
  134. ')
  135. optional_policy(`
  136. dbus_system_domain(named_t, named_exec_t)
  137. init_dbus_chat_script(named_t)
  138. sysnet_dbus_chat_dhcpc(named_t)
  139. optional_policy(`
  140. networkmanager_dbus_chat(named_t)
  141. ')
  142. ')
  143. optional_policy(`
  144. kerberos_read_keytab(named_t)
  145. kerberos_use(named_t)
  146. ')
  147. optional_policy(`
  148. ldap_stream_connect(named_t)
  149. ')
  150. optional_policy(`
  151. networkmanager_rw_udp_sockets(named_t)
  152. networkmanager_rw_packet_sockets(named_t)
  153. networkmanager_rw_routing_sockets(named_t)
  154. ')
  155. optional_policy(`
  156. seutil_sigchld_newrole(named_t)
  157. ')
  158. optional_policy(`
  159. udev_read_db(named_t)
  160. ')
  161. ########################################
  162. #
  163. # NDC local policy
  164. #
  165. allow ndc_t self:capability { dac_override net_admin };
  166. allow ndc_t self:capability2 block_suspend;
  167. allow ndc_t self:process signal_perms;
  168. allow ndc_t self:fifo_file rw_fifo_file_perms;
  169. allow ndc_t self:unix_stream_socket { accept listen };
  170. allow ndc_t dnssec_t:file read_file_perms;
  171. allow ndc_t dnssec_t:lnk_file read_lnk_file_perms;
  172. stream_connect_pattern(ndc_t, named_var_run_t, named_var_run_t, named_t)
  173. allow ndc_t named_conf_t:file read_file_perms;
  174. allow ndc_t named_conf_t:lnk_file read_lnk_file_perms;
  175. allow ndc_t named_zone_t:dir search_dir_perms;
  176. kernel_read_kernel_sysctls(ndc_t)
  177. kernel_read_system_state(ndc_t)
  178. corenet_all_recvfrom_unlabeled(ndc_t)
  179. corenet_all_recvfrom_netlabel(ndc_t)
  180. corenet_tcp_sendrecv_generic_if(ndc_t)
  181. corenet_tcp_sendrecv_generic_node(ndc_t)
  182. corenet_tcp_sendrecv_all_ports(ndc_t)
  183. corenet_tcp_bind_generic_node(ndc_t)
  184. corenet_tcp_connect_rndc_port(ndc_t)
  185. corenet_sendrecv_rndc_client_packets(ndc_t)
  186. domain_use_interactive_fds(ndc_t)
  187. files_search_pids(ndc_t)
  188. fs_getattr_xattr_fs(ndc_t)
  189. term_dontaudit_use_console(ndc_t)
  190. auth_use_nsswitch(ndc_t)
  191. init_use_fds(ndc_t)
  192. init_use_script_ptys(ndc_t)
  193. logging_send_syslog_msg(ndc_t)
  194. miscfiles_read_localization(ndc_t)
  195. userdom_use_user_terminals(ndc_t)
  196. ifdef(`distro_redhat',`
  197. allow ndc_t named_conf_t:dir search_dir_perms;
  198. ')
  199. optional_policy(`
  200. ppp_dontaudit_use_fds(ndc_t)
  201. ')
  202. optional_policy(`
  203. connect_udev_udp_socket(ndc_t)
  204. ')