Chris PeBenito 490639
## <module name="userdomain" layer="system">
Chris PeBenito 490639
## <summary>Policy for user domains</summary>
Chris PeBenito b16c6b
Chris PeBenito b16c6b
########################################
Chris PeBenito b16c6b
#
Chris PeBenito b16c6b
# Base user domain template
Chris PeBenito b16c6b
#
Chris PeBenito b16c6b
# This is common to user and admin domain
Chris PeBenito b16c6b
Chris PeBenito b16c6b
define(`base_user_domain',`
Chris PeBenito b16c6b
Chris PeBenito 0c73cd
	attribute $1_file_type;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	type $1_t, userdomain;
Chris PeBenito c9428d
	domain_type($1_t)
Chris PeBenito c9428d
	corecmd_shell_entry_type($1_t)
Chris PeBenito 0c73cd
	role $1_r types $1_t;
Chris PeBenito 0c73cd
	allow system_r $1_r;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# user pseudoterminal
Chris PeBenito 0c73cd
	type $1_devpts_t;
Chris PeBenito 0fd9dc
	term_user_pty($1_t,$1_devpts_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# type for contents of home directory
Chris PeBenito 0c73cd
	type $1_home_t, $1_file_type, home_type;
Chris PeBenito c9428d
	files_file_type($1_home_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# type of home directory
Chris PeBenito 0c73cd
	type $1_home_dir_t, home_dir_type, home_type;
Chris PeBenito c9428d
	files_file_type($1_home_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	type $1_tmp_t, $1_file_type;
Chris PeBenito c9428d
	files_tmp_file($1_tmp_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	type $1_tmpfs_t;
Chris PeBenito c9428d
	files_tmpfs_file($1_tmpfs_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	type $1_tty_device_t; 
Chris PeBenito 0fd9dc
	term_tty($1_t,$1_tty_device_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Local policy
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t self:capability { setgid chown fowner };
Chris PeBenito 0c73cd
	dontaudit $1_t self:capability { sys_nice fsetid };
Chris PeBenito 0c73cd
	allow $1_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem dyntransition };
Chris PeBenito 0c73cd
	allow $1_t self:process { ptrace setfscreate };
Chris PeBenito 0c73cd
	allow $1_t self:fd use;
Chris PeBenito cc41a9
	allow $1_t self:fifo_file rw_file_perms;
Chris PeBenito cc41a9
	allow $1_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 0fd9dc
	allow $1_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 0c73cd
	allow $1_t self:unix_dgram_socket sendto;
Chris PeBenito 0c73cd
	allow $1_t self:unix_stream_socket connectto;
Chris PeBenito cc41a9
	allow $1_t self:shm create_shm_perms;
Chris PeBenito cc41a9
	allow $1_t self:sem create_sem_perms;
Chris PeBenito cc41a9
	allow $1_t self:msgq create_msgq_perms;
Chris PeBenito 0c73cd
	allow $1_t self:msg { send receive };
Chris PeBenito 0c73cd
	dontaudit $1_t self:socket create;
Chris PeBenito 0c73cd
	# Irrelevant until we have labeled networking.
Chris PeBenito 0c73cd
	#allow $1_t self:udp_socket { sendto recvfrom };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# evolution and gnome-session try to create a netlink socket
Chris PeBenito 0c73cd
	dontaudit $1_t self:netlink_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito 0c73cd
	dontaudit $1_t self:netlink_route_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown nlmsg_read nlmsg_write };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# execute files in the home directory
Chris PeBenito cc41a9
	allow $1_t $1_home_t:file { rx_file_perms execute_no_trans };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# full control of the home directory
Chris PeBenito cc41a9
	allow $1_t $1_home_t:file { create_file_perms relabelfrom relabelto };
Chris PeBenito cc41a9
	allow $1_t $1_home_t:lnk_file { create_lnk_perms relabelfrom relabelto };
Chris PeBenito cc41a9
	allow $1_t $1_home_t:dir { create_dir_perms relabelfrom relabelto };
Chris PeBenito cc41a9
	allow $1_t $1_home_t:sock_file { create_file_perms relabelfrom relabelto };
Chris PeBenito cc41a9
	allow $1_t $1_home_t:fifo_file { create_file_perms relabelfrom relabelto };
Chris PeBenito cc41a9
	allow $1_t $1_home_dir_t:dir create_dir_perms;
Chris PeBenito cc41a9
	type_transition $1_t $1_home_dir_t:{ dir notdevfile_class_set } $1_home_t;
Chris PeBenito 0c73cd
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:file { rx_file_perms execute_no_trans };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Bind to a Unix domain socket in /tmp.
Chris PeBenito 0c73cd
	# cjp: this is combination is not checked and should be removed
Chris PeBenito 0c73cd
	allow $1_t $1_tmp_t:unix_stream_socket name_bind;
Chris PeBenito 0c73cd
Chris PeBenito cc41a9
	allow $1_t $1_tmpfs_t:dir rw_dir_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmpfs_t:file create_file_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmpfs_t:lnk_file create_lnk_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmpfs_t:sock_file create_file_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmpfs_t:fifo_file create_file_perms;
Chris PeBenito 0fd9dc
	fs_create_tmpfs_data($1_t,$1_tmpfs_t, { dir notdevfile_class_set } )
Chris PeBenito 0c73cd
Chris PeBenito cc41a9
	allow $1_t $1_tty_device_t:chr_file { setattr rw_file_perms };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t unpriv_userdomain:fd use;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Instantiate derived domains for a number of programs.
Chris PeBenito 0c73cd
	# These derived domains encode both information about the calling
Chris PeBenito 0c73cd
	# user domain and the program, and allow us to maintain separation
Chris PeBenito 0c73cd
	# between different instances of the program being run by different
Chris PeBenito 0c73cd
	# user domains.
Chris PeBenito 0c73cd
	per_userdomain_templates($1)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	kernel_read_kernel_sysctl($1_t)
Chris PeBenito 5e0da6
	selinux_get_fs_mount($1_t)
Chris PeBenito 0c73cd
	# Very permissive allowing every domain to see every type:
Chris PeBenito 0c73cd
	kernel_get_sysvipc_info($1_t)
Chris PeBenito 0c73cd
	# Find CDROM devices:
Chris PeBenito 0c73cd
	kernel_read_device_sysctl($1_t)
Chris PeBenito 0c73cd
	# GNOME checks for usb and other devices:
Chris PeBenito 8bd678
	dev_rw_usbfs($1_t)
Chris PeBenito 0fd9dc
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_if($1_t)
Chris PeBenito 0fd9dc
	corenet_raw_sendrecv_all_if($1_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_if($1_t)
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_nodes($1_t)
Chris PeBenito 0fd9dc
	corenet_raw_sendrecv_all_nodes($1_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_nodes($1_t)
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_ports($1_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_ports($1_t)
Chris PeBenito 0fd9dc
	corenet_tcp_bind_all_nodes($1_t)
Chris PeBenito 0fd9dc
	corenet_udp_bind_all_nodes($1_t)
Chris PeBenito 0c73cd
	# allow port_t name binding for UDP because it is not very usable otherwise
Chris PeBenito 0fd9dc
	corenet_udp_bind_generic_port($1_t)
Chris PeBenito 0c73cd
Karl MacMillan f0c985
	dev_read_input($1_t)
Karl MacMillan f0c985
	dev_read_misc($1_t)
Karl MacMillan f0c985
	dev_write_misc($1_t)
Karl MacMillan f0c985
	dev_write_snd_dev($1_t)
Karl MacMillan f0c985
	dev_read_snd_dev($1_t)
Karl MacMillan f0c985
	dev_read_snd_mixer_dev($1_t)
Karl MacMillan f0c985
	dev_write_snd_mixer_dev($1_t)
Karl MacMillan f0c985
	dev_read_rand($1_t)
Karl MacMillan f0c985
	dev_read_urand($1_t)
Chris PeBenito 0c73cd
	# open office is looking for the following
Karl MacMillan f0c985
	dev_getattr_agp_dev($1_t)
Karl MacMillan f0c985
	dev_dontaudit_rw_dri_dev($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 763c44
	fs_get_all_fs_quotas($1_t)
Chris PeBenito 0fd9dc
	fs_getattr_all_fs($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# for eject
Chris PeBenito 0fd9dc
	storage_getattr_fixed_disk($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	auth_read_login_records($1_t)
Chris PeBenito c9428d
	auth_dontaudit_write_login_records($1_t)
Chris PeBenito c9428d
	auth_run_pam($1_t,$1_r,{ $1_tty_device_t $1_devpts_t })
Chris PeBenito c9428d
	auth_run_utempter($1_t,$1_r,{ $1_tty_device_t $1_devpts_t })
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	corecmd_exec_bin($1_t)
Chris PeBenito c9428d
	corecmd_exec_sbin($1_t)
Chris PeBenito c9428d
	corecmd_exec_ls($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	domain_exec_all_entry_files($1_t)
Chris PeBenito c9428d
	domain_use_wide_inherit_fd($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_exec_generic_etc_files($1_t)
Chris PeBenito c9428d
	files_read_usr_src($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Caused by su - init scripts
Chris PeBenito c9428d
	init_dontaudit_use_script_pty($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	libs_use_ld_so($1_t)
Chris PeBenito c9428d
	libs_use_shared_libs($1_t)
Chris PeBenito c9428d
	libs_exec_ld_so($1_t)
Chris PeBenito c9428d
	libs_exec_lib_files($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	logging_dontaudit_getattr_all_logs($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	miscfiles_read_localization($1_t)
Chris PeBenito c9428d
	miscfiles_rw_man_cache($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 5e0da6
	seutil_run_newrole($1_t,$1_r,{ $1_devpts_t $1_tty_device_t })
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	mta_rw_spool($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 34c8fa
	tunable_policy(`allow_execmem',`
Chris PeBenito 0c73cd
		# Allow loading DSOs that require executable stack.
Chris PeBenito 0c73cd
		allow $1_t self:process execmem;
Chris PeBenito 34c8fa
	')
Chris PeBenito 0c73cd
Chris PeBenito 34c8fa
	tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 0fd9dc
		fs_manage_nfs_dirs($1_t)
Chris PeBenito 763c44
		fs_manage_nfs_files($1_t)
Chris PeBenito 0fd9dc
		fs_manage_nfs_symlinks($1_t)
Chris PeBenito 763c44
		fs_manage_nfs_named_sockets($1_t)
Chris PeBenito 763c44
		fs_manage_nfs_named_pipes($1_t)
Chris PeBenito 763c44
		fs_execute_nfs_files($1_t)
Chris PeBenito 34c8fa
	')
Chris PeBenito 0c73cd
Chris PeBenito 34c8fa
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 0fd9dc
		fs_manage_cifs_dirs($1_t)
Chris PeBenito 0fd9dc
		fs_manage_cifs_files($1_t)
Chris PeBenito 0fd9dc
		fs_manage_cifs_symlinks($1_t)
Chris PeBenito 0fd9dc
		fs_manage_cifs_named_sockets($1_t)
Chris PeBenito 0fd9dc
		fs_manage_cifs_named_pipes($1_t)
Chris PeBenito 0fd9dc
		fs_execute_cifs_files($1_t)
Chris PeBenito 34c8fa
	')
Chris PeBenito 0c73cd
Chris PeBenito 34c8fa
	tunable_policy(`user_direct_mouse',`
Karl MacMillan f0c985
		dev_read_mouse($1_t)
Chris PeBenito 34c8fa
	')
Chris PeBenito 0c73cd
Chris PeBenito 34c8fa
	tunable_policy(`user_ttyfile_stat',`
Chris PeBenito 0fd9dc
		term_getattr_all_user_ttys($1_t)
Chris PeBenito 34c8fa
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	optional_policy(`usermanage.te',`
Chris PeBenito c9428d
		usermanage_run_chfn($1_t,$1_r,{ $1_devpts_t $1_tty_device_t })
Chris PeBenito c9428d
		usermanage_run_passwd($1_t,$1_r,{ $1_devpts_t $1_tty_device_t })
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`TODO',`
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# When the user domain runs ps, there will be a number of access
Chris PeBenito 0c73cd
	# denials when ps tries to search /proc.  Do not audit these denials.
Chris PeBenito 0c73cd
	dontaudit $1_t domain:dir r_dir_perms;
Chris PeBenito 0c73cd
	dontaudit $1_t domain:notdevfile_class_set r_file_perms;
Chris PeBenito 0c73cd
	dontaudit $1_t domain:process { getattr getsession };
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Cups daemon running as user tries to write /etc/printcap
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	dontaudit $1_t usr_t:file setattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Access the power device.
Chris PeBenito cc41a9
	allow $1_t power_device_t:chr_file rw_file_perms;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Check to see if cdrom is mounted
Chris PeBenito 0c73cd
	allow $1_t mnt_t:dir { getattr search };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Added to allow reading of cdrom
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	allow $1_t rpc_pipefs_t:dir getattr;
Chris PeBenito 0c73cd
	allow $1_t nfsd_fs_t:dir getattr;
Chris PeBenito 0c73cd
	allow $1_t binfmt_misc_fs_t:dir getattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# /initrd is left mounted, various programs try to look at it
Chris PeBenito 0c73cd
	dontaudit $1_t ramfs_t:dir getattr;
Chris PeBenito 0c73cd
Chris PeBenito 3eed10
	tunable_policy(`read_default_t',`
Chris PeBenito 0c73cd
		allow $1_t default_t:dir r_dir_perms;
Chris PeBenito 0c73cd
		allow $1_t default_t:notdevfile_class_set r_file_perms;
Chris PeBenito 3eed10
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Running ifconfig as a user generates the following
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	dontaudit $1_t sysctl_net_t:dir search;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	dontaudit $1_t default_context_t:dir search;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	r_dir_file($1_t, usercanread)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	can_ypbind($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 3eed10
	tunable_policy(`allow_execmod',`
Chris PeBenito 0c73cd
		# Allow text relocations on system shared libraries, e.g. libGL.
Chris PeBenito 0c73cd
		allow $1_t texrel_shlib_t:file execmod;
Chris PeBenito 3eed10
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t fs_type:dir getattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# old "file_browse_domain":
Chris PeBenito 0c73cd
	# Regular files/directories that are not security sensitive
Chris PeBenito 0c73cd
	dontaudit $1_t file_type - secure_file_type:dir_file_class_set getattr;
Chris PeBenito 0c73cd
	dontaudit $1_t file_type - secure_file_type:dir { read search };
Chris PeBenito 0c73cd
	# /dev
Chris PeBenito 0c73cd
	dontaudit $1_t dev_fs:dir_file_class_set getattr;
Chris PeBenito 0c73cd
	dontaudit $1_t dev_fs:dir { read search };
Chris PeBenito 0c73cd
	# /proc
Chris PeBenito 0c73cd
	dontaudit $1_t sysctl_t:dir_file_class_set getattr;
Chris PeBenito 0c73cd
	dontaudit $1_t proc_fs:dir { read search };
Chris PeBenito 0c73cd
Chris PeBenito cc41a9
	allow $1_t autofs_t:dir { getattr search };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	can_exec($1_t, { removable_t noexattrfile } )
Chris PeBenito 3eed10
Chris PeBenito 3eed10
	tunable_policy(`user_rw_noexattrfile',`
Chris PeBenito 0c73cd
		create_dir_file($1_t, noexattrfile)
Chris PeBenito 0c73cd
		create_dir_file($1_t, removable_t)
Chris PeBenito 0c73cd
		# Write floppies 
Chris PeBenito 0c73cd
		allow $1_t removable_device_t:blk_file rw_file_perms;
Chris PeBenito 0c73cd
		allow $1_t usbtty_device_t:chr_file write;
Chris PeBenito 3eed10
	',`
Chris PeBenito 0c73cd
		r_dir_file($1_t, noexattrfile)
Chris PeBenito 0c73cd
		r_dir_file($1_t, removable_t)
Chris PeBenito 0c73cd
		allow $1_t removable_device_t:blk_file r_file_perms;
Chris PeBenito 3eed10
	')
Chris PeBenito 3eed10
Chris PeBenito 0c73cd
	allow $1_t usbtty_device_t:chr_file read;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	can_exec($1_t, noexattrfile)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# for running TeX programs
Chris PeBenito 0c73cd
	r_dir_file($1_t, tetex_data_t)
Chris PeBenito 0c73cd
	can_exec($1_t, tetex_data_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Run programs developed by other users in the same domain.
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	can_resmgrd_connect($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	can_ypbind($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t var_lock_t:dir search;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Grant permissions to access the system DBus
Chris PeBenito 0c73cd
	ifdef(`dbusd.te', `
Chris PeBenito 0c73cd
		dbusd_client(system, $1)
Chris PeBenito 0c73cd
		can_network_server_tcp($1_dbusd_t)
Chris PeBenito 0c73cd
		allow $1_dbusd_t reserved_port_t:tcp_socket name_bind;
Chris PeBenito 0c73cd
	
Chris PeBenito 0c73cd
		allow $1_t system_dbusd_t:dbus { send_msg acquire_svc };
Chris PeBenito 0c73cd
		dbusd_client($1, $1)
Chris PeBenito 0c73cd
		allow $1_t $1_dbusd_t:dbus { send_msg acquire_svc };
Chris PeBenito 0c73cd
		dbusd_domain($1)
Chris PeBenito 0c73cd
		ifdef(`hald.te', `
Chris PeBenito 0c73cd
			allow $1_t hald_t:dbus send_msg;
Chris PeBenito 0c73cd
			allow hald_t $1_t:dbus send_msg;
Chris PeBenito 0c73cd
		')
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Gnome pannel binds to the following
Chris PeBenito 0c73cd
	ifdef(`cups.te', `
Chris PeBenito cc41a9
		allow $1_t { cupsd_etc_t cupsd_rw_etc_t }:file r_file_perms;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Connect to inetd.
Chris PeBenito 0c73cd
	ifdef(`inetd.te', `
Chris PeBenito 0c73cd
		can_tcp_connect($1_t, inetd_t)
Chris PeBenito 0c73cd
		can_udp_send($1_t, inetd_t)
Chris PeBenito 0c73cd
		can_udp_send(inetd_t, $1_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Connect to portmap.
Chris PeBenito 0c73cd
	ifdef(`portmap.te', `can_tcp_connect($1_t, portmap_t)')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Inherit and use sockets from inetd
Chris PeBenito 0c73cd
	ifdef(`inetd.te', `
Chris PeBenito 0c73cd
		allow $1_t inetd_t:fd use;
Chris PeBenito 0c73cd
		allow $1_t inetd_t:tcp_socket rw_stream_socket_perms;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`xserver.te', `
Chris PeBenito 0c73cd
		# for /tmp/.ICE-unix
Chris PeBenito 0c73cd
		file_type_auto_trans($1_t, xdm_xserver_tmp_t, $1_tmp_t, sock_file)
Chris PeBenito 0c73cd
		allow $1_t xserver_misc_device_t:{ chr_file blk_file } rw_file_perms;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`xdm.te', `
Chris PeBenito 0c73cd
		# Connect to the X server run by the X Display Manager.
Chris PeBenito 0c73cd
		can_unix_connect($1_t, xdm_t)
Chris PeBenito 0c73cd
		allow $1_t xdm_tmp_t:sock_file rw_file_perms;
Chris PeBenito 0c73cd
		allow $1_t xdm_tmp_t:dir r_dir_perms;
Chris PeBenito cc41a9
		allow $1_t xdm_tmp_t:file r_file_perms;
Chris PeBenito 0c73cd
		allow $1_t xdm_xserver_tmp_t:sock_file { read write };
Chris PeBenito 0c73cd
		allow $1_t xdm_xserver_tmp_t:dir search;
Chris PeBenito 0c73cd
		allow $1_t xdm_xserver_t:unix_stream_socket connectto;
Chris PeBenito 0c73cd
		# certain apps want to read xdm.pid file
Chris PeBenito 0c73cd
		r_dir_file($1_t, xdm_var_run_t)
Chris PeBenito cc41a9
		allow $1_t xdm_var_lib_t:file r_file_perms;
Chris PeBenito 0c73cd
		allow xdm_t $1_home_dir_t:dir getattr;
Chris PeBenito 0c73cd
		ifdef(`xauth.te', `
Chris PeBenito 0c73cd
			file_type_auto_trans(xdm_t, $1_home_dir_t, $1_xauth_home_t, file)
Chris PeBenito 0c73cd
		')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
		# for shared memory
Chris PeBenito 0c73cd
		allow xdm_xserver_t $1_tmpfs_t:file { read write };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`rpcd.te', `
Chris PeBenito 0c73cd
		create_dir_file($1_t, nfsd_rw_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`cardmgr.te', `
Chris PeBenito 0c73cd
		# to allow monitoring of pcmcia status
Chris PeBenito cc41a9
		allow $1_t cardmgr_var_run_t:file r_file_perms;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Allow graphical boot to check battery lifespan
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	ifdef(`apmd.te', `
Chris PeBenito 0c73cd
		allow $1_t apmd_t:unix_stream_socket connectto;
Chris PeBenito 0c73cd
		allow $1_t apmd_var_run_t:sock_file write;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`automount.te', `
Chris PeBenito cc41a9
		allow $1_t autofs_t:dir { getattr search };
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`pamconsole.te', `
Chris PeBenito 0c73cd
		allow $1_t pam_var_console_t:dir search;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	') dnl endif TODO
Chris PeBenito b16c6b
Chris PeBenito b16c6b
')dnl end base_user_domain macro
Chris PeBenito b16c6b
Chris PeBenito b16c6b
########################################
Chris PeBenito b16c6b
#
Chris PeBenito b16c6b
# User domain template
Chris PeBenito b16c6b
#
Chris PeBenito b16c6b
Chris PeBenito b16c6b
define(`user_domain_template', `
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Declarations
Chris PeBenito 0c73cd
	#
Chris PeBenito b16c6b
Chris PeBenito 0c73cd
	# Inherit rules for ordinary users.
Chris PeBenito 0c73cd
	base_user_domain($1)
Chris PeBenito b16c6b
Chris PeBenito 0c73cd
	typeattribute $1_t unpriv_userdomain; #, web_client_domain, nscd_client_domain;
Chris PeBenito c9428d
	domain_wide_inherit_fd($1_t)
Chris PeBenito b16c6b
Chris PeBenito 0c73cd
	#typeattribute $1_devpts_t userpty_type, user_tty_type;
Chris PeBenito 0c73cd
	#typeattribute $1_home_dir_t user_home_dir_type;
Chris PeBenito 0c73cd
	#typeattribute $1_home_t user_home_type;
Chris PeBenito b16c6b
Chris PeBenito 0c73cd
	#typeattribute $1_tmp_t, user_tmpfile;
Chris PeBenito b16c6b
Chris PeBenito 0c73cd
	#typeattribute $1_tty_device_t user_tty_type;
Chris PeBenito b16c6b
 
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Local policy
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t $1_devpts_t:chr_file { setattr ioctl read getattr lock write append };
Chris PeBenito 0fd9dc
	term_create_pty($1_t,$1_devpts_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Rules used to associate a homedir as a mountpoint
Chris PeBenito 0c73cd
	allow $1_home_t self:filesystem associate;
Chris PeBenito 0c73cd
	allow $1_file_type $1_home_t:filesystem associate;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# user temporary files
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:file create_file_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:lnk_file create_lnk_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:dir create_dir_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:sock_file create_file_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:fifo_file create_file_perms;
Chris PeBenito c9428d
	files_create_tmp_files($1_t, $1_tmp_t, { dir notdevfile_class_set })
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# privileged home directory writers
Chris PeBenito cc41a9
	allow privhome $1_home_t:file create_file_perms;
Chris PeBenito cc41a9
	allow privhome $1_home_t:lnk_file create_lnk_perms;
Chris PeBenito cc41a9
	allow privhome $1_home_t:dir create_dir_perms;
Chris PeBenito cc41a9
	allow privhome $1_home_t:sock_file create_file_perms;
Chris PeBenito cc41a9
	allow privhome $1_home_t:fifo_file create_file_perms;
Chris PeBenito cc41a9
	type_transition privhome $1_home_dir_t:{ dir notdevfile_class_set } $1_home_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	kernel_read_system_state($1_t)
Chris PeBenito 0c73cd
	kernel_read_network_state($1_t)
Chris PeBenito 8bd678
	dev_read_sysfs($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# cjp: why?
Chris PeBenito 0c73cd
	bootloader_read_kernel_symbol_table($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# port access is audited even if dac would not have allowed it, so dontaudit it here
Chris PeBenito 0fd9dc
	corenet_dontaudit_tcp_bind_all_reserved_ports($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_read_generic_etc_files($1_t)
Chris PeBenito c9428d
	files_list_home($1_t)
Chris PeBenito c9428d
	files_read_usr_files($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	init_read_script_pid($1_t)
Chris PeBenito 0c73cd
	# The library functions always try to open read-write first,
Chris PeBenito 0c73cd
	# then fall back to read-only if it fails. 
Chris PeBenito c9428d
	init_dontaudit_write_script_pid($1_t)
Chris PeBenito 0c73cd
	# Stop warnings about access to /dev/console
Chris PeBenito c9428d
	init_dontaudit_use_fd($1_t)
Chris PeBenito c9428d
	init_dontaudit_use_script_fd($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	miscfiles_read_man_pages($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 5e0da6
	seutil_read_config($1_t)
Chris PeBenito 0c73cd
	# Allow users to execute checkpolicy without a domain transition
Chris PeBenito 0c73cd
	# so it can be used without privilege to write real binary policy file
Chris PeBenito 5e0da6
	seutil_exec_checkpol($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 34c8fa
	tunable_policy(`user_dmesg',`
Chris PeBenito 0c73cd
		kernel_read_ring_buffer($1_t)
Chris PeBenito 34c8fa
	',`
Chris PeBenito 0fd9dc
		kernel_dontaudit_read_ring_buffer($1_t)
Chris PeBenito 34c8fa
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Allow users to run TCP servers (bind to ports and accept connection from
Chris PeBenito 0c73cd
	# the same domain and outside users)  disabling this forces FTP passive mode
Chris PeBenito 0c73cd
	# and may change other protocols
Chris PeBenito 34c8fa
	tunable_policy(`user_tcp_server',`
Chris PeBenito 0fd9dc
		corenet_tcp_bind_generic_port($1_t)
Chris PeBenito 34c8fa
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# for running depmod as part of the kernel packaging process
Chris PeBenito 0c73cd
	optional_policy(`modutils.te',`
Chris PeBenito c9428d
		modutils_read_module_conf($1_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	optional_policy(`selinux.te',`
Chris PeBenito 0c73cd
		# for when the network connection is killed
Chris PeBenito 5e0da6
		seutil_dontaudit_newrole_signal($1_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Need the following rule to allow users to run vpnc
Chris PeBenito 0c73cd
	optional_policy(`xserver.te', `
Chris PeBenito 0c73cd
		corenetwork_bind_tcp_on_xserver_port($1_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`TODO',`
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	dontaudit $1_t boot_t:lnk_file read;
Chris PeBenito 0c73cd
	dontaudit $1_t boot_t:file read;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	can_kerberos($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# do not audit read on disk devices
Chris PeBenito 0c73cd
	dontaudit $1_t { removable_device_t fixed_disk_device_t }:blk_file read;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`xdm.te', `
Chris PeBenito 0c73cd
		allow xdm_t $1_home_t:lnk_file read;
Chris PeBenito 0c73cd
		allow xdm_t $1_home_t:dir search;
Chris PeBenito 0c73cd
		#
Chris PeBenito 0c73cd
		# Changing this to dontaudit should cause the .xsession-errors file to be written to /tmp
Chris PeBenito 0c73cd
		# 
Chris PeBenito 0c73cd
		dontaudit xdm_t $1_home_t:file rw_file_perms;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`ftpd.te', `
Chris PeBenito 3eed10
		tunable_policy(`ftp_home_dir',`
Chris PeBenito 0c73cd
			file_type_auto_trans(ftpd_t, $1_home_dir_t, $1_home_t)
Chris PeBenito 3eed10
		')
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 3eed10
	tunable_policy(`read_default_t',`
Chris PeBenito 0c73cd
		allow $1 default_t:dir r_dir_perms;
Chris PeBenito 0c73cd
		allow $1 default_t:notdevfile_class_set r_file_perms;
Chris PeBenito 3eed10
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	can_exec($1_t, usr_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Read directories and files with the readable_t type.
Chris PeBenito 0c73cd
	# This type is a general type for "world"-readable files.
Chris PeBenito 0c73cd
	allow $1_t readable_t:dir r_dir_perms;
Chris PeBenito 0c73cd
	allow $1_t readable_t:notdevfile_class_set r_file_perms;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Stat lost+found.
Chris PeBenito 0c73cd
	allow $1_t lost_found_t:dir getattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Read /var, /var/spool, /var/run.
Chris PeBenito 0c73cd
	allow $1_t var_t:dir r_dir_perms;
Chris PeBenito 0c73cd
	allow $1_t var_t:notdevfile_class_set r_file_perms;
Chris PeBenito 0c73cd
	allow $1_t var_spool_t:dir r_dir_perms;
Chris PeBenito 0c73cd
	allow $1_t var_spool_t:notdevfile_class_set r_file_perms;
Chris PeBenito 0c73cd
	allow $1_t var_run_t:dir r_dir_perms;
Chris PeBenito 0c73cd
	allow $1_t var_run_t:{ file lnk_file } r_file_perms;
Chris PeBenito 0c73cd
	allow $1_t var_lib_t:dir r_dir_perms;
Chris PeBenito 0c73cd
	allow $1_t var_lib_t:file { getattr read };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Allow users to rw usb devices
Chris PeBenito 3eed10
	tunable_policy(`user_rw_usb',`
Chris PeBenito 0c73cd
		rw_dir_create_file($1_t,usbdevfs_t)
Chris PeBenito 3eed10
	',`
Chris PeBenito 0c73cd
		r_dir_file($1_t,usbdevfs_t)
Chris PeBenito 3eed10
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Do not audit write denials to /etc/ld.so.cache.
Chris PeBenito 0c73cd
	dontaudit $1_t ld_so_cache_t:file write;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	dontaudit $1_t sysadm_home_t:file { read append };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`syslogd.te', `
Chris PeBenito 0c73cd
		# Some programs that are left in $1_t will try to connect
Chris PeBenito 0c73cd
		# to syslogd, but we do not want to let them generate log messages.
Chris PeBenito 0c73cd
		# Do not audit.
Chris PeBenito 0c73cd
		dontaudit $1_t devlog_t:sock_file { read write };
Chris PeBenito 0c73cd
		dontaudit $1_t syslogd_t:unix_dgram_socket sendto;
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t initrc_t:fifo_file write;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`user_can_mount', `
Chris PeBenito 0c73cd
		#
Chris PeBenito 0c73cd
		#  Allow users to mount file systems like floppies and cdrom
Chris PeBenito 0c73cd
		#
Chris PeBenito 0c73cd
		mount_domain($1, $1_mount, `, fs_domain')
Chris PeBenito 0c73cd
		r_dir_file($1_t, mnt_t)
Chris PeBenito 0c73cd
		allow $1_mount_t device_t:lnk_file read;
Chris PeBenito 0c73cd
		allow $1_mount_t removable_device_t:blk_file read;
Chris PeBenito 0c73cd
		allow $1_mount_t iso9660_t:filesystem relabelfrom;
Chris PeBenito 0c73cd
		allow $1_mount_t removable_t:filesystem { mount relabelto };
Chris PeBenito 0c73cd
		allow $1_mount_t removable_t:dir mounton;
Chris PeBenito 0c73cd
		ifdef(`xdm.te', `
Chris PeBenito 0c73cd
			allow $1_mount_t xdm_t:fd use;
Chris PeBenito 0c73cd
			allow $1_mount_t xdm_t:fifo_file { read write };
Chris PeBenito 0c73cd
		')
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	') dnl end TODO
Chris PeBenito b16c6b
')
Chris PeBenito 4d8ddf
Chris PeBenito 4d8ddf
########################################
Chris PeBenito 4d8ddf
#
Chris PeBenito 4d8ddf
# Admin domain template
Chris PeBenito 4d8ddf
#
Chris PeBenito 4d8ddf
define(`admin_domain_template',`
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# Declarations
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Inherit rules for ordinary users.
Chris PeBenito 0c73cd
	base_user_domain($1)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	typeattribute $1_t privhome; #, admin, web_client_domain, nscd_client_domain;
Chris PeBenito 8bd678
	domain_obj_id_change_exempt($1_t)
Chris PeBenito 0c73cd
	role system_r types $1_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	#ifdef(`direct_sysadm_daemon', `, priv_system_role')
Chris PeBenito 0c73cd
	#; dnl end of sysadm_t type declaration
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	typeattribute $1_devpts_t admin_terminal;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	typeattribute $1_tty_device_t admin_terminal;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# $1_t local policy
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t self:capability ~sys_module;
Chris PeBenito 0c73cd
	allow $1_t self:process { setexec setfscreate };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Set password information for other users.
Chris PeBenito 0c73cd
	allow $1_t self:passwd { passwd chfn chsh };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Skip authentication when pam_rootok is specified.
Chris PeBenito 0c73cd
	allow $1_t self:passwd rootok;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Manipulate other users crontab.
Chris PeBenito 0c73cd
	allow $1_t self:passwd crontab;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# for the administrator to run TCP servers directly
Chris PeBenito 0c73cd
	allow $1_t self:tcp_socket { acceptfrom connectto recvfrom };
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t $1_devpts_t:chr_file { setattr ioctl read getattr lock write append };
Chris PeBenito 0fd9dc
	term_create_pty($1_t,$1_devpts_t)
Chris PeBenito 0c73cd
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:dir create_dir_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:file create_file_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:lnk_file create_file_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:fifo_file create_file_perms;
Chris PeBenito cc41a9
	allow $1_t $1_tmp_t:sock_file create_file_perms;
Chris PeBenito c9428d
	files_create_tmp_files($1_t, $1_tmp_t, { dir notdevfile_class_set })
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	kernel_read_system_state($1_t)
Chris PeBenito 0c73cd
	kernel_read_network_state($1_t)
Chris PeBenito 0c73cd
	kernel_read_software_raid_state($1_t)
Chris PeBenito 0fd9dc
	kernel_getattr_core($1_t)
Chris PeBenito 0fd9dc
	kernel_getattr_message_if($1_t)
Chris PeBenito 0c73cd
	kernel_change_ring_buffer_level($1_t)
Chris PeBenito 0c73cd
	kernel_clear_ring_buffer($1_t)
Chris PeBenito 0c73cd
	kernel_read_ring_buffer($1_t)
Chris PeBenito 0c73cd
	kernel_get_sysvipc_info($1_t)
Chris PeBenito 0fd9dc
	kernel_rw_all_sysctl($1_t)
Chris PeBenito 5e0da6
	selinux_set_enforce_mode($1_t)
Chris PeBenito 5e0da6
	selinux_set_boolean($1_t)
Chris PeBenito 5e0da6
	selinux_set_parameters($1_t)
Chris PeBenito 0c73cd
	# Get security policy decisions:
Chris PeBenito 5e0da6
	selinux_get_fs_mount($1_t)
Chris PeBenito 5e0da6
	selinux_validate_context($1_t)
Chris PeBenito 5e0da6
	selinux_compute_access_vector($1_t)
Chris PeBenito 5e0da6
	selinux_compute_create_context($1_t)
Chris PeBenito 5e0da6
	selinux_compute_relabel_context($1_t)
Chris PeBenito 5e0da6
	selinux_compute_user_contexts($1_t)
Chris PeBenito 0c73cd
	# signal unlabeled processes:
Chris PeBenito 0fd9dc
	kernel_kill_unlabeled($1_t)
Chris PeBenito 0fd9dc
	kernel_signal_unlabeled($1_t)
Chris PeBenito 0fd9dc
	kernel_sigstop_unlabeled($1_t)
Chris PeBenito 0fd9dc
	kernel_signull_unlabeled($1_t)
Chris PeBenito 0fd9dc
	kernel_sigchld_unlabeled($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0fd9dc
	corenet_tcp_bind_generic_port($1_t)
Chris PeBenito 0c73cd
Karl MacMillan f0c985
	dev_getattr_generic_blk_file($1_t)
Karl MacMillan f0c985
	dev_getattr_generic_chr_file($1_t)
Karl MacMillan f0c985
	dev_getattr_all_blk_files($1_t)
Karl MacMillan f0c985
	dev_getattr_all_chr_files($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0fd9dc
	fs_getattr_all_fs($1_t)
Chris PeBenito 0fd9dc
	fs_set_all_quotas($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	storage_raw_read_removable_device($1_t)
Chris PeBenito 0c73cd
	storage_raw_write_removable_device($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0fd9dc
	term_use_console($1_t)
Chris PeBenito 0fd9dc
	term_use_unallocated_tty($1_t)
Chris PeBenito 0fd9dc
	term_use_all_user_ptys($1_t)
Chris PeBenito 0fd9dc
	term_use_all_user_ttys($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Manage almost all files
Chris PeBenito c9428d
	auth_manage_all_files_except_shadow($1_t)
Chris PeBenito 0c73cd
	# Relabel almost all files
Chris PeBenito c9428d
	auth_relabel_all_files_except_shadow($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	domain_setpriority_all_domains($1_t)
Chris PeBenito c9428d
	domain_read_all_domains_state($1_t)
Chris PeBenito 0c73cd
	# signal all domains:
Chris PeBenito 0c73cd
	domain_kill_all_domains($1_t)
Chris PeBenito 0c73cd
	domain_signal_all_domains($1_t)
Chris PeBenito 0c73cd
	domain_signull_all_domains($1_t)
Chris PeBenito 0c73cd
	domain_sigstop_all_domains($1_t)
Chris PeBenito 0c73cd
	domain_sigstop_all_domains($1_t)
Chris PeBenito 0c73cd
	domain_sigchld_all_domains($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_exec_usr_files($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	init_use_initctl($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	logging_send_syslog_msg($1_t)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	modutils_domtrans_insmod($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 5e0da6
	seutil_read_config($1_t)
Chris PeBenito 0c73cd
	# The following rule is temporary until such time that a complete
Chris PeBenito 0c73cd
	# policy management infrastructure is in place so that an administrator
Chris PeBenito 0c73cd
	# cannot directly manipulate policy files with arbitrary programs.
Chris PeBenito 5e0da6
	seutil_manage_src_pol($1_t)
Chris PeBenito 0c73cd
	# Violates the goal of limiting write access to checkpolicy.
Chris PeBenito 0c73cd
	# But presently necessary for installing the file_contexts file.
Chris PeBenito 5e0da6
	seutil_manage_binary_pol($1_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	optional_policy(`cron.te',`
Chris PeBenito 0c73cd
		cron_admin_template($1)
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`TODO',`
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Let admin stat the shadow file.
Chris PeBenito 0c73cd
	allow $1_t shadow_t:file getattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# for lsof
Chris PeBenito 0c73cd
	allow $1_t mtrr_device_t:file getattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t serial_device:chr_file setattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# allow setting up tunnels
Chris PeBenito 0c73cd
	allow $1_t tun_tap_device_t:chr_file rw_file_perms;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1_t ptyfile:chr_file getattr;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Run programs from staff home directories.
Chris PeBenito 0c73cd
	# Not ideal, but typical if users want to login as both sysadm_t or staff_t.
Chris PeBenito 0c73cd
	can_exec($1_t, staff_home_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Run admin programs that require different permissions in their own domain.
Chris PeBenito 0c73cd
	# These rules were moved into the appropriate program domain file.
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`startx.te', `
Chris PeBenito 0c73cd
		ifdef(`xserver.te', `
Chris PeBenito 0c73cd
			# Create files in /tmp/.X11-unix with our X servers derived
Chris PeBenito 0c73cd
			# tmp type rather than user_xserver_tmp_t.
Chris PeBenito 0c73cd
			file_type_auto_trans($1_xserver_t, xserver_tmpfile, $1_xserver_tmp_t, sock_file)
Chris PeBenito 0c73cd
		')
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	ifdef(`xdm.te', `
Chris PeBenito 0c73cd
		ifdef(`xauth.te', `
Chris PeBenito 3eed10
			tunable_policy(`xdm_sysadm_login',`
Chris PeBenito 0c73cd
				allow xdm_t $1_home_t:lnk_file read;
Chris PeBenito 0c73cd
				allow xdm_t $1_home_t:dir search;
Chris PeBenito 3eed10
			')
Chris PeBenito 0c73cd
			allow $1_t xdm_t:fifo_file rw_file_perms;
Chris PeBenito 0c73cd
		')
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# A user who is authorized for sysadm_t may nonetheless have
Chris PeBenito 0c73cd
	# a home directory labeled with user_home_t if the user is expected
Chris PeBenito 0c73cd
	# to login in either user_t or sysadm_t.  Hence, the derived domains
Chris PeBenito 0c73cd
	# for programs need to be able to access user_home_t.  
Chris PeBenito 0c73cd
	# 
Chris PeBenito 4d8ddf
Chris PeBenito 0c73cd
	# Allow our gph domain to write to .xsession-errors.
Chris PeBenito 0c73cd
	ifdef(`gnome-pty-helper.te', `
Chris PeBenito 0c73cd
		allow $1_gph_t user_home_dir_type:dir rw_dir_perms;
Chris PeBenito 0c73cd
		allow $1_gph_t user_home_type:file create_file_perms;
Chris PeBenito 0c73cd
	')
Chris PeBenito 4d8ddf
Chris PeBenito 0c73cd
	# for the administrator to run TCP servers directly
Chris PeBenito 0c73cd
	allow $1_t kernel_t:tcp_socket recvfrom;
Chris PeBenito 4d8ddf
Chris PeBenito 0c73cd
	# Connect data port to ftpd.
Chris PeBenito 0c73cd
	ifdef(`ftpd.te', `can_tcp_connect(ftpd_t, $1_t)')
Chris PeBenito 4d8ddf
Chris PeBenito 0c73cd
	# Connect second port to rshd.
Chris PeBenito 0c73cd
	ifdef(`rshd.te', `can_tcp_connect(rshd_t, $1_t)')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	# Allow MAKEDEV to work
Chris PeBenito 0c73cd
	allow $1_t device_t:dir rw_dir_perms;
Chris PeBenito 0c73cd
	allow $1_t device_type:{ blk_file chr_file } { create unlink rename };
Chris PeBenito 0c73cd
	allow $1_t device_t:lnk_file { create read };
Chris PeBenito 4d8ddf
Chris PeBenito 0c73cd
	# for lsof
Chris PeBenito 0c73cd
	allow $1_t domain:socket_class_set getattr;
Chris PeBenito 0c73cd
	allow $1_t eventpollfs_t:file getattr;
Chris PeBenito 0c73cd
	') dnl endif TODO
Chris PeBenito 4d8ddf
')
Chris PeBenito 490639
Chris PeBenito daa0e0
########################################
Chris PeBenito c9428d
## <interface name="userdom_spec_domtrans_all_users">
Chris PeBenito 4bf4ed
##	<description>
Chris PeBenito 4bf4ed
##		Execute a shell in all user domains.  This
Chris PeBenito 4bf4ed
##		is an explicit transition, requiring the
Chris PeBenito 4bf4ed
##		caller to use setexeccon().
Chris PeBenito 4bf4ed
##	</description>
Chris PeBenito 4bf4ed
##	<parameter name="domain">
Chris PeBenito 4bf4ed
##		The type of the process performing this action.
Chris PeBenito 4bf4ed
##	</parameter>
Chris PeBenito 4bf4ed
## </interface>
Chris PeBenito 4bf4ed
#
Chris PeBenito c9428d
define(`userdom_spec_domtrans_all_users',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito c9428d
	corecmd_shell_spec_domtrans($1,userdomain)
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito c9428d
define(`userdom_spec_domtrans_all_users_depend',`
Chris PeBenito 0c73cd
	type sysadm_t;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
########################################
Chris PeBenito c9428d
## <interface name="userdom_shell_domtrans_sysadm">
Chris PeBenito d490eb
##	<description>
Chris PeBenito d490eb
##		Execute a shell in the sysadm domain.
Chris PeBenito d490eb
##	</description>
Chris PeBenito d490eb
##	<parameter name="domain">
Chris PeBenito d490eb
##		The type of the process performing this action.
Chris PeBenito d490eb
##	</parameter>
Chris PeBenito d490eb
## </interface>
Chris PeBenito d490eb
#
Chris PeBenito c9428d
define(`userdom_shell_domtrans_sysadm',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	corecmd_domtrans_shell($1,sysadm_t)
Chris PeBenito d490eb
')
Chris PeBenito d490eb
Chris PeBenito c9428d
define(`userdom_shell_domtrans_sysadm_depend',`
Chris PeBenito 0c73cd
	type sysadm_t;
Chris PeBenito d490eb
')
Chris PeBenito d490eb
Chris PeBenito d490eb
########################################
Chris PeBenito c9428d
## <interface name="userdom_use_sysadm_terms">
Chris PeBenito daa0e0
##	<description>
Chris PeBenito daa0e0
##		Read and write administrative users
Chris PeBenito daa0e0
##		physical and pseudo terminals.
Chris PeBenito daa0e0
##	</description>
Chris PeBenito daa0e0
##	<parameter name="domain">
Chris PeBenito daa0e0
##		The type of the process performing this action.
Chris PeBenito daa0e0
##	</parameter>
Chris PeBenito daa0e0
## </interface>
Chris PeBenito 490639
#
Chris PeBenito c9428d
define(`userdom_use_sysadm_terms',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Karl MacMillan f0c985
	dev_list_all_dev_nodes($1)
Chris PeBenito 0fd9dc
	term_list_ptys($1)
Chris PeBenito 0c73cd
	allow $1 admin_terminal:chr_file { getattr read write ioctl };
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito c9428d
define(`userdom_use_sysadm_terms_depend',`
Chris PeBenito 0c73cd
	attribute admin_terminal;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class chr_file { getattr read write ioctl };
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito daa0e0
########################################
Chris PeBenito c9428d
## <interface name="userdom_dontaudit_use_sysadm_terms">
Chris PeBenito 763c44
##	<description>
Chris PeBenito 763c44
##		Do not audit attempts to use admin ttys and ptys.
Chris PeBenito 763c44
##	</description>
Chris PeBenito 763c44
##	<parameter name="domain">
Chris PeBenito 763c44
##		The type of the process performing this action.
Chris PeBenito 763c44
##	</parameter>
Chris PeBenito 763c44
## </interface>
Chris PeBenito 763c44
#
Chris PeBenito c9428d
define(`userdom_dontaudit_use_sysadm_terms',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 763c44
Chris PeBenito 763c44
	dontaudit $1 admin_terminal:chr_file { read write };
Chris PeBenito 763c44
')
Chris PeBenito 763c44
Chris PeBenito c9428d
define(`userdom_dontaudit_use_sysadm_terms_depend',`
Chris PeBenito 763c44
	attribute admin_terminal;
Chris PeBenito 763c44
Chris PeBenito 763c44
	class chr_file { read write };
Chris PeBenito 763c44
')
Chris PeBenito 763c44
Chris PeBenito 763c44
########################################
Chris PeBenito c9428d
## <interface name="userdom_search_all_users_home">
Chris PeBenito 4bf4ed
##	<description>
Chris PeBenito 4bf4ed
##		Search all users home directories.
Chris PeBenito 4bf4ed
##	</description>
Chris PeBenito 4bf4ed
##	<parameter name="domain">
Chris PeBenito 4bf4ed
##		The type of the process performing this action.
Chris PeBenito 4bf4ed
##	</parameter>
Chris PeBenito 4bf4ed
## </interface>
Chris PeBenito 4bf4ed
#
Chris PeBenito c9428d
define(`userdom_search_all_users_home',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_list_home($1)
Chris PeBenito 0c73cd
	allow $1 { home_dir_type home_type }:dir search;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito c9428d
define(`userdom_search_all_users_home_depend',`
Chris PeBenito 0c73cd
	attribute home_dir_type, home_type;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class dir search;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
########################################
Chris PeBenito c9428d
## <interface name="userdom_read_all_user_data">
Chris PeBenito daa0e0
##	<description>
Chris PeBenito 4bf4ed
##		Read all files in all users home directories.
Chris PeBenito daa0e0
##	</description>
Chris PeBenito daa0e0
##	<parameter name="domain">
Chris PeBenito daa0e0
##		The type of the process performing this action.
Chris PeBenito daa0e0
##	</parameter>
Chris PeBenito daa0e0
## </interface>
Chris PeBenito daa0e0
#
Chris PeBenito c9428d
define(`userdom_read_all_user_data',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_list_home($1)
Chris PeBenito cc41a9
	allow $1 home_type:dir r_dir_perms;
Chris PeBenito 0fd9dc
	allow $1 home_type:file r_file_perms;
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito c9428d
define(`userdom_read_all_user_data_depend',`
Chris PeBenito 0c73cd
	attribute home_type;
Chris PeBenito 0c73cd
Chris PeBenito cc41a9
	class dir r_dir_perms;
Chris PeBenito cc41a9
	class file r_file_perms;
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito daa0e0
########################################
Chris PeBenito c9428d
## <interface name="userdom_use_all_user_fd">
Chris PeBenito 490639
##	<description>
Chris PeBenito 490639
##		Inherit the file descriptors from all user domains
Chris PeBenito 490639
##	</description>
Chris PeBenito 490639
##	<parameter name="domain">
Chris PeBenito 490639
##		The type of the process performing this action.
Chris PeBenito 490639
##	</parameter>
Chris PeBenito 490639
## </interface>
Chris PeBenito 490639
#
Chris PeBenito c9428d
define(`userdom_use_all_user_fd',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 userdomain:fd use;
Chris PeBenito 490639
')
Chris PeBenito 490639
Chris PeBenito c9428d
define(`userdom_use_all_user_fd_depend',`
Chris PeBenito 0c73cd
	attribute userdomain;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class fd use;
Chris PeBenito 490639
')
Chris PeBenito 490639
Chris PeBenito daa0e0
########################################
Chris PeBenito c9428d
## <interface name="userdom_signal_all_users">
Chris PeBenito 4bf4ed
##	<description>
Chris PeBenito 4bf4ed
##		Send general signals to all user domains.
Chris PeBenito 4bf4ed
##	</description>
Chris PeBenito 4bf4ed
##	<parameter name="domain">
Chris PeBenito 4bf4ed
##		The type of the process performing this action.
Chris PeBenito 4bf4ed
##	</parameter>
Chris PeBenito 4bf4ed
## </interface>
Chris PeBenito 4bf4ed
#
Chris PeBenito c9428d
define(`userdom_signal_all_users',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 userdomain:process signal;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito c9428d
define(`userdom_signal_all_users_depend',`
Chris PeBenito 0c73cd
	attribute userdomain;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class process signal;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
########################################
Chris PeBenito c9428d
## <interface name="userdom_use_unpriv_users_fd">
Chris PeBenito daa0e0
##	<description>
Chris PeBenito daa0e0
##		Inherit the file descriptors from all user domains.
Chris PeBenito daa0e0
##	</description>
Chris PeBenito daa0e0
##	<parameter name="domain">
Chris PeBenito daa0e0
##		The type of the process performing this action.
Chris PeBenito daa0e0
##	</parameter>
Chris PeBenito daa0e0
## </interface>
Chris PeBenito daa0e0
#
Chris PeBenito c9428d
define(`userdom_use_unpriv_users_fd',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 unpriv_userdomain:fd use;
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito c9428d
define(`userdom_use_unpriv_users_fd_depend',`
Chris PeBenito 0c73cd
	attribute unpriv_userdomain;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class fd use;
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito daa0e0
########################################
Chris PeBenito c9428d
## <interface name="userdom_dontaudit_use_unpriv_user_fd">
Chris PeBenito daa0e0
##	<description>
Chris PeBenito daa0e0
##		Do not audit attempts to inherit the
Chris PeBenito daa0e0
##		file descriptors from all user domains.
Chris PeBenito daa0e0
##	</description>
Chris PeBenito daa0e0
##	<parameter name="domain">
Chris PeBenito daa0e0
##		The type of the process performing this action.
Chris PeBenito daa0e0
##	</parameter>
Chris PeBenito daa0e0
## </interface>
Chris PeBenito daa0e0
#
Chris PeBenito c9428d
define(`userdom_dontaudit_use_unpriv_user_fd',`
Chris PeBenito fa7bea
	gen_require(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	dontaudit $1 unpriv_userdomain:fd use;
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito c9428d
define(`userdom_dontaudit_use_unpriv_user_fd_depend',`
Chris PeBenito 0c73cd
	attribute unpriv_userdomain;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class fd use;
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito 490639
## </module>