
## <summary>New monitoring suite that aims to be faster and more stable, while giving you a clearer view of the state of your network.</summary>

########################################
## <summary>
##	Execute naemon in the naemon domin.
## </summary>
## <param name="domain">
## <summary>
##	Domain allowed to transition.
## </summary>
## </param>
#
interface(`naemon_domtrans',`
	gen_require(`
		type naemon_t, naemon_exec_t;
	')

	corecmd_search_bin($1)
	domtrans_pattern($1, naemon_exec_t, naemon_t)
')

########################################
## <summary>
##	Execute naemon server in the naemon domain.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_initrc_domtrans',`
	gen_require(`
		type naemon_initrc_exec_t;
	')

	init_labeled_script_domtrans($1, naemon_initrc_exec_t)
')

########################################
## <summary>
##	Search naemon cache directories.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_search_cache',`
	gen_require(`
		type naemon_cache_t;
	')

	allow $1 naemon_cache_t:dir search_dir_perms;
	files_search_var($1)
')

########################################
## <summary>
##	Read naemon cache files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_read_cache_files',`
	gen_require(`
		type naemon_cache_t;
	')

	files_search_var($1)
	read_files_pattern($1, naemon_cache_t, naemon_cache_t)
')

########################################
## <summary>
##	Create, read, write, and delete
##	naemon cache files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_manage_cache_files',`
	gen_require(`
		type naemon_cache_t;
	')

	files_search_var($1)
	manage_files_pattern($1, naemon_cache_t, naemon_cache_t)
')

########################################
## <summary>
##	Manage naemon cache dirs.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_manage_cache_dirs',`
	gen_require(`
		type naemon_cache_t;
	')

	files_search_var($1)
	manage_dirs_pattern($1, naemon_cache_t, naemon_cache_t)
')

########################################
## <summary>
##	Read naemon's log files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <rolecap/>
#
interface(`naemon_read_log',`
	gen_require(`
		type naemon_log_t;
	')

	logging_search_logs($1)
	read_files_pattern($1, naemon_log_t, naemon_log_t)
')

########################################
## <summary>
##	Append to naemon log files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_append_log',`
	gen_require(`
		type naemon_log_t;
	')

	logging_search_logs($1)
	append_files_pattern($1, naemon_log_t, naemon_log_t)
')

########################################
## <summary>
##	Manage naemon log files
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_manage_log',`
	gen_require(`
		type naemon_log_t;
	')

	logging_search_logs($1)
	manage_dirs_pattern($1, naemon_log_t, naemon_log_t)
	manage_files_pattern($1, naemon_log_t, naemon_log_t)
	manage_lnk_files_pattern($1, naemon_log_t, naemon_log_t)
')

########################################
## <summary>
##	Search naemon lib directories.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_search_lib',`
	gen_require(`
		type naemon_var_lib_t;
	')

	allow $1 naemon_var_lib_t:dir search_dir_perms;
	files_search_var_lib($1)
')

########################################
## <summary>
##	Read naemon lib files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_read_lib_files',`
	gen_require(`
		type naemon_var_lib_t;
	')

	files_search_var_lib($1)
	read_files_pattern($1, naemon_var_lib_t, naemon_var_lib_t)
')

########################################
## <summary>
##	Manage naemon lib files.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_manage_lib_files',`
	gen_require(`
		type naemon_var_lib_t;
	')

	files_search_var_lib($1)
	manage_files_pattern($1, naemon_var_lib_t, naemon_var_lib_t)
')

########################################
## <summary>
##	Manage naemon lib directories.
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
#
interface(`naemon_manage_lib_dirs',`
	gen_require(`
		type naemon_var_lib_t;
	')

	files_search_var_lib($1)
	manage_dirs_pattern($1, naemon_var_lib_t, naemon_var_lib_t)
')


########################################
## <summary>
##	All of the rules required to administrate
##	an naemon environment
## </summary>
## <param name="domain">
##	<summary>
##	Domain allowed access.
##	</summary>
## </param>
## <param name="role">
##	<summary>
##	Role allowed access.
##	</summary>
## </param>
## <rolecap/>
#
interface(`naemon_admin',`
	gen_require(`
		type naemon_t;
		type naemon_initrc_exec_t;
		type naemon_cache_t;
		type naemon_log_t;
		type naemon_var_lib_t;
	')

	allow $1 naemon_t:process { signal_perms };
	ps_process_pattern($1, naemon_t)

    tunable_policy(`deny_ptrace',`',`
        allow $1 naemon_t:process ptrace;
    ')

	naemon_initrc_domtrans($1)
	domain_system_change_exemption($1)
	role_transition $2 naemon_initrc_exec_t system_r;
	allow $2 system_r;

	files_search_var($1)
	admin_pattern($1, naemon_cache_t)

	logging_search_logs($1)
	admin_pattern($1, naemon_log_t)

	files_search_var_lib($1)
	admin_pattern($1, naemon_var_lib_t)
	optional_policy(`
		systemd_passwd_agent_exec($1)
		systemd_read_fifo_file_passwd_run($1)
	')
')
