mysql.te 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. policy_module(mysql, 1.15.1)
  2. ########################################
  3. #
  4. # Declarations
  5. #
  6. ## <desc>
  7. ## <p>
  8. ## Determine whether mysqld can
  9. ## connect to all TCP ports.
  10. ## </p>
  11. ## </desc>
  12. gen_tunable(mysql_connect_any, false)
  13. attribute_role mysqld_roles;
  14. type mysqld_t;
  15. type mysqld_exec_t;
  16. init_daemon_domain(mysqld_t, mysqld_exec_t)
  17. application_domain(mysqld_t, mysqld_exec_t)
  18. role mysqld_roles types mysqld_t;
  19. type mysqld_safe_t;
  20. type mysqld_safe_exec_t;
  21. init_daemon_domain(mysqld_safe_t, mysqld_safe_exec_t)
  22. type mysqld_var_run_t;
  23. files_pid_file(mysqld_var_run_t)
  24. init_daemon_run_dir(mysqld_var_run_t, "mysqld")
  25. type mysqld_db_t;
  26. files_type(mysqld_db_t)
  27. type mysqld_etc_t alias etc_mysqld_t;
  28. files_config_file(mysqld_etc_t)
  29. type mysqld_home_t;
  30. userdom_user_home_content(mysqld_home_t)
  31. type mysqld_unit_file_t;
  32. systemd_unit_file(mysqld_unit_file_t)
  33. type mysqld_initrc_exec_t;
  34. init_script_file(mysqld_initrc_exec_t)
  35. type mysqld_log_t;
  36. logging_log_file(mysqld_log_t)
  37. type mysqld_tmp_t;
  38. files_tmp_file(mysqld_tmp_t)
  39. type mysqlmanagerd_t;
  40. type mysqlmanagerd_exec_t;
  41. init_daemon_domain(mysqlmanagerd_t, mysqlmanagerd_exec_t)
  42. type mysqlmanagerd_initrc_exec_t;
  43. init_script_file(mysqlmanagerd_initrc_exec_t)
  44. type mysqlmanagerd_var_run_t;
  45. files_pid_file(mysqlmanagerd_var_run_t)
  46. ########################################
  47. #
  48. # Local policy
  49. #
  50. allow mysqld_t self:capability { dac_override ipc_lock setgid setuid sys_resource };
  51. dontaudit mysqld_t self:capability sys_tty_config;
  52. allow mysqld_t self:process { setsched getsched setrlimit signal_perms rlimitinh };
  53. allow mysqld_t self:fifo_file rw_fifo_file_perms;
  54. allow mysqld_t self:shm create_shm_perms;
  55. allow mysqld_t self:unix_stream_socket { connectto accept listen };
  56. allow mysqld_t self:tcp_socket { accept listen };
  57. manage_dirs_pattern(mysqld_t, mysqld_db_t, mysqld_db_t)
  58. manage_files_pattern(mysqld_t, mysqld_db_t, mysqld_db_t)
  59. manage_lnk_files_pattern(mysqld_t, mysqld_db_t, mysqld_db_t)
  60. files_var_lib_filetrans(mysqld_t, mysqld_db_t, { dir file lnk_file })
  61. filetrans_pattern(mysqld_t, mysqld_db_t, mysqld_var_run_t, sock_file)
  62. allow mysqld_t mysqld_etc_t:dir list_dir_perms;
  63. allow mysqld_t { mysqld_etc_t mysqld_home_t }:file read_file_perms;
  64. allow mysqld_t mysqld_etc_t:lnk_file read_lnk_file_perms;
  65. manage_dirs_pattern(mysqld_t, mysqld_log_t, mysqld_log_t)
  66. manage_files_pattern(mysqld_t, mysqld_log_t, mysqld_log_t)
  67. manage_lnk_files_pattern(mysqld_t, mysqld_log_t, mysqld_log_t)
  68. logging_log_filetrans(mysqld_t, mysqld_log_t, { dir file })
  69. manage_dirs_pattern(mysqld_t, mysqld_tmp_t, mysqld_tmp_t)
  70. manage_files_pattern(mysqld_t, mysqld_tmp_t, mysqld_tmp_t)
  71. files_tmp_filetrans(mysqld_t, mysqld_tmp_t, { file dir })
  72. manage_dirs_pattern(mysqld_t, mysqld_var_run_t, mysqld_var_run_t)
  73. manage_files_pattern(mysqld_t, mysqld_var_run_t, mysqld_var_run_t)
  74. manage_sock_files_pattern(mysqld_t, mysqld_var_run_t, mysqld_var_run_t)
  75. files_pid_filetrans(mysqld_t, mysqld_var_run_t, { dir file sock_file })
  76. kernel_read_kernel_sysctls(mysqld_t)
  77. kernel_read_vm_sysctls(mysqld_t)
  78. kernel_read_network_state(mysqld_t)
  79. kernel_read_system_state(mysqld_t)
  80. corenet_all_recvfrom_unlabeled(mysqld_t)
  81. corenet_all_recvfrom_netlabel(mysqld_t)
  82. corenet_tcp_sendrecv_generic_if(mysqld_t)
  83. corenet_tcp_sendrecv_generic_node(mysqld_t)
  84. corenet_tcp_bind_generic_node(mysqld_t)
  85. corenet_sendrecv_mysqld_server_packets(mysqld_t)
  86. corenet_tcp_bind_mysqld_port(mysqld_t)
  87. corenet_sendrecv_mysqld_client_packets(mysqld_t)
  88. corenet_tcp_connect_mysqld_port(mysqld_t)
  89. corenet_tcp_sendrecv_mysqld_port(mysqld_t)
  90. corecmd_exec_bin(mysqld_t)
  91. corecmd_exec_shell(mysqld_t)
  92. dev_read_sysfs(mysqld_t)
  93. dev_read_urand(mysqld_t)
  94. domain_use_interactive_fds(mysqld_t)
  95. fs_getattr_all_fs(mysqld_t)
  96. fs_search_auto_mountpoints(mysqld_t)
  97. fs_rw_hugetlbfs_files(mysqld_t)
  98. files_read_etc_runtime_files(mysqld_t)
  99. files_read_usr_files(mysqld_t)
  100. auth_use_nsswitch(mysqld_t)
  101. logging_send_syslog_msg(mysqld_t)
  102. miscfiles_read_localization(mysqld_t)
  103. userdom_search_user_home_dirs(mysqld_t)
  104. userdom_dontaudit_use_unpriv_user_fds(mysqld_t)
  105. tunable_policy(`mysql_connect_any',`
  106. corenet_sendrecv_all_client_packets(mysqld_t)
  107. corenet_tcp_connect_all_ports(mysqld_t)
  108. corenet_tcp_sendrecv_all_ports(mysqld_t)
  109. ')
  110. optional_policy(`
  111. daemontools_service_domain(mysqld_t, mysqld_exec_t)
  112. ')
  113. optional_policy(`
  114. seutil_sigchld_newrole(mysqld_t)
  115. ')
  116. optional_policy(`
  117. udev_read_db(mysqld_t)
  118. ')
  119. #######################################
  120. #
  121. # Safe local policy
  122. #
  123. allow mysqld_safe_t self:capability { chown dac_override fowner kill };
  124. allow mysqld_safe_t self:process { setsched getsched setrlimit };
  125. allow mysqld_safe_t self:fifo_file rw_fifo_file_perms;
  126. allow mysqld_safe_t self:capability sys_tty_config;
  127. allow mysqld_safe_t mysqld_t:process signull;
  128. read_lnk_files_pattern(mysqld_safe_t, mysqld_db_t, mysqld_db_t)
  129. manage_files_pattern(mysqld_safe_t, mysqld_db_t, mysqld_db_t)
  130. allow mysqld_safe_t mysqld_etc_t:dir list_dir_perms;
  131. allow mysqld_safe_t { mysqld_etc_t mysqld_home_t }:file read_file_perms;
  132. allow mysqld_safe_t mysqld_etc_t:lnk_file read_lnk_file_perms;
  133. list_dirs_pattern(mysqld_safe_t, mysqld_log_t, mysqld_log_t)
  134. manage_files_pattern(mysqld_safe_t, mysqld_log_t, mysqld_log_t)
  135. manage_lnk_files_pattern(mysqld_safe_t, mysqld_log_t, mysqld_log_t)
  136. logging_log_filetrans(mysqld_safe_t, mysqld_log_t, file)
  137. manage_files_pattern(mysqld_safe_t, mysqld_var_run_t, mysqld_var_run_t)
  138. delete_sock_files_pattern(mysqld_safe_t, { mysqld_db_t mysqld_var_run_t }, mysqld_var_run_t)
  139. domtrans_pattern(mysqld_safe_t, mysqld_exec_t, mysqld_t)
  140. kernel_read_system_state(mysqld_safe_t)
  141. kernel_read_kernel_sysctls(mysqld_safe_t)
  142. corecmd_exec_bin(mysqld_safe_t)
  143. corecmd_exec_shell(mysqld_safe_t)
  144. dev_list_sysfs(mysqld_safe_t)
  145. domain_read_all_domains_state(mysqld_safe_t)
  146. files_read_etc_files(mysqld_safe_t)
  147. files_read_usr_files(mysqld_safe_t)
  148. files_search_pids(mysqld_safe_t)
  149. files_dontaudit_getattr_all_dirs(mysqld_safe_t)
  150. files_dontaudit_search_all_mountpoints(mysqld_safe_t)
  151. logging_send_syslog_msg(mysqld_safe_t)
  152. miscfiles_read_localization(mysqld_safe_t)
  153. userdom_search_user_home_dirs(mysqld_safe_t)
  154. optional_policy(`
  155. hostname_exec(mysqld_safe_t)
  156. ')
  157. ########################################
  158. #
  159. # Manager local policy
  160. #
  161. allow mysqlmanagerd_t self:capability { dac_override kill };
  162. allow mysqlmanagerd_t self:process signal;
  163. allow mysqlmanagerd_t self:fifo_file rw_fifo_file_perms;
  164. allow mysqlmanagerd_t self:tcp_socket create_stream_socket_perms;
  165. allow mysqlmanagerd_t self:unix_stream_socket create_stream_socket_perms;
  166. allow mysqlmanagerd_t mysqld_t:process signal;
  167. allow mysqlmanagerd_t mysqld_etc_t:dir list_dir_perms;
  168. allow mysqlmanagerd_t { mysqld_etc_t mysqld_home_t }:file read_file_perms;
  169. allow mysqlmanagerd_t mysqld_etc_t:lnk_file read_lnk_file_perms;
  170. domtrans_pattern(mysqlmanagerd_t, mysqld_exec_t, mysqld_t)
  171. manage_files_pattern(mysqlmanagerd_t, mysqld_var_run_t, mysqlmanagerd_var_run_t)
  172. manage_sock_files_pattern(mysqlmanagerd_t, mysqld_var_run_t, mysqlmanagerd_var_run_t)
  173. filetrans_pattern(mysqlmanagerd_t, mysqld_var_run_t, mysqlmanagerd_var_run_t, { file sock_file })
  174. stream_connect_pattern(mysqlmanagerd_t, { mysqld_db_t mysqld_var_run_t }, mysqld_var_run_t, mysqld_t)
  175. kernel_read_system_state(mysqlmanagerd_t)
  176. corecmd_exec_shell(mysqlmanagerd_t)
  177. corenet_all_recvfrom_unlabeled(mysqlmanagerd_t)
  178. corenet_all_recvfrom_netlabel(mysqlmanagerd_t)
  179. corenet_tcp_sendrecv_generic_if(mysqlmanagerd_t)
  180. corenet_tcp_sendrecv_generic_node(mysqlmanagerd_t)
  181. corenet_tcp_bind_generic_node(mysqlmanagerd_t)
  182. corenet_sendrecv_mysqlmanagerd_server_packets(mysqlmanagerd_t)
  183. corenet_tcp_bind_mysqlmanagerd_port(mysqlmanagerd_t)
  184. corenet_sendrecv_mysqlmanagerd_client_packets(mysqlmanagerd_t)
  185. corenet_tcp_connect_mysqlmanagerd_port(mysqlmanagerd_t)
  186. corenet_tcp_sendrecv_mysqlmanagerd_port(mysqlmanagerd_t)
  187. dev_read_urand(mysqlmanagerd_t)
  188. files_read_etc_files(mysqlmanagerd_t)
  189. files_read_usr_files(mysqlmanagerd_t)
  190. files_search_pids(mysqlmanagerd_t)
  191. files_search_var_lib(mysqlmanagerd_t)
  192. miscfiles_read_localization(mysqlmanagerd_t)
  193. userdom_search_user_home_dirs(mysqlmanagerd_t)