Chris PeBenito 5b6ddb
## <summary>Policy for UML</summary>
Chris PeBenito 5b6ddb
	
Chris PeBenito 5b6ddb
#######################################
Chris PeBenito 5b6ddb
## <summary>
Chris PeBenito 5b6ddb
##	The per user domain template for the uml module.
Chris PeBenito 5b6ddb
## </summary>
Chris PeBenito 5b6ddb
## <desc>
Chris PeBenito 5b6ddb
##	

Chris PeBenito 5b6ddb
##	This template creates a derived domains which are used
Chris PeBenito 5b6ddb
##	for uml program.
Chris PeBenito 5b6ddb
##	

Chris PeBenito 5b6ddb
##	

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

Chris PeBenito 5b6ddb
## </desc>
Chris PeBenito 5b6ddb
## <param name="userdomain_prefix">
Chris PeBenito 5b6ddb
##	<summary>
Chris PeBenito 5b6ddb
##	The prefix of the user domain (e.g., user
Chris PeBenito 5b6ddb
##	is the prefix for user_t).
Chris PeBenito 5b6ddb
##	</summary>
Chris PeBenito 5b6ddb
## </param>
Chris PeBenito 5b6ddb
## <param name="user_domain">
Chris PeBenito 5b6ddb
##	<summary>
Chris PeBenito 5b6ddb
##	The type of the user domain.
Chris PeBenito 5b6ddb
##	</summary>
Chris PeBenito 5b6ddb
## </param>
Chris PeBenito 5b6ddb
## <param name="user_role">
Chris PeBenito 5b6ddb
##	<summary>
Chris PeBenito 5b6ddb
##	The role associated with the user domain.
Chris PeBenito 5b6ddb
##	</summary>
Chris PeBenito 5b6ddb
## </param>
Chris PeBenito 5b6ddb
#
Chris PeBenito 5b6ddb
template(`uml_per_userdomain_template',`
Chris PeBenito 5b6ddb
	
Chris PeBenito 5b6ddb
	########################################
Chris PeBenito 5b6ddb
	#
Chris PeBenito 5b6ddb
	# Declarations
Chris PeBenito 5b6ddb
	#
Chris PeBenito 5b6ddb
	type $1_uml_t;
Chris PeBenito 5b6ddb
	domain_type($1_uml_t)
Chris PeBenito 5b6ddb
	role $3 types $1_uml_t;
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	type $1_uml_exec_t;
Chris PeBenito 5b6ddb
	domain_entry_file($1_uml_t,$1_uml_exec_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	type $1_uml_ro_t;
Chris PeBenito 5b6ddb
	files_type($1_uml_ro_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	type $1_uml_rw_t;
Chris PeBenito 5b6ddb
	files_type($1_uml_rw_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	type $1_uml_tmp_t;
Chris PeBenito 5b6ddb
	files_tmp_file($1_uml_tmp_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	type $1_uml_tmpfs_t;
Chris PeBenito 5b6ddb
	files_tmpfs_file($1_uml_tmpfs_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	type $1_uml_devpts_t;
Chris PeBenito 5b6ddb
	term_pty($1_uml_devpts_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	########################################
Chris PeBenito 5b6ddb
	#
Chris PeBenito 5b6ddb
	# Local policy
Chris PeBenito 5b6ddb
	#
Chris PeBenito 5b6ddb
	allow $1_uml_t self:fifo_file rw_file_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t self:process { fork signal_perms ptrace };
Chris PeBenito 5b6ddb
	allow $1_uml_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 5b6ddb
	# Use the network.
Chris PeBenito 5b6ddb
	allow $1_uml_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t self:udp_socket create_socket_perms;
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $1_uml_t $2:process sigchld;
Chris PeBenito 5b6ddb
	allow $1_uml_t $2:fifo_file { ioctl read write getattr lock append };
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# allow the UML thing to happen
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_devpts_t:chr_file { rw_file_perms setattr };
Chris PeBenito 5b6ddb
	term_create_pty($1_uml_t,$1_uml_devpts_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_tmp_t:dir create_dir_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_tmp_t:file create_file_perms;
Chris PeBenito 103fe2
	files_tmp_filetrans($1_uml_t, $1_uml_tmp_t, { file dir })
Chris PeBenito 5b6ddb
	can_exec($1_uml_t, $1_uml_tmp_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_tmpfs_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_tmpfs_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_tmpfs_t:lnk_file { create read getattr setattr link unlink rename };
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_tmpfs_t:sock_file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_tmpfs_t:fifo_file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 103fe2
	fs_tmpfs_filetrans($1_uml_t,$1_uml_tmpfs_t,{ dir file lnk_file sock_file fifo_file })
Chris PeBenito 5b6ddb
	can_exec($1_uml_t, $1_uml_tmpfs_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# access config files
Chris PeBenito 5b6ddb
	allow $1_uml_t { $1_uml_ro_t uml_ro_t }:dir r_dir_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t { $1_uml_ro_t uml_ro_t }:file r_file_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t { $1_uml_ro_t uml_ro_t }:lnk_file { getattr read };
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_rw_t:dir create_dir_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_rw_t:file create_file_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_rw_t:lnk_file create_lnk_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_rw_t:sock_file create_file_perms;
Chris PeBenito 5b6ddb
	allow $1_uml_t $1_uml_rw_t:fifo_file create_file_perms;
Chris PeBenito 103fe2
	userdom_user_home_dir_filetrans($1,$1_uml_t,$1_uml_rw_t,{ file lnk_file sock_file fifo_file })
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $2 uml_ro_t:dir r_dir_perms;
Chris PeBenito 5b6ddb
	allow $2 uml_ro_t:file r_file_perms;
Chris PeBenito 5b6ddb
	allow $2 uml_ro_t:lnk_file { getattr read };
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $2 { $1_uml_ro_t $1_uml_rw_t }:{ file sock_file fifo_file } { relabelfrom relabelto create_file_perms };
Chris PeBenito 5b6ddb
	allow $2 { $1_uml_ro_t $1_uml_rw_t }:lnk_file { relabelfrom relabelto create_lnk_perms };
Chris PeBenito 5b6ddb
	allow $2 { $1_uml_ro_t $1_uml_rw_t $1_uml_exec_t }:dir { relabelfrom relabelto create_dir_perms };
Chris PeBenito 5b6ddb
	allow $2 $1_uml_exec_t:file { relabelfrom relabelto create_file_perms };
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $2 $1_uml_t:process ptrace;
Chris PeBenito 5b6ddb
	allow $2 $1_uml_t:process signal_perms;
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# allow ps, ptrace, signal
Chris PeBenito 5b6ddb
	allow $2 $1_uml_t:dir { search getattr read };
Chris PeBenito 5b6ddb
	allow $2 $1_uml_t:{ file lnk_file } { read getattr };
Chris PeBenito 5b6ddb
	allow $2 $1_uml_t:process getattr;
Chris PeBenito 5b6ddb
	# We need to suppress this denial because procps tries to access
Chris PeBenito 5b6ddb
	# /proc/pid/environ and this now triggers a ptrace check in recent kernels
Chris PeBenito 5b6ddb
	# (2.4 and 2.6).  Might want to change procps to not do this, or only if
Chris PeBenito 5b6ddb
	# running in a privileged domain.
Chris PeBenito 5b6ddb
	dontaudit $2 $1_uml_t:process ptrace;
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $2 $1_uml_tmp_t:dir create_dir_perms;
Chris PeBenito 5b6ddb
	allow $2 $1_uml_tmp_t:file create_file_perms;
Chris PeBenito 5b6ddb
	allow $2 $1_uml_tmp_t:lnk_file create_lnk_perms;
Chris PeBenito 5b6ddb
	allow $2 $1_uml_tmp_t:sock_file create_file_perms;
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# Transition from the user domain to this domain.
Chris PeBenito 5b6ddb
	domain_auto_trans($2, { uml_exec_t $1_uml_exec_t }, $1_uml_t)
Chris PeBenito 5b6ddb
	can_exec($1_uml_t, { uml_exec_t $1_uml_exec_t })
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# for mconsole
Chris PeBenito 5b6ddb
	allow { $2 $1_uml_t } $1_uml_t:unix_dgram_socket sendto;
Chris PeBenito 5b6ddb
	allow $1_uml_t $2:unix_dgram_socket sendto;
Chris PeBenito 5b6ddb
	
Chris PeBenito 5b6ddb
	kernel_read_system_state($1_uml_t)
Chris PeBenito 5b6ddb
	# for SKAS - need something better
Chris PeBenito 5b6ddb
	kernel_write_proc_files($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# for xterm
Chris PeBenito 5b6ddb
	corecmd_exec_bin($1_uml_t)
Chris PeBenito 5b6ddb
	corecmd_exec_sbin($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	corenet_tcp_sendrecv_generic_if($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_udp_sendrecv_generic_if($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_raw_sendrecv_generic_if($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_tcp_sendrecv_all_nodes($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_udp_sendrecv_all_nodes($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_raw_sendrecv_all_nodes($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_tcp_sendrecv_all_ports($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_udp_sendrecv_all_ports($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_non_ipsec_sendrecv($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_tcp_bind_all_nodes($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_udp_bind_all_nodes($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_tcp_connect_all_ports($1_uml_t)
Chris PeBenito 5b6ddb
	corenet_rw_tun_tap_dev($1_uml_t)
Chris PeBenito 5b6ddb
	
Chris PeBenito 15722e
	domain_use_interactive_fds($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# for xterm
Chris PeBenito 5b6ddb
	files_read_etc_files($1_uml_t)
Chris PeBenito 5b6ddb
	files_dontaudit_read_etc_runtime_files($1_uml_t)
Chris PeBenito 5b6ddb
	# putting uml data under /var is usual...
Chris PeBenito 5b6ddb
	files_search_var($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	fs_getattr_xattr_fs($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	init_read_utmp($1_uml_t)
Chris PeBenito 5b6ddb
	init_dontaudit_write_utmp($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# for xterm
Chris PeBenito 5b6ddb
	libs_use_ld_so($1_uml_t)
Chris PeBenito 5b6ddb
	libs_use_shared_libs($1_uml_t)
Chris PeBenito 5b6ddb
	libs_exec_lib_files($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# Inherit and use descriptors from newrole.
Chris PeBenito 15722e
	seutil_use_newrole_fds($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	# Use the network.
Chris PeBenito 5b6ddb
	sysnet_read_config($1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	userdom_use_user_terminals($1,$1_uml_t)
Chris PeBenito 5b6ddb
Chris PeBenito bb7170
	optional_policy(`
Chris PeBenito 5b6ddb
		mount_send_nfs_client_request($1_uml_t)
Chris PeBenito 5b6ddb
	')
Chris PeBenito 5b6ddb
Chris PeBenito bb7170
	optional_policy(`
Chris PeBenito 5b6ddb
		nis_use_ypbind($1_uml_t)
Chris PeBenito 5b6ddb
	')
Chris PeBenito 5b6ddb
Chris PeBenito bb7170
	optional_policy(`
Chris PeBenito 5b6ddb
		ssh_tcp_connect($1_uml_t)
Chris PeBenito 5b6ddb
	')
Chris PeBenito 5b6ddb
	
Chris PeBenito 5b6ddb
	ifdef(`TODO',`
Chris PeBenito 5b6ddb
		# for X
Chris PeBenito bb7170
		optional_policy(`
Chris PeBenito 5b6ddb
			ifelse($1, sysadm,`
Chris PeBenito 5b6ddb
			',`
Chris PeBenito bb7170
				optional_policy(`
Chris PeBenito 5b6ddb
					allow $1_uml_t xdm_xserver_tmp_t:dir search;
Chris PeBenito 5b6ddb
				')
Chris PeBenito 5b6ddb
				allow $1_uml_t $1_xserver_tmp_t:sock_file write;
Chris PeBenito 5b6ddb
				allow $1_uml_t $1_xserver_t:unix_stream_socket connectto;
Chris PeBenito 5b6ddb
			')
Chris PeBenito 5b6ddb
		')
Chris PeBenito 5b6ddb
Chris PeBenito bb7170
		optional_policy(`
Chris PeBenito 5b6ddb
			# for uml_net
Chris PeBenito 5b6ddb
			domain_auto_trans($1_uml_t, uml_net_exec_t, uml_net_t)
Chris PeBenito 5b6ddb
			allow uml_net_t $1_uml_t:unix_stream_socket { read write };
Chris PeBenito 5b6ddb
			allow uml_net_t $1_uml_t:unix_dgram_socket { read write };
Chris PeBenito 5b6ddb
			dontaudit uml_net_t privfd:fd use;
Chris PeBenito 5b6ddb
			can_access_pty(uml_net_t, $1_uml)
Chris PeBenito 5b6ddb
			dontaudit uml_net_t $1_uml_rw_t:dir { getattr search };
Chris PeBenito 5b6ddb
		')
Chris PeBenito 5b6ddb
		#TODO
Chris PeBenito bb7170
		optional_policy(`
Chris PeBenito 5b6ddb
			allow $1_uml_t $1_xauth_home_t:file { getattr read };
Chris PeBenito 5b6ddb
		')
Chris PeBenito 5b6ddb
	')
Chris PeBenito 5b6ddb
')
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
########################################
Chris PeBenito 5b6ddb
## <summary>
Chris PeBenito 5b6ddb
##	Set attributes on uml utility socket files.
Chris PeBenito 5b6ddb
## </summary>
Chris PeBenito 5b6ddb
## <param name="domain">
Chris PeBenito 5b6ddb
##	<summary>
Chris PeBenito 5b6ddb
##	Domain allowed access.
Chris PeBenito 5b6ddb
##	</summary>
Chris PeBenito 5b6ddb
## </param>
Chris PeBenito 5b6ddb
#
Chris PeBenito 5b6ddb
interface(`uml_setattr_util_sockets',`
Chris PeBenito 5b6ddb
	gen_require(`
Chris PeBenito 5b6ddb
		type uml_switch_var_run_t;
Chris PeBenito 5b6ddb
	')
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $1 uml_switch_var_run_t:sock_file setattr;
Chris PeBenito 5b6ddb
')
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
########################################
Chris PeBenito 5b6ddb
## <summary>
Chris PeBenito 5b6ddb
##	Manage uml utility files.
Chris PeBenito 5b6ddb
## </summary>
Chris PeBenito 5b6ddb
## <param name="domain">
Chris PeBenito 5b6ddb
##	<summary>
Chris PeBenito 5b6ddb
##	Domain allowed access.
Chris PeBenito 5b6ddb
##	</summary>
Chris PeBenito 5b6ddb
## </param>
Chris PeBenito 5b6ddb
#
Chris PeBenito 5b6ddb
interface(`uml_manage_util_files',`
Chris PeBenito 5b6ddb
	gen_require(`
Chris PeBenito 5b6ddb
		type uml_switch_var_run_t;
Chris PeBenito 5b6ddb
	')
Chris PeBenito 5b6ddb
Chris PeBenito 5b6ddb
	allow $1 uml_switch_var_run_t:dir rw_dir_perms;
Chris PeBenito 5b6ddb
	allow $1 uml_switch_var_run_t:file create_file_perms;
Chris PeBenito 5b6ddb
	allow $1 uml_switch_var_run_t:lnk_file create_lnk_perms;
Chris PeBenito 5b6ddb
')