Chris PeBenito 31b7c0
#DESC Sendmail - Mail server
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Authors:  Stephen Smalley <sds@epoch.ncsc.mil> and Timothy Fraser  
Chris PeBenito 31b7c0
# X-Debian-Packages: sendmail sendmail-wide
Chris PeBenito 31b7c0
# Depends: mta.te
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
#################################
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# Rules for the sendmail_t domain.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
# sendmail_t is the domain for the sendmail 
Chris PeBenito 31b7c0
# daemon started by the init rc scripts.
Chris PeBenito 31b7c0
#
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
daemon_base_domain(sendmail_launch)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow sendmail_launch_t { etc_t proc_t etc_runtime_t self }:file { getattr read };
Chris PeBenito 31b7c0
allow sendmail_launch_t { bin_t sbin_t etc_t }:lnk_file { getattr read };
Chris PeBenito 31b7c0
allow sendmail_launch_t { bin_t sbin_t }:dir search;
Chris PeBenito 31b7c0
can_exec(sendmail_launch_t, { etc_t bin_t sbin_t shell_exec_t })
Chris PeBenito 31b7c0
access_terminal(sendmail_launch_t, sysadm)
Chris PeBenito 31b7c0
ifdef(`consoletype.te', `
Chris PeBenito 31b7c0
domain_auto_trans(sendmail_launch_t, consoletype_exec_t, consoletype_t)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
read_locale(sendmail_launch_t)
Chris PeBenito 31b7c0
r_dir_file(sendmail_launch_t, etc_mail_t)
Chris PeBenito 31b7c0
allow sendmail_launch_t self:fifo_file rw_file_perms;
Chris PeBenito 31b7c0
allow sendmail_launch_t self:capability { chown kill sys_nice };
Chris PeBenito 31b7c0
allow sendmail_launch_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
can_ps(sendmail_launch_t, sendmail_t)
Chris PeBenito 31b7c0
dontaudit sendmail_launch_t domain:dir search;
Chris PeBenito 31b7c0
allow sendmail_launch_t sendmail_t:process signal;
Chris PeBenito 31b7c0
ifdef(`distro_redhat', `
Chris PeBenito 31b7c0
lock_domain(sendmail_launch)
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
dontaudit sendmail_launch_t mnt_t:dir search;
Chris PeBenito 31b7c0
allow sendmail_launch_t devpts_t:dir search;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
file_type_auto_trans(sendmail_launch_t, var_run_t, sendmail_var_run_t, file)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
daemon_core_rules(sendmail, `, nscd_client_domain, mta_delivery_agent, mail_server_domain, mail_server_sender')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# stuff from daemon_domain and daemon_base_domain because we can not have an
Chris PeBenito 31b7c0
# automatic transition from initrc_t
Chris PeBenito 31b7c0
rhgb_domain(sendmail_t)
Chris PeBenito 31b7c0
read_sysctl(sendmail_t)
Chris PeBenito 31b7c0
domain_auto_trans(sendmail_launch_t, sendmail_exec_t, sendmail_t)
Chris PeBenito 31b7c0
allow sendmail_t privfd:fd use;
Chris PeBenito 31b7c0
allow { sendmail_t sendmail_launch_t } var_t:dir { getattr search };
Chris PeBenito 31b7c0
var_run_domain(sendmail)
Chris PeBenito 31b7c0
allow sendmail_t { ttyfile devtty_t }:chr_file rw_file_perms;
Chris PeBenito 31b7c0
dontaudit { sendmail_t sendmail_launch_t } sysadm_home_dir_t:dir search;
Chris PeBenito 31b7c0
read_locale(sendmail_t)
Chris PeBenito 31b7c0
allow sendmail_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
tmp_domain(sendmail)
Chris PeBenito 31b7c0
logdir_domain(sendmail)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Use capabilities
Chris PeBenito 31b7c0
allow sendmail_t self:capability { setuid setgid net_bind_service sys_nice chown sys_tty_config };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Use the network.
Chris PeBenito 31b7c0
can_network(sendmail_t)
Chris PeBenito 31b7c0
allow sendmail_t port_type:tcp_socket name_connect;
Chris PeBenito 31b7c0
can_ypbind(sendmail_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow sendmail_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito 31b7c0
allow sendmail_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 31b7c0
allow sendmail_t self:fifo_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Bind to the SMTP port.
Chris PeBenito 31b7c0
allow sendmail_t smtp_port_t:tcp_socket name_bind;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow sendmail_t etc_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Write to /etc/aliases and /etc/mail.
Chris PeBenito 31b7c0
allow sendmail_t etc_aliases_t:file { setattr rw_file_perms };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow sendmail_t etc_mail_t:dir rw_dir_perms;
Chris PeBenito 31b7c0
allow sendmail_t etc_mail_t:file create_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Write to /var/spool/mail and /var/spool/mqueue.
Chris PeBenito 31b7c0
allow sendmail_t var_spool_t:dir { getattr search };
Chris PeBenito 31b7c0
allow sendmail_t mail_spool_t:dir rw_dir_perms;
Chris PeBenito 31b7c0
allow sendmail_t mail_spool_t:file create_file_perms;
Chris PeBenito 31b7c0
allow sendmail_t mqueue_spool_t:dir rw_dir_perms;
Chris PeBenito 31b7c0
allow sendmail_t mqueue_spool_t:file create_file_perms;
Chris PeBenito 31b7c0
allow sendmail_t urandom_device_t:chr_file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Read /usr/lib/sasl2/.*
Chris PeBenito 31b7c0
allow sendmail_t lib_t:file { getattr read };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# When sendmail runs as user_mail_domain, it needs some extra permissions
Chris PeBenito 31b7c0
# to update /etc/mail/statistics.
Chris PeBenito 31b7c0
allow user_mail_domain etc_mail_t:file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Silently deny attempts to access /root.
Chris PeBenito 31b7c0
dontaudit system_mail_t { staff_home_dir_t sysadm_home_dir_t}:dir { getattr search };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# Run procmail in its own domain, if defined.
Chris PeBenito 31b7c0
ifdef(`procmail.te',`
Chris PeBenito 31b7c0
domain_auto_trans(sendmail_t, procmail_exec_t, procmail_t)
Chris PeBenito 31b7c0
domain_auto_trans(system_mail_t, procmail_exec_t, procmail_t)
Chris PeBenito 31b7c0
allow sendmail_t bin_t:dir { getattr search };
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
read_sysctl(sendmail_t)
Chris PeBenito 31b7c0
read_sysctl(system_mail_t)
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
allow system_mail_t etc_mail_t:dir { getattr search };
Chris PeBenito 31b7c0
allow system_mail_t etc_runtime_t:file { getattr read };
Chris PeBenito 31b7c0
allow system_mail_t proc_t:dir search;
Chris PeBenito 31b7c0
allow system_mail_t proc_t:file { getattr read };
Chris PeBenito 31b7c0
allow system_mail_t proc_t:lnk_file read;
Chris PeBenito 31b7c0
dontaudit system_mail_t proc_net_t:dir search;
Chris PeBenito 31b7c0
allow system_mail_t fs_t:filesystem getattr;
Chris PeBenito 31b7c0
allow system_mail_t self:dir { getattr search };
Chris PeBenito 31b7c0
allow system_mail_t var_t:dir getattr;
Chris PeBenito 31b7c0
allow system_mail_t var_spool_t:dir getattr;
Chris PeBenito 31b7c0
dontaudit system_mail_t userpty_type:chr_file { getattr read write };
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# sendmail -q 
Chris PeBenito 31b7c0
allow system_mail_t mqueue_spool_t:dir rw_dir_perms;
Chris PeBenito 31b7c0
allow system_mail_t mqueue_spool_t:file create_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
ifdef(`crond.te', `
Chris PeBenito 31b7c0
dontaudit system_mail_t system_crond_tmp_t:file append;
Chris PeBenito 31b7c0
')
Chris PeBenito 31b7c0
dontaudit sendmail_t admin_tty_type:chr_file rw_file_perms;
Chris PeBenito 31b7c0
Chris PeBenito 31b7c0
# sendmail wants to read /var/run/utmp if the controlling tty is /dev/console
Chris PeBenito 31b7c0
allow sendmail_t initrc_var_run_t:file { getattr read };
Chris PeBenito 31b7c0
dontaudit sendmail_t initrc_var_run_t:file { lock write };
Chris PeBenito 31b7c0