Chris PeBenito 6b9383
Chris PeBenito 6b9383
policy_module(mta,1.0)
Chris PeBenito 6b9383
Chris PeBenito 075c4f
########################################
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
# Declarations
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
Chris PeBenito 246839
attribute mta_user_agent;
Chris PeBenito 246839
attribute mailserver_delivery;
Chris PeBenito 246839
attribute mailserver_domain;
Chris PeBenito 246839
attribute mailserver_sender;
Chris PeBenito 246839
Chris PeBenito 04926d
attribute user_mail_domain;
Chris PeBenito 04926d
Chris PeBenito 6b9383
type etc_aliases_t;
Chris PeBenito 8fd367
files_type(etc_aliases_t)
Chris PeBenito 6b9383
Chris PeBenito 6b9383
type etc_mail_t;
Chris PeBenito 9bbc75
files_config_file(etc_mail_t)
Chris PeBenito 6b9383
Chris PeBenito 6b9383
type mqueue_spool_t;
Chris PeBenito 8fd367
files_type(mqueue_spool_t)
Chris PeBenito 6b9383
Chris PeBenito 6b9383
type mail_spool_t;
Chris PeBenito 8fd367
files_type(mail_spool_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
type sendmail_exec_t;
Chris PeBenito 8fd367
files_type(sendmail_exec_t)
Chris PeBenito 075c4f
Chris PeBenito 88dd38
type system_mail_t, user_mail_domain;
Chris PeBenito c9428d
domain_type(system_mail_t)
Chris PeBenito 12ae75
domain_entry_file(system_mail_t,sendmail_exec_t)
Chris PeBenito 075c4f
role system_r types system_mail_t;
Chris PeBenito 075c4f
Chris PeBenito 2d13f7
type system_mail_tmp_t;
Chris PeBenito 2d13f7
files_tmp_file(system_mail_tmp_t)
Chris PeBenito 2d13f7
Chris PeBenito 12ae75
# cjp: need to resolve this, but require{}
Chris PeBenito 12ae75
# does not work in the else part of the optional
Chris PeBenito 12ae75
#ifdef(`targeted_policy',`',`
Chris PeBenito 12ae75
#	optional_policy(`sendmail.te',`',`
Chris PeBenito 12ae75
#		init_system_domain(system_mail_t,sendmail_exec_t)
Chris PeBenito 12ae75
#	')
Chris PeBenito 12ae75
#')
Chris PeBenito 7bba9d
Chris PeBenito 075c4f
########################################
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
# System mail local policy
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow system_mail_t self:capability { setuid setgid chown };
Chris PeBenito 0fd9dc
allow system_mail_t self:process { signal_perms setrlimit };
Chris PeBenito 0a10b1
allow system_mail_t self:tcp_socket create_socket_perms;
Chris PeBenito 075c4f
Don Miner f13da8
allow system_mail_t etc_mail_t:dir { getattr search };
Chris PeBenito e8d0a6
allow system_mail_t etc_mail_t:file r_file_perms;
Chris PeBenito e8d0a6
Chris PeBenito 075c4f
# re-exec itself
Chris PeBenito 0a10b1
can_exec(system_mail_t, sendmail_exec_t)
Chris PeBenito 0a10b1
allow system_mail_t sendmail_exec_t:lnk_file r_file_perms;
Chris PeBenito 075c4f
Chris PeBenito 2d13f7
allow system_mail_t system_mail_tmp_t:dir create_dir_perms;
Chris PeBenito 2d13f7
allow system_mail_t system_mail_tmp_t:file create_file_perms;
Chris PeBenito 2d13f7
files_create_tmp_files(system_mail_t, system_mail_tmp_t, { file dir })
Chris PeBenito 2d13f7
Chris PeBenito 075c4f
kernel_read_kernel_sysctl(system_mail_t)
Chris PeBenito 075c4f
kernel_read_system_state(system_mail_t)
Chris PeBenito 075c4f
kernel_read_network_state(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_if(system_mail_t)
Chris PeBenito 0fd9dc
corenet_raw_sendrecv_all_if(system_mail_t)
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_nodes(system_mail_t)
Chris PeBenito 0fd9dc
corenet_raw_sendrecv_all_nodes(system_mail_t)
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_ports(system_mail_t)
Chris PeBenito 98a8ea
corenet_tcp_bind_all_nodes(system_mail_t)
Chris PeBenito e8d0a6
corenet_tcp_connect_smtp_port(system_mail_t)
Chris PeBenito 628417
corenet_tcp_connect_all_ports(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 98a8ea
dev_read_rand(system_mail_t)
Karl MacMillan f0c985
dev_read_urand(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 0fd9dc
fs_getattr_xattr_fs(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
init_use_script_pty(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 8fd367
files_read_etc_files(system_mail_t)
Chris PeBenito 246839
files_read_etc_runtime_files(system_mail_t)
Chris PeBenito 246839
files_search_spool(system_mail_t)
Chris PeBenito 075c4f
# It wants to check for nscd
Chris PeBenito c9428d
files_dontaudit_search_pids(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
corecmd_exec_bin(system_mail_t)
Chris PeBenito 246839
corecmd_search_sbin(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
libs_use_ld_so(system_mail_t)
Chris PeBenito c9428d
libs_use_shared_libs(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
logging_send_syslog_msg(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
miscfiles_read_localization(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito c9428d
sysnet_read_config(system_mail_t)
Chris PeBenito 98a8ea
sysnet_dns_name_resolve(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 246839
userdom_use_sysadm_terms(system_mail_t)
Chris PeBenito 246839
Chris PeBenito 15c235
ifdef(`hide_broken_symptoms',`
Chris PeBenito 15c235
	# Red Hat systems seem to have a stray
Chris PeBenito 15c235
	# fds open from the initrd
Chris PeBenito 15c235
	ifdef(`distro_redhat',`
Chris PeBenito 15c235
		kernel_dontaudit_use_fd(system_mail_t)
Chris PeBenito 15c235
		storage_dontaudit_read_fixed_disk(system_mail_t)
Chris PeBenito 15c235
	')
Chris PeBenito 15c235
')
Chris PeBenito 15c235
Chris PeBenito 246839
ifdef(`targeted_policy',`
Chris PeBenito fe9d17
	typealias system_mail_t alias sysadm_mail_t;
Chris PeBenito fe9d17
Chris PeBenito 246839
	allow system_mail_t mail_spool_t:dir create_dir_perms;
Chris PeBenito 246839
	allow system_mail_t mail_spool_t:file create_file_perms;
Chris PeBenito 246839
	allow system_mail_t mail_spool_t:lnk_file create_lnk_perms;
Chris PeBenito 246839
	allow system_mail_t mail_spool_t:fifo_file rw_file_perms;
Chris PeBenito 246839
Chris PeBenito 246839
	allow system_mail_t mqueue_spool_t:dir create_dir_perms;
Chris PeBenito 246839
	allow system_mail_t mqueue_spool_t:file create_file_perms;
Chris PeBenito 246839
	allow system_mail_t mqueue_spool_t:lnk_file create_lnk_perms;
Chris PeBenito 246839
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 88dd38
	# cjp: fix this to generic_user interfaces
Chris PeBenito 88dd38
	userdom_manage_user_home_subdirs(user,mailserver_delivery)
Chris PeBenito 88dd38
	userdom_manage_user_home_subdir_files(user,mailserver_delivery)
Chris PeBenito 88dd38
	userdom_manage_user_home_subdir_symlinks(user,mailserver_delivery)
Chris PeBenito 88dd38
	userdom_manage_user_home_subdir_pipes(user,mailserver_delivery)
Chris PeBenito 88dd38
	userdom_manage_user_home_subdir_sockets(user,mailserver_delivery)
Chris PeBenito 88dd38
	userdom_create_user_home(user,mailserver_delivery,{ dir file lnk_file fifo_file sock_file })
Chris PeBenito 88dd38
Chris PeBenito af4752
# cjp: another require-in-else to resolve
Chris PeBenito af4752
#	optional_policy(`postfix.te',`',`
Chris PeBenito 246839
		corecmd_exec_bin(system_mail_t)
Chris PeBenito 246839
		corecmd_exec_sbin(system_mail_t)
Chris PeBenito 246839
Chris PeBenito 246839
		domain_exec_all_entry_files(system_mail_t)
Chris PeBenito 246839
Chris PeBenito 246839
		files_exec_etc_files(system_mail_t)
Chris PeBenito 246839
Chris PeBenito 246839
		libs_use_ld_so(system_mail_t)
Chris PeBenito 246839
		libs_use_shared_libs(system_mail_t)
Chris PeBenito 246839
		libs_exec_ld_so(system_mail_t)
Chris PeBenito 246839
		libs_exec_lib_files(system_mail_t)
Chris PeBenito af4752
#	')
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito e749cd
optional_policy(`apache.te',`
Chris PeBenito e749cd
	apache_read_squirrelmail_data(system_mail_t)
Chris PeBenito e749cd
	apache_append_squirrelmail_data(system_mail_t)
Chris PeBenito e749cd
Chris PeBenito e749cd
	# apache should set close-on-exec
Chris PeBenito e749cd
	apache_dontaudit_append_log(system_mail_t)
Chris PeBenito e749cd
	apache_dontaudit_rw_stream_socket(system_mail_t)
Chris PeBenito e749cd
	apache_dontaudit_rw_tcp_socket(system_mail_t)
Chris PeBenito e749cd
	apache_dontaudit_rw_sys_script_stream_socket(system_mail_t)
Chris PeBenito e749cd
')
Chris PeBenito e749cd
Chris PeBenito e8d0a6
optional_policy(`arpwatch.te',`
Chris PeBenito e8d0a6
	arpwatch_rw_tmp_files(system_mail_t)
Chris PeBenito e8d0a6
')
Chris PeBenito e8d0a6
Chris PeBenito 246839
optional_policy(`cron.te',`
Chris PeBenito 246839
	cron_read_system_job_tmp_files(system_mail_t)
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito 93070c
optional_policy(`cvs.te',`
Chris PeBenito 93070c
	cvs_read_data(system_mail_t)
Chris PeBenito 93070c
')
Chris PeBenito 93070c
Chris PeBenito 246839
optional_policy(`logrotate.te',`
Chris PeBenito 246839
	logrotate_read_tmp_files(system_mail_t)
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito ab940a
optional_policy(`nis.te',`
Chris PeBenito ab940a
	nis_use_ypbind(system_mail_t)
Chris PeBenito ab940a
')
Chris PeBenito ab940a
Chris PeBenito 493d6c
optional_policy(`nscd.te',`
Chris PeBenito 493d6c
	nscd_use_socket(system_mail_t)
Chris PeBenito 493d6c
')
Chris PeBenito 493d6c
Chris PeBenito 04926d
optional_policy(`postfix.te',`
Chris PeBenito 04926d
	postfix_stub(system_mail_t)
Chris PeBenito 04926d
Chris PeBenito 04926d
	allow system_mail_t etc_aliases_t:dir create_dir_perms;
Chris PeBenito 04926d
	allow system_mail_t etc_aliases_t:file create_file_perms;
Chris PeBenito 04926d
	allow system_mail_t etc_aliases_t:lnk_file create_lnk_perms;
Chris PeBenito 04926d
	allow system_mail_t etc_aliases_t:sock_file create_file_perms;
Chris PeBenito 04926d
	allow system_mail_t etc_aliases_t:fifo_file create_file_perms;
Chris PeBenito 60789e
	files_create_etc_config(system_mail_t,etc_aliases_t,{ file lnk_file sock_file fifo_file })
Chris PeBenito 04926d
Chris PeBenito d3f715
	domain_use_wide_inherit_fd(system_mail_t)
Chris PeBenito d3f715
Chris PeBenito 04926d
	optional_policy(`crond.te',`
Chris PeBenito 04926d
		cron_crw_tcp_socket(system_mail_t)
Chris PeBenito 04926d
	')
Chris PeBenito 725926
Chris PeBenito 725926
	allow mta_user_agent sysadm_t:fifo_file { read write };
Chris PeBenito 725926
	type_transition postfix_master_t postfix_etc_t:dir etc_aliases_t;
Chris PeBenito 04926d
')
Chris PeBenito 04926d
Chris PeBenito 7bba9d
optional_policy(`sendmail.te',`
Chris PeBenito 04926d
	sendmail_stub(system_mail_t)
Chris PeBenito 12ae75
Chris PeBenito df00b2
	allow system_mail_t etc_mail_t:dir { getattr search };
Chris PeBenito 7bba9d
Chris PeBenito df00b2
	# sendmail -q 
Chris PeBenito df00b2
	allow system_mail_t mqueue_spool_t:dir rw_dir_perms;
Chris PeBenito df00b2
	allow system_mail_t mqueue_spool_t:file create_file_perms;
Chris PeBenito d3f715
Chris PeBenito d3f715
	# FIXME:
Chris PeBenito d3f715
	allow system_mail_t sendmail_log_t:file manage_file_perms;
Chris PeBenito d3f715
	logging_create_log(system_mail_t,sendmail_log_t)
Chris PeBenito 246839
')
Chris PeBenito 246839
Chris PeBenito 246839
ifdef(`TODO',`
Chris PeBenito 12ae75
optional_policy(`procmail.te',`
Chris PeBenito 12ae75
	procmail_exec(system_mail_t)
Chris PeBenito 12ae75
')
Chris PeBenito 12ae75
Chris PeBenito 246839
optional_policy(`sendmail.te',`
Chris PeBenito 246839
	allow system_mail_t { var_t var_spool_t }:dir getattr;
Chris PeBenito 246839
	dontaudit system_mail_t userpty_type:chr_file { getattr read write };
Chris PeBenito df00b2
Chris PeBenito df00b2
	optional_policy(`crond.te', `
Chris PeBenito df00b2
		dontaudit system_mail_t system_crond_tmp_t:file append;
Chris PeBenito df00b2
	')
Chris PeBenito 7bba9d
')
Chris PeBenito 075c4f
Chris PeBenito 246839
ifdef(`targeted_policy',`
Chris PeBenito df00b2
	allow system_mail_t { var_t var_spool_t }:dir getattr;
Chris PeBenito df00b2
',`
Chris PeBenito df00b2
	# allow the sysadmin to do "mail someone < /home/user/whatever"
Chris PeBenito df00b2
	allow sysadm_mail_t user_home_dir_type:dir search;
Chris PeBenito df00b2
	r_dir_file(sysadm_mail_t, user_home_type)
Chris PeBenito 7bba9d
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
Chris PeBenito 246839
optional_policy(`qmail.te',`
Chris PeBenito 246839
	allow system_mail_t qmail_etc_t:dir search;
Chris PeBenito 246839
	allow system_mail_t qmail_etc_t:{ file lnk_file } read;
Chris PeBenito 96ce00
')
Chris PeBenito 725926
') dnl end TODO
Chris PeBenito 725926
Chris PeBenito 725926
allow mta_user_agent system_crond_tmp_t:file { read getattr };
Chris PeBenito 4483ee
Chris PeBenito 4483ee
optional_policy(`arpwatch.te',`
Chris PeBenito 4483ee
	# why is mail delivered to a directory of type arpwatch_data_t?
Chris PeBenito 725926
	arpwatch_search_data(mailserver_delivery)
Chris PeBenito 4483ee
	arpwatch_manage_tmp_files(system_mail_t)
Chris PeBenito 4483ee
	arpwatch_manage_tmp_files(mta_user_agent)
Chris PeBenito 4483ee
	ifdef(`hide_broken_symptoms', `
Chris PeBenito 4483ee
		arpwatch_dontaudit_rw_packet_socket(system_mail_t)
Chris PeBenito 4483ee
		arpwatch_dontaudit_rw_packet_socket(mta_user_agent)
Chris PeBenito 4483ee
	')
Chris PeBenito 4483ee
')