## Open source database.
######################################
##
## Execute MySQL in the mysql domain.
##
##
##
## Domain allowed to transition.
##
##
#
interface(`mysql_domtrans',`
gen_require(`
type mysqld_t, mysqld_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, mysqld_exec_t, mysqld_t)
')
########################################
##
## Execute mysqld in the mysqld domain, and
## allow the specified role the mysqld domain.
##
##
##
## Domain allowed to transition.
##
##
##
##
## Role allowed access.
##
##
#
interface(`mysql_run_mysqld',`
gen_require(`
attribute_role mysqld_roles;
')
mysql_domtrans($1)
roleattribute $2 mysqld_roles;
')
########################################
##
## Send generic signals to mysqld.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_signal',`
gen_require(`
type mysqld_t;
')
allow $1 mysqld_t:process signal;
')
########################################
##
## Connect to mysqld with a tcp socket.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_tcp_connect',`
gen_require(`
type mysqld_t;
')
corenet_tcp_recvfrom_labeled($1, mysqld_t)
corenet_tcp_connect_mysqld_port($1)
corenet_sendrecv_mysqld_client_packets($1)
')
########################################
##
## Connect to mysqld with a unix
# domain stream socket.
##
##
##
## Domain allowed access.
##
##
##
#
interface(`mysql_stream_connect',`
gen_require(`
type mysqld_t, mysqld_runtime_t, mysqld_db_t;
')
files_search_runtime($1)
stream_connect_pattern($1, { mysqld_db_t mysqld_runtime_t }, mysqld_runtime_t, mysqld_t)
')
########################################
##
## Read mysqld configuration content.
##
##
##
## Domain allowed access.
##
##
##
#
interface(`mysql_read_config',`
gen_require(`
type mysqld_etc_t;
')
files_search_etc($1)
allow $1 mysqld_etc_t:dir list_dir_perms;
allow $1 mysqld_etc_t:file read_file_perms;
allow $1 mysqld_etc_t:lnk_file read_lnk_file_perms;
')
########################################
##
## Search mysqld db directories.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_search_db',`
gen_require(`
type mysqld_db_t;
')
files_search_var_lib($1)
allow $1 mysqld_db_t:dir search_dir_perms;
')
########################################
##
## Read and write mysqld database directories.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_rw_db_dirs',`
gen_require(`
type mysqld_db_t;
')
files_search_var_lib($1)
allow $1 mysqld_db_t:dir rw_dir_perms;
')
########################################
##
## Create, read, write, and delete
## mysqld database directories.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_manage_db_dirs',`
gen_require(`
type mysqld_db_t;
')
files_search_var_lib($1)
allow $1 mysqld_db_t:dir manage_dir_perms;
')
#######################################
##
## Append mysqld database files.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_append_db_files',`
gen_require(`
type mysqld_db_t;
')
files_search_var_lib($1)
append_files_pattern($1, mysqld_db_t, mysqld_db_t)
')
#######################################
##
## Read and write mysqld database files.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_rw_db_files',`
gen_require(`
type mysqld_db_t;
')
files_search_var_lib($1)
rw_files_pattern($1, mysqld_db_t, mysqld_db_t)
')
#######################################
##
## Create, read, write, and delete
## mysqld database files.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_manage_db_files',`
gen_require(`
type mysqld_db_t;
')
files_search_var_lib($1)
manage_files_pattern($1, mysqld_db_t, mysqld_db_t)
')
########################################
##
## create mysqld db dir.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_var_lib_filetrans_db_dir',`
gen_require(`
type mysqld_db_t;
')
files_var_lib_filetrans($1, mysqld_db_t, dir, "mysql")
')
########################################
##
## Create, read, write, and delete
## mysqld home files.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_manage_mysqld_home_files',`
gen_require(`
type mysqld_home_t;
')
userdom_search_user_home_dirs($1)
allow $1 mysqld_home_t:file manage_file_perms;
')
########################################
##
## Relabel mysqld home files.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_relabel_mysqld_home_files',`
gen_require(`
type mysqld_home_t;
')
userdom_search_user_home_dirs($1)
allow $1 mysqld_home_t:file relabel_file_perms;
')
########################################
##
## Create objects in user home
## directories with the mysqld home type.
##
##
##
## Domain allowed access.
##
##
##
##
## Class of the object being created.
##
##
##
##
## The name of the object being created.
##
##
#
interface(`mysql_home_filetrans_mysqld_home',`
gen_require(`
type mysqld_home_t;
')
userdom_user_home_dir_filetrans($1, mysqld_home_t, $2, $3)
')
########################################
##
## Write mysqld log files.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_write_log',`
gen_require(`
type mysqld_log_t;
')
logging_search_logs($1)
allow $1 mysqld_log_t:dir search_dir_perms;
allow $1 mysqld_log_t:file write_file_perms;
')
########################################
##
## create mysqld log dir.
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_log_filetrans_log_dir',`
gen_require(`
type mysqld_log_t;
')
logging_search_logs($1)
logging_log_filetrans($1, mysqld_log_t, dir, "mysql")
')
######################################
##
## Execute mysqld safe in the
## mysqld safe domain.
##
##
##
## Domain allowed to transition.
##
##
#
interface(`mysql_domtrans_mysql_safe',`
gen_require(`
type mysqld_safe_t, mysqld_safe_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, mysqld_safe_exec_t, mysqld_safe_t)
')
#####################################
##
## Read mysqld pid files. (Deprecated)
##
##
##
## Domain allowed access.
##
##
#
interface(`mysql_read_pid_files',`
refpolicywarn(`$0($*) has been deprecated.')
')
#####################################
##
## Search mysqld pid files. (Deprecated)
##
##
##
## Domain allowed access.
##
##
##
#
interface(`mysql_search_pid_files',`
refpolicywarn(`$0($*) has been deprecated.')
')
########################################
##
## All of the rules required to
## administrate an mysqld environment.
##
##
##
## Domain allowed access.
##
##
##
##
## Role allowed access.
##
##
##
#
interface(`mysql_admin',`
gen_require(`
type mysqld_t, mysqld_runtime_t, mysqld_etc_t;
type mysqld_tmp_t, mysqld_db_t, mysqld_log_t;
type mysqld_safe_t, mysqlmanagerd_t, mysqlmanagerd_runtime_t;
type mysqld_initrc_exec_t, mysqlmanagerd_initrc_exec_t, mysqld_home_t;
')
allow $1 { mysqld_safe_t mysqld_t mysqlmanagerd_t }:process { ptrace signal_perms };
ps_process_pattern($1, { mysqld_safe_t mysqld_t mysqlmanagerd_t })
init_startstop_service($1, $2, mysqld_t, mysqld_initrc_exec_t)
init_startstop_service($1, $2, mysqlmanagerd_t, mysqlmanagerd_initrc_exec_t)
files_search_runtime($1)
admin_pattern($1, { mysqlmanagerd_runtime_t mysqld_runtime_t })
files_search_var_lib($1)
admin_pattern($1, mysqld_db_t)
files_search_etc($1)
admin_pattern($1, { mysqld_etc_t mysqld_home_t })
logging_search_logs($1)
admin_pattern($1, mysqld_log_t)
files_search_tmp($1)
admin_pattern($1, mysqld_tmp_t)
mysql_run_mysqld($1, $2)
')