Chris PeBenito a5ef55
## <summary>Intrusion Detection and Log Analysis with iptables</summary>
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Execute a domain transition to run psad.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed to transition.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_domtrans',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_t, psad_exec_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	domtrans_pattern($1, psad_exec_t, psad_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Send a generic signal to psad
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_signal',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	allow $1 psad_t:process signal;
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
#######################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Send a null signal to psad.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_signull',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	allow $1 psad_t:process signull;
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Read psad etc configuration files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_read_config',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_etc_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_etc($1)
Chris PeBenito a5ef55
	read_files_pattern($1, psad_etc_t, psad_etc_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Manage psad etc configuration files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_manage_config',`
Chris PeBenito 3f67f7
	gen_require(`
Chris PeBenito 3f67f7
		type psad_etc_t;
Chris PeBenito 3f67f7
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_etc($1)
Chris PeBenito a5ef55
	manage_dirs_pattern($1, psad_etc_t, psad_etc_t)
Chris PeBenito 3f67f7
	manage_files_pattern($1, psad_etc_t, psad_etc_t)
Chris PeBenito a5ef55
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Read psad PID files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_read_pid_files',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_var_run_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_pids($1)
Chris PeBenito a5ef55
	read_files_pattern($1, psad_var_run_t, psad_var_run_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Read psad PID files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_rw_pid_files',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_var_run_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_pids($1)
Chris PeBenito a5ef55
	rw_files_pattern($1, psad_var_run_t, psad_var_run_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Allow the specified domain to read psad's log files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
## <rolecap/>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_read_log',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_var_log_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	logging_search_logs($1)
Chris PeBenito a5ef55
	list_dirs_pattern($1, psad_var_log_t, psad_var_log_t)
Chris PeBenito a5ef55
	read_files_pattern($1, psad_var_log_t, psad_var_log_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Allow the specified domain to append to psad's log files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
## <rolecap/>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_append_log',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_var_log_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	logging_search_logs($1)
Chris PeBenito a5ef55
	list_dirs_pattern($1, psad_var_log_t, psad_var_log_t)
Chris PeBenito a5ef55
	append_files_pattern($1, psad_var_log_t, psad_var_log_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Read and write psad fifo files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_rw_fifo_file',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_var_lib($1)
Chris PeBenito a5ef55
	search_dirs_pattern($1, psad_var_lib_t, psad_var_lib_t)
Chris PeBenito a5ef55
	rw_fifo_files_pattern($1, psad_var_lib_t, psad_var_lib_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
#######################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	Read and write psad tmp files.
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_rw_tmp_files',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_tmp_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_tmp($1)
Chris PeBenito a5ef55
	rw_files_pattern($1, psad_tmp_t, psad_tmp_t)
Chris PeBenito a5ef55
')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
########################################
Chris PeBenito a5ef55
## <summary>
Chris PeBenito a5ef55
##	All of the rules required to administrate 
Chris PeBenito a5ef55
##	an psad environment
Chris PeBenito a5ef55
## </summary>
Chris PeBenito a5ef55
## <param name="domain">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	Domain allowed access.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
## <param name="role">
Chris PeBenito a5ef55
##	<summary>
Chris PeBenito a5ef55
##	The role to be allowed to manage the syslog domain.
Chris PeBenito a5ef55
##	</summary>
Chris PeBenito a5ef55
## </param>
Chris PeBenito a5ef55
## <rolecap/>
Chris PeBenito a5ef55
#
Chris PeBenito a5ef55
interface(`psad_admin',`
Chris PeBenito a5ef55
	gen_require(`
Chris PeBenito a5ef55
		type psad_t, psad_var_run_t, psad_var_log_t;
Chris PeBenito a5ef55
		type psad_initrc_exec_t, psad_var_lib_t;
Chris PeBenito a5ef55
		type psad_tmp_t;
Chris PeBenito a5ef55
	')
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	allow $1 psad_t:process { ptrace signal_perms };
Chris PeBenito a5ef55
	ps_process_pattern($1, psad_t)
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	init_labeled_script_domtrans($1, psad_initrc_exec_t)
Chris PeBenito a5ef55
	domain_system_change_exemption($1)
Chris PeBenito a5ef55
	role_transition $2 psad_initrc_exec_t system_r;
Chris PeBenito a5ef55
	allow $2 system_r;
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_etc($1)
Chris PeBenito a5ef55
	admin_pattern($1, psad_etc_t)
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_pids($1)
Chris PeBenito a5ef55
	admin_pattern($1, psad_var_run_t)
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	logging_search_logs($1)
Chris PeBenito a5ef55
	admin_pattern($1, psad_var_log_t)
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_var_lib($1)
Chris PeBenito a5ef55
	admin_pattern($1, psad_var_lib_t)
Chris PeBenito a5ef55
Chris PeBenito a5ef55
	files_search_tmp($1)
Chris PeBenito a5ef55
	admin_pattern($1, psad_tmp_t)
Chris PeBenito a5ef55
')