Chris PeBenito 4bf4ed
## <module name="mta" layer="keyservices">
Chris PeBenito 4bf4ed
## <summary>Policy common to all email tranfer agents.</summary>
Chris PeBenito 6b9383
Chris PeBenito 6b9383
#######################################
Chris PeBenito 6b9383
#
Chris PeBenito 6b9383
# Per user domain template for this module
Chris PeBenito 6b9383
#
Chris PeBenito 6b9383
# mta_per_userdomain_template(userdomain_prefix)
Chris PeBenito 6b9383
#
Chris PeBenito 6b9383
define(`mta_per_userdomain_template',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 6b9383
Chris PeBenito 0c73cd
	type $1_mail_t; # , user_mail_domain, nscd_client_domain;
Chris PeBenito 0c73cd
	domain_make_domain($1_mail_t)
Chris PeBenito 0c73cd
	role $1_r types $1_mail_t;
Chris PeBenito 6b9383
Chris PeBenito 0c73cd
	type $1_mail_tmp_t;
Chris PeBenito 0c73cd
	files_make_temporary_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 0c73cd
	allow $1_mail_t self:process { sigkill sigstop signull signal setrlimit };
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# tcp networking
Chris PeBenito 0c73cd
	allow $1_mail_t self:tcp_socket { create connect ioctl read getattr write setattr append bind getopt setopt shutdown };
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# re-exec itself
Chris PeBenito 0c73cd
	allow $1_mail_t sendmail_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito 0c73cd
	allow $1_mail_t sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# Transition from the user domain to the derived domain.
Chris PeBenito 0c73cd
	allow $1_t sendmail_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito 0c73cd
	allow $1_t sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 0c73cd
	allow $1_t $1_mail_t:process transition;
Chris PeBenito 0c73cd
	type_transition $1_t sendmail_exec_t:process $1_mail_t;
Chris PeBenito 0c73cd
	dontaudit $1_t $1_mail_t:process { noatsecure siginh rlimitinh };
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	allow $1_t $1_mail_t:fd use;
Chris PeBenito 0c73cd
	allow $1_mail_t $1_t:fd use;
Chris PeBenito 0c73cd
	allow $1_mail_t $1_t:fifo_file rw_file_perms;
Chris PeBenito 0c73cd
	allow $1_mail_t $1_t:process sigchld;
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	kernel_read_kernel_sysctl($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	corenetwork_sendrecv_tcp_on_all_interfaces($1_mail_t)
Chris PeBenito 0c73cd
	corenetwork_sendrecv_raw_on_all_interfaces($1_mail_t)
Chris PeBenito 0c73cd
	corenetwork_sendrecv_tcp_on_all_nodes($1_mail_t)
Chris PeBenito 0c73cd
	corenetwork_sendrecv_raw_on_all_nodes($1_mail_t)
Chris PeBenito 0c73cd
	corenetwork_sendrecv_tcp_on_all_ports($1_mail_t)
Chris PeBenito 0c73cd
	corenetwork_bind_tcp_on_all_nodes($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	domain_use_widely_inheritable_file_descriptors($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	libraries_use_dynamic_loader($1_mail_t)
Chris PeBenito 0c73cd
	libraries_use_shared_libraries($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	corecommands_execute_general_programs($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	files_read_general_system_config($1_mail_t)
Chris PeBenito 6b9383
Chris PeBenito 0c73cd
	logging_send_system_log_message($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	miscfiles_read_localization($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	sysnetwork_read_network_config($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	tunable_policy(`use_dns',`
Chris PeBenito 0c73cd
		allow $1_mail_t self:udp_socket { create ioctl read getattr write setattr append bind getopt setopt shutdown connect };
Chris PeBenito 0c73cd
		corenetwork_sendrecv_udp_on_all_interfaces($1_mail_t)
Chris PeBenito 0c73cd
		corenetwork_sendrecv_udp_on_all_nodes($1_mail_t)
Chris PeBenito 0c73cd
		corenetwork_bind_udp_on_all_nodes($1_mail_t)
Chris PeBenito 0c73cd
		corenetwork_sendrecv_udp_on_dns_port($1_mail_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	optional_policy(`procmail.te',`
Chris PeBenito 0c73cd
		procmail_execute($1_mail_t)
Chris PeBenito 0c73cd
	')
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	ifdef(`TODO',`
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	can_ypbind($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	allow $1_mail_t device_t:dir search;
Chris PeBenito 0c73cd
	allow $1_mail_t { var_t var_spool_t }:dir search;
Chris PeBenito 0c73cd
	allow $1_mail_t sbin_t:dir search;
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# It wants to check for nscd
Chris PeBenito 0c73cd
	dontaudit $1_mail_t var_run_t:dir search;
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# For when the user wants to send mail via port 25 localhost
Chris PeBenito 0c73cd
	can_tcp_connect($1_t, mail_server_domain)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# Read user temporary files.
Chris PeBenito 0c73cd
	allow $1_mail_t $1_tmp_t:file r_file_perms;
Chris PeBenito 0c73cd
	dontaudit $1_mail_t $1_tmp_t:file append;
Chris PeBenito 0c73cd
	ifdef(`postfix.te', `
Chris PeBenito 0c73cd
		# postfix seems to need write access if the file handle is opened read/write
Chris PeBenito 0c73cd
		allow $1_mail_t $1_tmp_t:file write;
Chris PeBenito 0c73cd
	')
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	allow mta_user_agent $1_tmp_t:file { read getattr };
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# Write to the user domain tty.
Chris PeBenito 0c73cd
	allow mta_user_agent $1_tty_device_t:chr_file { read write getattr ioctl };
Chris PeBenito 0c73cd
	allow mta_user_agent devpts_t:dir { read search getattr };
Chris PeBenito 0c73cd
	allow mta_user_agent $1_devpts_t:chr_file { read write getattr ioctl };
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	allow $1_mail_t $1_tty_device_t:chr_file { read write getattr ioctl };
Chris PeBenito 0c73cd
	allow $1_mail_t devpts_t:dir { read search getattr };
Chris PeBenito 0c73cd
	allow $1_mail_t $1_devpts_t:chr_file { read write getattr ioctl };
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# Inherit and use descriptors from gnome-pty-helper.
Chris PeBenito 0c73cd
	ifdef(`gnome-pty-helper.te', `allow $1_mail_t $1_gph_t:fd use;')
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	# Create dead.letter in user home directories.
Chris PeBenito 0c73cd
	file_type_auto_trans($1_mail_t, $1_home_dir_t, $1_home_t, file)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	if (use_samba_home_dirs) {
Chris PeBenito 0c73cd
		rw_dir_create_file($1_mail_t, cifs_t)
Chris PeBenito 0c73cd
	}
Chris PeBenito 075c4f
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 075c4f
Chris PeBenito 0c73cd
	# for reading .forward - maybe we need a new type for it?
Chris PeBenito 0c73cd
	# also for delivering mail to maildir
Chris PeBenito 0c73cd
	file_type_auto_trans(mta_delivery_agent, $1_home_dir_t, $1_home_t)
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	ifdef(`qmail.te', `
Chris PeBenito 0c73cd
		allow $1_mail_t qmail_etc_t:dir search;
Chris PeBenito 0c73cd
		allow $1_mail_t qmail_etc_t:{ file lnk_file } read;
Chris PeBenito 0c73cd
	')
Chris PeBenito 075c4f
Chris PeBenito 0c73cd
	') dnl end TODO
Chris PeBenito 6b9383
')
Chris PeBenito 6b9383
Chris PeBenito 6b9383
define(`mta_per_userdomain_template_depend',`
Chris PeBenito 6b9383
Chris PeBenito 6b9383
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
# mta_make_mailserver_domain(domain,entrypointtype)
Chris PeBenito 075c4f
#
Chris PeBenito 7bba9d
define(`mta_make_mailserver_domain',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	init_make_daemon_domain($1,$2)
Chris PeBenito 0c73cd
	typeattribute $1 mailserver_domain;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 7bba9d
define(`mta_make_mailserver_domain_depend',`
Chris PeBenito 0c73cd
	attribute mailserver_domain;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito 7bba9d
# mta_make_sendmail_mailserver_domain(domain,entrypointtype)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_make_sendmail_mailserver_domain',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	mta_make_mailserver_domain($1,sendmail_exec_t)
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_make_sendmail_mailserver_domain_depend',`
Chris PeBenito 0c73cd
	type sendmail_exec_t;
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito c6a3a2
# mta_send_mail(domain)
Chris PeBenito 075c4f
#
Chris PeBenito c6a3a2
define(`mta_send_mail',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 0c73cd
	allow $1 sendmail_exec_t:file { getattr read execute };
Chris PeBenito 0c73cd
	allow $1 system_mail_t:process transition;
Chris PeBenito 0c73cd
	type_transition $1 sendmail_exec_t:process system_mail_t;
Chris PeBenito 0c73cd
	dontaudit $1 system_mail_t:process { noatsecure siginh rlimitinh };
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 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito c6a3a2
define(`mta_send_mail_depend',`
Chris PeBenito 0c73cd
	type system_mail_t, sendmail_exec_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class file { getattr read execute };
Chris PeBenito 0c73cd
	class lnk_file { getattr read };
Chris PeBenito 0c73cd
	class process { transition noatsecure siginh rlimitinh sigchld };
Chris PeBenito 0c73cd
	class fd use;
Chris PeBenito 0c73cd
	class fifo_file rw_file_perms;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
# mta_execute(domain)
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
define(`mta_execute',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 sendmail_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
define(`mta_execute_depend',`
Chris PeBenito 0c73cd
	type sendmail_exec_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class file { getattr read execute execute_no_trans };
Chris PeBenito 075c4f
')
Chris PeBenito 7bba9d
Chris PeBenito daa0e0
########################################
Chris PeBenito daa0e0
## <interface name="mta_read_mail_aliases">
Chris PeBenito daa0e0
##	<description>
Chris PeBenito daa0e0
##		Read mail address aliases.
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
##	<infoflow type="read" weight="10"/>
Chris PeBenito daa0e0
## </interface>
Chris PeBenito daa0e0
#
Chris PeBenito daa0e0
define(`mta_read_mail_aliases',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 etc_aliases_t:file { getattr read };
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito daa0e0
define(`mta_read_mail_aliases_depend',`
Chris PeBenito 0c73cd
	type etc_aliases_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class file { getattr read };
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
# mta_modify_mail_aliases(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_modify_mail_aliases',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow sendmail_t etc_aliases_t:file { getattr read write append setattr };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_modify_mail_aliases_depend',`
Chris PeBenito 0c73cd
	type etc_aliases_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class file { getattr read write append setattr };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito 4bf4ed
# mta_get_mail_spool_attributes(domain)
Chris PeBenito 4bf4ed
#
Chris PeBenito 4bf4ed
define(`mta_get_mail_spool_attributes',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	files_search_system_spool_directory($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 4bf4ed
define(`mta_get_mail_spool_attributes_depend',`
Chris PeBenito 0c73cd
	type mail_spool_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class dir r_dir_perms;
Chris PeBenito 0c73cd
	class file getattr;
Chris PeBenito 0c73cd
	class lnk_file read;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
#######################################
Chris PeBenito 4bf4ed
#
Chris PeBenito b16c6b
# mta_modify_mail_spool(domain)
Chris PeBenito b16c6b
#
Chris PeBenito b16c6b
define(`mta_modify_mail_spool',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	files_search_system_spool_directory($1)
Chris PeBenito 0c73cd
	allow $1 mail_spool_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 0c73cd
	allow $1 mail_spool_t:file { getattr read write append setattr };
Chris PeBenito b16c6b
')
Chris PeBenito b16c6b
Chris PeBenito b16c6b
define(`mta_modify_mail_spool_depend',`
Chris PeBenito 0c73cd
	type mail_spool_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 0c73cd
	class file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito b16c6b
')
Chris PeBenito b16c6b
Chris PeBenito b16c6b
#######################################
Chris PeBenito b16c6b
#
Chris PeBenito 7bba9d
# mta_manage_mail_spool(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_manage_mail_spool',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	files_search_system_spool_directory($1)
Chris PeBenito 0c73cd
	allow $1 mail_spool_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 0c73cd
	allow $1 mail_spool_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_manage_mail_spool_depend',`
Chris PeBenito 0c73cd
	type mail_spool_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 0c73cd
	class file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
# mta_manage_mail_queue(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_manage_mail_queue',`
Chris PeBenito 0c73cd
	requires_block_template(`$0'_depend)
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	allow $1 mqueue_spool_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 0c73cd
	allow $1 mqueue_spool_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_manage_mail_queue_depend',`
Chris PeBenito 0c73cd
	type mqueue_spool_t;
Chris PeBenito 0c73cd
Chris PeBenito 0c73cd
	class dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 0c73cd
	class file { create ioctl read getattr lock write setattr append link unlink rename }
Chris PeBenito 7bba9d
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
## </module>