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