## <summary>Cluster Configuration System.</summary>

########################################
## <summary>
##	Execute a domain transition to run ccs.
## </summary>
## <param name="domain">
## <summary>
##	Domain allowed to transition.
## </summary>
## </param>
#
interface(`ccs_domtrans',`
	gen_require(`
		type ccs_t, ccs_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, ccs_exec_t, ccs_t)
')

########################################
## <summary>
##	Connect to ccs over an unix stream socket.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`ccs_stream_connect',`
	gen_require(`
		type ccs_t, ccs_var_run_t;
	')

	files_search_pids($1)
	stream_connect_pattern($1, ccs_var_run_t, ccs_var_run_t, ccs_t)
')

########################################
## <summary>
##	Read cluster configuration files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`ccs_read_config',`
	gen_require(`
		type cluster_conf_t;
	')

	files_search_etc($1)
	read_files_pattern($1, cluster_conf_t, cluster_conf_t)
')

########################################
## <summary>
##	Create, read, write, and delete
##	cluster configuration files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`ccs_manage_config',`
	gen_require(`
		type cluster_conf_t;
	')

	files_search_etc($1)
	manage_dirs_pattern($1, cluster_conf_t, cluster_conf_t)
	manage_files_pattern($1, cluster_conf_t, cluster_conf_t)
')

########################################
## <summary>
##	All of the rules required to
##	administrate an ccs environment.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	Role allowed access.
##	</summary>
## </param>
## <rolecap/>
#
interface(`ccs_admin',`
	gen_require(`
		type ccs_t, ccs_initrc_exec_t, cluster_conf_t;
		type ccs_var_lib_t, ccs_var_log_t;
		type ccs_var_run_t, ccs_tmp_t;
	')

	allow $1 ccs_t:process { signal_perms };
	ps_process_pattern($1, ccs_t)

    tunable_policy(`deny_ptrace',`',`
        allow $1 ccs_t:process ptrace;
    ')

	init_labeled_script_domtrans($1, ccs_initrc_exec_t)
	domain_system_change_exemption($1)
	role_transition $2 ccs_initrc_exec_t system_r;
	allow $2 system_r;

	files_search_etc($1)
	admin_pattern($1, cluster_conf_t)

	files_search_var_lib($1)
	admin_pattern($1, ccs_var_lib_t)

	logging_search_logs($1)
	admin_pattern($1, ccs_var_log_t)

	files_search_pids($1)
	admin_pattern($1, ccs_var_run_t)

	files_search_tmp($1)
	admin_pattern($1, ccs_tmp_t)
')
