selinux-policy/policy/modules/services/mysql.te

244 lines
7.1 KiB
Plaintext
Raw Normal View History

2010-05-24 19:32:01 +00:00
policy_module(mysql, 1.12.0)
2005-08-03 17:56:26 +00:00
########################################
#
# Declarations
#
## <desc>
## <p>
## Allow mysqld to connect to all ports
## </p>
## </desc>
gen_tunable(mysql_connect_any, false)
2005-08-03 17:56:26 +00:00
type mysqld_t;
type mysqld_exec_t;
init_daemon_domain(mysqld_t, mysqld_exec_t)
2005-08-03 17:56:26 +00:00
2009-05-06 14:26:20 +00:00
type mysqld_safe_t;
type mysqld_safe_exec_t;
init_daemon_domain(mysqld_safe_t, mysqld_safe_exec_t)
2005-08-03 17:56:26 +00:00
type mysqld_var_run_t;
files_pid_file(mysqld_var_run_t)
type mysqld_db_t;
2005-09-05 18:17:17 +00:00
files_type(mysqld_db_t)
2005-08-03 17:56:26 +00:00
type mysqld_etc_t alias etc_mysqld_t;
2005-10-24 18:40:24 +00:00
files_config_file(mysqld_etc_t)
2005-08-03 17:56:26 +00:00
2008-11-18 19:55:10 +00:00
type mysqld_initrc_exec_t;
init_script_file(mysqld_initrc_exec_t)
2005-08-03 17:56:26 +00:00
type mysqld_log_t;
logging_log_file(mysqld_log_t)
type mysqld_tmp_t;
files_tmp_file(mysqld_tmp_t)
type mysqlmanagerd_t;
type mysqlmanagerd_exec_t;
init_daemon_domain(mysqlmanagerd_t, mysqlmanagerd_exec_t)
type mysqlmanagerd_initrc_exec_t;
init_script_file(mysqlmanagerd_initrc_exec_t)
type mysqlmanagerd_var_run_t;
files_pid_file(mysqlmanagerd_var_run_t)
2005-08-03 17:56:26 +00:00
########################################
#
# Local policy
#
allow mysqld_t self:capability { dac_override ipc_lock setgid setuid sys_resource net_bind_service };
2005-08-03 17:56:26 +00:00
dontaudit mysqld_t self:capability sys_tty_config;
allow mysqld_t self:process { setsched getsched setrlimit signal_perms rlimitinh };
allow mysqld_t self:fifo_file rw_fifo_file_perms;
2008-11-18 19:55:10 +00:00
allow mysqld_t self:shm create_shm_perms;
2005-08-03 17:56:26 +00:00
allow mysqld_t self:unix_stream_socket create_stream_socket_perms;
allow mysqld_t self:tcp_socket create_stream_socket_perms;
2005-10-14 17:55:40 +00:00
allow mysqld_t self:udp_socket create_socket_perms;
2005-08-03 17:56:26 +00:00
manage_dirs_pattern(mysqld_t, mysqld_db_t, mysqld_db_t)
manage_files_pattern(mysqld_t, mysqld_db_t, mysqld_db_t)
2010-08-26 13:41:21 +00:00
manage_sock_files_pattern(mysqld_t, mysqld_db_t, mysqld_db_t)
manage_lnk_files_pattern(mysqld_t, mysqld_db_t, mysqld_db_t)
files_var_lib_filetrans(mysqld_t, mysqld_db_t, { dir file lnk_file })
2005-08-03 17:56:26 +00:00
allow mysqld_t mysqld_etc_t:file read_file_perms;
2005-10-26 18:07:20 +00:00
allow mysqld_t mysqld_etc_t:lnk_file { getattr read };
allow mysqld_t mysqld_etc_t:dir list_dir_perms;
2005-08-03 17:56:26 +00:00
2006-12-12 20:08:08 +00:00
allow mysqld_t mysqld_log_t:file manage_file_perms;
logging_log_filetrans(mysqld_t, mysqld_log_t, file)
2005-08-03 17:56:26 +00:00
manage_dirs_pattern(mysqld_t, mysqld_tmp_t, mysqld_tmp_t)
manage_files_pattern(mysqld_t, mysqld_tmp_t, mysqld_tmp_t)
2006-02-21 18:40:44 +00:00
files_tmp_filetrans(mysqld_t, mysqld_tmp_t, { file dir })
2005-08-03 17:56:26 +00:00
2010-08-26 13:41:21 +00:00
manage_dirs_pattern(mysqld_t, mysqld_var_run_t, mysqld_var_run_t)
manage_files_pattern(mysqld_t, mysqld_var_run_t, mysqld_var_run_t)
manage_sock_files_pattern(mysqld_t, mysqld_var_run_t, mysqld_var_run_t)
2010-08-26 13:41:21 +00:00
files_pid_filetrans(mysqld_t, mysqld_var_run_t, { dir file sock_file })
2005-08-03 17:56:26 +00:00
kernel_read_system_state(mysqld_t)
2006-05-30 19:46:34 +00:00
kernel_read_kernel_sysctls(mysqld_t)
2005-08-03 17:56:26 +00:00
corenet_all_recvfrom_unlabeled(mysqld_t)
corenet_all_recvfrom_netlabel(mysqld_t)
corenet_tcp_sendrecv_generic_if(mysqld_t)
corenet_udp_sendrecv_generic_if(mysqld_t)
corenet_tcp_sendrecv_generic_node(mysqld_t)
corenet_udp_sendrecv_generic_node(mysqld_t)
2005-08-03 17:56:26 +00:00
corenet_tcp_sendrecv_all_ports(mysqld_t)
2005-10-14 17:55:40 +00:00
corenet_udp_sendrecv_all_ports(mysqld_t)
corenet_tcp_bind_generic_node(mysqld_t)
2005-08-03 17:56:26 +00:00
corenet_tcp_bind_mysqld_port(mysqld_t)
corenet_tcp_connect_mysqld_port(mysqld_t)
2006-05-30 19:46:34 +00:00
corenet_sendrecv_mysqld_client_packets(mysqld_t)
corenet_sendrecv_mysqld_server_packets(mysqld_t)
2005-08-03 17:56:26 +00:00
dev_read_sysfs(mysqld_t)
dev_read_urand(mysqld_t)
2005-08-03 17:56:26 +00:00
fs_getattr_all_fs(mysqld_t)
fs_search_auto_mountpoints(mysqld_t)
2008-11-18 19:55:10 +00:00
fs_rw_hugetlbfs_files(mysqld_t)
2005-08-03 17:56:26 +00:00
2006-02-20 21:33:25 +00:00
domain_use_interactive_fds(mysqld_t)
2005-08-03 17:56:26 +00:00
files_getattr_var_lib_dirs(mysqld_t)
2005-08-03 17:56:26 +00:00
files_read_etc_runtime_files(mysqld_t)
files_read_etc_files(mysqld_t)
2005-08-03 17:56:26 +00:00
files_read_usr_files(mysqld_t)
files_search_var_lib(mysqld_t)
2005-08-03 17:56:26 +00:00
auth_use_nsswitch(mysqld_t)
2005-08-03 17:56:26 +00:00
logging_send_syslog_msg(mysqld_t)
miscfiles_read_localization(mysqld_t)
sysnet_read_config(mysqld_t)
2006-02-20 21:33:25 +00:00
userdom_dontaudit_use_unpriv_user_fds(mysqld_t)
2005-08-03 17:56:26 +00:00
# for /root/.my.cnf - should not be needed:
2008-11-05 16:10:46 +00:00
userdom_read_user_home_content_files(mysqld_t)
2005-08-03 17:56:26 +00:00
ifdef(`distro_redhat',`
# because Fedora has the sock_file in the database directory
type_transition mysqld_t mysqld_db_t:sock_file mysqld_var_run_t;
')
tunable_policy(`mysql_connect_any',`
corenet_tcp_connect_all_ports(mysqld_t)
corenet_sendrecv_all_client_packets(mysqld_t)
')
optional_policy(`
daemontools_service_domain(mysqld_t, mysqld_exec_t)
')
optional_policy(`
2005-08-03 17:56:26 +00:00
seutil_sigchld_newrole(mysqld_t)
')
optional_policy(`
2005-08-03 17:56:26 +00:00
udev_read_db(mysqld_t)
')
2009-05-06 14:26:20 +00:00
#######################################
#
# Local mysqld_safe policy
#
allow mysqld_safe_t self:capability { chown dac_override fowner kill };
dontaudit mysqld_safe_t self:capability sys_ptrace;
2009-05-06 14:26:20 +00:00
allow mysqld_safe_t self:fifo_file rw_fifo_file_perms;
2010-08-26 13:41:21 +00:00
allow mysqld_safe_t self:process { setsched getsched setrlimit };
2009-05-06 14:26:20 +00:00
read_lnk_files_pattern(mysqld_safe_t, mysqld_db_t, mysqld_db_t)
2009-05-06 14:26:20 +00:00
domtrans_pattern(mysqld_safe_t, mysqld_exec_t, mysqld_t)
2009-05-06 14:44:57 +00:00
2009-05-06 14:26:20 +00:00
allow mysqld_safe_t mysqld_log_t:file manage_file_perms;
2009-12-18 15:44:35 +00:00
manage_files_pattern(mysqld_safe_t, mysqld_var_run_t, mysqld_var_run_t)
delete_sock_files_pattern(mysqld_safe_t, mysqld_var_run_t, mysqld_var_run_t)
2009-12-18 15:44:35 +00:00
kernel_read_system_state(mysqld_safe_t)
kernel_read_kernel_sysctls(mysqld_safe_t)
corecmd_exec_bin(mysqld_safe_t)
2009-05-06 14:26:20 +00:00
dev_list_sysfs(mysqld_safe_t)
2009-05-06 14:44:57 +00:00
2010-03-12 13:59:23 +00:00
domain_read_all_domains_state(mysqld_safe_t)
2010-08-26 13:41:21 +00:00
files_dontaudit_search_all_mountpoints(mysqld_safe_t)
2009-05-06 14:26:20 +00:00
files_read_etc_files(mysqld_safe_t)
files_read_usr_files(mysqld_safe_t)
2010-03-12 13:59:23 +00:00
files_dontaudit_getattr_all_dirs(mysqld_safe_t)
logging_log_filetrans(mysqld_safe_t, mysqld_log_t, file)
2009-05-06 14:26:20 +00:00
hostname_exec(mysqld_safe_t)
2009-05-06 14:44:57 +00:00
2009-12-18 15:44:35 +00:00
miscfiles_read_localization(mysqld_safe_t)
2009-05-06 14:44:57 +00:00
2009-12-18 15:44:35 +00:00
mysql_manage_db_files(mysqld_safe_t)
2009-05-06 14:26:20 +00:00
mysql_read_config(mysqld_safe_t)
mysql_search_pid_files(mysqld_safe_t)
mysql_write_log(mysqld_safe_t)
########################################
#
# MySQL Manager Policy
#
allow mysqlmanagerd_t self:capability { dac_override kill };
allow mysqlmanagerd_t self:process signal;
allow mysqlmanagerd_t self:fifo_file rw_fifo_file_perms;
allow mysqlmanagerd_t self:tcp_socket create_stream_socket_perms;
allow mysqlmanagerd_t self:unix_stream_socket create_stream_socket_perms;
mysql_read_config(initrc_t)
mysql_read_config(mysqlmanagerd_t)
mysql_read_pid_files(mysqlmanagerd_t)
mysql_search_db(mysqlmanagerd_t)
mysql_signal(mysqlmanagerd_t)
mysql_stream_connect(mysqlmanagerd_t)
domtrans_pattern(mysqlmanagerd_t, mysqld_exec_t, mysqld_t)
manage_files_pattern(mysqlmanagerd_t, mysqld_var_run_t, mysqlmanagerd_var_run_t)
manage_sock_files_pattern(mysqlmanagerd_t, mysqld_var_run_t, mysqlmanagerd_var_run_t)
filetrans_pattern(mysqlmanagerd_t, mysqld_var_run_t, mysqlmanagerd_var_run_t, { file sock_file })
kernel_read_system_state(mysqlmanagerd_t)
corecmd_exec_shell(mysqlmanagerd_t)
corenet_all_recvfrom_unlabeled(mysqlmanagerd_t)
corenet_all_recvfrom_netlabel(mysqlmanagerd_t)
corenet_tcp_sendrecv_generic_if(mysqlmanagerd_t)
corenet_tcp_sendrecv_generic_node(mysqlmanagerd_t)
corenet_tcp_sendrecv_all_ports(mysqlmanagerd_t)
corenet_tcp_bind_generic_node(mysqlmanagerd_t)
corenet_tcp_bind_mysqlmanagerd_port(mysqlmanagerd_t)
corenet_tcp_connect_mysqlmanagerd_port(mysqlmanagerd_t)
corenet_sendrecv_mysqlmanagerd_server_packets(mysqlmanagerd_t)
corenet_sendrecv_mysqlmanagerd_client_packets(mysqlmanagerd_t)
dev_read_urand(mysqlmanagerd_t)
files_read_etc_files(mysqlmanagerd_t)
files_read_usr_files(mysqlmanagerd_t)
miscfiles_read_localization(mysqlmanagerd_t)
userdom_getattr_user_home_dirs(mysqlmanagerd_t)