Chris PeBenito 0fbfa5
#DESC MTA - Mail agents
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Author: Russell Coker <russell@coker.com.au>
Chris PeBenito 0fbfa5
# X-Debian-Packages: postfix exim sendmail sendmail-wide
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# policy for all mail servers, including allowing user to send mail from the
Chris PeBenito 0fbfa5
# command-line and for cron jobs to use sendmail -t
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# sendmail_exec_t is the type of /usr/sbin/sendmail
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# define sendmail_exec_t if sendmail.te does not do it for us
Chris PeBenito 0fbfa5
ifdef(`sendmail.te', `', `
Chris PeBenito 0fbfa5
type sendmail_exec_t, file_type, exec_type, sysadmfile;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# create a system_mail_t domain for daemons, init scripts, etc when they run
Chris PeBenito 0fbfa5
# "mail user@domain"
Chris PeBenito 0fbfa5
mail_domain(system)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`targeted_policy', `
Chris PeBenito 0fbfa5
# rules are currently defined in sendmail.te, but it is not included in 
Chris PeBenito 0fbfa5
# targeted policy.  We could move these rules permanantly here.
Chris PeBenito 0fbfa5
ifdef(`postfix.te', `', `can_exec_any(system_mail_t)')
Chris PeBenito a08248
allow system_mail_t self:dir search;
Chris PeBenito 5493c2
allow system_mail_t self:lnk_file read;
Chris PeBenito 0fbfa5
r_dir_file(system_mail_t, { proc_t proc_net_t })
Chris PeBenito 0fbfa5
allow system_mail_t fs_t:filesystem getattr;
Chris PeBenito 0fbfa5
allow system_mail_t { var_t var_spool_t }:dir getattr;
Chris PeBenito 0fbfa5
create_dir_file(system_mail_t, mqueue_spool_t)
Chris PeBenito 0fbfa5
create_dir_file(system_mail_t, mail_spool_t)
Chris PeBenito 0fbfa5
allow system_mail_t mail_spool_t:fifo_file rw_file_perms;
Chris PeBenito 0fbfa5
allow system_mail_t etc_mail_t:file { getattr read };
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
ifdef(`sendmail.te', `
Chris PeBenito 0fbfa5
# sendmail has an ugly design, the one process parses input from the user and
Chris PeBenito 0fbfa5
# then does system things with it.
Chris PeBenito 0fbfa5
domain_auto_trans(initrc_t, sendmail_exec_t, sendmail_t)
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
domain_auto_trans(initrc_t, sendmail_exec_t, system_mail_t)
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
allow initrc_t sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# allow the sysadmin to do "mail someone < /home/user/whatever"
Chris PeBenito 0fbfa5
allow sysadm_mail_t user_home_dir_type:dir search;
Chris PeBenito 0fbfa5
r_dir_file(sysadm_mail_t, user_home_type)
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
# for a mail server process that does things in response to a user command
Chris PeBenito 0fbfa5
allow mta_user_agent userdomain:process sigchld;
Chris PeBenito 0fbfa5
allow mta_user_agent { userdomain privfd }:fd use;
Chris PeBenito 0fbfa5
ifdef(`crond.te', `
Chris PeBenito 0fbfa5
allow mta_user_agent crond_t:process sigchld;
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
allow mta_user_agent sysadm_t:fifo_file { read write };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow { system_mail_t mta_user_agent } privmail:fd use;
Chris PeBenito 0fbfa5
allow { system_mail_t mta_user_agent } privmail:process sigchld;
Chris PeBenito 0fbfa5
allow { system_mail_t mta_user_agent } privmail:fifo_file { read write };
Chris PeBenito 0fbfa5
allow { system_mail_t mta_user_agent } admin_tty_type:chr_file { read write };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow mta_delivery_agent home_root_t:dir { getattr search };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for /var/spool/mail
Chris PeBenito 0fbfa5
ra_dir_create_file(mta_delivery_agent, mail_spool_t)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for piping mail to a command
Chris PeBenito 0fbfa5
can_exec(mta_delivery_agent, shell_exec_t)
Chris PeBenito 0fbfa5
allow mta_delivery_agent bin_t:dir search;
Chris PeBenito 0fbfa5
allow mta_delivery_agent bin_t:lnk_file read;
Chris PeBenito 0fbfa5
allow mta_delivery_agent devtty_t:chr_file rw_file_perms;
Chris PeBenito 0fbfa5
allow mta_delivery_agent { etc_runtime_t proc_t }:file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow system_mail_t etc_runtime_t:file { getattr read };
Chris PeBenito 5493c2
allow system_mail_t { random_device_t urandom_device_t }:chr_file { getattr read };
Chris PeBenito fe9d17
ifdef(`targeted_policy', `
Chris PeBenito fe9d17
typealias system_mail_t alias sysadm_mail_t;
Chris PeBenito fe9d17
')
Chris PeBenito fe9d17