policy_module(bcfg2, 1.1.0)

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

type bcfg2_t;
type bcfg2_exec_t;
init_daemon_domain(bcfg2_t, bcfg2_exec_t)

type bcfg2_initrc_exec_t;
init_script_file(bcfg2_initrc_exec_t)

type bcfg2_var_lib_t;
files_type(bcfg2_var_lib_t)

type bcfg2_unit_file_t;
systemd_unit_file(bcfg2_unit_file_t)

type bcfg2_var_run_t;
files_pid_file(bcfg2_var_run_t)

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

allow bcfg2_t self:fifo_file rw_fifo_file_perms;
allow bcfg2_t self:tcp_socket { accept listen };
allow bcfg2_t self:unix_stream_socket { accept connectto listen };

manage_dirs_pattern(bcfg2_t, bcfg2_var_lib_t, bcfg2_var_lib_t)
manage_files_pattern(bcfg2_t, bcfg2_var_lib_t, bcfg2_var_lib_t)
files_var_lib_filetrans(bcfg2_t, bcfg2_var_lib_t, dir)

manage_files_pattern(bcfg2_t, bcfg2_var_run_t, bcfg2_var_run_t)
files_pid_filetrans(bcfg2_t, bcfg2_var_run_t, file)

kernel_read_system_state(bcfg2_t)

corenet_all_recvfrom_unlabeled(bcfg2_t)
corenet_all_recvfrom_netlabel(bcfg2_t)
corenet_tcp_sendrecv_generic_if(bcfg2_t)
corenet_tcp_sendrecv_generic_node(bcfg2_t)
corenet_tcp_bind_generic_node(bcfg2_t)

corenet_sendrecv_cyphesis_server_packets(bcfg2_t)
corenet_tcp_bind_cyphesis_port(bcfg2_t)
corenet_tcp_sendrecv_cyphesis_port(bcfg2_t)

corecmd_exec_bin(bcfg2_t)

dev_read_urand(bcfg2_t)

domain_use_interactive_fds(bcfg2_t)


auth_use_nsswitch(bcfg2_t)

logging_send_syslog_msg(bcfg2_t)
