Chris PeBenito 31b7c0
#DESC Mysqld - Database server
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Author:  Russell Coker <russell@coker.com.au>
Chris PeBenito 31b7c0
# X-Debian-Packages: mysql-server
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the mysqld_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# mysqld_exec_t is the type of the mysqld executable.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
daemon_domain(mysqld, `, nscd_client_domain')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow mysqld_t mysqld_port_t:tcp_socket { name_bind name_connect };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow mysqld_t mysqld_var_run_t:sock_file create_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
etcdir_domain(mysqld)
Chris PeBenito 31b7c0
type mysqld_db_t, file_type, sysadmfile;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
log_domain(mysqld)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for temporary tables
Chris PeBenito 31b7c0
tmp_domain(mysqld)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow mysqld_t usr_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow mysqld_t self:fifo_file { read write };
Chris PeBenito 31b7c0
allow mysqld_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow initrc_t mysqld_t:unix_stream_socket connectto;
Chris PeBenito 31b7c0
allow initrc_t mysqld_var_run_t:sock_file write;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow initrc_t mysqld_log_t:file { write append setattr ioctl };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow mysqld_t self:capability { dac_override setgid setuid net_bind_service sys_resource };
Chris PeBenito 31b7c0
allow mysqld_t self:process { setrlimit setsched getsched };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow mysqld_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Allow access to the mysqld databases
Chris PeBenito 31b7c0
create_dir_file(mysqld_t, mysqld_db_t)
Chris PeBenito 31b7c0
file_type_auto_trans(mysqld_t, var_lib_t, mysqld_db_t, { dir file })
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_network(mysqld_t)
Chris PeBenito 31b7c0
can_ypbind(mysqld_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# read config files
Chris PeBenito 31b7c0
r_dir_file(initrc_t, mysqld_etc_t)
Chris PeBenito 31b7c0
allow mysqld_t { etc_t etc_runtime_t }:{ file lnk_file } { read getattr };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow mysqld_t etc_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_sysctl(mysqld_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
can_unix_connect(sysadm_t, mysqld_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# for /root/.my.cnf - should not be needed
Chris PeBenito 31b7c0
allow mysqld_t sysadm_home_dir_t:dir search;
Chris PeBenito 31b7c0
allow mysqld_t sysadm_home_t:file { read getattr };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`logrotate.te', `
Chris PeBenito 31b7c0
r_dir_file(logrotate_t, mysqld_etc_t)
Chris PeBenito 31b7c0
allow logrotate_t mysqld_db_t:dir search;
Chris PeBenito 31b7c0
allow logrotate_t mysqld_var_run_t:dir search;
Chris PeBenito 31b7c0
allow logrotate_t mysqld_var_run_t:sock_file write;
Chris PeBenito 31b7c0
can_unix_connect(logrotate_t, mysqld_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`daemontools.te', `
Chris PeBenito 31b7c0
domain_auto_trans( svc_run_t, mysqld_exec_t, mysqld_t)
Chris PeBenito 31b7c0
allow svc_start_t mysqld_t:process signal;
Chris PeBenito 31b7c0
svc_ipc_domain(mysqld_t)
Chris PeBenito 31b7c0
')dnl end ifdef daemontools
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`distro_redhat', `
Chris PeBenito 31b7c0
allow initrc_t mysqld_db_t:dir create_dir_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# because Fedora has the sock_file in the database directory
Chris PeBenito 31b7c0
file_type_auto_trans(mysqld_t, mysqld_db_t, mysqld_var_run_t, sock_file)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
ifdef(`targeted_policy', `', `
Chris PeBenito 31b7c0
bool allow_user_mysql_connect false;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
if (allow_user_mysql_connect) {
Chris PeBenito 31b7c0
allow userdomain mysqld_var_run_t:dir search;
Chris PeBenito 31b7c0
allow userdomain mysqld_var_run_t:sock_file write;
Chris PeBenito 31b7c0
}
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`crond.te', `
Chris PeBenito 31b7c0
allow system_crond_t mysqld_etc_t:file { getattr read };
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
allow mysqld_t self:netlink_route_socket r_netlink_socket_perms;