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 6b9383
files_make_file(etc_aliases_t)
Chris PeBenito 6b9383
Chris PeBenito 6b9383
type etc_mail_t;
Chris PeBenito 6b9383
files_make_file(etc_mail_t)
Chris PeBenito 6b9383
Chris PeBenito 7bba9d
attribute mailserver_domain;
Chris PeBenito 7bba9d
Chris PeBenito 6b9383
type mqueue_spool_t;
Chris PeBenito 6b9383
files_make_file(mqueue_spool_t)
Chris PeBenito 6b9383
Chris PeBenito 6b9383
type mail_spool_t;
Chris PeBenito 6b9383
files_make_file(mail_spool_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
type sendmail_exec_t;
Chris PeBenito 075c4f
files_make_file(sendmail_exec_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
type system_mail_t; #, user_mail_domain, nscd_client_domain;
Chris PeBenito 075c4f
domain_make_domain(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 7bba9d
domain_make_entrypoint_file(system_mail_t,sendmail_exec_t)
Chris PeBenito 7bba9d
', `
Chris PeBenito ff3138
init_make_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 0a10b1
allow system_mail_t self:process { signal_perms setrlinit };
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 d11566
corenetwork_sendrecv_tcp_on_all_interfaces(system_mail_t)
Chris PeBenito d11566
corenetwork_sendrecv_raw_on_all_interfaces(system_mail_t)
Chris PeBenito d11566
corenetwork_sendrecv_tcp_on_all_nodes(system_mail_t)
Chris PeBenito d11566
corenetwork_sendrecv_raw_on_all_nodes(system_mail_t)
Chris PeBenito 075c4f
corenetwork_bind_tcp_on_all_nodes(system_mail_t)
Chris PeBenito d11566
corenetwork_sendrecv_tcp_on_all_ports(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
devices_get_pseudorandom_data(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 763c44
fs_get_persistent_fs_attributes(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
init_script_use_pseudoterminal(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
files_read_runtime_system_config(system_mail_t)
Chris PeBenito 075c4f
files_read_general_system_config(system_mail_t)
Chris PeBenito 075c4f
# It wants to check for nscd
Chris PeBenito 075c4f
files_ignore_search_runtime_data_directory(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
corecommands_execute_general_programs(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
libraries_use_dynamic_loader(system_mail_t)
Chris PeBenito dd14d0
libraries_use_shared_libraries(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
logging_send_system_log_message(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
miscfiles_read_localization(system_mail_t)
Chris PeBenito 075c4f
Chris PeBenito 075c4f
sysnetwork_read_network_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 0c73cd
	corenetwork_sendrecv_udp_on_all_interfaces(system_mail_t)
Chris PeBenito 0c73cd
	corenetwork_sendrecv_udp_on_all_nodes(system_mail_t)
Chris PeBenito 0c73cd
	corenetwork_bind_udp_on_all_nodes(system_mail_t)
Chris PeBenito 0c73cd
	corenetwork_sendrecv_udp_on_dns_port(system_mail_t)
Chris PeBenito 075c4f
')
Chris PeBenito 075c4f
Chris PeBenito 075c4f
optional_policy(`procmail.te',`
Chris PeBenito 0c73cd
	procmail_execute(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
Chris PeBenito 075c4f
can_ypbind(system_mail_t)
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 075c4f
domain_execute_all_entrypoint_programs(system_mail_t)
Chris PeBenito 075c4f
files_execute_system_config_script(system_mail_t)
Chris PeBenito 075c4f
corecommands_execute_general_programs(system_mail_t)
Chris PeBenito 075c4f
corecommands_execute_system_programs(system_mail_t)
Chris PeBenito 075c4f
libraries_use_dynamic_loader(system_mail_t)
Chris PeBenito dd14d0
libraries_use_shared_libraries(system_mail_t)
Chris PeBenito 075c4f
libraries_execute_dynamic_loader(system_mail_t)
Chris PeBenito 075c4f
libraries_execute_library_scripts(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 075c4f
') dnl end TODO