policy_module(smokeping, 1.2.0)

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

type smokeping_t;
type smokeping_exec_t;
init_daemon_domain(smokeping_t, smokeping_exec_t)

type smokeping_initrc_exec_t;
init_script_file(smokeping_initrc_exec_t)

type smokeping_var_run_t;
files_pid_file(smokeping_var_run_t)

type smokeping_var_lib_t;
files_type(smokeping_var_lib_t)

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

dontaudit smokeping_t self:capability { dac_read_search  };
allow smokeping_t self:process { setpgid signal_perms };
allow smokeping_t self:fifo_file rw_fifo_file_perms;
allow smokeping_t self:unix_stream_socket { accept listen };

manage_dirs_pattern(smokeping_t, smokeping_var_run_t, smokeping_var_run_t)
manage_files_pattern(smokeping_t, smokeping_var_run_t, smokeping_var_run_t)
files_pid_filetrans(smokeping_t, smokeping_var_run_t, { file dir })

manage_dirs_pattern(smokeping_t, smokeping_var_lib_t, smokeping_var_lib_t)
manage_files_pattern(smokeping_t, smokeping_var_lib_t, smokeping_var_lib_t)
files_var_lib_filetrans(smokeping_t, smokeping_var_lib_t, { file dir })
allow smokeping_t smokeping_var_lib_t:file map;

corecmd_exec_bin(smokeping_t)

dev_read_urand(smokeping_t)

files_search_tmp(smokeping_t)

auth_use_nsswitch(smokeping_t)
auth_dontaudit_read_shadow(smokeping_t)

logging_send_syslog_msg(smokeping_t)

mta_send_mail(smokeping_t)

netutils_domtrans_ping(smokeping_t)

#######################################
#
# Cgi local policy
#

optional_policy(`
	apache_content_template(smokeping_cgi)
	apache_content_alias_template(smokeping_cgi, smokeping_cgi)

	manage_dirs_pattern(smokeping_cgi_script_t, smokeping_var_lib_t, smokeping_var_lib_t)
	manage_files_pattern(smokeping_cgi_script_t, smokeping_var_lib_t, smokeping_var_lib_t)
    allow smokeping_cgi_script_t smokeping_var_lib_t:file map;

	getattr_files_pattern(smokeping_cgi_script_t, smokeping_var_run_t, smokeping_var_run_t)

	files_read_etc_files(smokeping_cgi_script_t)
	files_search_tmp(smokeping_cgi_script_t)
	files_search_var_lib(smokeping_cgi_script_t)

	auth_read_passwd(smokeping_cgi_script_t)

	logging_send_syslog_msg(smokeping_cgi_script_t)

	sysnet_dns_name_resolve(smokeping_cgi_script_t)

	netutils_domtrans_ping(smokeping_cgi_script_t)
')
