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 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 8fd367
files_type(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 246839
type system_mail_t;
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 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
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 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 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 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 etc_mail_t:file r_file_perms;
Chris PeBenito 246839
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 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 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 7bba9d
optional_policy(`sendmail.te',`
Chris PeBenito 12ae75
	sendmail_stub()
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 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 246839
allow system_mail_t privmail:fd use;
Chris PeBenito 246839
allow system_mail_t privmail:process sigchld;
Chris PeBenito 246839
allow system_mail_t privmail:fifo_file { read write };
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 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 4483ee
	arpwatch_search_data_dir(mta_delivery_agent)
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
')
Chris PeBenito 4483ee
Chris PeBenito 075c4f
') dnl end TODO