## <summary>Multilayer virtual switch.</summary>

########################################
## <summary>
##	Execute openvswitch in the openvswitch domain.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed to transition.
##	</summary>
## </param>
#
interface(`openvswitch_domtrans',`
	gen_require(`
		type openvswitch_t, openvswitch_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, openvswitch_exec_t, openvswitch_t)
')

########################################
## <summary>
##	Read openvswitch pid files.  (Deprecated)
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`openvswitch_read_pid_files',`
	refpolicywarn(`$0($*) has been deprecated, please use openvswitch_read_runtime_files() instead.')
	openvswitch_read_runtime_files($1)
')

########################################
## <summary>
##	Read openvswitch runtime files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`openvswitch_read_runtime_files',`
	gen_require(`
		type openvswitch_runtime_t;
	')

	files_search_runtime($1)
	read_files_pattern($1, openvswitch_runtime_t, openvswitch_runtime_t)
')

########################################
## <summary>
##	All of the rules required to
##	administrate an openvswitch environment.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	Role allowed access.
##	</summary>
## </param>
## <rolecap/>
#
interface(`openvswitch_admin',`
	gen_require(`
		type openvswitch_t, openvswitch_initrc_exec_t, openvswitch_conf_t;
		type openvswitch_var_lib_t, openvswitch_log_t, openvswitch_runtime_t;
	')

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

	init_startstop_service($1, $2, openvswitch_t, openvswitch_initrc_exec_t)

	files_search_etc($1)
	admin_pattern($1, openvswitch_conf_t)

	files_search_var_lib($1)
	admin_pattern($1, openvswitch_var_lib_t)

	logging_search_logs($1)
	admin_pattern($1, openvswitch_log_t)

	files_search_runtime($1)
	admin_pattern($1, openvswitch_runtime_t)
')
