policy_module(glusterfs, 1.7.0)

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

type glusterd_t;
type glusterd_exec_t;
init_daemon_domain(glusterd_t, glusterd_exec_t)

type glusterd_conf_t;
files_type(glusterd_conf_t)

type glusterd_initrc_exec_t;
init_script_file(glusterd_initrc_exec_t)

type glusterd_log_t;
logging_log_file(glusterd_log_t)

type glusterd_runtime_t alias glusterd_var_run_t;
files_runtime_file(glusterd_runtime_t)

type glusterd_tmp_t;
files_tmp_file(glusterd_tmp_t)

type glusterd_var_lib_t;
files_type(glusterd_var_lib_t)

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

allow glusterd_t self:capability { chown dac_override dac_read_search fowner sys_admin sys_resource };
allow glusterd_t self:process { setrlimit signal };
allow glusterd_t self:fifo_file rw_fifo_file_perms;
allow glusterd_t self:tcp_socket { accept listen };
allow glusterd_t self:unix_stream_socket { accept listen };

manage_dirs_pattern(glusterd_t, glusterd_conf_t, glusterd_conf_t)
manage_files_pattern(glusterd_t, glusterd_conf_t, glusterd_conf_t)
files_etc_filetrans(glusterd_t, glusterd_conf_t, dir)

manage_dirs_pattern(glusterd_t, glusterd_tmp_t, glusterd_tmp_t)
manage_files_pattern(glusterd_t, glusterd_tmp_t, glusterd_tmp_t)
manage_sock_files_pattern(glusterd_t, glusterd_tmp_t, glusterd_tmp_t)
files_tmp_filetrans(glusterd_t, glusterd_tmp_t, { dir file sock_file })

manage_dirs_pattern(glusterd_t, glusterd_log_t, glusterd_log_t)
append_files_pattern(glusterd_t, glusterd_log_t, glusterd_log_t)
create_files_pattern(glusterd_t, glusterd_log_t, glusterd_log_t)
setattr_files_pattern(glusterd_t, glusterd_log_t, glusterd_log_t)
logging_log_filetrans(glusterd_t, glusterd_log_t, dir)

manage_dirs_pattern(glusterd_t, glusterd_runtime_t, glusterd_runtime_t)
manage_files_pattern(glusterd_t, glusterd_runtime_t, glusterd_runtime_t)
manage_sock_files_pattern(glusterd_t, glusterd_runtime_t, glusterd_runtime_t)
files_runtime_filetrans(glusterd_t, glusterd_runtime_t, { dir file sock_file })

manage_dirs_pattern(glusterd_t, glusterd_var_lib_t, glusterd_var_lib_t)
manage_files_pattern(glusterd_t, glusterd_var_lib_t, glusterd_var_lib_t)
files_var_lib_filetrans(glusterd_t, glusterd_var_lib_t, dir)

can_exec(glusterd_t, glusterd_exec_t)

kernel_read_system_state(glusterd_t)

corecmd_exec_bin(glusterd_t)
corecmd_exec_shell(glusterd_t)

corenet_all_recvfrom_netlabel(glusterd_t)
corenet_tcp_sendrecv_generic_if(glusterd_t)
corenet_udp_sendrecv_generic_if(glusterd_t)
corenet_tcp_sendrecv_generic_node(glusterd_t)
corenet_udp_sendrecv_generic_node(glusterd_t)
corenet_tcp_bind_generic_node(glusterd_t)
corenet_udp_bind_generic_node(glusterd_t)

# Too coarse?
corenet_sendrecv_all_server_packets(glusterd_t)
corenet_tcp_bind_all_reserved_ports(glusterd_t)
corenet_udp_bind_all_rpc_ports(glusterd_t)
corenet_udp_bind_ipp_port(glusterd_t)

corenet_sendrecv_all_client_packets(glusterd_t)
corenet_tcp_connect_all_unreserved_ports(glusterd_t)

dev_read_sysfs(glusterd_t)
dev_read_urand(glusterd_t)

domain_read_all_domains_state(glusterd_t)

domain_use_interactive_fds(glusterd_t)

files_read_usr_files(glusterd_t)

auth_use_nsswitch(glusterd_t)

logging_send_syslog_msg(glusterd_t)

miscfiles_read_localization(glusterd_t)
