Chris PeBenito 17de1b
Chris PeBenito 9c4067
policy_module(mta, 2.2.1)
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
Chris PeBenito 9c4067
type mail_forward_t;
Chris PeBenito 9c4067
files_type(mail_forward_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 363e8f
allow system_mail_t self:fifo_file rw_fifo_file_perms;
Chris PeBenito 17de1b
Chris PeBenito 0bfccd
read_files_pattern(system_mail_t, etc_mail_t, etc_mail_t)
Chris PeBenito 9c4067
Chris PeBenito 363e8f
read_files_pattern(system_mail_t, mailcontent_type, mailcontent_type)
Chris PeBenito 17de1b
Chris PeBenito 9c4067
allow system_mail_t mail_forward_t:file read_file_perms;
Chris PeBenito 9c4067
Chris PeBenito 36095d
allow system_mail_t mta_exec_type:file entrypoint;
Chris PeBenito 36095d
Chris PeBenito 363e8f
can_exec(system_mail_t, mta_exec_type)
Chris PeBenito 36095d
Chris PeBenito 17de1b
kernel_read_system_state(system_mail_t)
Chris PeBenito 17de1b
kernel_read_network_state(system_mail_t)
Chris PeBenito 9c4067
kernel_request_load_module(system_mail_t)
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 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 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)
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)
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(`
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 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
	exim_domtrans(system_mail_t)
Chris PeBenito 363e8f
	exim_manage_log(system_mail_t)
Chris PeBenito 363e8f
')
Chris PeBenito 363e8f
Chris PeBenito 363e8f
optional_policy(`
Chris PeBenito 363e8f
	fail2ban_append_log(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(`
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
	# postfix needs this for newaliases
Chris PeBenito 17de1b
	files_getattr_tmp_dirs(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	postfix_exec_master(system_mail_t)
Chris PeBenito 17de1b
	postfix_read_config(system_mail_t)
Chris PeBenito 17de1b
	postfix_search_spool(system_mail_t)
Chris PeBenito 17de1b
Chris PeBenito 17de1b
	ifdef(`distro_redhat',`
Chris PeBenito 17de1b
		# compatability for old default main.cf
Chris PeBenito 0bfccd
		postfix_config_filetrans(system_mail_t, etc_aliases_t, { dir file lnk_file sock_file fifo_file })
Chris PeBenito 17de1b
	')
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(`
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
Chris PeBenito 9c4067
read_files_pattern(mailserver_delivery, mail_forward_t, mail_forward_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
Chris PeBenito 9c4067
########################################
Chris PeBenito 9c4067
#
Chris PeBenito 296273
# User send mail local policy
Chris PeBenito 296273
#
Chris PeBenito 296273
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
')