All pastes #736695 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-10-14 19:20 UTC
rendered paste body
## <summary>SELinux policy module</summary>
## <desc>
##	<p>
##		SELinux policy module 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;
        ')

	########################################
	#
	# Declarations
	#
        type $1_xchat_t;
        application_domain($1_xchat_t,xchat_exec_t)
        role $3 types $1_xchat_t;
	
        type $1_xchat_home_t alias $1_xchat_rw_t;
        files_poly_member($1_xchat_home_t)
        userdom_user_home_content($1,$1_xchat_home_t)

        type $1_xchat_tmpfs_t;
        files_tmpfs_file($1_xchat_tmpfs_t)

	########################################
	#
	# Local Policy
	#

	# XChat policy for self:
	allow $1_xchat_t self:process { signal getsched sigkill };
	allow $1_xchat_t self:fifo_file { read write getattr };
	allow $1_xchat_t self:netlink_route_socket { getattr write read nlmsg_read create bind };
	allow $1_xchat_t self:tcp_socket { create connect setopt write read getattr};
	allow $1_xchat_t self:udp_socket { connect read getattr write create };

	# XChat policy for interacting with XChat:
	allow $1_xchat_t $2:fd use;
		
	# XChat may only manage directories and files in $HOME
	manage_dirs_pattern($1_xchat_t,$1_xchat_home_t,$1_xchat_home_t)
    	manage_files_pattern($1_xchat_t,$1_xchat_home_t,$1_xchat_home_t)

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

	userdom_manage_user_home_content_dirs($1,$1_xchat_t)
	userdom_manage_user_home_content_files($1,$1_xchat_t)

	manage_dirs_pattern($2,$1_xchat_home_t,$1_xchat_home_t)
    	manage_files_pattern($2,$1_xchat_home_t,$1_xchat_home_t)

	relabel_dirs_pattern($2,$1_xchat_home_t,$1_xchat_home_t)
	relabel_files_pattern($2,$1_xchat_home_t,$1_xchat_home_t)

	# Xchat may have file, dir, link, sock and fifo access to tmpfs.
	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)

	# XChat may interact using tcp/ip on the network. However it may not bind any sockets to ports
	# Caution: denials with regard to binding tcp sockets to ports will not be audited
	corenet_tcp_sendrecv_all_ports($1_xchat_t)
   	corenet_tcp_connect_all_ports($1_xchat_t)
   	corenet_all_recvfrom_unlabeled($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)

	corenet_dontaudit_tcp_sendrecv_generic_port($1_xchat_t)
 	corenet_dontaudit_tcp_bind_generic_port($1_xchat_t)

	# XChat may retrieve state and configuration info about this system
	# Without these permissions XChat may still work!
	kernel_read_system_state($1_xchat_t)
	sysnet_read_config($1_xchat_t)	
	
	# XChat may read /etc and /usr, dir files and links
	# Without these permissions XChat may still work!
	files_read_etc_files($1_xchat_t)
	files_read_etc_symlinks($1_xchat_t)
	
	files_read_usr_files($1_xchat_t)
	files_read_usr_symlinks($1_xchat_t)

	# Do not audit XChat encounters with unlabeled objects
	kernel_dontaudit_list_unlabeled($1_xchat_t)
	kernel_dontaudit_getattr_unlabeled_files($1_xchat_t)
	kernel_dontaudit_read_unlabeled_files($1_xchat_t)
	
	# Filesystem related. Do not audit. For explanation refer to refpolicy.
	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)

	# XChat may get attributes of our systems filesystem
	dev_getattr_sysfs_dirs($1_xchat_t)
	# XChat may search auto mountpoints
	fs_search_auto_mountpoints($1_xchat_t)
	# XChat may listinotify filessystem
	fs_list_inotifyfs($1_xchat_t)

	# XChat auto transition pattern
	domain_auto_trans($2, xchat_exec_t, $1_xchat_t)
	# Rules with regard to auto transition
	allow $2 $1_xchat_t:process { noatsecure siginh rlimitinh };

	# XChat process pattern
	ps_process_pattern($2,$1_xchat_t)
	# Rules with regard to process
	allow $2 $1_xchat_t:process signal_perms;

	# XChat calls to interfaces in other domains:
	libs_exec_lib_files($1_xchat_t)
	corecmd_bin_entry_type($1_xchat_t)
	dev_read_urand($1_xchat_t)
	dbus_connect_system_bus($1_xchat_t)
	dbus_send_system_bus($1_xchat_t)
	libs_use_ld_so($1_xchat_t)
	miscfiles_read_localization($1_xchat_t)

	# This is the X Server interface that we use to display XChat
	xserver_user_client_template($1,$1_xchat_t,$1_xchat_tmpfs_t)
	# All other stuff related to X Server is denied
	xserver_dontaudit_read_xdm_tmp_files($1_xchat_t)
	xserver_dontaudit_getattr_xdm_tmp_sockets($1_xchat_t)

	# XChat policy for NFS and Samba $HOME
	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)
   	')
')

########################################
## <summary>
##      Read XChat per user homedir
## </summary>
## <desc>
##      <p>
##      Read XChat per user homedir
##      </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_read_user_home_files',`
        gen_require(`
                type $1_xchat_home_t;
        ')

        allow $2 $1_xchat_home_t:dir list_dir_perms;
        allow $2 $1_xchat_home_t:file read_file_perms;
')

########################################
## <summary>
##      Write XChat per user homedir
## </summary>
## <desc>
##      <p>
##      Write XChat per user homedir
##      </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_write_user_home_files',`
        gen_require(`
                type $1_xchat_home_t;
        ')

        allow $2 $1_xchat_home_t:dir list_dir_perms;
        allow $2 $1_xchat_home_t:file write;
')

########################################
## <summary>
##      Run XChat in user XChat domain.
## </summary>
## <desc>
##      <p>
##      Run XChat in user XChat domain.
##      </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_domtrans_user_xchat',`
        gen_require(`
                type $1_xchat_t, xchat_exec_t;
        ')

        domtrans_pattern($2, xchat_exec_t,$1_xchat_t)
')

########################################
## <summary>
##      Read/write XChat per user tcp_socket
## </summary>
## <desc>
##      <p>
##      Read/write XChat per user tcp_socket
##      </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_rw_user_tcp_sockets',`
        gen_require(`
                type $1_xchat_t;
        ')

        allow $2 $1_xchat_t:tcp_socket rw_socket_perms;
')