Chris PeBenito 0fbfa5
# Macros for MTA domains.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Author:   Russell Coker <russell@coker.com.au>
Chris PeBenito 0fbfa5
# Based on the work of: Stephen Smalley <sds@epoch.ncsc.mil>
Chris PeBenito 0fbfa5
#                       Timothy Fraser 
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# mail_domain(domain_prefix)
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# Define a derived domain for the sendmail program when executed by
Chris PeBenito 0fbfa5
# a user domain to send outgoing mail.  These domains are separate and
Chris PeBenito 0fbfa5
# independent of the domain used for the sendmail daemon process.
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
# The type declaration for the executable type for this program is
Chris PeBenito 0fbfa5
# provided separately in domains/program/mta.te. 
Chris PeBenito 0fbfa5
#
Chris PeBenito 0fbfa5
undefine(`mail_domain')
Chris PeBenito 0fbfa5
define(`mail_domain',`
Chris PeBenito 0fbfa5
# Derived domain based on the calling user domain and the program.
Chris PeBenito 0fbfa5
type $1_mail_t, domain, privlog, user_mail_domain, nscd_client_domain;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`sendmail.te', `
Chris PeBenito 0fbfa5
sendmail_user_domain($1)
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
can_exec($1_mail_t, sendmail_exec_t)
Chris PeBenito 0fbfa5
allow $1_mail_t sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# The user role is authorized for this domain.
Chris PeBenito 0fbfa5
role $1_r types $1_mail_t;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
uses_shlib($1_mail_t)
Chris PeBenito 0fbfa5
can_network_client_tcp($1_mail_t)
Chris PeBenito 0fbfa5
can_resolve($1_mail_t)
Chris PeBenito 0fbfa5
can_ypbind($1_mail_t)
Chris PeBenito 0fbfa5
allow $1_mail_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito 0fbfa5
allow $1_mail_t self:unix_stream_socket create_socket_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
read_locale($1_mail_t)
Chris PeBenito 0fbfa5
read_sysctl($1_mail_t)
Chris PeBenito 0fbfa5
allow $1_mail_t device_t:dir search;
Chris PeBenito 0fbfa5
allow $1_mail_t { var_t var_spool_t }:dir search;
Chris PeBenito 0fbfa5
allow $1_mail_t self:process { fork signal_perms setrlimit };
Chris PeBenito 0fbfa5
allow $1_mail_t sbin_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# It wants to check for nscd
Chris PeBenito 0fbfa5
dontaudit $1_mail_t var_run_t:dir search;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Use capabilities
Chris PeBenito 0fbfa5
allow $1_mail_t self:capability { setuid setgid chown };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Execute procmail.
Chris PeBenito 0fbfa5
can_exec($1_mail_t, bin_t)
Chris PeBenito 0fbfa5
ifdef(`procmail.te',`
Chris PeBenito 0fbfa5
can_exec($1_mail_t, procmail_exec_t)')
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifelse(`$1', `system', `
Chris PeBenito 0fbfa5
# Transition from a system domain to the derived domain.
Chris PeBenito 0fbfa5
domain_auto_trans(privmail, sendmail_exec_t, system_mail_t)
Chris PeBenito 0fbfa5
allow privmail sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
ifdef(`crond.te', `
Chris PeBenito 0fbfa5
# Read cron temporary files.
Chris PeBenito 0fbfa5
allow system_mail_t system_crond_tmp_t:file { read getattr ioctl };
Chris PeBenito 0fbfa5
allow mta_user_agent system_crond_tmp_t:file { read getattr };
Chris PeBenito 0fbfa5
')
Chris PeBenito 0fbfa5
allow system_mail_t initrc_devpts_t:chr_file { read write getattr };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
', `
Chris PeBenito 0fbfa5
# For when the user wants to send mail via port 25 localhost
Chris PeBenito 0fbfa5
can_tcp_connect($1_t, mail_server_domain)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Transition from the user domain to the derived domain.
Chris PeBenito 0fbfa5
domain_auto_trans($1_t, sendmail_exec_t, $1_mail_t)
Chris PeBenito 0fbfa5
allow $1_t sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Read user temporary files.
Chris PeBenito 0fbfa5
allow $1_mail_t $1_tmp_t:file r_file_perms;
Chris PeBenito 0fbfa5
dontaudit $1_mail_t $1_tmp_t:file append;
Chris PeBenito 0fbfa5
ifdef(`postfix.te', `
Chris PeBenito 0fbfa5
# postfix seems to need write access if the file handle is opened read/write
Chris PeBenito 0fbfa5
allow $1_mail_t $1_tmp_t:file write;
Chris PeBenito 0fbfa5
')dnl end if postfix
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow mta_user_agent $1_tmp_t:file { read getattr };
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Write to the user domain tty.
Chris PeBenito 0fbfa5
access_terminal(mta_user_agent, $1)
Chris PeBenito 0fbfa5
access_terminal($1_mail_t, $1)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Inherit and use descriptors from gnome-pty-helper.
Chris PeBenito 0fbfa5
ifdef(`gnome-pty-helper.te', `allow $1_mail_t $1_gph_t:fd use;')
Chris PeBenito 0fbfa5
allow $1_mail_t privfd:fd use;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# Create dead.letter in user home directories.
Chris PeBenito 0fbfa5
file_type_auto_trans($1_mail_t, $1_home_dir_t, $1_home_t, file)
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
if (use_samba_home_dirs) {
Chris PeBenito 0fbfa5
rw_dir_create_file($1_mail_t, cifs_t)
Chris PeBenito 0fbfa5
}
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# if you do not want to allow dead.letter then use the following instead
Chris PeBenito 0fbfa5
#allow $1_mail_t { $1_home_dir_t $1_home_t }:dir r_dir_perms;
Chris PeBenito 0fbfa5
#allow $1_mail_t $1_home_t:file r_file_perms;
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
# for reading .forward - maybe we need a new type for it?
Chris PeBenito 0fbfa5
# also for delivering mail to maildir
Chris PeBenito 0fbfa5
file_type_auto_trans(mta_delivery_agent, $1_home_dir_t, $1_home_t)
Chris PeBenito 0fbfa5
')dnl end if system
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
allow $1_mail_t etc_t:file { getattr read };
Chris PeBenito 0fbfa5
ifdef(`qmail.te', `
Chris PeBenito 0fbfa5
allow $1_mail_t qmail_etc_t:dir search;
Chris PeBenito 0fbfa5
allow $1_mail_t qmail_etc_t:{ file lnk_file } read;
Chris PeBenito 0fbfa5
')dnl end if qmail
Chris PeBenito 0fbfa5
Chris PeBenito 0fbfa5
')