# # Macros for spamassassin domains. # # Author: Colin Walters # spamassassin_domain(domain_prefix) # # Define derived domains for various spamassassin tools when executed # by a user domain. # # The type declarations for the executable types of these programs are # provided separately in domains/program/spamassassin.te and # domains/program/spamc.te. # undefine(`spamassassin_domain') ifdef(`spamassassin.te', `define(`using_spamassassin', `')') ifdef(`spamd.te', `define(`using_spamassassin', `')') ifdef(`spamc.te', `define(`using_spamassassin', `')') ifdef(`using_spamassassin',` ####### # Macros used internally in these spamassassin macros. # ### # Define a domain for a spamassassin-like program (spamc/spamassassin). # # Note: most of this should really be in a generic macro like # base_user_program($1, foo) define(`spamassassin_program_domain',` type $1_$2_t, domain, privlog; domain_auto_trans($1_t, $2_exec_t, $1_$2_t) role $1_r types $1_$2_t; general_domain_access($1_$2_t) base_file_read_access($1_$2_t) normal_config_file_read_access($1_$2_t) uses_shlib($1_$2_t) read_locale($1_$2_t) dontaudit $1_$2_t var_t:dir search; allow $1_$2_t privfd:fd use; allow $1_$2_t userpty_type:chr_file rw_file_perms; ') dnl end spamassassin_program_domain ### # Give privileges to a domain for accessing ~/.spamassassin # and a few other misc things like /dev/random. # This is granted to /usr/bin/spamassassin and # /usr/sbin/spamd, but NOT spamc (because it does not need it). # define(`spamassassin_agent_privs',` allow $1 { home_root_t user_home_dir_type sysadm_home_dir_t }:dir { search getattr }; file_type_auto_trans($1, $2_home_dir_t, $2_home_spamassassin_t) create_dir_file($1, $2_home_spamassassin_t) allow $1 random_device_t:chr_file r_file_perms; ') ####### # Define the main spamassassin macro. This itself creates a # domain for /usr/bin/spamassassin, and also spamc/spamd if # applicable. # define(`spamassassin_domain',` spamassassin_program_domain($1, spamassassin) # For perl libraries. allow $1_spamassassin_t lib_t:file rx_file_perms; # Ignore perl digging in /proc and /var. dontaudit $1_spamassassin_t proc_t:dir search; dontaudit $1_spamassassin_t { sysctl_t sysctl_kernel_t }:dir search; # The type of ~/.spamassassin type $1_home_spamassassin_t, file_type, sysadmfile; create_dir_file($1_t, $1_home_spamassassin_t) allow $1_t $1_home_spamassassin_t:notdevfile_class_set { relabelfrom relabelto }; allow $1_t $1_home_spamassassin_t:dir { relabelfrom relabelto }; spamassassin_agent_privs($1_spamassassin_t, $1) # Uncomment if you have spamassassin do DNS lookups #can_network($1_spamassassin_t) ### # Define the domain for /usr/bin/spamc # ifdef(`spamc.te',` spamassassin_program_domain($1, spamc) can_network($1_spamc_t) # Allow connecting to a local spamd ifdef(`spamd.te',` can_tcp_connect($1_spamc_t, spamd_t) ') dnl endif spamd.te ') dnl endif spamc.te ### # Define the domain for /usr/sbin/spamd # ifdef(`spamd.te',` spamassassin_agent_privs(spamd_t, $1) ') dnl endif spamd.te ') dnl end spamassassin_domain ', ` define(`spamassassin_domain',`') ')