Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Macros for clamscan
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author:  Brian May <bam@snoopy.apana.org.au>
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# can_clamd_connect(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a domain that can access clamd
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`can_clamd_connect',`
Chris PeBenito ab58ad
allow $1_t clamd_var_run_t:dir search;
Chris PeBenito ab58ad
allow $1_t clamd_var_run_t:sock_file write;
Chris PeBenito ab58ad
allow $1_t clamd_sock_t:sock_file write;
Chris PeBenito ab58ad
can_unix_connect($1_t, clamd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# clamscan_domain(domain_prefix)
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Define a derived domain for the clamscan program when executed
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
define(`clamscan_domain', `
Chris PeBenito ab58ad
# Derived domain based on the calling user domain and the program.
Chris PeBenito ab58ad
type $1_clamscan_t, domain, privlog;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Uses shared librarys
Chris PeBenito ab58ad
uses_shlib($1_clamscan_t)
Chris PeBenito ab58ad
allow $1_clamscan_t fs_t:filesystem getattr;
Chris PeBenito ab58ad
r_dir_file($1_clamscan_t, etc_t)
Chris PeBenito ab58ad
read_locale($1_clamscan_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Access virus signatures
Chris PeBenito ab58ad
allow $1_clamscan_t var_lib_t:dir search;
Chris PeBenito ab58ad
r_dir_file($1_clamscan_t, clamav_var_lib_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow temp files
Chris PeBenito ab58ad
tmp_domain($1_clamscan)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Why is this required?
Chris PeBenito ab58ad
allow $1_clamscan_t proc_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow $1_clamscan_t proc_t:file r_file_perms;
Chris PeBenito ab58ad
read_sysctl($1_clamscan_t)
Chris PeBenito ab58ad
allow $1_clamscan_t self:unix_stream_socket { connect create read write };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
define(`user_clamscan_domain',`
Chris PeBenito ab58ad
clamscan_domain($1)
Chris PeBenito ab58ad
role $1_r types $1_clamscan_t;
Chris PeBenito ab58ad
domain_auto_trans($1_t, clamscan_exec_t, $1_clamscan_t)
Chris PeBenito ab58ad
access_terminal($1_clamscan_t, $1)
Chris PeBenito ab58ad
r_dir_file($1_clamscan_t,$1_home_t);
Chris PeBenito ab58ad
r_dir_file($1_clamscan_t,$1_home_dir_t);
Chris PeBenito ab58ad
allow $1_clamscan_t $1_home_t:file r_file_perms;
Chris PeBenito ab58ad
allow $1_clamscan_t privfd:fd use;
Chris PeBenito ab58ad
ifdef(`gnome-pty-helper.te', `allow $1_clamscan_t $1_gph_t:fd use;')
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad