policy_module(hsqldb, 1.0.0)

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

type hsqldb_t;
type hsqldb_exec_t;
init_daemon_domain(hsqldb_t, hsqldb_exec_t)

type hsqldb_tmp_t;
files_tmp_file(hsqldb_tmp_t)

type hsqldb_var_lib_t;
files_type(hsqldb_var_lib_t)

type hsqldb_unit_file_t;
systemd_unit_file(hsqldb_unit_file_t)

########################################
#
# hsqldb local policy 
# 

allow hsqldb_t self:process execmem;

allow hsqldb_t self:fifo_file rw_fifo_file_perms;
allow hsqldb_t self:stream_socket_class_set create_stream_socket_perms;

manage_dirs_pattern(hsqldb_t, hsqldb_tmp_t, hsqldb_tmp_t)
manage_files_pattern(hsqldb_t, hsqldb_tmp_t, hsqldb_tmp_t)
files_tmp_filetrans(hsqldb_t, hsqldb_tmp_t, { dir file })
allow hsqldb_t hsqldb_tmp_t:file map;

manage_dirs_pattern(hsqldb_t, hsqldb_var_lib_t, hsqldb_var_lib_t)
manage_files_pattern(hsqldb_t, hsqldb_var_lib_t, hsqldb_var_lib_t)
manage_lnk_files_pattern(hsqldb_t, hsqldb_var_lib_t, hsqldb_var_lib_t)
manage_sock_files_pattern(hsqldb_t, hsqldb_var_lib_t, hsqldb_var_lib_t)
files_var_lib_filetrans(hsqldb_t, hsqldb_var_lib_t, { dir })

kernel_read_system_state(hsqldb_t)
kernel_read_network_state(hsqldb_t)

corecmd_exec_bin(hsqldb_t)

corenet_tcp_bind_generic_node(hsqldb_t)
corenet_tcp_bind_tor_port(hsqldb_t)
corenet_tcp_connect_tor_port(hsqldb_t)

dev_list_sysfs(hsqldb_t)

dev_read_urand(hsqldb_t)
dev_read_rand(hsqldb_t)

fs_read_cgroup_files(hsqldb_t)
fs_search_cgroup_dirs(hsqldb_t)

auth_use_nsswitch(hsqldb_t)

sysnet_read_config(hsqldb_t)
