Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for spamassassin domains.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author: Colin Walters <walters@verbum.org>
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# spamassassin_domain(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define derived domains for various spamassassin tools when executed
Chris PeBenito ab58ad
# by a user domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# The type declarations for the executable types of these programs are
Chris PeBenito ab58ad
# provided separately in domains/program/spamassassin.te and
Chris PeBenito ab58ad
# domains/program/spamc.te.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
undefine(`spamassassin_domain')
Chris PeBenito ab58ad
ifdef(`spamassassin.te', `define(`using_spamassassin', `')')
Chris PeBenito ab58ad
ifdef(`spamd.te', `define(`using_spamassassin', `')')
Chris PeBenito ab58ad
ifdef(`spamc.te', `define(`using_spamassassin', `')')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`using_spamassassin',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#######
Chris PeBenito ab58ad
# Macros used internally in these spamassassin macros.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
###
Chris PeBenito ab58ad
# Define a domain for a spamassassin-like program (spamc/spamassassin).
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Note: most of this should really be in a generic macro like
Chris PeBenito ab58ad
# base_user_program($1, foo)
Chris PeBenito ab58ad
define(`spamassassin_program_domain',`
Chris PeBenito ab58ad
type $1_$2_t, domain, privlog $3;
Chris PeBenito ab58ad
domain_auto_trans($1_t, $2_exec_t, $1_$2_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
role $1_r types $1_$2_t;
Chris PeBenito ab58ad
general_domain_access($1_$2_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
base_file_read_access($1_$2_t)
Chris PeBenito ab58ad
r_dir_file($1_$2_t, etc_t)
Chris PeBenito ab58ad
ifdef(`sendmail.te', `
Chris PeBenito ab58ad
r_dir_file($1_$2_t, etc_mail_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow $1_$2_t etc_runtime_t:file r_file_perms;
Chris PeBenito ab58ad
uses_shlib($1_$2_t)
Chris PeBenito ab58ad
read_locale($1_$2_t)
Chris PeBenito ab58ad
dontaudit $1_$2_t var_t:dir search;
Chris PeBenito ab58ad
tmp_domain($1_$2)
Chris PeBenito ab58ad
allow $1_$2_t privfd:fd use;
Chris PeBenito ab58ad
allow $1_$2_t userpty_type:chr_file rw_file_perms;
Chris PeBenito ab58ad
') dnl end spamassassin_program_domain
Chris PeBenito ab58ad
Chris PeBenito ab58ad
###
Chris PeBenito ab58ad
# Give privileges to a domain for accessing ~/.spamassassin
Chris PeBenito ab58ad
# and a few other misc things like /dev/random.
Chris PeBenito ab58ad
# This is granted to /usr/bin/spamassassin and
Chris PeBenito ab58ad
# /usr/sbin/spamd, but NOT spamc (because it does not need it).
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`spamassassin_agent_privs',`
Chris PeBenito ab58ad
allow $1 home_root_t:dir r_dir_perms;
Chris PeBenito ab58ad
file_type_auto_trans($1, $2_home_dir_t, $2_spamassassin_home_t)
Chris PeBenito ab58ad
create_dir_file($1, $2_spamassassin_home_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow $1 urandom_device_t:chr_file r_file_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#######
Chris PeBenito ab58ad
# Define the main spamassassin macro.  This itself creates a
Chris PeBenito ab58ad
# domain for /usr/bin/spamassassin, and also spamc/spamd if
Chris PeBenito ab58ad
# applicable.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`spamassassin_domain',`
Chris PeBenito ab58ad
spamassassin_program_domain($1, spamassassin)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# For perl libraries.
Chris PeBenito ab58ad
allow $1_spamassassin_t lib_t:file rx_file_perms;
Chris PeBenito ab58ad
# Ignore perl digging in /proc and /var.
Chris PeBenito ab58ad
dontaudit $1_spamassassin_t proc_t:dir search;
Chris PeBenito ab58ad
dontaudit $1_spamassassin_t proc_t:lnk_file read;
Chris PeBenito ab58ad
dontaudit $1_spamassassin_t { sysctl_t sysctl_kernel_t }:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# For ~/.spamassassin
Chris PeBenito ab58ad
home_domain($1, spamassassin)
Chris PeBenito ab58ad
file_type_auto_trans($1_spamassassin_t, $1_home_dir_t, $1_spamassassin_home_t, dir)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
spamassassin_agent_privs($1_spamassassin_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_resolve($1_spamassassin_t)
Chris PeBenito ab58ad
# set tunable if you have spamassassin do DNS lookups
Chris PeBenito ab58ad
if (spamassasin_can_network) {
Chris PeBenito ab58ad
can_network($1_spamassassin_t)
Chris PeBenito ab58ad
allow $1_spamassassin_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
if (spamassasin_can_network && allow_ypbind) {
Chris PeBenito ab58ad
uncond_can_ypbind($1_spamassassin_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
###
Chris PeBenito ab58ad
# Define the domain for /usr/bin/spamc
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
ifdef(`spamc.te',`
Chris PeBenito ab58ad
spamassassin_program_domain($1, spamc, `, nscd_client_domain')
Chris PeBenito ab58ad
can_network($1_spamc_t)
Chris PeBenito ab58ad
allow $1_spamc_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind($1_spamc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow connecting to a local spamd
Chris PeBenito ab58ad
ifdef(`spamd.te',`
Chris PeBenito ab58ad
can_tcp_connect($1_spamc_t, spamd_t)
Chris PeBenito ab58ad
can_unix_connect($1_spamc_t, spamd_t)
Chris PeBenito ab58ad
allow $1_spamc_t spamd_tmp_t:sock_file rw_file_perms;
Chris PeBenito ab58ad
') dnl endif spamd.te
Chris PeBenito ab58ad
') dnl endif spamc.te
Chris PeBenito ab58ad
Chris PeBenito ab58ad
###
Chris PeBenito ab58ad
# Define the domain for /usr/sbin/spamd
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
ifdef(`spamd.te',`
Chris PeBenito ab58ad
Chris PeBenito ab58ad
spamassassin_agent_privs(spamd_t, $1)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
') dnl endif spamd.te
Chris PeBenito ab58ad
Chris PeBenito ab58ad
') dnl end spamassassin_domain
Chris PeBenito ab58ad
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`spamassassin_domain',`')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
')