Chris PeBenito 4bf4ed
## <summary>Policy common to all email tranfer agents.</summary>
Chris PeBenito 6b9383
Chris PeBenito 12ae75
########################################
Chris PeBenito 12ae75
## <summary>
Chris PeBenito 12ae75
##	MTA stub interface.  No access allowed.
Chris PeBenito 12ae75
## </summary>
Chris PeBenito 12ae75
## <param name="domain" optional="true">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 12ae75
##	N/A
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 12ae75
## </param>
Chris PeBenito 12ae75
#
Chris PeBenito 12ae75
interface(`mta_stub',`
Chris PeBenito 12ae75
	gen_require(`
Chris PeBenito 12ae75
		type sendmail_exec_t;
Chris PeBenito 12ae75
	')
Chris PeBenito 12ae75
')
Chris PeBenito 12ae75
Chris PeBenito 6b9383
#######################################
Chris PeBenito 451c1e
## <summary>
Chris PeBenito 08cd98
##	Basic mail transfer agent domain template.
Chris PeBenito 451c1e
## </summary>
Chris PeBenito 451c1e
## <desc>
Chris PeBenito 451c1e
##	

Chris PeBenito 451c1e
##	This template creates a derived domain which is
Chris PeBenito 451c1e
##	a email transfer agent, which sends mail on
Chris PeBenito 451c1e
##	behalf of the user.
Chris PeBenito 451c1e
##	

Chris PeBenito 451c1e
##	

Chris PeBenito 08cd98
##	This is the basic types and rules, common
Chris PeBenito 1504ff
##	to the system agent and user agents.
Chris PeBenito 451c1e
##	

Chris PeBenito 451c1e
## </desc>
Chris PeBenito 08cd98
## <param name="domain_prefix">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 08cd98
##	The prefix of the domain (e.g., user
Chris PeBenito 451c1e
##	is the prefix for user_t).
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 451c1e
## </param>
Chris PeBenito 6b9383
#
Chris PeBenito 08cd98
template(`mta_base_mail_template',`
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	##############################
Chris PeBenito 08cd98
	#
Chris PeBenito 08cd98
	# $1_mail_t declarations
Chris PeBenito 08cd98
	#
Chris PeBenito 0efe52
Chris PeBenito 04926d
	type $1_mail_t, user_mail_domain;
Chris PeBenito c9428d
	domain_type($1_mail_t)
Chris PeBenito 08cd98
	domain_entry_file($1_mail_t,sendmail_exec_t)
Chris PeBenito 6b9383
Chris PeBenito 9fd4b8
	type $1_mail_tmp_t;
Chris PeBenito 9fd4b8
	files_tmp_file($1_mail_tmp_t)
Chris PeBenito 6b9383
Chris PeBenito 0c73cd
	##############################
Chris PeBenito 0c73cd
	#
Chris PeBenito 0c73cd
	# $1_mail_t local policy
Chris PeBenito 0c73cd
	#
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	allow $1_mail_t self:capability { setuid setgid chown };
Chris PeBenito 0a10b1
	allow $1_mail_t self:process { signal_perms setrlimit };
Chris PeBenito 0a10b1
	allow $1_mail_t self:tcp_socket create_socket_perms;
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# re-exec itself
Chris PeBenito 0a10b1
	can_exec($1_mail_t, sendmail_exec_t)
Chris PeBenito 0a10b1
	allow $1_mail_t sendmail_exec_t:lnk_file r_file_perms;
Chris PeBenito 075c4f
Chris PeBenito 445522
	kernel_read_kernel_sysctls($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_if($1_mail_t)
Chris PeBenito 0fd9dc
	corenet_raw_sendrecv_all_if($1_mail_t)
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_nodes($1_mail_t)
Chris PeBenito 0fd9dc
	corenet_raw_sendrecv_all_nodes($1_mail_t)
Chris PeBenito 0fd9dc
	corenet_tcp_sendrecv_all_ports($1_mail_t)
Chris PeBenito bd7037
	corenet_non_ipsec_sendrecv($1_mail_t)
Chris PeBenito 0fd9dc
	corenet_tcp_bind_all_nodes($1_mail_t)
Chris PeBenito cff75c
	corenet_tcp_connect_all_ports($1_mail_t)
Chris PeBenito 08cd98
	corenet_tcp_connect_smtp_port($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
	corecmd_exec_bin($1_mail_t)
Chris PeBenito b24f35
	corecmd_search_sbin($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 8fd367
	files_read_etc_files($1_mail_t)
Chris PeBenito b24f35
	files_search_spool($1_mail_t)
Chris PeBenito 246839
	# It wants to check for nscd
Chris PeBenito 246839
	files_dontaudit_search_pids($1_mail_t)
Chris PeBenito 6b9383
Chris PeBenito 08cd98
	libs_use_ld_so($1_mail_t)
Chris PeBenito 08cd98
	libs_use_shared_libs($1_mail_t)
Chris PeBenito 08cd98
Chris PeBenito c9428d
	logging_send_syslog_msg($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	miscfiles_read_localization($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
	sysnet_read_config($1_mail_t)
Chris PeBenito 98a8ea
	sysnet_dns_name_resolve($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 08cd98
	optional_policy(`nis',`
Chris PeBenito 08cd98
		nis_use_ypbind($1_mail_t)
Chris PeBenito 08cd98
	')
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	optional_policy(`nscd',`
Chris PeBenito 1815ba
		nscd_socket_use($1_mail_t)
Chris PeBenito 08cd98
	')
Chris PeBenito 08cd98
Chris PeBenito fc0e8c
	optional_policy(`postfix',`
Chris PeBenito fc0e8c
		postfix_domtrans_user_mail_handler($1_mail_t)
Chris PeBenito fc0e8c
	')
Chris PeBenito fc0e8c
Chris PeBenito 08cd98
	optional_policy(`procmail',`
Chris PeBenito 08cd98
		procmail_exec($1_mail_t)
Chris PeBenito 08cd98
	')
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	optional_policy(`sendmail',`
Chris PeBenito 9fd4b8
		gen_require(`
Chris PeBenito 9fd4b8
			type etc_mail_t, mail_spool_t, mqueue_spool_t;
Chris PeBenito 9fd4b8
		')
Chris PeBenito 9fd4b8
Chris PeBenito 08cd98
		allow $1_mail_t $1_mail_tmp_t:dir create_dir_perms;
Chris PeBenito 08cd98
		allow $1_mail_t $1_mail_tmp_t:file create_file_perms;
Chris PeBenito 103fe2
		files_tmp_filetrans($1_mail_t, $1_mail_tmp_t, { file dir })
Chris PeBenito 08cd98
Chris PeBenito 08cd98
		allow $1_mail_t etc_mail_t:dir { getattr search };
Chris PeBenito 08cd98
Chris PeBenito 08cd98
		# Write to /var/spool/mail and /var/spool/mqueue.
Chris PeBenito 08cd98
		allow $1_mail_t mail_spool_t:dir rw_dir_perms;
Chris PeBenito 08cd98
		allow $1_mail_t mail_spool_t:file create_file_perms;
Chris PeBenito 08cd98
		allow $1_mail_t mqueue_spool_t:dir rw_dir_perms;
Chris PeBenito 08cd98
		allow $1_mail_t mqueue_spool_t:file create_file_perms;
Chris PeBenito 08cd98
Chris PeBenito 08cd98
		# Check available space.
Chris PeBenito 08cd98
		fs_getattr_xattr_fs($1_mail_t)
Chris PeBenito 08cd98
Chris PeBenito 08cd98
		files_read_etc_runtime_files($1_mail_t)
Chris PeBenito 08cd98
Chris PeBenito 08cd98
		# Write to /var/log/sendmail.st
Chris PeBenito 08cd98
		sendmail_manage_log($1_mail_t)
Chris PeBenito 08cd98
		sendmail_create_log($1_mail_t)
Chris PeBenito 08cd98
	')
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	ifdef(`TODO',`
Chris PeBenito 08cd98
	ifdef(`qmail.te', `
Chris PeBenito 08cd98
		allow $1_mail_t qmail_etc_t:dir search;
Chris PeBenito 08cd98
		allow $1_mail_t qmail_etc_t:{ file lnk_file } read;
Chris PeBenito 08cd98
	')
Chris PeBenito 08cd98
	') dnl end TODO
Chris PeBenito 08cd98
')
Chris PeBenito 08cd98
Chris PeBenito 08cd98
#######################################
Chris PeBenito 08cd98
## <summary>
Chris PeBenito 08cd98
##	The per user domain template for the mta module.
Chris PeBenito 08cd98
## </summary>
Chris PeBenito 08cd98
## <desc>
Chris PeBenito 08cd98
##	

Chris PeBenito 08cd98
##	This template creates a derived domain which is
Chris PeBenito 08cd98
##	a email transfer agent, which sends mail on
Chris PeBenito 08cd98
##	behalf of the user.
Chris PeBenito 08cd98
##	

Chris PeBenito 08cd98
##	

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

Chris PeBenito 08cd98
## </desc>
Chris PeBenito 08cd98
## <param name="userdomain_prefix">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 08cd98
##	The prefix of the user domain (e.g., user
Chris PeBenito 08cd98
##	is the prefix for user_t).
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 08cd98
## </param>
Chris PeBenito 08cd98
## <param name="user_domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 08cd98
##	The type of the user domain.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 08cd98
## </param>
Chris PeBenito 08cd98
## <param name="user_role">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 08cd98
##	The role associated with the user domain.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 08cd98
## </param>
Chris PeBenito 08cd98
#
Chris PeBenito 08cd98
template(`mta_per_userdomain_template',`
Chris PeBenito 9417cb
Chris PeBenito 9417cb
	##############################
Chris PeBenito 9417cb
	#
Chris PeBenito 9417cb
	# Declarations
Chris PeBenito 9417cb
	#
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	mta_base_mail_template($1)
Chris PeBenito 08cd98
	role $3 types $1_mail_t;
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	##############################
Chris PeBenito 08cd98
	#
Chris PeBenito 08cd98
	# $1_mail_t local policy
Chris PeBenito 08cd98
	#
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	# Transition from the user domain to the derived domain.
Chris PeBenito 08cd98
	domain_auto_trans($2, sendmail_exec_t, $1_mail_t)
Chris PeBenito 08cd98
	allow $2 sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	allow $2 $1_mail_t:fd use;
Chris PeBenito 08cd98
	allow $1_mail_t $2:fd use;
Chris PeBenito 08cd98
	allow $1_mail_t $2:fifo_file rw_file_perms;
Chris PeBenito 08cd98
	allow $1_mail_t $2:process sigchld;
Chris PeBenito 08cd98
Chris PeBenito 08cd98
	# For when the user wants to send mail via port 25 localhost
Chris PeBenito 08cd98
	kernel_tcp_recvfrom($2)
Chris PeBenito 08cd98
	allow $2 mailserver_domain:tcp_socket { connectto recvfrom };
Chris PeBenito 08cd98
	allow mailserver_domain $2:tcp_socket { acceptfrom recvfrom };
Chris PeBenito 08cd98
Chris PeBenito 15722e
	domain_use_interactive_fds($1_mail_t)
Chris PeBenito 08cd98
Chris PeBenito 451c1e
	userdom_use_user_terminals($1,$1_mail_t)
Chris PeBenito 246839
	# Write to the user domain tty. cjp: why?
Chris PeBenito 246839
	userdom_use_user_terminals($1,mta_user_agent)
Chris PeBenito 88dd38
	# Create dead.letter in user home directories.
Chris PeBenito 103fe2
	userdom_manage_user_home_content_files($1,$1_mail_t)
Chris PeBenito 103fe2
	userdom_user_home_dir_filetrans_user_home_content($1,$1_mail_t,file)
Chris PeBenito 88dd38
	# for reading .forward - maybe we need a new type for it?
Chris PeBenito 88dd38
	# also for delivering mail to maildir
Chris PeBenito 103fe2
	userdom_manage_user_home_content_dirs($1,mailserver_delivery)
Chris PeBenito 103fe2
	userdom_manage_user_home_content_files($1,mailserver_delivery)
Chris PeBenito 103fe2
	userdom_manage_user_home_content_symlinks($1,mailserver_delivery)
Chris PeBenito 103fe2
	userdom_manage_user_home_content_pipes($1,mailserver_delivery)
Chris PeBenito 103fe2
	userdom_manage_user_home_content_sockets($1,mailserver_delivery)
Chris PeBenito 103fe2
	userdom_user_home_dir_filetrans_user_home_content($1,mailserver_delivery,{ dir file lnk_file fifo_file sock_file })
Chris PeBenito 807a77
	# Read user temporary files.
Chris PeBenito 807a77
	userdom_read_user_tmp_files($1,$1_mail_t)
Chris PeBenito 807a77
	userdom_dontaudit_append_user_tmp_files($1,$1_mail_t)
Chris PeBenito 807a77
	# cjp: this should probably be read all user tmp
Chris PeBenito 807a77
	# files in an appropriate place for mta_user_agent
Chris PeBenito 807a77
	userdom_read_user_tmp_files($1,mta_user_agent)
Chris PeBenito 451c1e
Chris PeBenito b24f35
	tunable_policy(`use_samba_home_dirs',`
Chris PeBenito b24f35
		fs_manage_cifs_files($1_mail_t)
Chris PeBenito b24f35
		fs_manage_cifs_symlinks($1_mail_t)
Chris PeBenito b24f35
	')
Chris PeBenito b24f35
Chris PeBenito 132880
	optional_policy(`postfix',`
Chris PeBenito 04926d
		allow $1_mail_t self:capability dac_override;
Chris PeBenito 04926d
Chris PeBenito 807a77
		# Read user temporary files.
Chris PeBenito 0c73cd
		# postfix seems to need write access if the file handle is opened read/write
Chris PeBenito 807a77
		userdom_rw_user_tmp_files($1,$1_mail_t)
Chris PeBenito 807a77
Chris PeBenito 807a77
		postfix_read_config($1_mail_t)
Chris PeBenito 807a77
		postfix_list_spool($1_mail_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
Chris PeBenito 807a77
	ifdef(`TODO',`
Chris PeBenito 0c73cd
	# if you do not want to allow dead.letter then use the following instead
Chris PeBenito 0c73cd
	#allow $1_mail_t { $1_home_dir_t $1_home_t }:dir r_dir_perms;
Chris PeBenito 0c73cd
	#allow $1_mail_t $1_home_t:file r_file_perms;
Chris PeBenito 0c73cd
	') dnl end TODO
Chris PeBenito 6b9383
')
Chris PeBenito 6b9383
Chris PeBenito 1504ff
########################################
Chris PeBenito 1504ff
## <summary>
Chris PeBenito 1504ff
##	Provide extra permissions for admin users
Chris PeBenito 1504ff
##	mail domain.
Chris PeBenito 1504ff
## </summary>
Chris PeBenito 1504ff
## <param name="userdomain_prefix">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 1504ff
##	The prefix of the user domain (e.g., user
Chris PeBenito 1504ff
##	is the prefix for user_t).
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 1504ff
## </param>
Chris PeBenito 1504ff
## <param name="user_domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 1504ff
##	The type of the user domain.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 1504ff
## </param>
Chris PeBenito 1504ff
#
Chris PeBenito 1504ff
template(`mta_admin_template',`
Chris PeBenito 4ace0f
	gen_require(`
Chris PeBenito 4ace0f
		type $1_mail_t;
Chris PeBenito 4ace0f
	')
Chris PeBenito 4ace0f
Chris PeBenito 1504ff
	ifdef(`strict_policy',`
Chris PeBenito 1504ff
		# allow the sysadmin to do "mail someone < /home/user/whatever"
Chris PeBenito 103fe2
		userdom_read_unpriv_users_home_content_files($1_mail_t)
Chris PeBenito 1504ff
	')
Chris PeBenito 1504ff
Chris PeBenito 1504ff
	optional_policy(`postfix',`
Chris PeBenito 1504ff
		gen_require(`
Chris PeBenito 1504ff
			attribute mta_user_agent;
Chris PeBenito 1504ff
			type etc_aliases_t;
Chris PeBenito 1504ff
		')
Chris PeBenito 1504ff
Chris PeBenito 1504ff
		allow mta_user_agent $2:fifo_file { read write };
Chris PeBenito 1504ff
Chris PeBenito 1504ff
		allow $1_mail_t etc_aliases_t:dir create_dir_perms;
Chris PeBenito 1504ff
		allow $1_mail_t etc_aliases_t:file create_file_perms;
Chris PeBenito 1504ff
		allow $1_mail_t etc_aliases_t:lnk_file create_lnk_perms;
Chris PeBenito 1504ff
		allow $1_mail_t etc_aliases_t:sock_file create_file_perms;
Chris PeBenito 1504ff
		allow $1_mail_t etc_aliases_t:fifo_file create_file_perms;
Chris PeBenito 103fe2
		files_etc_filetrans($1_mail_t,etc_aliases_t,{ file lnk_file sock_file fifo_file })
Chris PeBenito 1504ff
Chris PeBenito 1504ff
		# postfix needs this for newaliases
Chris PeBenito 9e04f5
		files_getattr_tmp_dirs($1_mail_t)
Chris PeBenito 1504ff
Chris PeBenito 1504ff
		postfix_exec_master($1_mail_t)
Chris PeBenito 1504ff
Chris PeBenito 1504ff
		ifdef(`distro_redhat',`
Chris PeBenito 1504ff
			# compatability for old default main.cf
Chris PeBenito 103fe2
			postfix_config_filetrans($1_mail_t,etc_aliases_t,{ dir file lnk_file sock_file fifo_file })
Chris PeBenito 1504ff
		')
Chris PeBenito 1504ff
	')
Chris PeBenito 1504ff
')
Chris PeBenito 1504ff
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito c9428d
# mta_mailserver(domain,entrypointtype)
Chris PeBenito 075c4f
#
Chris PeBenito 199895
interface(`mta_mailserver',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		attribute mailserver_domain;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito 246839
	# For when the user wants to send mail via port 25 localhost
Chris PeBenito 246839
	kernel_tcp_recvfrom($1)
Chris PeBenito 246839
Chris PeBenito c9428d
	init_daemon_domain($1,$2)
Chris PeBenito 0c73cd
	typeattribute $1 mailserver_domain;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito e5f806
########################################
Chris PeBenito e5f806
## <summary>
Chris PeBenito e5f806
##	Modified mailserver interface for
Chris PeBenito e5f806
##	sendmail daemon use.
Chris PeBenito e5f806
## </summary>
Chris PeBenito e5f806
## <desc>
Chris PeBenito e5f806
##	

Chris PeBenito e5f806
##	A modified MTA mail server interface for
Chris PeBenito e5f806
##	the sendmail program.  It's design does
Chris PeBenito e5f806
##	not fit well with policy, and using the
Chris PeBenito e5f806
##	regular interface causes a type_transition
Chris PeBenito e5f806
##	conflict if direct running of init scripts
Chris PeBenito e5f806
##	is enabled.
Chris PeBenito e5f806
##	

Chris PeBenito e5f806
##	

Chris PeBenito e5f806
##	This interface should most likely only be used
Chris PeBenito e5f806
##	by the sendmail policy.
Chris PeBenito e5f806
##	

Chris PeBenito e5f806
## </desc>
Chris PeBenito e5f806
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito e5f806
##	The type to be used for the mail server.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito e5f806
## </param>
Chris PeBenito e5f806
## <param name="entry_point">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito e5f806
##	The type to be used for the domain entry point program.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito e5f806
## </param>
Chris PeBenito 199895
interface(`mta_sendmail_mailserver',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito e5f806
		attribute mailserver_domain;
Chris PeBenito 5e6f9e
		type sendmail_exec_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito 246839
	# For when the user wants to send mail via port 25 localhost
Chris PeBenito 246839
	kernel_tcp_recvfrom($1)
Chris PeBenito 246839
Chris PeBenito e5f806
	init_system_domain($1,sendmail_exec_t)
Chris PeBenito e5f806
	typeattribute $1 mailserver_domain;
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 246839
## <summary>
Chris PeBenito 246839
##	Make a type a mailserver type used
Chris PeBenito 246839
##	for sending mail.
Chris PeBenito 246839
## </summary>
Chris PeBenito 246839
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 246839
##	Mail server domain type used for sending mail.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 246839
## </param>
Chris PeBenito 246839
#
Chris PeBenito 246839
interface(`mta_mailserver_sender',`
Chris PeBenito 246839
	gen_require(`
Chris PeBenito 246839
		attribute mailserver_sender;
Chris PeBenito 246839
	')
Chris PeBenito 246839
Chris PeBenito 246839
	typeattribute $1 mailserver_sender;
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito 246839
#######################################
Chris PeBenito 246839
## <summary>
Chris PeBenito 246839
##	Make a type a mailserver type used
Chris PeBenito 246839
##	for delivering mail to local users.
Chris PeBenito 246839
## </summary>
Chris PeBenito 246839
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 246839
##	Mail server domain type used for delivering mail.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 246839
## </param>
Chris PeBenito 246839
#
Chris PeBenito 246839
interface(`mta_mailserver_delivery',`
Chris PeBenito 246839
	gen_require(`
Chris PeBenito 246839
		attribute mailserver_delivery;
Chris PeBenito 88dd38
		type mail_spool_t;
Chris PeBenito 246839
	')
Chris PeBenito 246839
Chris PeBenito 246839
	typeattribute $1 mailserver_delivery;
Chris PeBenito 799a0b
Chris PeBenito 88dd38
	allow $1 mail_spool_t:dir ra_dir_perms;
Chris PeBenito 88dd38
	allow $1 mail_spool_t:file { create ioctl read getattr lock append };
Chris PeBenito 88dd38
	allow $1 mail_spool_t:lnk_file { create read getattr };
Chris PeBenito 88dd38
Chris PeBenito 132880
	optional_policy(`dovecot',`
Chris PeBenito 29ce00
		dovecot_manage_spool($1)
Chris PeBenito 29ce00
	')
Chris PeBenito 29ce00
Chris PeBenito 132880
	optional_policy(`mailman',`
Chris PeBenito 799a0b
		# so MTA can access /var/lib/mailman/mail/wrapper
Chris PeBenito 799a0b
		files_search_var_lib($1)
Chris PeBenito 799a0b
Chris PeBenito 799a0b
		mailman_domtrans($1)
Chris PeBenito 799a0b
		mailman_read_data_symlinks($1)
Chris PeBenito 799a0b
	')
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito 246839
#######################################
Chris PeBenito 246839
## <summary>
Chris PeBenito 246839
##	Make a type a mailserver type used
Chris PeBenito 246839
##	for sending mail on behalf of local
Chris PeBenito 246839
##	users to the local mail spool.
Chris PeBenito 246839
## </summary>
Chris PeBenito 246839
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 246839
##	Mail server domain type used for sending local mail.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 246839
## </param>
Chris PeBenito 246839
#
Chris PeBenito 246839
interface(`mta_mailserver_user_agent',`
Chris PeBenito 246839
	gen_require(`
Chris PeBenito e749cd
		attribute mta_user_agent;
Chris PeBenito 246839
	')
Chris PeBenito 246839
Chris PeBenito e749cd
	typeattribute $1 mta_user_agent;
Chris PeBenito e749cd
Chris PeBenito 132880
	optional_policy(`apache',`
Chris PeBenito e749cd
		# apache should set close-on-exec
Chris PeBenito 1815ba
		apache_dontaudit_rw_stream_sockets($1)
Chris PeBenito 1815ba
		apache_dontaudit_rw_sys_script_stream_sockets($1)
Chris PeBenito e749cd
	')
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito 246839
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito c6a3a2
# mta_send_mail(domain)
Chris PeBenito 075c4f
#
Chris PeBenito 199895
interface(`mta_send_mail',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 88dd38
		attribute mta_user_agent;
Chris PeBenito 5e6f9e
		type system_mail_t, sendmail_exec_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito 0a10b1
	allow $1 sendmail_exec_t:lnk_file r_file_perms;
Chris PeBenito 0a10b1
	domain_auto_trans($1, sendmail_exec_t, system_mail_t)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 system_mail_t:fd use;
Chris PeBenito 0c73cd
	allow system_mail_t $1:fd use;
Chris PeBenito 0c73cd
	allow system_mail_t $1:fifo_file rw_file_perms;
Chris PeBenito 0c73cd
	allow system_mail_t $1:process sigchld;
Chris PeBenito 953541
Chris PeBenito 953541
	allow mta_user_agent $1:fd use;
Chris PeBenito 953541
	allow mta_user_agent $1:process sigchld;
Chris PeBenito 953541
	allow mta_user_agent $1:fifo_file { read write };
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito c9428d
# mta_exec(domain)
Chris PeBenito 075c4f
#
Chris PeBenito 199895
interface(`mta_exec',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		type sendmail_exec_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito 0a10b1
	can_exec($1, sendmail_exec_t)
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito daa0e0
########################################
Chris PeBenito f7ebea
## <summary>
Chris PeBenito f932d8
##	Read mail server configuration.
Chris PeBenito f932d8
## </summary>
Chris PeBenito f932d8
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito cc5df2
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito f932d8
## </param>
Chris PeBenito f932d8
#
Chris PeBenito f932d8
interface(`mta_read_config',`
Chris PeBenito f932d8
	gen_require(`
Chris PeBenito f932d8
		type etc_mail_t;
Chris PeBenito f932d8
	')
Chris PeBenito f932d8
Chris PeBenito f932d8
	files_search_etc($1)
Chris PeBenito 30705b
	allow $1 etc_mail_t:dir list_dir_perms;
Chris PeBenito 30705b
	allow $1 etc_mail_t:file r_file_perms;
Chris PeBenito 30705b
	allow $1 etc_mail_t:lnk_file { getattr read };
Chris PeBenito f932d8
')
Chris PeBenito f932d8
Chris PeBenito f932d8
########################################
Chris PeBenito f932d8
## <summary>
Chris PeBenito 414e41
##	Read mail address aliases.
Chris PeBenito f7ebea
## </summary>
Chris PeBenito 414e41
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito cc5df2
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 414e41
## </param>
Chris PeBenito daa0e0
#
Chris PeBenito 199895
interface(`mta_read_aliases',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		type etc_aliases_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito 5e6f9e
	files_search_etc($1)
Chris PeBenito 0a10b1
	allow $1 etc_aliases_t:file r_file_perms;
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito cc5df2
########################################
Chris PeBenito cc5df2
## <summary>
Chris PeBenito cc5df2
##	Type transition files created in /etc
Chris PeBenito cc5df2
##	to the mail address aliases type.
Chris PeBenito cc5df2
## </summary>
Chris PeBenito cc5df2
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito cc5df2
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito cc5df2
## </param>
Chris PeBenito cc5df2
#
Chris PeBenito 103fe2
interface(`mta_etc_filetrans_aliases',`
Chris PeBenito cc5df2
	gen_require(`
Chris PeBenito cc5df2
		type etc_aliases_t;
Chris PeBenito cc5df2
	')
Chris PeBenito cc5df2
Chris PeBenito 103fe2
	files_etc_filetrans($1,etc_aliases_t, file)
Chris PeBenito cc5df2
')
Chris PeBenito cc5df2
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito c9428d
# mta_rw_aliases(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 199895
interface(`mta_rw_aliases',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		type etc_aliases_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito 5e6f9e
	files_search_etc($1)
Chris PeBenito 04926d
	allow $1 etc_aliases_t:file { rw_file_perms setattr };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito a42ca7
## <summary>
Chris PeBenito 799a0b
##	Do not audit attempts to read and write TCP
Chris PeBenito 799a0b
##	sockets of mail delivery domains.
Chris PeBenito 799a0b
## </summary>
Chris PeBenito 799a0b
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 799a0b
##	Mail server domain.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 799a0b
## </param>
Chris PeBenito 799a0b
#
Chris PeBenito 1815ba
interface(`mta_dontaudit_rw_delivery_tcp_sockets',`
Chris PeBenito 799a0b
	gen_require(`
Chris PeBenito 77f6e2
		attribute mailserver_delivery;
Chris PeBenito 799a0b
	')
Chris PeBenito 799a0b
Chris PeBenito 799a0b
	dontaudit $1 mailserver_delivery:tcp_socket { read write };
Chris PeBenito 799a0b
')
Chris PeBenito 799a0b
Chris PeBenito 799a0b
#######################################
Chris PeBenito 799a0b
## <summary>
Chris PeBenito 799a0b
##	Connect to all mail servers over TCP.
Chris PeBenito 799a0b
## </summary>
Chris PeBenito 799a0b
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 799a0b
##	Mail server domain.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 799a0b
## </param>
Chris PeBenito 799a0b
#
Chris PeBenito 799a0b
interface(`mta_tcp_connect_all_mailservers',`
Chris PeBenito 799a0b
	gen_require(`
Chris PeBenito 799a0b
		attribute mailserver_domain;
Chris PeBenito 799a0b
	')
Chris PeBenito 799a0b
Chris PeBenito 799a0b
	allow $1 mailserver_domain:tcp_socket { connectto recvfrom };
Chris PeBenito 799a0b
	allow mailserver_domain $1:tcp_socket { acceptfrom recvfrom };
Chris PeBenito 799a0b
	kernel_tcp_recvfrom($1)
Chris PeBenito 799a0b
')
Chris PeBenito 799a0b
Chris PeBenito 799a0b
#######################################
Chris PeBenito 799a0b
## <summary>
Chris PeBenito a42ca7
##	Do not audit attempts to read a symlink
Chris PeBenito a42ca7
##	in the mail spool.
Chris PeBenito a42ca7
## </summary>
Chris PeBenito a42ca7
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito a42ca7
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito a42ca7
## </param>
Chris PeBenito a42ca7
#
Chris PeBenito 1815ba
interface(`mta_dontaudit_read_spool_symlinks',`
Chris PeBenito a42ca7
	gen_require(`
Chris PeBenito a42ca7
		type mail_spool_t;
Chris PeBenito a42ca7
	')
Chris PeBenito a42ca7
Chris PeBenito a42ca7
	dontaudit $1 mail_spool_t:lnk_file read;
Chris PeBenito a42ca7
')
Chris PeBenito a42ca7
Chris PeBenito a42ca7
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito c9428d
# mta_getattr_spool(domain)
Chris PeBenito 4bf4ed
#
Chris PeBenito 199895
interface(`mta_getattr_spool',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		type mail_spool_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_search_spool($1)
Chris PeBenito 0c73cd
	allow $1 mail_spool_t:dir r_dir_perms;
Chris PeBenito 0c73cd
	allow $1 mail_spool_t:lnk_file read;
Chris PeBenito 0c73cd
	allow $1 mail_spool_t:file getattr;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito 1815ba
interface(`mta_dontaudit_getattr_spool_files',`
Chris PeBenito 0f5d13
	gen_require(`
Chris PeBenito 0f5d13
		type mail_spool_t;
Chris PeBenito 0f5d13
	')
Chris PeBenito 0f5d13
Chris PeBenito 0f5d13
	files_dontaudit_search_spool($1)
Chris PeBenito 0f5d13
	dontaudit $1 mail_spool_t:dir search;
Chris PeBenito 0f5d13
	dontaudit $1 mail_spool_t:lnk_file read;
Chris PeBenito 0f5d13
	dontaudit $1 mail_spool_t:file getattr;
Chris PeBenito 0f5d13
')
Chris PeBenito 0f5d13
Chris PeBenito 4bf4ed
#######################################
Chris PeBenito a089b6
## <summary>
Chris PeBenito a089b6
##	Create private objects in the 
Chris PeBenito a089b6
##	mail spool directory.
Chris PeBenito a089b6
## </summary>
Chris PeBenito a089b6
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito a089b6
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito a089b6
## </param>
Chris PeBenito a089b6
## <param name="private type">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito a089b6
##	The type of the object to be created.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito a089b6
## </param>
Chris PeBenito 1c1ac6
## <param name="object">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 1c1ac6
##	The object class of the object being created.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito a089b6
## </param>
Chris PeBenito a089b6
#
Chris PeBenito 103fe2
interface(`mta_spool_filetrans',`
Chris PeBenito a089b6
	gen_require(`
Chris PeBenito a089b6
		type mail_spool_t;
Chris PeBenito a089b6
	')
Chris PeBenito a089b6
Chris PeBenito a089b6
	files_search_spool($1)
Chris PeBenito a089b6
	allow $1 mail_spool_t:dir rw_dir_perms;
Chris PeBenito 1c1ac6
	type_transition $1 mail_spool_t:$3 $2;
Chris PeBenito a089b6
')
Chris PeBenito a089b6
Chris PeBenito a089b6
#######################################
Chris PeBenito 4bf4ed
#
Chris PeBenito c9428d
# mta_rw_spool(domain)
Chris PeBenito b16c6b
#
Chris PeBenito 199895
interface(`mta_rw_spool',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		type mail_spool_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_search_spool($1)
Chris PeBenito 5e6f9e
	allow $1 mail_spool_t:dir r_dir_perms;
Chris PeBenito b24f35
	allow $1 mail_spool_t:lnk_file { getattr read };
Chris PeBenito 0a10b1
	allow $1 mail_spool_t:file { rw_file_perms setattr };
Chris PeBenito b16c6b
')
Chris PeBenito b16c6b
Chris PeBenito b16c6b
#######################################
Chris PeBenito 246839
## <summary>
Chris PeBenito 246839
##	Create, read, and write the mail spool.
Chris PeBenito 246839
## </summary>
Chris PeBenito 246839
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 246839
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 246839
## </param>
Chris PeBenito 246839
#
Chris PeBenito 246839
interface(`mta_append_spool',`
Chris PeBenito 246839
	gen_require(`
Chris PeBenito 246839
		type mail_spool_t;
Chris PeBenito 246839
	')
Chris PeBenito 246839
Chris PeBenito 246839
	files_search_spool($1)
Chris PeBenito 246839
	allow $1 mail_spool_t:dir ra_dir_perms;
Chris PeBenito 246839
	allow $1 mail_spool_t:lnk_file { getattr read };
Chris PeBenito 246839
	allow $1 mail_spool_t:file create_file_perms;
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito 246839
#######################################
Chris PeBenito 04926d
## <summary>
Chris PeBenito 04926d
##	Delete from the mail spool.
Chris PeBenito 04926d
## </summary>
Chris PeBenito 04926d
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 04926d
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 04926d
## </param>
Chris PeBenito 04926d
#
Chris PeBenito 04926d
interface(`mta_delete_spool',`
Chris PeBenito 04926d
	gen_require(`
Chris PeBenito 04926d
		type mail_spool_t;
Chris PeBenito 04926d
	')
Chris PeBenito 04926d
Chris PeBenito 04926d
	files_search_spool($1)
Chris PeBenito 04926d
	allow $1 mail_spool_t:dir { list_dir_perms write remove_name };
Chris PeBenito 04926d
	allow $1 mail_spool_t:file unlink;
Chris PeBenito 04926d
')
Chris PeBenito 04926d
Chris PeBenito 04926d
#######################################
Chris PeBenito b16c6b
#
Chris PeBenito c9428d
# mta_manage_spool(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 199895
interface(`mta_manage_spool',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		type mail_spool_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito c9428d
	files_search_spool($1)
Chris PeBenito 9bbc75
	allow $1 mail_spool_t:dir manage_dir_perms;
Chris PeBenito 9bbc75
	allow $1 mail_spool_t:lnk_file create_lnk_perms;
Chris PeBenito 9bbc75
	allow $1 mail_spool_t:file manage_file_perms;
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 3e6c81
## <summary>
Chris PeBenito 3e6c81
##	Do not audit attempts to read and
Chris PeBenito 3e6c81
##	write the mail queue.
Chris PeBenito 3e6c81
## </summary>
Chris PeBenito 3e6c81
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 3e6c81
##	Domain to not audit.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 3e6c81
## </param>
Chris PeBenito 3e6c81
#
Chris PeBenito 3e6c81
interface(`mta_dontaudit_rw_queue',`
Chris PeBenito 3e6c81
	gen_require(`
Chris PeBenito 3e6c81
		type mqueue_spool_t;
Chris PeBenito 3e6c81
	')
Chris PeBenito 3e6c81
Chris PeBenito 3e6c81
	dontaudit $1 mqueue_spool_t:file { getattr read write };
Chris PeBenito 3e6c81
')
Chris PeBenito 3e6c81
Chris PeBenito 3e6c81
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito c9428d
# mta_manage_queue(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 199895
interface(`mta_manage_queue',`
Chris PeBenito 5e6f9e
	gen_require(`
Chris PeBenito 5e6f9e
		type mqueue_spool_t;
Chris PeBenito 5e6f9e
	')
Chris PeBenito 0c73cd
Chris PeBenito b24f35
	files_search_spool($1)
Chris PeBenito 0a10b1
	allow $1 mqueue_spool_t:dir rw_dir_perms;
Chris PeBenito 0a10b1
	allow $1 mqueue_spool_t:file create_file_perms;
Chris PeBenito 7bba9d
')
Chris PeBenito 04926d
Chris PeBenito 04926d
#######################################
Chris PeBenito 04926d
## <summary>
Chris PeBenito 04926d
##	Read sendmail binary.
Chris PeBenito ef5ca0
## </summary>
Chris PeBenito 04926d
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 04926d
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 04926d
## </param>
Chris PeBenito 04926d
#
Chris PeBenito 04926d
# cjp: added for postfix
Chris PeBenito 04926d
interface(`mta_read_sendmail_bin',`
Chris PeBenito 04926d
	gen_require(`
Chris PeBenito 60789e
		type sendmail_exec_t;
Chris PeBenito 04926d
	')
Chris PeBenito 04926d
Chris PeBenito 04926d
	allow $1 sendmail_exec_t:file r_file_perms;
Chris PeBenito 04926d
')
Chris PeBenito 04926d
Chris PeBenito 04926d
#######################################
Chris PeBenito 04926d
## <summary>
Chris PeBenito 04926d
##	Read and write unix domain stream sockets
Chris PeBenito 04926d
##	of user mail domains.
Chris PeBenito 04926d
## </summary>
Chris PeBenito 04926d
## <param name="domain">
Chris PeBenito 885b83
##	<summary>
Chris PeBenito 04926d
##	Domain allowed access.
Chris PeBenito 885b83
##	</summary>
Chris PeBenito 04926d
## </param>
Chris PeBenito 04926d
#
Chris PeBenito 1815ba
interface(`mta_rw_user_mail_stream_sockets',`
Chris PeBenito 04926d
	gen_require(`
Chris PeBenito 04926d
		attribute user_mail_domain;
Chris PeBenito 04926d
	')
Chris PeBenito 04926d
Chris PeBenito 04926d
	allow $1 user_mail_domain:unix_stream_socket rw_socket_perms;
Chris PeBenito 04926d
')