policy_module(openhpi)

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

type openhpid_t;
type openhpid_exec_t;
init_daemon_domain(openhpid_t, openhpid_exec_t)

type openhpid_initrc_exec_t;
init_script_file(openhpid_initrc_exec_t)

type openhpid_runtime_t alias openhpid_var_run_t;
files_runtime_file(openhpid_runtime_t)

type openhpid_var_lib_t;
files_type(openhpid_var_lib_t)

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

allow openhpid_t self:capability kill;
allow openhpid_t self:process signal;
allow openhpid_t self:fifo_file rw_fifo_file_perms;
allow openhpid_t self:netlink_route_socket r_netlink_socket_perms;
allow openhpid_t self:unix_stream_socket { accept listen };
allow openhpid_t self:tcp_socket create_stream_socket_perms;
allow openhpid_t self:udp_socket create_socket_perms;

manage_dirs_pattern(openhpid_t, openhpid_var_lib_t, openhpid_var_lib_t)
manage_files_pattern(openhpid_t, openhpid_var_lib_t, openhpid_var_lib_t)
files_var_lib_filetrans(openhpid_t, openhpid_var_lib_t, dir)

manage_files_pattern(openhpid_t, openhpid_runtime_t, openhpid_runtime_t)
files_runtime_filetrans(openhpid_t, openhpid_runtime_t, file)

corenet_all_recvfrom_netlabel(openhpid_t)
corenet_tcp_sendrecv_generic_if(openhpid_t)
corenet_tcp_sendrecv_generic_node(openhpid_t)
corenet_tcp_bind_generic_node(openhpid_t)

corenet_sendrecv_openhpid_server_packets(openhpid_t)
corenet_tcp_bind_openhpid_port(openhpid_t)

dev_read_urand(openhpid_t)

files_read_etc_files(openhpid_t)

logging_send_syslog_msg(openhpid_t)

miscfiles_read_localization(openhpid_t)
