Chris PeBenito 4bf4ed
## <module name="mta" layer="keyservices">
Chris PeBenito 4bf4ed
## <summary>Policy common to all email tranfer agents.</summary>
Chris PeBenito 6b9383
Chris PeBenito 6b9383
#######################################
Chris PeBenito 6b9383
#
Chris PeBenito 6b9383
# Per user domain template for this module
Chris PeBenito 6b9383
#
Chris PeBenito 6b9383
# mta_per_userdomain_template(userdomain_prefix)
Chris PeBenito 6b9383
#
Chris PeBenito 6b9383
define(`mta_per_userdomain_template',`
Chris PeBenito bd202f
requires_block_template(`$0'_depend)
Chris PeBenito 6b9383
Chris PeBenito 075c4f
type $1_mail_t; # , user_mail_domain, nscd_client_domain;
Chris PeBenito 6b9383
domain_make_domain($1_mail_t)
Chris PeBenito 075c4f
role $1_r types $1_mail_t;
Chris PeBenito 6b9383
Chris PeBenito 6b9383
type $1_mail_tmp_t;
Chris PeBenito 38e24a
files_make_temporary_file($1_mail_tmp_t)
Chris PeBenito 6b9383
Chris PeBenito 075c4f
##############################
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
# $1_mail_t local policy
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow $1_mail_t self:capability { setuid setgid chown };
Chris PeBenito 075c4f
allow $1_mail_t self:process { sigkill sigstop signull signal setrlimit };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# tcp networking
Chris PeBenito 075c4f
allow $1_mail_t self:tcp_socket { create connect ioctl read getattr write setattr append bind getopt setopt shutdown };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# re-exec itself
Chris PeBenito 075c4f
allow $1_mail_t sendmail_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito 075c4f
allow $1_mail_t sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Transition from the user domain to the derived domain.
Chris PeBenito 075c4f
allow $1_t sendmail_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito 075c4f
allow $1_t sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 075c4f
allow $1_t $1_mail_t:process transition;
Chris PeBenito e7fcdc
type_transition $1_t sendmail_exec_t:process $1_mail_t;
Chris PeBenito 4bf4ed
allow $1_t $1_mail_t:fd use;
Chris PeBenito 4bf4ed
allow $1_mail_t $1_t:fd use;
Chris PeBenito 4bf4ed
allow $1_mail_t $1_t:fifo_file rw_file_perms;
Chris PeBenito 4bf4ed
allow $1_mail_t $1_t:process sigchld;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
kernel_read_kernel_sysctl($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
corenetwork_network_tcp_on_all_interfaces($1_mail_t)
Chris PeBenito 075c4f
corenetwork_network_raw_on_all_interfaces($1_mail_t)
Chris PeBenito 075c4f
corenetwork_network_tcp_on_all_nodes($1_mail_t)
Chris PeBenito 075c4f
corenetwork_network_raw_on_all_nodes($1_mail_t)
Chris PeBenito 075c4f
corenetwork_network_tcp_on_all_ports($1_mail_t)
Chris PeBenito 075c4f
corenetwork_bind_tcp_on_all_nodes($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
domain_use_widely_inheritable_file_descriptors($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
libraries_use_dynamic_loader($1_mail_t)
Chris PeBenito dd14d0
libraries_use_shared_libraries($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
corecommands_execute_general_programs($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
files_read_general_system_config($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 6b9383
logging_send_system_log_message($1_mail_t)
Chris PeBenito 6b9383
Chris PeBenito 075c4f
miscfiles_read_localization($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
sysnetwork_read_network_config($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
tunable_policy(`use_dns',`
Chris PeBenito 075c4f
allow $1_mail_t self:udp_socket { create ioctl read getattr write setattr append bind getopt setopt shutdown connect };
Chris PeBenito 075c4f
corenetwork_network_udp_on_all_interfaces($1_mail_t)
Chris PeBenito 075c4f
corenetwork_network_udp_on_all_nodes($1_mail_t)
Chris PeBenito 075c4f
corenetwork_bind_udp_on_all_nodes($1_mail_t)
Chris PeBenito 075c4f
corenetwork_network_udp_on_dns_port($1_mail_t)
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
optional_policy(`procmail.te',`
Chris PeBenito 075c4f
procmail_execute($1_mail_t)
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`TODO',`
Chris PeBenito 075c4f
Chris PeBenito 075c4f
can_ypbind($1_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow $1_mail_t device_t:dir search;
Chris PeBenito 075c4f
allow $1_mail_t { var_t var_spool_t }:dir search;
Chris PeBenito 075c4f
allow $1_mail_t sbin_t:dir search;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# It wants to check for nscd
Chris PeBenito 075c4f
dontaudit $1_mail_t var_run_t:dir search;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# For when the user wants to send mail via port 25 localhost
Chris PeBenito 075c4f
can_tcp_connect($1_t, mail_server_domain)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Read user temporary files.
Chris PeBenito 075c4f
allow $1_mail_t $1_tmp_t:file r_file_perms;
Chris PeBenito 075c4f
dontaudit $1_mail_t $1_tmp_t:file append;
Chris PeBenito 075c4f
ifdef(`postfix.te', `
Chris PeBenito 075c4f
# postfix seems to need write access if the file handle is opened read/write
Chris PeBenito 075c4f
allow $1_mail_t $1_tmp_t:file write;
Chris PeBenito 075c4f
')dnl end if postfix
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow mta_user_agent $1_tmp_t:file { read getattr };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Write to the user domain tty.
Chris PeBenito 075c4f
allow mta_user_agent $1_tty_device_t:chr_file { read write getattr ioctl };
Chris PeBenito 075c4f
allow mta_user_agent devpts_t:dir { read search getattr };
Chris PeBenito 075c4f
allow mta_user_agent $1_devpts_t:chr_file { read write getattr ioctl };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
allow $1_mail_t $1_tty_device_t:chr_file { read write getattr ioctl };
Chris PeBenito 075c4f
allow $1_mail_t devpts_t:dir { read search getattr };
Chris PeBenito 075c4f
allow $1_mail_t $1_devpts_t:chr_file { read write getattr ioctl };
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Inherit and use descriptors from gnome-pty-helper.
Chris PeBenito 075c4f
ifdef(`gnome-pty-helper.te', `allow $1_mail_t $1_gph_t:fd use;')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# Create dead.letter in user home directories.
Chris PeBenito 075c4f
file_type_auto_trans($1_mail_t, $1_home_dir_t, $1_home_t, file)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
if (use_samba_home_dirs) {
Chris PeBenito 075c4f
rw_dir_create_file($1_mail_t, cifs_t)
Chris PeBenito 075c4f
}
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# if you do not want to allow dead.letter then use the following instead
Chris PeBenito 075c4f
#allow $1_mail_t { $1_home_dir_t $1_home_t }:dir r_dir_perms;
Chris PeBenito 075c4f
#allow $1_mail_t $1_home_t:file r_file_perms;
Chris PeBenito 075c4f
Chris PeBenito 075c4f
# for reading .forward - maybe we need a new type for it?
Chris PeBenito 075c4f
# also for delivering mail to maildir
Chris PeBenito 075c4f
file_type_auto_trans(mta_delivery_agent, $1_home_dir_t, $1_home_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
ifdef(`qmail.te', `
Chris PeBenito 075c4f
allow $1_mail_t qmail_etc_t:dir search;
Chris PeBenito 075c4f
allow $1_mail_t qmail_etc_t:{ file lnk_file } read;
Chris PeBenito 075c4f
')dnl end if qmail
Chris PeBenito 075c4f
Chris PeBenito 075c4f
') dnl end TODO
Chris PeBenito 6b9383
')
Chris PeBenito 6b9383
Chris PeBenito 6b9383
define(`mta_per_userdomain_template_depend',`
Chris PeBenito 6b9383
Chris PeBenito 6b9383
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
# mta_make_mailserver_domain(domain,entrypointtype)
Chris PeBenito 075c4f
#
Chris PeBenito 7bba9d
define(`mta_make_mailserver_domain',`
Chris PeBenito 075c4f
requires_block_template(`$0'_depend)
Chris PeBenito ff3138
init_make_daemon_domain($1,$2)
Chris PeBenito 075c4f
typeattribute $1 mailserver_domain;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 7bba9d
define(`mta_make_mailserver_domain_depend',`
Chris PeBenito 075c4f
attribute mailserver_domain;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito 7bba9d
# mta_make_sendmail_mailserver_domain(domain,entrypointtype)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_make_sendmail_mailserver_domain',`
Chris PeBenito 7bba9d
requires_block_template(`$0'_depend)
Chris PeBenito 7bba9d
mta_make_mailserver_domain($1,sendmail_exec_t)
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_make_sendmail_mailserver_domain_depend',`
Chris PeBenito 7bba9d
type sendmail_exec_t;
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito c6a3a2
# mta_send_mail(domain)
Chris PeBenito 075c4f
#
Chris PeBenito c6a3a2
define(`mta_send_mail',`
Chris PeBenito 075c4f
requires_block_template(`$0'_depend)
Chris PeBenito 7bba9d
allow $1 sendmail_exec_t:lnk_file { getattr read };
Chris PeBenito 075c4f
allow $1 sendmail_exec_t:file { getattr read execute };
Chris PeBenito 075c4f
allow $1 system_mail_t:process transition;
Chris PeBenito e7fcdc
type_transition $1 sendmail_exec_t:process system_mail_t;
Chris PeBenito 075c4f
dontaudit $1 system_mail_t:process { noatsecure siginh rlimitinh };
Chris PeBenito c6a3a2
allow $1 system_mail_t:fd use;
Chris PeBenito c6a3a2
allow system_mail_t $1:fd use;
Chris PeBenito 4bf4ed
allow system_mail_t $1:fifo_file rw_file_perms;
Chris PeBenito 4bf4ed
allow system_mail_t $1:process sigchld;
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito c6a3a2
define(`mta_send_mail_depend',`
Chris PeBenito 075c4f
type system_mail_t, sendmail_exec_t;
Chris PeBenito 075c4f
class file { getattr read execute };
Chris PeBenito 7bba9d
class lnk_file { getattr read };
Chris PeBenito c6a3a2
class process { transition noatsecure siginh rlimitinh sigchld };
Chris PeBenito c6a3a2
class fd use;
Chris PeBenito c6a3a2
class fifo_file { ioctl read getattr lock write append };
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
#######################################
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
# mta_execute(domain)
Chris PeBenito 075c4f
#
Chris PeBenito 075c4f
define(`mta_execute',`
Chris PeBenito 075c4f
requires_block_template(`$0'_depend)
Chris PeBenito 075c4f
allow $1 sendmail_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
define(`mta_execute_depend',`
Chris PeBenito 075c4f
type sendmail_exec_t;
Chris PeBenito 075c4f
class file { getattr read execute execute_no_trans };
Chris PeBenito 075c4f
')
Chris PeBenito 7bba9d
Chris PeBenito daa0e0
########################################
Chris PeBenito daa0e0
## <interface name="mta_read_mail_aliases">
Chris PeBenito daa0e0
##	<description>
Chris PeBenito daa0e0
##		Read mail address aliases.
Chris PeBenito daa0e0
##	</description>
Chris PeBenito daa0e0
##	<parameter name="domain">
Chris PeBenito daa0e0
##		The type of the process performing this action.
Chris PeBenito daa0e0
##	</parameter>
Chris PeBenito daa0e0
##	<infoflow type="read" weight="10"/>
Chris PeBenito daa0e0
## </interface>
Chris PeBenito daa0e0
#
Chris PeBenito daa0e0
define(`mta_read_mail_aliases',`
Chris PeBenito daa0e0
requires_block_template(`$0'_depend)
Chris PeBenito daa0e0
allow $1 etc_aliases_t:file { getattr read };
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito daa0e0
define(`mta_read_mail_aliases_depend',`
Chris PeBenito daa0e0
type etc_aliases_t;
Chris PeBenito daa0e0
class file { getattr read };
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
# mta_modify_mail_aliases(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_modify_mail_aliases',`
Chris PeBenito 7bba9d
requires_block_template(`$0'_depend)
Chris PeBenito 7bba9d
allow sendmail_t etc_aliases_t:file { getattr read write append setattr };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_modify_mail_aliases_depend',`
Chris PeBenito 7bba9d
type etc_aliases_t;
Chris PeBenito 7bba9d
class file { getattr read write append setattr };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito 4bf4ed
# mta_get_mail_spool_attributes(domain)
Chris PeBenito 4bf4ed
#
Chris PeBenito 4bf4ed
define(`mta_get_mail_spool_attributes',`
Chris PeBenito 4bf4ed
requires_block_template(`$0'_depend)
Chris PeBenito 4bf4ed
files_search_system_spool_directory($1)
Chris PeBenito 4bf4ed
allow $1 mail_spool_t:dir r_dir_perms;
Chris PeBenito 4bf4ed
allow $1 mail_spool_t:lnk_file read;
Chris PeBenito 4bf4ed
allow $1 mail_spool_t:file getattr;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
define(`mta_get_mail_spool_attributes_depend',`
Chris PeBenito 4bf4ed
type mail_spool_t;
Chris PeBenito 4bf4ed
class dir r_dir_perms;
Chris PeBenito 4bf4ed
class file getattr;
Chris PeBenito 4bf4ed
class lnk_file read;
Chris PeBenito 4bf4ed
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
#######################################
Chris PeBenito 4bf4ed
#
Chris PeBenito b16c6b
# mta_modify_mail_spool(domain)
Chris PeBenito b16c6b
#
Chris PeBenito b16c6b
define(`mta_modify_mail_spool',`
Chris PeBenito b16c6b
requires_block_template(`$0'_depend)
Chris PeBenito 4bf4ed
files_search_system_spool_directory($1)
Chris PeBenito b16c6b
allow $1 mail_spool_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito b16c6b
allow $1 mail_spool_t:file { getattr read write append setattr };
Chris PeBenito b16c6b
')
Chris PeBenito b16c6b
Chris PeBenito b16c6b
define(`mta_modify_mail_spool_depend',`
Chris PeBenito b16c6b
type mail_spool_t;
Chris PeBenito b16c6b
class dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito b16c6b
class file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito b16c6b
')
Chris PeBenito b16c6b
Chris PeBenito b16c6b
#######################################
Chris PeBenito b16c6b
#
Chris PeBenito 7bba9d
# mta_manage_mail_spool(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_manage_mail_spool',`
Chris PeBenito 7bba9d
requires_block_template(`$0'_depend)
Chris PeBenito 4bf4ed
files_search_system_spool_directory($1)
Chris PeBenito 7bba9d
allow $1 mail_spool_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 7bba9d
allow $1 mail_spool_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_manage_mail_spool_depend',`
Chris PeBenito 7bba9d
type mail_spool_t;
Chris PeBenito 7bba9d
class dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 7bba9d
class file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
#######################################
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
# mta_manage_mail_queue(domain)
Chris PeBenito 7bba9d
#
Chris PeBenito 7bba9d
define(`mta_manage_mail_queue',`
Chris PeBenito 7bba9d
requires_block_template(`$0'_depend)
Chris PeBenito 7bba9d
allow $1 mqueue_spool_t:dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 7bba9d
allow $1 mqueue_spool_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 7bba9d
')
Chris PeBenito 7bba9d
Chris PeBenito 7bba9d
define(`mta_manage_mail_queue_depend',`
Chris PeBenito 7bba9d
type mqueue_spool_t;
Chris PeBenito 7bba9d
class dir { read getattr lock search ioctl add_name remove_name write };
Chris PeBenito 7bba9d
class file { create ioctl read getattr lock write setattr append link unlink rename }
Chris PeBenito 7bba9d
')
Chris PeBenito 4bf4ed
Chris PeBenito 4bf4ed
## </module>