policy_module(psad)

########################################
#
# Declarations
#

type psad_t;
type psad_exec_t;
init_daemon_domain(psad_t, psad_exec_t)

type psad_etc_t;
files_config_file(psad_etc_t)

type psad_initrc_exec_t;
init_script_file(psad_initrc_exec_t)

type psad_runtime_t alias psad_var_run_t;
files_runtime_file(psad_runtime_t)

type psad_var_lib_t;
files_type(psad_var_lib_t)

type psad_var_log_t;
logging_log_file(psad_var_log_t)

type psad_tmp_t;
files_tmp_file(psad_tmp_t)

########################################
#
# Local policy
#

allow psad_t self:capability { dac_override net_admin net_raw setgid setuid };
dontaudit psad_t self:capability sys_tty_config;
allow psad_t self:process signal_perms;
allow psad_t self:fifo_file rw_fifo_file_perms;
allow psad_t self:rawip_socket create_socket_perms;

allow psad_t psad_etc_t:dir list_dir_perms;
allow psad_t psad_etc_t:file read_file_perms;
allow psad_t psad_etc_t:lnk_file read_lnk_file_perms;

manage_dirs_pattern(psad_t, psad_var_log_t, psad_var_log_t)
append_files_pattern(psad_t, psad_var_log_t, psad_var_log_t)
create_files_pattern(psad_t, psad_var_log_t, psad_var_log_t)
setattr_files_pattern(psad_t, psad_var_log_t, psad_var_log_t)
logging_log_filetrans(psad_t, psad_var_log_t, { file dir })

manage_dirs_pattern(psad_t, psad_runtime_t, psad_runtime_t)
manage_files_pattern(psad_t, psad_runtime_t, psad_runtime_t)
manage_sock_files_pattern(psad_t, psad_runtime_t, psad_runtime_t)
files_runtime_filetrans(psad_t, psad_runtime_t, { dir file sock_file })

manage_dirs_pattern(psad_t, psad_tmp_t, psad_tmp_t)
manage_files_pattern(psad_t, psad_tmp_t, psad_tmp_t)
files_tmp_filetrans(psad_t, psad_tmp_t, { file dir })

manage_fifo_files_pattern(psad_t, psad_var_lib_t, psad_var_lib_t)

kernel_read_system_state(psad_t)
kernel_read_network_state(psad_t)
kernel_read_net_sysctls(psad_t)

corecmd_exec_bin(psad_t)
corecmd_exec_shell(psad_t)

corenet_all_recvfrom_netlabel(psad_t)
corenet_tcp_sendrecv_generic_if(psad_t)
corenet_tcp_sendrecv_generic_node(psad_t)

corenet_sendrecv_whois_client_packets(psad_t)
corenet_tcp_connect_whois_port(psad_t)

dev_read_urand(psad_t)

files_read_etc_runtime_files(psad_t)
files_read_usr_files(psad_t)

fs_getattr_all_fs(psad_t)

auth_use_nsswitch(psad_t)

logging_read_generic_logs(psad_t)
logging_read_syslog_config(psad_t)
logging_send_syslog_msg(psad_t)

miscfiles_read_localization(psad_t)

sysnet_exec_ifconfig(psad_t)

optional_policy(`
	iptables_domtrans(psad_t)
')

optional_policy(`
	mta_send_mail(psad_t)
	mta_read_queue(psad_t)
')
