All pastes #911511 Raw Edit

xchat if

public text v1 · immutable
·published 2008-02-20 19:31 UTC
rendered paste body
## <summary>SELinux policy module for XChat</summary>
## <desc>
##	<p>
##		Provides SELinux security for XChat
##	</p>
## </desc>

#######################################
## <summary>
##      The per role template for the XChat module.
## </summary>
## <desc>
##      <p>
##      This template creates derived domains which are used
##      for XChat.
##      </p>
##      <p>
##      This template is invoked automatically for each user, and
##      generally does not need to be invoked directly
##      by policy writers.
##      </p>
## </desc>
## <param name="userdomain_prefix">
##      <summary>
##      The prefix of the user domain (e.g., user
##      is the prefix for user_t).
##      </summary>
## </param>
## <param name="user_domain">
##      <summary>
##      The type of the user domain.
##      </summary>
## </param>
## <param name="user_role">
##      <summary>
##      The role associated with the user domain.
##      </summary>
## </param>
#
template(`xchat_per_role_template',`
	gen_require(`
		type xchat_exec_t, user_xchat_home_t;
	')
	
	gen_tunable(xchat_confine_$1,false)

	########################################
	#
	# Declarations
	#
	type $1_xchat_t;
	application_domain($1_xchat_t,xchat_exec_t)
	role $3 types $1_xchat_t;

	type $1_xchat_tmpfs_t;
	files_tmpfs_file($1_xchat_tmpfs_t)

	ifelse(`$1',`user',`',`
		typealias user_xchat_home_t alias $1_xchat_home_t;
	')

	########################################
	#
 	# Bools & tunables
  	#

	tunable_policy(`xchat_confine_$1',`
		domain_auto_trans($2,xchat_exec_t,$1_xchat_t)
	',`
		can_exec($2,xchat_exec_t)
	')

	tunable_policy(`write_untrusted_content',`
		userdom_manage_user_home_content_dirs($1,$1_xchat_t)
		userdom_manage_user_home_content_files($1,$1_xchat_t)
		userdom_manage_user_home_content_sockets($1,$1_xchat_t)
		userdom_read_user_home_content_symlinks($1,$1_xchat_t)
 	')

	tunable_policy(`use_nfs_home_dirs',`
 	   	fs_manage_nfs_dirs($1_xchat_t)
		fs_manage_nfs_files($1_xchat_t)
		fs_manage_nfs_symlinks($1_xchat_t)
	')

	tunable_policy(`use_samba_home_dirs',`
		fs_manage_cifs_dirs($1_xchat_t)
		fs_manage_cifs_files($1_xchat_t)
		fs_manage_cifs_symlinks($1_xchat_t)
	')

	########################################
	#
 	# Local Policy
  	#
 	allow $1_xchat_t self:process { signal getsched setsched sigkill };
	allow $1_xchat_t self:fifo_file rw_fifo_file_perms;
	allow $1_xchat_t self:sem create_sem_perms;
 	allow $1_xchat_t self:netlink_route_socket r_netlink_socket_perms;
  	allow $1_xchat_t self:tcp_socket { create_socket_perms accept listen };
   	allow $1_xchat_t self:udp_socket create_socket_perms;

 	allow $1_xchat_t $2:fd use;
 	allow $1_xchat_t $2:process sigchld;

   	# XChat(GConfd-2) wants to stream connect to /tmp/orbit-*
   	allow $1_xchat_t $2:unix_stream_socket connectto;
  	allow $2 $1_xchat_t:unix_stream_socket connectto;

   	allow $2 $1_xchat_t:fd use;
   	allow $2 $1_xchat_t:shm { associate getattr unix_read unix_write };
    allow $2 $1_xchat_t:process { ptrace signal_perms };
    
	ps_process_pattern($2,$1_xchat_t)

	manage_dirs_pattern($1_xchat_t,user_xchat_home_t,user_xchat_home_t)
	manage_files_pattern($1_xchat_t,user_xchat_home_t,user_xchat_home_t)
   	manage_sock_files_pattern($1_xchat_t,user_xchat_home_t,user_xchat_home_t)

   	userdom_user_home_dir_filetrans($1,$1_xchat_t,user_xchat_home_t,{ dir sock_file file })
   	userdom_search_user_home_dirs($1,$1_xchat_t)

	userdom_list_user_files($1,$1_xchat_t)
	userdom_list_user_home_dirs($1,$1_xchat_t)
    # userdom_list_user_home_content_dirs($1,$1_xchat_t)

    userdom_read_user_home_content_files($1,$1_xchat_t)
    userdom_read_user_home_content_symlinks($1,$1_xchat_t)

    userdom_read_user_tmp_files($1,$1_xchat_t)
    userdom_manage_user_tmp_dirs($1,$1_xchat_t)
    userdom_manage_user_tmp_files($1,$1_xchat_t)
    userdom_manage_user_tmp_sockets($1,$1_xchat_t)

    userdom_tmp_filetrans_user_tmp($1,$1_xchat_t,{ file dir sock_file })

    # XChat wants getattr to Beagle sock_file in home
    dontaudit $1_xchat_t $1_home_t:sock_file getattr;

	userdom_unlink_unpriv_users_home_content_files($1_xchat_t)

    userdom_dontaudit_write_user_home_content_files($1,$1_xchat_t)

    manage_dirs_pattern($2,user_xchat_home_t,user_xchat_home_t)
    manage_files_pattern($2,user_xchat_home_t,user_xchat_home_t)
    manage_sock_files_pattern($2,user_xchat_home_t,user_xchat_home_t)

    relabel_dirs_pattern($2,user_xchat_home_t,user_xchat_home_t)
    relabel_files_pattern($2,user_xchat_home_t,user_xchat_home_t)
    relabel_sock_files_pattern($2,user_xchat_home_t,user_xchat_home_t)

    manage_files_pattern($1_xchat_t,$1_xchat_tmpfs_t,$1_xchat_tmpfs_t)
   	manage_lnk_files_pattern($1_xchat_t,$1_xchat_tmpfs_t,$1_xchat_tmpfs_t)
  	manage_fifo_files_pattern($1_xchat_t,$1_xchat_tmpfs_t,$1_xchat_tmpfs_t)
   	manage_sock_files_pattern($1_xchat_t,$1_xchat_tmpfs_t,$1_xchat_tmpfs_t)

  	fs_tmpfs_filetrans($1_xchat_t,$1_xchat_tmpfs_t,{ file lnk_file sock_file fifo_file })
   	fs_rw_tmpfs_files($1_xchat_t)

	corenet_tcp_connect_xchat_port($1_xchat_t)
	corenet_sendrecv_xchat_client_packets($1_xchat_t)

	corenet_tcp_bind_xchat_port($1_xchat_t)
	corenet_send_xchat_server_packets($1_xchat_t)

  	corenet_all_recvfrom_netlabel($1_xchat_t)
	corenet_all_recvfrom_unlabeled($1_xchat_t)
    
    corenet_tcp_sendrecv_all_ports($1_xchat_t)
    corenet_tcp_connect_all_ports($1_xchat_t)
    corenet_tcp_connect_generic_port($1_xchat_t)
	corenet_tcp_sendrecv_all_if($1_xchat_t)
    corenet_tcp_sendrecv_all_nodes($1_xchat_t)
    corenet_tcp_bind_all_nodes($1_xchat_t)

	kernel_read_system_state($1_xchat_t)
	sysnet_read_config($1_xchat_t)

	files_read_etc_files($1_xchat_t)
	files_read_etc_symlinks($1_xchat_t)

	files_read_etc_runtime_files($1_xchat_t)

	files_read_usr_files($1_xchat_t)
	files_read_usr_symlinks($1_xchat_t)

  	kernel_dontaudit_list_unlabeled($1_xchat_t)
   	kernel_dontaudit_getattr_unlabeled_files($1_xchat_t)
  	kernel_dontaudit_read_unlabeled_files($1_xchat_t)

   	files_dontaudit_list_non_security($1_xchat_t)
   	files_dontaudit_getattr_non_security_files($1_xchat_t)
  	fs_dontaudit_getattr_all_fs($1_xchat_t)

   	dev_getattr_sysfs_dirs($1_xchat_t)
   	fs_search_auto_mountpoints($1_xchat_t)
   	fs_list_inotifyfs($1_xchat_t)

  	term_dontaudit_getattr_pty_dirs($1_xchat_t)

   	selinux_dontaudit_getattr_fs($1_xchat_t)

 	dev_dontaudit_getattr_all_blk_files($1_xchat_t)
   	dev_dontaudit_getattr_all_chr_files($1_xchat_t)

	libs_exec_lib_files($1_xchat_t)
	libs_use_ld_so($1_xchat_t)

	miscfiles_read_localization($1_xchat_t)

	logging_send_syslog_msg($1_xchat_t)

	corecmd_exec_bin($1_xchat_t)
	corecmd_dontaudit_exec_all_executables($1_xchat_t)
	corecmd_bin_entry_type($1_xchat_t)
	corecmd_read_bin_symlinks($1_xchat_t)
    corecmd_shell_entry_type($1_xchat_t)

    dev_read_urand($1_xchat_t)     
    dev_read_rand($1_xchat_t)

    dev_read_sound($1_xchat_t)
    dev_write_sound($1_xchat_t)

   	alsa_read_rw_config($1_xchat_t)

  	userdom_use_user_terminals($1,$1_xchat_t)

  	xserver_user_client_template($1,$1_xchat_t,$1_xchat_tmpfs_t)
	# xserver_dontaudit_read_xdm_tmp_files($1_xchat_t)
    # xserver_dontaudit_getattr_xdm_tmp_sockets($1_xchat_t)

	optional_policy(`
		dbus_system_bus_client_template($1_xchat,$1_xchat_t)
	')

	optional_policy(`
		gnome_manage_user_gnome_config($1,$1_xchat_t)
		gnome_domtrans_user_gconf($1,$1_xchat_t)
		gnome_stream_connect_gconf_template($1,$1_xchat_t)
	')

	optional_policy(`
		mozilla_read_user_home_files($1,$1_xchat_t)
		mozilla_domtrans_user_mozilla($1,$1_xchat_t)
		mozilla_dbus_chat($1,$1_xchat_t)
    ')

	optional_policy(`
		automount_dontaudit_getattr_tmp_dirs($1_xchat_t)
	')
')

########################################
## <summary>
##	Send and receive messages from
##	XChat over dbus.
## </summary>
## <desc>
##	<p>
##	Send and receive messages from
##	Xchat over dbus.
##	</p>
##	<p>
##	This is a templated interface, and should only
##	be called from a per-userdomain template.
##	</p>
## </desc>
## <param name="userdomain_prefix">
##	<summary>
##	The prefix of the user domain (e.g., user
##	is the prefix for user_t).
##	</summary>
## </param>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
template(`xchat_dbus_chat',`
	gen_require(`
		type $1_xchat_t;
		class dbus send_msg;
	')

	allow $2 $1_xchat_t:dbus send_msg;
	allow $1_xchat_t $2:dbus send_msg;
')