460ff9c
## <summary>Net Saint / NAGIOS - network monitoring server</summary>
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Create a set of derived types for various
460ff9c
##	nagios plugins,
460ff9c
## </summary>
460ff9c
## <param name="plugins_group_name">
460ff9c
##	<summary>
460ff9c
##	The name to be used for deriving type names.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
template(`nagios_plugin_template',`
460ff9c
	gen_require(`
460ff9c
		attribute nagios_plugin_domain;
460ff9c
		type nagios_t, nrpe_t;
460ff9c
	')
460ff9c
460ff9c
	type nagios_$1_plugin_t, nagios_plugin_domain;
460ff9c
	type nagios_$1_plugin_exec_t;
460ff9c
	application_domain(nagios_$1_plugin_t, nagios_$1_plugin_exec_t)
460ff9c
	role system_r types nagios_$1_plugin_t;
460ff9c
460ff9c
	domtrans_pattern(nrpe_t, nagios_$1_plugin_exec_t, nagios_$1_plugin_t)
460ff9c
	allow nagios_t nagios_$1_plugin_exec_t:file ioctl; 
460ff9c
460ff9c
	# needed by command.cfg
460ff9c
	domtrans_pattern(nagios_t, nagios_$1_plugin_exec_t, nagios_$1_plugin_t)
460ff9c
460ff9c
	kernel_read_system_state(nagios_$1_plugin_t)
460ff9c
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
## Execute the nagios unconfined plugins with
460ff9c
## a domain transition.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
## <summary>
460ff9c
## Domain allowed access.
460ff9c
## </summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_domtrans_unconfined_plugins',`
460ff9c
   gen_require(`
460ff9c
        type nagios_unconfined_plugin_t;
460ff9c
        type nagios_unconfined_plugin_exec_t;
460ff9c
   ')
460ff9c
460ff9c
    domtrans_pattern($1, nagios_unconfined_plugin_exec_t, nagios_unconfined_plugin_t)
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Do not audit attempts to read or write nagios
460ff9c
##	unnamed pipes.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain to not audit.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_dontaudit_rw_pipes',`
460ff9c
	gen_require(`
460ff9c
		type nagios_t;
460ff9c
	')
460ff9c
460ff9c
	dontaudit $1 nagios_t:fifo_file rw_fifo_file_perms;
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Allow the specified domain to read
460ff9c
##	nagios configuration files.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
## <rolecap/>
460ff9c
#
460ff9c
interface(`nagios_read_config',`
460ff9c
	gen_require(`
460ff9c
		type nagios_etc_t;
460ff9c
	')
460ff9c
460ff9c
	allow $1 nagios_etc_t:dir list_dir_perms;
460ff9c
	allow $1 nagios_etc_t:file read_file_perms;
460ff9c
	files_search_etc($1)
460ff9c
')
460ff9c
######################################
460ff9c
## <summary>
460ff9c
##	Read nagios lib files.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_read_lib',`
460ff9c
	gen_require(`
460ff9c
		type nagios_var_lib_t;
460ff9c
	')
460ff9c
460ff9c
	files_search_var($1)
460ff9c
    list_dirs_pattern($1, nagios_var_lib_t, nagios_var_lib_t)
460ff9c
	read_files_pattern($1, nagios_var_lib_t, nagios_var_lib_t)
460ff9c
')
460ff9c
460ff9c
######################################
460ff9c
## <summary>
460ff9c
##	Read nagios logs.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_read_log',`
460ff9c
	gen_require(`
460ff9c
		type nagios_log_t;
460ff9c
	')
460ff9c
460ff9c
	logging_search_logs($1)
460ff9c
	read_files_pattern($1, nagios_log_t, nagios_log_t)
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Do not audit attempts to read or write nagios logs.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain to not audit.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_dontaudit_rw_log',`
460ff9c
	gen_require(`
460ff9c
		type nagios_log_t;
460ff9c
	')
460ff9c
460ff9c
	dontaudit $1 nagios_log_t:file rw_file_perms;
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Search nagios spool directories.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_search_spool',`
460ff9c
	gen_require(`
460ff9c
		type nagios_spool_t;
460ff9c
	')
460ff9c
460ff9c
	allow $1 nagios_spool_t:dir search_dir_perms;
460ff9c
	files_search_spool($1)
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Append nagios spool files.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_append_spool',`
460ff9c
	gen_require(`
460ff9c
		type nagios_spool_t;
460ff9c
	')
460ff9c
460ff9c
	allow $1 nagios_spool_t:file append_file_perms;
460ff9c
	files_search_spool($1)
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Allow the specified domain to read
460ff9c
##	nagios temporary files.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_read_tmp_files',`
460ff9c
	gen_require(`
460ff9c
		type nagios_tmp_t;
460ff9c
	')
460ff9c
460ff9c
	allow $1 nagios_tmp_t:file read_file_perms;
460ff9c
	files_search_tmp($1)
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Allow the specified domain to read
460ff9c
##	nagios temporary files.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_rw_inerited_tmp_files',`
460ff9c
	gen_require(`
460ff9c
		type nagios_tmp_t;
460ff9c
	')
460ff9c
460ff9c
	allow $1 nagios_tmp_t:file rw_inherited_file_perms;
460ff9c
	files_search_tmp($1)
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	Execute the nagios NRPE with
460ff9c
##	a domain transition.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed to transition.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_domtrans_nrpe',`
460ff9c
	gen_require(`
460ff9c
		type nrpe_t, nrpe_exec_t;
460ff9c
	')
460ff9c
460ff9c
	domtrans_pattern($1, nrpe_exec_t, nrpe_t)
460ff9c
')
460ff9c
460ff9c
######################################
460ff9c
## <summary>
460ff9c
## Do not audit attempts to write nrpe daemon unnamed pipes.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
## <summary>
460ff9c
## Domain allowed access.
460ff9c
## </summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_dontaudit_write_pipes_nrpe',`
460ff9c
 gen_require(`
460ff9c
                type nrpe_t;
460ff9c
        ')
460ff9c
460ff9c
        dontaudit $1 nrpe_t:fifo_file write;
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##	All of the rules required to administrate
460ff9c
##	an nagios environment
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##	<summary>
460ff9c
##	Domain allowed access.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
## <param name="role">
460ff9c
##	<summary>
460ff9c
##	The role to be allowed to manage the nagios domain.
460ff9c
##	</summary>
460ff9c
## </param>
460ff9c
## <rolecap/>
460ff9c
#
460ff9c
interface(`nagios_admin',`
460ff9c
	gen_require(`
460ff9c
		type nagios_t, nrpe_t, nagios_initrc_exec_t;
460ff9c
		type nagios_tmp_t, nagios_log_t, nagios_var_run_t;
460ff9c
		type nagios_etc_t, nrpe_etc_t, nagios_spool_t;
460ff9c
	')
460ff9c
460ff9c
	allow $1 nagios_t:process signal_perms;
460ff9c
	ps_process_pattern($1, nagios_t)
460ff9c
	tunable_policy(`deny_ptrace',`',`
460ff9c
		allow $1 nagios_t:process ptrace;
460ff9c
	')
460ff9c
460ff9c
	init_labeled_script_domtrans($1, nagios_initrc_exec_t)
460ff9c
	domain_system_change_exemption($1)
460ff9c
	role_transition $2 nagios_initrc_exec_t system_r;
460ff9c
	allow $2 system_r;
460ff9c
460ff9c
	files_list_tmp($1)
460ff9c
	admin_pattern($1, nagios_tmp_t)
460ff9c
460ff9c
	logging_list_logs($1)
460ff9c
	admin_pattern($1, nagios_log_t)
460ff9c
460ff9c
	files_list_etc($1)
460ff9c
	admin_pattern($1, nagios_etc_t)
460ff9c
460ff9c
	files_list_spool($1)
460ff9c
	admin_pattern($1, nagios_spool_t)
460ff9c
460ff9c
	files_list_pids($1)
460ff9c
	admin_pattern($1, nagios_var_run_t)
460ff9c
460ff9c
	admin_pattern($1, nrpe_etc_t)
460ff9c
')
460ff9c
460ff9c
########################################
460ff9c
## <summary>
460ff9c
##      Send a null signal to nagios_unconfined_plugin.
460ff9c
## </summary>
460ff9c
## <param name="domain">
460ff9c
##      <summary>
460ff9c
##      Domain allowed access.
460ff9c
##      </summary>
460ff9c
## </param>
460ff9c
#
460ff9c
interface(`nagios_unconfined_signull',`
460ff9c
	gen_require(`
460ff9c
		type nagios_unconfined_plugin_t;
460ff9c
	')
460ff9c
460ff9c
	allow $1 nagios_unconfined_plugin_t:process signull;
460ff9c
')
nknazeko 5a42318
nknazeko 5a42318
########################################
nknazeko 5a42318
# 
nknazeko 5a42318
# Nagios interface compatibility blocks
nknazeko 5a42318
#
nknazeko 5a42318
# The following definitions ensure compatibility with distribution policy
nknazeko 5a42318
# versions that do not contain given interfaces (epel, or older Fedora
nknazeko 5a42318
# releases).
nknazeko 5a42318
# Each block tests for existence of given interface and defines it if needed.
nknazeko 5a42318
#
nknazeko 5a42318
nknazeko 5a42318
########################################
nknazeko 5a42318
## <summary>
nknazeko 5a42318
##	Allow caller to signull sssd.
nknazeko 5a42318
##	Backport from RHEL8
nknazeko 5a42318
## </summary>
nknazeko 5a42318
## <param name="domain">
nknazeko 5a42318
##	<summary>
nknazeko 5a42318
##	Domain allowed access.
nknazeko 5a42318
##	</summary>
nknazeko 5a42318
## </param>
nknazeko 5a42318
#
nknazeko 5a42318
ifndef(`sssd_signull',`
nknazeko 5a42318
	interface(`sssd_signull',`
nknazeko 5a42318
		gen_require(`
nknazeko 5a42318
			type sssd_t;
nknazeko 5a42318
		')
nknazeko 5a42318
nknazeko 5a42318
		allow $1 sssd_t:process signull;
nknazeko 5a42318
	')
nknazeko 5a42318
')