Chris PeBenito 29af4c
policy_module(mta, 2.3.0)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# Declarations
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 36095d
attribute mailcontent_type;
Chris PeBenito 36095d
attribute mta_exec_type;
Chris PeBenito 17de1b
attribute mta_user_agent;
Chris PeBenito 17de1b
attribute mailserver_delivery;
Chris PeBenito 17de1b
attribute mailserver_domain;
Chris PeBenito 17de1b
attribute mailserver_sender;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
attribute user_mail_domain;
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type etc_aliases_t;
Chris PeBenito 17de1b
files_type(etc_aliases_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type etc_mail_t;
Chris PeBenito 17de1b
files_config_file(etc_mail_t)
Chris PeBenito 17de1b
Dan Walsh 3eaa99
type mail_home_t alias mail_forward_t;
Dan Walsh 3eaa99
userdom_user_home_content(mail_home_t)
Chris PeBenito 9c4067
Chris PeBenito 17de1b
type mqueue_spool_t;
Chris PeBenito 36095d
files_mountpoint(mqueue_spool_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type mail_spool_t;
Chris PeBenito 36095d
files_mountpoint(mail_spool_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
type sendmail_exec_t;
Chris PeBenito 36095d
mta_agent_executable(sendmail_exec_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
mta_base_mail_template(system)
Chris PeBenito 17de1b
role system_r types system_mail_t;
Chris PeBenito 17de1b
Chris PeBenito 296273
mta_base_mail_template(user)
Chris PeBenito 296273
typealias user_mail_t alias { staff_mail_t sysadm_mail_t };
Chris PeBenito 296273
typealias user_mail_t alias { auditadm_mail_t secadm_mail_t };
Chris PeBenito 296273
typealias user_mail_tmp_t alias { staff_mail_tmp_t sysadm_mail_tmp_t };
Chris PeBenito 296273
typealias user_mail_tmp_t alias { auditadm_mail_tmp_t secadm_mail_tmp_t };
Chris PeBenito 296273
ubac_constrained(user_mail_t)
Chris PeBenito 296273
ubac_constrained(user_mail_tmp_t)
Chris PeBenito 296273
Chris PeBenito 17de1b
########################################
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
# System mail local policy
Chris PeBenito 17de1b
#
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# newalias required this, not sure if it is needed in 'if' file
Chris PeBenito 363e8f
allow system_mail_t self:capability { dac_override fowner };
Chris PeBenito 9c4067
Chris PeBenito 363e8f
read_files_pattern(system_mail_t, mailcontent_type, mailcontent_type)
Chris PeBenito 17de1b
Chris PeBenito 363e8f
dev_read_sysfs(system_mail_t)
Chris PeBenito 17de1b
dev_read_rand(system_mail_t)
Chris PeBenito 17de1b
dev_read_urand(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito e19b8d
files_read_usr_files(system_mail_t)
Chris PeBenito e19b8d
Chris PeBenito 363e8f
fs_rw_anon_inodefs_files(system_mail_t)
Chris PeBenito 363e8f
Chris PeBenito 363e8f
selinux_getattr_fs(system_mail_t)
Chris PeBenito 363e8f
Chris PeBenito e19b8d
term_dontaudit_use_unallocated_ttys(system_mail_t)
Chris PeBenito e19b8d
Chris PeBenito 17de1b
init_use_script_ptys(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito 296273
userdom_use_user_terminals(system_mail_t)
Chris PeBenito 296273
userdom_dontaudit_search_user_home_dirs(system_mail_t)
Dan Walsh 3eaa99
userdom_dontaudit_list_admin_dir(system_mail_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
logging_append_all_logs(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	apache_read_squirrelmail_data(system_mail_t)
Chris PeBenito 17de1b
	apache_append_squirrelmail_data(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	# apache should set close-on-exec
Chris PeBenito 17de1b
	apache_dontaudit_append_log(system_mail_t)
Chris PeBenito 17de1b
	apache_dontaudit_rw_stream_sockets(system_mail_t)
Chris PeBenito 17de1b
	apache_dontaudit_rw_tcp_sockets(system_mail_t)
Chris PeBenito 17de1b
	apache_dontaudit_rw_sys_script_stream_sockets(system_mail_t)
Dan Walsh 3eaa99
	apache_dontaudit_write_tmp_files(system_mail_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	# apache should set close-on-exec
Dan Walsh 3eaa99
	apache_dontaudit_rw_stream_sockets(mta_user_agent)
Dan Walsh 3eaa99
	apache_dontaudit_rw_sys_script_stream_sockets(mta_user_agent)
Dan Walsh 3eaa99
	apache_append_log(mta_user_agent)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	arpwatch_manage_tmp_files(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	ifdef(`hide_broken_symptoms', `
Chris PeBenito 17de1b
		arpwatch_dontaudit_rw_packet_sockets(system_mail_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Dan Walsh 3eaa99
	bugzilla_search_dirs(system_mail_t)
Dan Walsh 3eaa99
	bugzilla_dontaudit_rw_script_stream_sockets(system_mail_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Chris PeBenito 363e8f
	clamav_stream_connect(system_mail_t)
Chris PeBenito 363e8f
	clamav_append_log(system_mail_t)
Chris PeBenito 363e8f
')
Chris PeBenito 363e8f
Chris PeBenito 363e8f
optional_policy(`
Chris PeBenito 17de1b
	cron_read_system_job_tmp_files(system_mail_t)
Chris PeBenito 17de1b
	cron_dontaudit_write_pipes(system_mail_t)
Chris PeBenito e19b8d
	cron_rw_system_job_stream_sockets(system_mail_t)
Dan Walsh 3eaa99
	cron_rw_inherited_spool_files(system_mail_t)
Dan Walsh 3eaa99
	cron_rw_inherited_user_spool_files(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 363e8f
	courier_manage_spool_dirs(system_mail_t)
Chris PeBenito 363e8f
	courier_manage_spool_files(system_mail_t)
Chris PeBenito 363e8f
	courier_rw_spool_pipes(system_mail_t)
Chris PeBenito 363e8f
')
Chris PeBenito 363e8f
Chris PeBenito 363e8f
optional_policy(`
Chris PeBenito 17de1b
	cvs_read_data(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 363e8f
	fail2ban_append_log(system_mail_t)
Dan Walsh 3eaa99
	fail2ban_dontaudit_leaks(system_mail_t)
Chris PeBenito 363e8f
')
Chris PeBenito 363e8f
Chris PeBenito 363e8f
optional_policy(`
Chris PeBenito 17de1b
	logrotate_read_tmp_files(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	logwatch_read_tmp_files(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito b9e523
	# newaliases runs as system_mail_t when the sendmail initscript does a restart
Chris PeBenito b9e523
	milter_getattr_all_sockets(system_mail_t)
Chris PeBenito b9e523
')
Chris PeBenito b9e523
Chris PeBenito b9e523
optional_policy(`
Dan Walsh 3eaa99
	munin_dontaudit_leaks(system_mail_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Chris PeBenito 17de1b
	nagios_read_tmp_files(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 0bfccd
	manage_dirs_pattern(system_mail_t, etc_aliases_t, etc_aliases_t)
Chris PeBenito 0bfccd
	manage_files_pattern(system_mail_t, etc_aliases_t, etc_aliases_t)
Chris PeBenito 0bfccd
	manage_lnk_files_pattern(system_mail_t, etc_aliases_t, etc_aliases_t)
Chris PeBenito 0bfccd
	manage_fifo_files_pattern(system_mail_t, etc_aliases_t, etc_aliases_t)
Chris PeBenito 0bfccd
	manage_sock_files_pattern(system_mail_t, etc_aliases_t, etc_aliases_t)
Chris PeBenito 0bfccd
	files_etc_filetrans(system_mail_t, etc_aliases_t, { file lnk_file sock_file fifo_file })
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	domain_use_interactive_fds(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	qmail_domtrans_inject(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	sxid_read_log(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 296273
	userdom_dontaudit_use_user_ptys(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		cron_dontaudit_append_system_job_tmp_files(system_mail_t)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Dan Walsh 3eaa99
	spamd_stream_connect(system_mail_t)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Chris PeBenito 17de1b
	smartmon_read_tmp_files(system_mail_t)
Chris PeBenito 17de1b
')
Chris PeBenito 17de1b
Chris PeBenito 17de1b
# should break this up among sections:
Chris PeBenito 17de1b
Chris PeBenito 17de1b
optional_policy(`
Chris PeBenito 17de1b
	# why is mail delivered to a directory of type arpwatch_data_t?
Chris PeBenito 17de1b
	arpwatch_search_data(mailserver_delivery)
Chris PeBenito 17de1b
	arpwatch_manage_tmp_files(mta_user_agent)
Chris PeBenito 350b6a
Chris PeBenito 17de1b
	ifdef(`hide_broken_symptoms', `
Chris PeBenito 17de1b
		arpwatch_dontaudit_rw_packet_sockets(mta_user_agent)
Chris PeBenito 17de1b
	')
Chris PeBenito 350b6a
Chris PeBenito 17de1b
	optional_policy(`
Chris PeBenito 17de1b
		cron_read_system_job_tmp_files(mta_user_agent)
Chris PeBenito 17de1b
	')
Chris PeBenito 17de1b
')
Chris PeBenito 296273
Chris PeBenito 296273
########################################
Chris PeBenito 296273
#
Chris PeBenito 9c4067
# Mailserver delivery local policy
Chris PeBenito 9c4067
#
Chris PeBenito 9c4067
Chris PeBenito 96831f
allow mailserver_delivery mail_spool_t:dir list_dir_perms;
Chris PeBenito 96831f
create_files_pattern(mailserver_delivery, mail_spool_t, mail_spool_t)
Chris PeBenito 96831f
read_files_pattern(mailserver_delivery, mail_spool_t, mail_spool_t)
Chris PeBenito 96831f
append_files_pattern(mailserver_delivery, mail_spool_t, mail_spool_t)
Chris PeBenito 96831f
create_lnk_files_pattern(mailserver_delivery, mail_spool_t, mail_spool_t)
Chris PeBenito 96831f
read_lnk_files_pattern(mailserver_delivery, mail_spool_t, mail_spool_t)
Chris PeBenito 96831f
Dan Walsh 3eaa99
userdom_search_admin_dir(mailserver_delivery)
Dan Walsh 3eaa99
read_files_pattern(mailserver_delivery, mail_home_t, mail_home_t)
Chris PeBenito 9c4067
Chris PeBenito 9c4067
read_files_pattern(mailserver_delivery, system_mail_tmp_t, system_mail_tmp_t)
Chris PeBenito 9c4067
Chris PeBenito 9c4067
tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 9c4067
	fs_manage_cifs_dirs(mailserver_delivery)
Chris PeBenito 9c4067
	fs_manage_cifs_files(mailserver_delivery)
Chris PeBenito 9c4067
	fs_manage_cifs_symlinks(mailserver_delivery)
Chris PeBenito 9c4067
')
Chris PeBenito 9c4067
Chris PeBenito 9c4067
tunable_policy(`use_nfs_home_dirs',`
Chris PeBenito 9c4067
	fs_manage_nfs_dirs(mailserver_delivery)
Chris PeBenito 9c4067
	fs_manage_nfs_files(mailserver_delivery)
Chris PeBenito 9c4067
	fs_manage_nfs_symlinks(mailserver_delivery)
Chris PeBenito 9c4067
')
Chris PeBenito 9c4067
Chris PeBenito 96831f
optional_policy(`
Chris PeBenito 96831f
	dovecot_manage_spool(mailserver_delivery)
Chris PeBenito 96831f
	dovecot_domtrans_deliver(mailserver_delivery)
Chris PeBenito 96831f
')
Chris PeBenito 96831f
Chris PeBenito 96831f
optional_policy(`
Chris PeBenito 96831f
	# so MTA can access /var/lib/mailman/mail/wrapper
Chris PeBenito 96831f
	files_search_var_lib(mailserver_delivery)
Chris PeBenito 96831f
Chris PeBenito 96831f
	mailman_domtrans(mailserver_delivery)
Chris PeBenito 96831f
	mailman_read_data_symlinks(mailserver_delivery)
Chris PeBenito 96831f
')
Chris PeBenito 96831f
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	uucp_domtrans_uux(mailserver_delivery)
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Chris PeBenito 9c4067
########################################
Chris PeBenito 9c4067
#
Chris PeBenito 296273
# User send mail local policy
Chris PeBenito 296273
#
Chris PeBenito 296273
Dan Walsh 3eaa99
Chris PeBenito 296273
domain_use_interactive_fds(user_mail_t)
Chris PeBenito 296273
Chris PeBenito 296273
userdom_use_user_terminals(user_mail_t)
Chris PeBenito 296273
# Write to the user domain tty. cjp: why?
Chris PeBenito 296273
userdom_use_user_terminals(mta_user_agent)
Chris PeBenito 296273
# Create dead.letter in user home directories.
Chris PeBenito 296273
userdom_manage_user_home_content_files(user_mail_t)
Chris PeBenito 296273
userdom_user_home_dir_filetrans_user_home_content(user_mail_t, file)
Chris PeBenito 296273
# for reading .forward - maybe we need a new type for it?
Chris PeBenito 296273
# also for delivering mail to maildir
Chris PeBenito 296273
userdom_manage_user_home_content_dirs(mailserver_delivery)
Chris PeBenito 296273
userdom_manage_user_home_content_files(mailserver_delivery)
Chris PeBenito 296273
userdom_manage_user_home_content_symlinks(mailserver_delivery)
Chris PeBenito 296273
userdom_manage_user_home_content_pipes(mailserver_delivery)
Chris PeBenito 296273
userdom_manage_user_home_content_sockets(mailserver_delivery)
Chris PeBenito 296273
userdom_user_home_dir_filetrans_user_home_content(mailserver_delivery, { dir file lnk_file fifo_file sock_file })
Chris PeBenito 296273
# Read user temporary files.
Chris PeBenito 296273
userdom_read_user_tmp_files(user_mail_t)
Chris PeBenito 296273
userdom_dontaudit_append_user_tmp_files(user_mail_t)
Chris PeBenito 296273
# cjp: this should probably be read all user tmp
Chris PeBenito 296273
# files in an appropriate place for mta_user_agent
Chris PeBenito 296273
userdom_read_user_tmp_files(mta_user_agent)
Chris PeBenito 296273
Chris PeBenito 296273
tunable_policy(`use_samba_home_dirs',`
Chris PeBenito 296273
	fs_manage_cifs_files(user_mail_t)
Chris PeBenito 296273
	fs_manage_cifs_symlinks(user_mail_t)
Chris PeBenito 296273
')
Chris PeBenito 296273
Chris PeBenito 296273
optional_policy(`
Chris PeBenito 296273
	allow user_mail_t self:capability dac_override;
Chris PeBenito 296273
Chris PeBenito 296273
	# Read user temporary files.
Chris PeBenito 296273
	# postfix seems to need write access if the file handle is opened read/write
Chris PeBenito 296273
	userdom_rw_user_tmp_files(user_mail_t)
Chris PeBenito 296273
Chris PeBenito 296273
	postfix_read_config(user_mail_t)
Chris PeBenito 296273
	postfix_list_spool(user_mail_t)
Chris PeBenito 296273
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
########################################
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
# Comman user_mail_domain policy
Dan Walsh 3eaa99
#
Dan Walsh 3eaa99
Dan Walsh 3eaa99
allow user_mail_domain self:fifo_file rw_fifo_file_perms;
Dan Walsh 3eaa99
allow user_mail_domain mta_exec_type:file entrypoint;
Dan Walsh 3eaa99
Dan Walsh 3eaa99
read_files_pattern(user_mail_domain, etc_aliases_t, etc_aliases_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
can_exec(user_mail_domain, mta_exec_type)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
allow system_mail_t user_mail_domain:file read_file_perms;
Dan Walsh 3eaa99
Dan Walsh 3eaa99
read_files_pattern(user_mail_domain, etc_mail_t, etc_mail_t)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
kernel_read_system_state(user_mail_domain)
Dan Walsh 3eaa99
kernel_read_network_state(user_mail_domain)
Dan Walsh 3eaa99
kernel_request_load_module(user_mail_domain)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	# postfix needs this for newaliases
Dan Walsh 3eaa99
	files_getattr_tmp_dirs(user_mail_domain)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	postfix_exec_master(user_mail_domain)
Dan Walsh 3eaa99
	postfix_read_config(user_mail_domain)
Dan Walsh 3eaa99
	postfix_search_spool(user_mail_domain)
Dan Walsh 3eaa99
Dan Walsh 3eaa99
	ifdef(`distro_redhat',`
Dan Walsh 3eaa99
		# compatability for old default main.cf
Dan Walsh 3eaa99
		postfix_config_filetrans(user_mail_domain, etc_aliases_t, { dir file lnk_file sock_file fifo_file })
Dan Walsh 3eaa99
	')
Dan Walsh 3eaa99
')
Dan Walsh 3eaa99
Dan Walsh 3eaa99
optional_policy(`
Dan Walsh 3eaa99
	exim_domtrans(user_mail_domain)
Dan Walsh 3eaa99
	exim_manage_log(user_mail_domain)
Dan Walsh 3eaa99
')