Chris PeBenito eb4216
## <summary>QEMU machine emulator and virtualizer</summary>
Chris PeBenito eb4216
Chris PeBenito 8a1c9c
########################################
Chris PeBenito 8a1c9c
## <summary>
Chris PeBenito 8a1c9c
##	Creates types and rules for a basic
Chris PeBenito 8a1c9c
##	qemu process domain.
Chris PeBenito 8a1c9c
## </summary>
Chris PeBenito 8a1c9c
## <param name="prefix">
Chris PeBenito 8a1c9c
##	<summary>
Chris PeBenito 8a1c9c
##	Prefix for the domain.
Chris PeBenito 8a1c9c
##	</summary>
Chris PeBenito 8a1c9c
## </param>
Chris PeBenito 8a1c9c
#
Chris PeBenito 8a1c9c
template(`qemu_domain_template',`
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	##############################
Chris PeBenito 8a1c9c
	#
Chris PeBenito 8a1c9c
	# Local Policy
Chris PeBenito 8a1c9c
	#
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	type $1_t;
Chris PeBenito 8a1c9c
	domain_type($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	type $1_tmp_t;
Chris PeBenito 8a1c9c
	files_tmp_file($1_tmp_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	##############################
Chris PeBenito 8a1c9c
	#
Chris PeBenito 8a1c9c
	# Local Policy
Chris PeBenito 8a1c9c
	#
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	allow $1_t self:capability { dac_read_search dac_override };
Chris PeBenito 8a1c9c
	allow $1_t self:process { execstack execmem signal getsched };
Chris PeBenito 8a1c9c
	allow $1_t self:fifo_file rw_file_perms;
Chris PeBenito 8a1c9c
	allow $1_t self:shm create_shm_perms;
Chris PeBenito 8a1c9c
	allow $1_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 8a1c9c
	allow $1_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito 8a1c9c
	allow $1_t self:tun_socket create;
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	manage_dirs_pattern($1_t, $1_tmp_t, $1_tmp_t)
Chris PeBenito 8a1c9c
	manage_files_pattern($1_t, $1_tmp_t, $1_tmp_t)
Chris PeBenito 8a1c9c
	files_tmp_filetrans($1_t, $1_tmp_t, { file dir })
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	kernel_read_system_state($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	corenet_all_recvfrom_unlabeled($1_t)
Chris PeBenito 8a1c9c
	corenet_all_recvfrom_netlabel($1_t)
Chris PeBenito 8a1c9c
	corenet_tcp_sendrecv_generic_if($1_t)
Chris PeBenito 8a1c9c
	corenet_tcp_sendrecv_generic_node($1_t)
Chris PeBenito 8a1c9c
	corenet_tcp_sendrecv_all_ports($1_t)
Chris PeBenito 8a1c9c
	corenet_tcp_bind_generic_node($1_t)
Chris PeBenito 8a1c9c
	corenet_tcp_bind_vnc_port($1_t)
Chris PeBenito 8a1c9c
	corenet_rw_tun_tap_dev($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
#	dev_rw_kvm($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	domain_use_interactive_fds($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	files_read_etc_files($1_t)
Chris PeBenito 8a1c9c
	files_read_usr_files($1_t)
Chris PeBenito 8a1c9c
	files_read_var_files($1_t)
Chris PeBenito 8a1c9c
	files_search_all($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	fs_list_inotifyfs($1_t)
Chris PeBenito 8a1c9c
	fs_rw_anon_inodefs_files($1_t)
Chris PeBenito 8a1c9c
	fs_rw_tmpfs_files($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	storage_raw_write_removable_device($1_t)
Chris PeBenito 8a1c9c
	storage_raw_read_removable_device($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	term_use_ptmx($1_t)
Chris PeBenito 8a1c9c
	term_getattr_pty_fs($1_t)
Chris PeBenito 8a1c9c
	term_use_generic_ptys($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	miscfiles_read_localization($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	sysnet_read_config($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	userdom_use_user_terminals($1_t)
Chris PeBenito 8a1c9c
	userdom_attach_admin_tun_iface($1_t)
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	optional_policy(`
Chris PeBenito 8a1c9c
		samba_domtrans_smbd($1_t)
Chris PeBenito 8a1c9c
	')
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	optional_policy(`
Chris PeBenito 8a1c9c
		virt_manage_images($1_t)
Chris PeBenito 8a1c9c
		virt_read_config($1_t)
Chris PeBenito 8a1c9c
		virt_read_lib_files($1_t)
Chris PeBenito 8a1c9c
		virt_attach_tun_iface($1_t)
Chris PeBenito 8a1c9c
	')
Chris PeBenito 8a1c9c
Chris PeBenito 8a1c9c
	optional_policy(`
Chris PeBenito 8a1c9c
		xserver_stream_connect($1_t)
Chris PeBenito 8a1c9c
		xserver_read_xdm_tmp_files($1_t)
Chris PeBenito 8a1c9c
		xserver_read_xdm_pid($1_t)
Chris PeBenito 8a1c9c
#		xserver_xdm_rw_shm($1_t)
Chris PeBenito 8a1c9c
	')
Chris PeBenito 8a1c9c
')
Chris PeBenito 8a1c9c
Chris PeBenito 72295e
#######################################
Chris PeBenito 72295e
## <summary>
Chris PeBenito 72295e
##	The per role template for the qemu module.
Chris PeBenito 72295e
## </summary>
Chris PeBenito 72295e
## <desc>
Chris PeBenito 72295e
##	

Chris PeBenito 72295e
##	This template creates a derived domains which are used
Chris PeBenito 72295e
##	for qemu web browser.
Chris PeBenito 72295e
##	

Chris PeBenito 72295e
##	

Chris PeBenito 72295e
##	This template is invoked automatically for each user, and
Chris PeBenito 72295e
##	generally does not need to be invoked directly
Chris PeBenito 72295e
##	by policy writers.
Chris PeBenito 72295e
##	

Chris PeBenito 72295e
## </desc>
Chris PeBenito 72295e
## <param name="user_role">
Chris PeBenito 72295e
##	<summary>
Chris PeBenito 72295e
##	The role associated with the user domain.
Chris PeBenito 72295e
##	</summary>
Chris PeBenito 72295e
## </param>
Chris PeBenito 72295e
## <param name="user_domain">
Chris PeBenito 72295e
##	<summary>
Chris PeBenito 72295e
##	The type of the user domain.
Chris PeBenito 72295e
##	</summary>
Chris PeBenito 72295e
## </param>
Chris PeBenito 72295e
#
Chris PeBenito 72295e
template(`qemu_role',`
Chris PeBenito 72295e
	gen_require(`
Chris PeBenito 72295e
		type qemu_t, qemu_exec_t;
Chris PeBenito 2c207d
		type qemu_config_t, qemu_config_exec_t;
Chris PeBenito 72295e
	')
Chris PeBenito 72295e
Chris PeBenito 72295e
	role $1 types { qemu_t qemu_config_t };
Chris PeBenito 72295e
Chris PeBenito 72295e
	domtrans_pattern($2, qemu_exec_t, qemu_t)
Chris PeBenito 72295e
 	domtrans_pattern($2, qemu_config_exec_t, qemu_config_t)
Chris PeBenito 2c207d
	allow qemu_t $2:process signull;
Chris PeBenito 72295e
')
Chris PeBenito 72295e
Chris PeBenito eb4216
########################################
Chris PeBenito eb4216
## <summary>
Chris PeBenito eb4216
##	Execute a domain transition to run qemu.
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## <param name="domain">
Chris PeBenito eb4216
## <summary>
Chris PeBenito eb4216
##	Domain allowed to transition.
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## </param>
Chris PeBenito eb4216
#
Chris PeBenito eb4216
interface(`qemu_domtrans',`
Chris PeBenito eb4216
	gen_require(`
Chris PeBenito eb4216
		type qemu_t, qemu_exec_t;
Chris PeBenito eb4216
	')
Chris PeBenito eb4216
Chris PeBenito eb4216
	domtrans_pattern($1, qemu_exec_t, qemu_t)
Chris PeBenito eb4216
')
Chris PeBenito eb4216
Chris PeBenito eb4216
########################################
Chris PeBenito eb4216
## <summary>
Chris PeBenito eb4216
##	Execute qemu in the qemu domain.
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## <param name="domain">
Chris PeBenito eb4216
##	<summary>
Chris PeBenito eb4216
##	Domain allowed access.
Chris PeBenito eb4216
##	</summary>
Chris PeBenito eb4216
## </param>
Chris PeBenito eb4216
## <param name="role">
Chris PeBenito eb4216
##	<summary>
Chris PeBenito eb4216
##	The role to allow the qemu domain.
Chris PeBenito eb4216
##	</summary>
Chris PeBenito eb4216
## </param>
Chris PeBenito eb4216
#
Chris PeBenito eb4216
interface(`qemu_run',`
Chris PeBenito eb4216
	gen_require(`
Chris PeBenito eb4216
		type qemu_t;
Chris PeBenito eb4216
	')
Chris PeBenito eb4216
Chris PeBenito eb4216
	qemu_domtrans($1)
Chris PeBenito eb4216
	role $2 types qemu_t;
Chris PeBenito 72295e
Chris PeBenito 72295e
	optional_policy(`
Chris PeBenito 72295e
		samba_run_smb(qemu_t, $2, $3)
Chris PeBenito 72295e
	')
Chris PeBenito eb4216
')
Chris PeBenito eb4216
Chris PeBenito eb4216
########################################
Chris PeBenito eb4216
## <summary>
Chris PeBenito eb4216
##	Allow the domain to read state files in /proc.
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## <param name="domain">
Chris PeBenito eb4216
##	<summary>
Chris PeBenito eb4216
##	Domain to allow access.
Chris PeBenito eb4216
##	</summary>
Chris PeBenito eb4216
## </param>
Chris PeBenito eb4216
#
Chris PeBenito eb4216
interface(`qemu_read_state',`
Chris PeBenito eb4216
	gen_require(`
Chris PeBenito eb4216
		type qemu_t;
Chris PeBenito eb4216
	')
Chris PeBenito eb4216
Chris PeBenito eb4216
	read_files_pattern($1, qemu_t, qemu_t)
Chris PeBenito eb4216
')
Chris PeBenito eb4216
Chris PeBenito eb4216
########################################
Chris PeBenito eb4216
## <summary>
Chris PeBenito 72295e
##	Set the schedule on qemu.
Chris PeBenito 72295e
## </summary>
Chris PeBenito 72295e
## <param name="domain">
Chris PeBenito 72295e
##	<summary>
Chris PeBenito 72295e
##	Domain allowed access.
Chris PeBenito 72295e
##	</summary>
Chris PeBenito 72295e
## </param>
Chris PeBenito 72295e
#
Chris PeBenito 72295e
interface(`qemu_setsched',`
Chris PeBenito 72295e
	gen_require(`
Chris PeBenito 72295e
		type qemu_t;
Chris PeBenito 72295e
	')
Chris PeBenito 72295e
Chris PeBenito 72295e
	allow $1 qemu_t:process setsched;
Chris PeBenito 72295e
')
Chris PeBenito 72295e
Chris PeBenito 72295e
########################################
Chris PeBenito 72295e
## <summary>
Chris PeBenito eb4216
##	Send a signal to qemu.
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## <param name="domain">
Chris PeBenito eb4216
##	<summary>
Chris PeBenito eb4216
##	Domain allowed access.
Chris PeBenito eb4216
##	</summary>
Chris PeBenito eb4216
## </param>
Chris PeBenito eb4216
#
Chris PeBenito eb4216
interface(`qemu_signal',`
Chris PeBenito eb4216
	gen_require(`
Chris PeBenito eb4216
		type qemu_t;
Chris PeBenito eb4216
	')
Chris PeBenito eb4216
Chris PeBenito eb4216
	allow $1 qemu_t:process signal;
Chris PeBenito eb4216
')
Chris PeBenito eb4216
Chris PeBenito eb4216
########################################
Chris PeBenito eb4216
## <summary>
Chris PeBenito eb4216
##	Send a sigill to qemu
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## <param name="domain">
Chris PeBenito eb4216
##	<summary>
Chris PeBenito eb4216
##	Domain allowed access.
Chris PeBenito eb4216
##	</summary>
Chris PeBenito eb4216
## </param>
Chris PeBenito eb4216
#
Chris PeBenito eb4216
interface(`qemu_kill',`
Chris PeBenito eb4216
	gen_require(`
Chris PeBenito eb4216
		type qemu_t;
Chris PeBenito eb4216
	')
Chris PeBenito eb4216
Chris PeBenito eb4216
	allow $1 qemu_t:process sigkill;
Chris PeBenito eb4216
')
Chris PeBenito eb4216
Chris PeBenito eb4216
########################################
Chris PeBenito eb4216
## <summary>
Chris PeBenito eb4216
##	Execute a domain transition to run qemu unconfined.
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## <param name="domain">
Chris PeBenito eb4216
## <summary>
Chris PeBenito eb4216
##	Domain allowed to transition.
Chris PeBenito eb4216
## </summary>
Chris PeBenito eb4216
## </param>
Chris PeBenito eb4216
#
Chris PeBenito eb4216
interface(`qemu_domtrans_unconfined',`
Chris PeBenito eb4216
	gen_require(`
Chris PeBenito a77795
		type unconfined_qemu_t, qemu_exec_t;
Chris PeBenito eb4216
	')
Chris PeBenito eb4216
Chris PeBenito a77795
	domtrans_pattern($1, qemu_exec_t, unconfined_qemu_t)
Chris PeBenito eb4216
')
Chris PeBenito eb4216
Chris PeBenito eb4216
########################################
Chris PeBenito eb4216
## <summary>
Chris PeBenito 72295e
##	Manage qemu temporary dirs.
Chris PeBenito 72295e
## </summary>
Chris PeBenito 72295e
## <param name="domain">
Chris PeBenito 72295e
##	<summary>
Chris PeBenito 72295e
##	Domain allowed access.
Chris PeBenito 72295e
##	</summary>
Chris PeBenito 72295e
## </param>
Chris PeBenito 72295e
#
Chris PeBenito 72295e
interface(`qemu_manage_tmp_dirs',`
Chris PeBenito 72295e
	gen_require(`
Chris PeBenito 72295e
		type qemu_tmp_t;
Chris PeBenito 72295e
	')
Chris PeBenito 72295e
Chris PeBenito 72295e
	manage_dirs_pattern($1, qemu_tmp_t, qemu_tmp_t)
Chris PeBenito 72295e
')
Chris PeBenito 72295e
Chris PeBenito 72295e
########################################
Chris PeBenito 72295e
## <summary>
Chris PeBenito 72295e
##	Manage qemu temporary files.
Chris PeBenito 72295e
## </summary>
Chris PeBenito 72295e
## <param name="domain">
Chris PeBenito 72295e
##	<summary>
Chris PeBenito 72295e
##	Domain allowed access.
Chris PeBenito 72295e
##	</summary>
Chris PeBenito 72295e
## </param>
Chris PeBenito 72295e
#
Chris PeBenito 72295e
interface(`qemu_manage_tmp_files',`
Chris PeBenito 72295e
	gen_require(`
Chris PeBenito 72295e
		type qemu_tmp_t;
Chris PeBenito 72295e
	')
Chris PeBenito 72295e
Chris PeBenito 72295e
	manage_files_pattern($1, qemu_tmp_t, qemu_tmp_t)
Chris PeBenito 72295e
')