policy_module(cyphesis, 1.3.0)

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

type cyphesis_t;
type cyphesis_exec_t;
init_daemon_domain(cyphesis_t, cyphesis_exec_t)
application_executable_file(cyphesis_exec_t)

type cyphesis_initrc_exec_t;
init_script_file(cyphesis_initrc_exec_t)

type cyphesis_log_t;
logging_log_file(cyphesis_log_t)

type cyphesis_tmp_t;
files_tmp_file(cyphesis_tmp_t)

type cyphesis_var_run_t;
files_pid_file(cyphesis_var_run_t)

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

allow cyphesis_t self:process { setfscreate setsched signal };
allow cyphesis_t self:fifo_file rw_fifo_file_perms;
allow cyphesis_t self:tcp_socket { accept listen };
allow cyphesis_t self:unix_stream_socket { accept listen };

append_files_pattern(cyphesis_t, cyphesis_log_t, cyphesis_log_t)
create_files_pattern(cyphesis_t, cyphesis_log_t, cyphesis_log_t)
setattr_files_pattern(cyphesis_t, cyphesis_log_t, cyphesis_log_t)
logging_log_filetrans(cyphesis_t, cyphesis_log_t, file)

manage_dirs_pattern(cyphesis_t, cyphesis_var_run_t, cyphesis_var_run_t)
manage_files_pattern(cyphesis_t, cyphesis_var_run_t, cyphesis_var_run_t)
manage_sock_files_pattern(cyphesis_t, cyphesis_var_run_t, cyphesis_var_run_t)
files_pid_filetrans(cyphesis_t, cyphesis_var_run_t, dir)

kernel_read_system_state(cyphesis_t)
kernel_read_kernel_sysctls(cyphesis_t)

corecmd_search_bin(cyphesis_t)
corecmd_getattr_bin_files(cyphesis_t)

corenet_tcp_sendrecv_generic_if(cyphesis_t)
corenet_tcp_sendrecv_generic_node(cyphesis_t)
corenet_tcp_bind_generic_node(cyphesis_t)

corenet_sendrecv_cyphesis_server_packets(cyphesis_t)
corenet_tcp_bind_cyphesis_port(cyphesis_t)
corenet_tcp_sendrecv_cyphesis_port(cyphesis_t)

dev_read_urand(cyphesis_t)

domain_use_interactive_fds(cyphesis_t)


logging_send_syslog_msg(cyphesis_t)

sysnet_dns_name_resolve(cyphesis_t)

optional_policy(`
	dbus_system_bus_client(cyphesis_t)

	optional_policy(`
		avahi_dbus_chat(cyphesis_t)
	')
')

optional_policy(`
	kerberos_use(cyphesis_t)
')

optional_policy(`
	postgresql_stream_connect(cyphesis_t)
')
