Chris PeBenito 6e2123
## <summary>Wireshark packet capture tool.</summary>
Chris PeBenito 6e2123
Chris PeBenito 6e2123
#######################################
Chris PeBenito 6e2123
## <summary>
Chris PeBenito 6e2123
##	The per role template for the wireshark module.
Chris PeBenito 6e2123
## </summary>
Chris PeBenito 6e2123
## <desc>
Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
##	This template creates a derived domains which are used
Chris PeBenito 6e2123
##	for wireshark packet capture tool.
Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
##	

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

Chris PeBenito 6e2123
## </desc>
Chris PeBenito 6e2123
## <param name="userdomain_prefix">
Chris PeBenito 6e2123
##	<summary>
Chris PeBenito 6e2123
##	The prefix of the user domain (e.g., user
Chris PeBenito 6e2123
##	is the prefix for user_t).
Chris PeBenito 6e2123
##	</summary>
Chris PeBenito 6e2123
## </param>
Chris PeBenito 6e2123
## <param name="user_domain">
Chris PeBenito 6e2123
##	<summary>
Chris PeBenito 6e2123
##	The type of the user domain.
Chris PeBenito 6e2123
##	</summary>
Chris PeBenito 6e2123
## </param>
Chris PeBenito 6e2123
## <param name="user_role">
Chris PeBenito 6e2123
##	<summary>
Chris PeBenito 6e2123
##	The role associated with the user domain.
Chris PeBenito 6e2123
##	</summary>
Chris PeBenito 6e2123
## </param>
Chris PeBenito 6e2123
#
Chris PeBenito 6e2123
template(`wireshark_per_role_template',`
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	gen_require(`
Chris PeBenito 6e2123
		type wireshark_exec_t;
Chris PeBenito 6e2123
	')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	##############################
Chris PeBenito 6e2123
	#
Chris PeBenito 6e2123
	# Declarations
Chris PeBenito 6e2123
	#
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	# Type for program
Chris PeBenito 6e2123
	type $1_wireshark_t;
Chris PeBenito 0bfccd
	application_domain($1_wireshark_t, wireshark_exec_t)
Chris PeBenito 6e2123
	role $3 types $1_wireshark_t;
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	type $1_wireshark_home_t;
Chris PeBenito 6e2123
	files_poly_member($1_wireshark_home_t)
Chris PeBenito 0bfccd
	userdom_user_home_content($1, $1_wireshark_home_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	type $1_wireshark_tmp_t;
Chris PeBenito 6e2123
	files_tmp_file($1_wireshark_tmp_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	type $1_wireshark_tmpfs_t;
Chris PeBenito 6e2123
	files_tmpfs_file($1_wireshark_tmpfs_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	##############################
Chris PeBenito 6e2123
	#
Chris PeBenito 6e2123
	# Local Policy
Chris PeBenito 6e2123
	#
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	allow $1_wireshark_t self:capability { net_admin net_raw setgid };
Chris PeBenito 6e2123
	allow $1_wireshark_t self:process { signal getsched };
Chris PeBenito 6e2123
	allow $1_wireshark_t self:fifo_file { getattr read write };
Chris PeBenito 6e2123
	allow $1_wireshark_t self:shm destroy;
Chris PeBenito 6e2123
	allow $1_wireshark_t self:shm create_shm_perms;
Chris PeBenito 6e2123
	allow $1_wireshark_t self:netlink_route_socket { nlmsg_read create_socket_perms };
Chris PeBenito 6e2123
	allow $1_wireshark_t self:packet_socket { setopt bind ioctl getopt create read };
Chris PeBenito 6e2123
	allow $1_wireshark_t self:tcp_socket create_socket_perms;
Chris PeBenito 6e2123
	allow $1_wireshark_t self:udp_socket create_socket_perms;
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	# Re-execute itself (why?)
Chris PeBenito 6e2123
	can_exec($1_wireshark_t, wireshark_exec_t)
Chris PeBenito 6e2123
	corecmd_search_bin($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	# /home/.wireshark
Chris PeBenito 0bfccd
	manage_dirs_pattern($1_wireshark_t, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	manage_files_pattern($1_wireshark_t, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	manage_lnk_files_pattern($1_wireshark_t, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	userdom_user_home_dir_filetrans($1, $1_wireshark_t, $1_wireshark_home_t, dir)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	# Store temporary files
Chris PeBenito 0bfccd
	manage_dirs_pattern($1_wireshark_t, $1_wireshark_tmp_t, $1_wireshark_tmp_t)
Chris PeBenito 0bfccd
	manage_files_pattern($1_wireshark_t, $1_wireshark_tmp_t, $1_wireshark_tmp_t)
Chris PeBenito 6e2123
	files_tmp_filetrans($1_wireshark_t, $1_wireshark_tmp_t, { dir file })
Chris PeBenito 6e2123
Chris PeBenito 0bfccd
	manage_dirs_pattern($1_wireshark_t, $1_wireshark_tmpfs_t, $1_wireshark_tmpfs_t)
Chris PeBenito 0bfccd
	manage_files_pattern($1_wireshark_t, $1_wireshark_tmpfs_t, $1_wireshark_tmpfs_t)
Chris PeBenito 0bfccd
	manage_lnk_files_pattern($1_wireshark_t, $1_wireshark_tmpfs_t, $1_wireshark_tmpfs_t)
Chris PeBenito 0bfccd
	manage_sock_files_pattern($1_wireshark_t, $1_wireshark_tmpfs_t, $1_wireshark_tmpfs_t)
Chris PeBenito 0bfccd
	manage_fifo_files_pattern($1_wireshark_t, $1_wireshark_tmpfs_t, $1_wireshark_tmpfs_t)
Chris PeBenito 0bfccd
	fs_tmpfs_filetrans($1_wireshark_t, $1_wireshark_tmpfs_t, { dir file lnk_file sock_file fifo_file })
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	domain_auto_trans($2, wireshark_exec_t, $1_wireshark_t)
Chris PeBenito 6e2123
	allow $1_wireshark_t $2:fd use;
Chris PeBenito 6e2123
	allow $1_wireshark_t $2:process sigchld;
Chris PeBenito 6e2123
Chris PeBenito 0bfccd
	manage_dirs_pattern($2, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	manage_files_pattern($2, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	manage_lnk_files_pattern($2, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	relabel_dirs_pattern($2, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	relabel_files_pattern($2, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 0bfccd
	relabel_lnk_files_pattern($2, $1_wireshark_home_t, $1_wireshark_home_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	kernel_read_kernel_sysctls($1_wireshark_t)
Chris PeBenito 6e2123
	kernel_read_system_state($1_wireshark_t)
Chris PeBenito 6e2123
	kernel_read_sysctl($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	corecmd_search_bin($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	corenet_tcp_connect_generic_port($1_wireshark_t)
Chris PeBenito 6e2123
	corenet_tcp_sendrecv_generic_if($1_wireshark_t)
Chris PeBenito 2a9837
Chris PeBenito 6e2123
	dev_read_urand($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	files_read_etc_files($1_wireshark_t)
Chris PeBenito 6e2123
	files_read_usr_files($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	fs_list_inotifyfs($1_wireshark_t)
Chris PeBenito 6e2123
	fs_search_auto_mountpoints($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	libs_read_lib_files($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	miscfiles_read_fonts($1_wireshark_t)
Chris PeBenito 6e2123
	miscfiles_read_localization($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	seutil_use_newrole_fds($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	sysnet_read_config($1_wireshark_t)
Chris PeBenito 6e2123
Chris PeBenito 0bfccd
	userdom_manage_user_home_content_files($1, $1_wireshark_t)
Chris PeBenito 2a9837
Chris PeBenito 6e2123
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 6e2123
		fs_manage_nfs_dirs($1_wireshark_t)
Chris PeBenito 6e2123
		fs_manage_nfs_files($1_wireshark_t)
Chris PeBenito 6e2123
		fs_manage_nfs_symlinks($1_wireshark_t)
Chris PeBenito 6e2123
	')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 6e2123
		fs_manage_cifs_dirs($1_wireshark_t)
Chris PeBenito 6e2123
		fs_manage_cifs_files($1_wireshark_t)
Chris PeBenito 6e2123
		fs_manage_cifs_symlinks($1_wireshark_t)
Chris PeBenito 6e2123
	')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	optional_policy(`
Chris PeBenito 6e2123
		nscd_socket_use($1_wireshark_t)
Chris PeBenito 6e2123
	')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	# Manual transition from userhelper 
Chris PeBenito 6e2123
	optional_policy(`
Chris PeBenito 0bfccd
		userhelper_use_user_fd($1, $1_wireshark_t)
Chris PeBenito 0bfccd
		userhelper_sigchld_user($1, $1_wireshark_t)
Chris PeBenito 6e2123
	')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	optional_policy(`
Chris PeBenito 0bfccd
		xserver_user_client_template($1, $1_wireshark_t, $1_wireshark_tmpfs_t)
Chris PeBenito 6e2123
		xserver_create_xdm_tmp_sockets($1_wireshark_t)
Chris PeBenito 6e2123
	')
Chris PeBenito 2a9837
Chris PeBenito 6e2123
	ifdef(`TODO',`
Chris PeBenito 6e2123
		# Why does it write this?
Chris PeBenito 6e2123
		optional_policy(`
Chris PeBenito 6e2123
			dontaudit sysadm_wireshark_t snmpd_var_lib_t:file write;
Chris PeBenito 6e2123
		')
Chris PeBenito 6e2123
		#TODO
Chris PeBenito 6e2123
		gnome_application($1_wireshark, $1)
Chris PeBenito 6e2123
		gnome_file_dialog($1_wireshark, $1)
Chris PeBenito 6e2123
		# FIXME: policy is incomplete
Chris PeBenito 6e2123
	')
Chris PeBenito 2a9837
Chris PeBenito 6e2123
')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
#######################################
Chris PeBenito 6e2123
## <summary>
Chris PeBenito 6e2123
##	The administrative functions template for the wireshark module.
Chris PeBenito 6e2123
## </summary>
Chris PeBenito 6e2123
## <desc>
Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
##	This template creates rules for administrating wireshark,
Chris PeBenito 6e2123
##	allowing the specified user to manage wireshark files.
Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
## </desc>
Chris PeBenito 6e2123
## <param name="userdomain_prefix">
Chris PeBenito 6e2123
##	<summary>
Chris PeBenito 6e2123
##	The prefix of the user domain (e.g., user
Chris PeBenito 6e2123
##	is the prefix for user_t).
Chris PeBenito 6e2123
##	</summary>
Chris PeBenito 6e2123
## </param>
Chris PeBenito 6e2123
#
Chris PeBenito 6e2123
template(`wireshark_admin_template',`
Chris PeBenito 6e2123
	gen_require(`
Chris PeBenito 6e2123
		type $1_wireshark_t;
Chris PeBenito 6e2123
	')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
	# Create various types of sockets
Chris PeBenito 6e2123
	allow $1_wireshark_t self:netlink_route_socket create_netlink_socket_perms;
Chris PeBenito 6e2123
	allow $1_wireshark_t self:udp_socket create_socket_perms;
Chris PeBenito 6e2123
	allow $1_wireshark_t self:packet_socket create_socket_perms;
Chris PeBenito 6e2123
	allow $1_wireshark_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 6e2123
	allow $1_wireshark_t self:tcp_socket create_socket_perms;
Chris PeBenito 2a9837
Chris PeBenito 0bfccd
	userdom_use_user_terminals($1, $1_wireshark_t)
Chris PeBenito 6e2123
	# wireshark tries to write to user terminal
Chris PeBenito 0bfccd
	userdom_dontaudit_use_user_terminals($1, $1_wireshark_t)
Chris PeBenito 6e2123
')
Chris PeBenito 6e2123
Chris PeBenito 6e2123
########################################
Chris PeBenito 6e2123
## <summary>
Chris PeBenito 6e2123
##	Run wireshark in wireshark domain.
Chris PeBenito 6e2123
## </summary>
Chris PeBenito 6e2123
## <desc>
Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
##	Run wireshark in wireshark domain.
Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
##	This is a templated interface, and should only
Chris PeBenito 6e2123
##	be called from a per-userdomain template.
Chris PeBenito 6e2123
##	

Chris PeBenito 6e2123
## </desc>
Chris PeBenito 6e2123
## <param name="userdomain_prefix">
Chris PeBenito 6e2123
##	<summary>
Chris PeBenito 6e2123
##	The prefix of the user domain (e.g., user
Chris PeBenito 6e2123
##	is the prefix for user_t).
Chris PeBenito 6e2123
##	</summary>
Chris PeBenito 6e2123
## </param>
Chris PeBenito 6e2123
## <param name="domain">
Chris PeBenito 6e2123
##	<summary>
Chris PeBenito 6e2123
##	Domain allowed access.
Chris PeBenito 6e2123
##	</summary>
Chris PeBenito 6e2123
## </param>
Chris PeBenito 6e2123
#
Chris PeBenito 6e2123
template(`wireshark_domtrans_user_wireshark',`
Chris PeBenito 6e2123
	gen_require(`
Chris PeBenito 6e2123
		type $1_wireshark_t, wireshark_exec_t;
Chris PeBenito 6e2123
	')
Chris PeBenito 6e2123
Chris PeBenito 0bfccd
	domtrans_pattern($2, wireshark_exec_t, $1_wireshark_t)
Chris PeBenito 6e2123
')