policy_module(cyphesis)

########################################
#
# 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_runtime_t alias cyphesis_var_run_t;
files_runtime_file(cyphesis_runtime_t)

type cyphesis_tmp_t;
files_tmp_file(cyphesis_tmp_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_runtime_t, cyphesis_runtime_t)
manage_files_pattern(cyphesis_t, cyphesis_runtime_t, cyphesis_runtime_t)
manage_sock_files_pattern(cyphesis_t, cyphesis_runtime_t, cyphesis_runtime_t)
files_runtime_filetrans(cyphesis_t, cyphesis_runtime_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)

dev_read_urand(cyphesis_t)

domain_use_interactive_fds(cyphesis_t)

files_read_etc_files(cyphesis_t)
files_read_usr_files(cyphesis_t)

logging_send_syslog_msg(cyphesis_t)

miscfiles_read_localization(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)
')
