policy_module(redis, 1.10.0)

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

type redis_t;
type redis_exec_t;
init_daemon_domain(redis_t, redis_exec_t)

type redis_conf_t;
files_config_file(redis_conf_t)

type redis_initrc_exec_t;
init_script_file(redis_initrc_exec_t)

type redis_log_t;
logging_log_file(redis_log_t)

type redis_runtime_t alias redis_var_run_t;
files_runtime_file(redis_runtime_t)

type redis_var_lib_t;
files_type(redis_var_lib_t)

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

allow redis_t self:process { setrlimit signal_perms getsched };
allow redis_t self:fifo_file rw_fifo_file_perms;
allow redis_t self:unix_stream_socket create_stream_socket_perms;
allow redis_t self:tcp_socket create_stream_socket_perms;

allow redis_t redis_conf_t:file rw_file_perms;

manage_dirs_pattern(redis_t, redis_log_t, redis_log_t)
manage_files_pattern(redis_t, redis_log_t, redis_log_t)
manage_lnk_files_pattern(redis_t, redis_log_t, redis_log_t)
logging_log_filetrans(redis_t, redis_log_t, dir)

manage_dirs_pattern(redis_t, redis_var_lib_t, redis_var_lib_t)
manage_files_pattern(redis_t, redis_var_lib_t, redis_var_lib_t)
manage_lnk_files_pattern(redis_t, redis_var_lib_t, redis_var_lib_t)
files_search_var_lib(redis_t)

manage_dirs_pattern(redis_t, redis_runtime_t, redis_runtime_t)
manage_files_pattern(redis_t, redis_runtime_t, redis_runtime_t)
manage_lnk_files_pattern(redis_t, redis_runtime_t, redis_runtime_t)

kernel_read_net_sysctls(redis_t)
kernel_read_system_state(redis_t)
kernel_read_vm_overcommit_sysctl(redis_t)

corenet_all_recvfrom_netlabel(redis_t)
corenet_tcp_sendrecv_generic_if(redis_t)
corenet_tcp_sendrecv_generic_node(redis_t)
corenet_tcp_bind_generic_node(redis_t)

corenet_sendrecv_redis_server_packets(redis_t)
corenet_tcp_bind_redis_port(redis_t)
corenet_tcp_connect_redis_port(redis_t)

dev_read_sysfs(redis_t)
dev_read_urand(redis_t)

logging_send_syslog_msg(redis_t)

miscfiles_read_generic_certs(redis_t)
miscfiles_read_localization(redis_t)

sysnet_dns_name_resolve(redis_t)
