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 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 7bba9d
attribute mailserver_domain;
Chris PeBenito 7bba9d
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 075c4f
type system_mail_t; #, user_mail_domain, nscd_client_domain;
Chris PeBenito c9428d
domain_type(system_mail_t)
Chris PeBenito 075c4f
role system_r types system_mail_t;
Chris PeBenito 075c4f
Chris PeBenito 254bbc
ifdef(`targeted_policy',`',`
Chris PeBenito 7bba9d
optional_policy(`sendmail.te', `
Chris PeBenito c9428d
domain_entry_file(system_mail_t,sendmail_exec_t)
Chris PeBenito 7bba9d
', `
Chris PeBenito c9428d
init_system_domain(system_mail_t,sendmail_exec_t)
Chris PeBenito 7bba9d
') dnl end if sendmail
Chris PeBenito 7bba9d
') dnl end targeted_policy
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 075c4f
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_bind_all_nodes(system_mail_t)
Chris PeBenito 0fd9dc
corenet_tcp_sendrecv_all_ports(system_mail_t)
Chris PeBenito 075c4f
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 c9428d
files_read_etc_runtime_files(system_mail_t)
Chris PeBenito 8fd367
files_read_etc_files(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 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 075c4f
Chris PeBenito 075c4f
tunable_policy(`use_dns',`
Chris PeBenito 0a10b1
	allow system_mail_t self:udp_socket create_socket_perms;
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_if(system_mail_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_all_nodes(system_mail_t)
Chris PeBenito 0fd9dc
	corenet_udp_bind_all_nodes(system_mail_t)
Chris PeBenito 0fd9dc
	corenet_udp_sendrecv_dns_port(system_mail_t)
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito ab940a
optional_policy(`nis.te',`
Chris PeBenito ab940a
	nis_use_ypbind(system_mail_t)
Chris PeBenito ab940a
')
Chris PeBenito ab940a
Chris PeBenito 075c4f
optional_policy(`procmail.te',`
Chris PeBenito ab940a
	procmail_exec(system_mail_t)
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`TODO',`
Chris PeBenito 075c4f
Chris PeBenito 7bba9d
optional_policy(`sendmail.te',`
Chris PeBenito 7bba9d
allow system_mail_t etc_mail_t:dir { getattr search };
Chris PeBenito 7bba9d
allow system_mail_t etc_runtime_t:file { getattr read };
Chris PeBenito 7bba9d
allow system_mail_t proc_t:dir search;
Chris PeBenito 7bba9d
allow system_mail_t proc_t:file { getattr read };
Chris PeBenito 7bba9d
allow system_mail_t proc_t:lnk_file read;
Chris PeBenito 7bba9d
dontaudit system_mail_t proc_net_t:dir search;
Chris PeBenito 7bba9d
allow system_mail_t fs_t:filesystem getattr;
Chris PeBenito 7bba9d
allow system_mail_t var_t:dir getattr;
Chris PeBenito 7bba9d
allow system_mail_t var_spool_t:dir getattr;
Chris PeBenito 7bba9d
dontaudit system_mail_t userpty_type:chr_file { getattr read write };
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
# sendmail -q 
Chris PeBenito 7bba9d
allow system_mail_t mqueue_spool_t:dir rw_dir_perms;
Chris PeBenito 7bba9d
allow system_mail_t mqueue_spool_t:file create_file_perms;
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
ifdef(`crond.te', `
Chris PeBenito 7bba9d
dontaudit system_mail_t system_crond_tmp_t:file append;
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
') dnl end if sendmail
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow system_mail_t device_t:dir search;
Chris PeBenito 075c4f
allow system_mail_t { var_t var_spool_t }:dir search;
Chris PeBenito 075c4f
allow system_mail_t sbin_t:dir search;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Transition from a system domain to the derived domain.
Chris PeBenito 075c4f
domain_auto_trans(privmail, sendmail_exec_t, system_mail_t)
Chris PeBenito 075c4f
allow privmail sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`crond.te', `
Chris PeBenito 075c4f
# Read cron temporary files.
Chris PeBenito 0a10b1
allow system_mail_t system_crond_tmp_t:file r_file_perms;
Chris PeBenito 0a10b1
allow mta_user_agent system_crond_tmp_t:file r_file_perms;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`qmail.te', `
Chris PeBenito 075c4f
allow system_mail_t qmail_etc_t:dir search;
Chris PeBenito 075c4f
allow system_mail_t qmail_etc_t:{ file lnk_file } read;
Chris PeBenito 075c4f
')dnl end if qmail
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`targeted_policy', `
Chris PeBenito 075c4f
# rules are currently defined in sendmail.te, but it is not included in 
Chris PeBenito 075c4f
# targeted policy.  We could move these rules permanantly here.
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`postfix.te', `', `
Chris PeBenito c9428d
domain_exec_all_entry_files(system_mail_t)
Chris PeBenito 8fd367
files_exec_etc_files(system_mail_t)
Chris PeBenito c9428d
corecmd_exec_bin(system_mail_t)
Chris PeBenito c9428d
corecmd_exec_sbin(system_mail_t)
Chris PeBenito c9428d
libs_use_ld_so(system_mail_t)
Chris PeBenito c9428d
libs_use_shared_libs(system_mail_t)
Chris PeBenito c9428d
libs_exec_ld_so(system_mail_t)
Chris PeBenito c9428d
libs_exec_lib_files(system_mail_t)
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow system_mail_t { var_t var_spool_t }:dir getattr;
Chris PeBenito 075c4f
Chris PeBenito 0a10b1
allow system_mail_t mqueue_spool_t:dir create_dir_perms;
Chris PeBenito 0a10b1
allow system_mail_t mqueue_spool_t:file create_file_perms;
Chris PeBenito 0a10b1
allow system_mail_t mqueue_spool_t:lnk_file create_lnk_perms;
Chris PeBenito 075c4f
Chris PeBenito 0a10b1
allow system_mail_t mail_spool_t:dir create_dir_perms;
Chris PeBenito 0a10b1
allow system_mail_t mail_spool_t:file create_file_perms;
Chris PeBenito 0a10b1
allow system_mail_t mail_spool_t:lnk_file create_lnk_perms;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow system_mail_t mail_spool_t:fifo_file rw_file_perms;
Chris PeBenito 0a10b1
allow system_mail_t etc_mail_t:file r_file_perms;
Chris PeBenito 075c4f
', ` dnl if not targeted policy:
Chris PeBenito 7bba9d
optional_policy(`sendmail.te', `
Chris PeBenito 075c4f
# sendmail has an ugly design, the one process parses input from the user and
Chris PeBenito 075c4f
# then does system things with it.
Chris PeBenito 075c4f
domain_auto_trans(initrc_t, sendmail_exec_t, sendmail_t)
Chris PeBenito 7bba9d
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# allow the sysadmin to do "mail someone < /home/user/whatever"
Chris PeBenito 075c4f
allow sysadm_mail_t user_home_dir_type:dir search;
Chris PeBenito 075c4f
r_dir_file(sysadm_mail_t, user_home_type)
Chris PeBenito 075c4f
') dnl end ifdef targeted_policy
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# for a mail server process that does things in response to a user command
Chris PeBenito 075c4f
allow mta_user_agent userdomain:process sigchld;
Chris PeBenito 075c4f
allow mta_user_agent { userdomain privfd }:fd use;
Chris PeBenito 075c4f
ifdef(`crond.te', `
Chris PeBenito 075c4f
allow mta_user_agent crond_t:process sigchld;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
allow mta_user_agent sysadm_t:fifo_file { read write };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow { system_mail_t mta_user_agent } privmail:fd use;
Chris PeBenito 075c4f
allow { system_mail_t mta_user_agent } privmail:process sigchld;
Chris PeBenito 075c4f
allow { system_mail_t mta_user_agent } privmail:fifo_file { read write };
Chris PeBenito 075c4f
allow { system_mail_t mta_user_agent } admin_tty_type:chr_file { read write };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`arpwatch.te', `
Chris PeBenito 075c4f
# why is mail delivered to a directory of type arpwatch_data_t?
Chris PeBenito 075c4f
allow mta_delivery_agent arpwatch_data_t:dir search;
Chris PeBenito 075c4f
allow { system_mail_t mta_user_agent } arpwatch_tmp_t:file rw_file_perms;
Chris PeBenito 075c4f
ifdef(`hide_broken_symptoms', `
Chris PeBenito 075c4f
dontaudit { system_mail_t mta_user_agent } arpwatch_t:packet_socket { read write };
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
')dnl end if arpwatch.te
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow mta_delivery_agent home_root_t:dir { getattr search };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# for /var/spool/mail
Chris PeBenito 075c4f
ra_dir_create_file(mta_delivery_agent, mail_spool_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# for piping mail to a command
Chris PeBenito 075c4f
can_exec(mta_delivery_agent, shell_exec_t)
Chris PeBenito 075c4f
allow mta_delivery_agent bin_t:dir search;
Chris PeBenito 075c4f
allow mta_delivery_agent bin_t:lnk_file read;
Chris PeBenito 0a10b1
allow mta_delivery_agent { etc_runtime_t proc_t }:file r_file_perms;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Transition from a system domain to the derived domain.
Chris PeBenito 075c4f
domain_auto_trans(privmail, sendmail_exec_t, system_mail_t)
Chris PeBenito 0a10b1
allow privmail sendmail_exec_t:lnk_file r_file_perms;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`crond.te', `
Chris PeBenito 075c4f
# Read cron temporary files.
Chris PeBenito 0a10b1
allow system_mail_t system_crond_tmp_t:file r_file_perms;
Chris PeBenito 0a10b1
allow mta_user_agent system_crond_tmp_t:file r_file_perms;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 96ce00
optional_policy(`logrotate.te', `
Chris PeBenito 96ce00
	allow { system_mail_t mta_user_agent } logrotate_tmp_t:file r_file_perms;
Chris PeBenito 96ce00
')
Chris PeBenito 96ce00
Chris PeBenito 075c4f
') dnl end TODO