2019-05-08 14:53:59 +03:00
|
|
|
policy_module(knot, 1.0.0)
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# Declarations
|
|
|
|
#
|
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
attribute_role knot_roles;
|
|
|
|
|
2019-05-08 14:53:59 +03:00
|
|
|
type knotd_t;
|
|
|
|
type knotd_exec_t;
|
|
|
|
init_daemon_domain(knotd_t, knotd_exec_t)
|
|
|
|
|
|
|
|
type knotc_t;
|
|
|
|
type knotc_exec_t;
|
|
|
|
application_domain(knotc_t, knotc_exec_t)
|
|
|
|
init_daemon_domain(knotc_t, knotc_exec_t)
|
2019-07-10 11:05:57 +03:00
|
|
|
role knot_roles types knotc_t;
|
2019-05-08 14:53:59 +03:00
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
type knot_conf_t;
|
|
|
|
files_config_file(knot_conf_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
type knot_initrc_exec_t;
|
|
|
|
init_script_file(knot_initrc_exec_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
type knot_runtime_t;
|
|
|
|
files_pid_file(knot_runtime_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
|
|
|
|
type knot_var_lib_t;
|
|
|
|
files_type(knot_var_lib_t)
|
|
|
|
|
|
|
|
type knot_tmp_t;
|
|
|
|
files_tmp_file(knot_tmp_t)
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# knotd local policy
|
|
|
|
#
|
2019-07-10 11:05:57 +03:00
|
|
|
allow knotd_t self:capability { dac_override dac_read_search setgid setpcap setuid };
|
|
|
|
allow knotd_t self:process { signal_perms getcap getsched setsched };
|
2019-05-08 14:53:59 +03:00
|
|
|
allow knotd_t self:tcp_socket create_stream_socket_perms;
|
2019-07-10 11:05:57 +03:00
|
|
|
allow knotd_t self:udp_socket create_socket_perms;
|
|
|
|
allow knotd_t self:unix_stream_socket create_stream_socket_perms;
|
2019-05-08 14:53:59 +03:00
|
|
|
|
|
|
|
corenet_tcp_bind_generic_node(knotd_t)
|
|
|
|
corenet_udp_bind_generic_node(knotd_t)
|
2019-07-10 11:05:57 +03:00
|
|
|
|
|
|
|
corenet_sendrecv_dns_server_packets(knotd_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
corenet_tcp_bind_dns_port(knotd_t)
|
|
|
|
corenet_udp_bind_dns_port(knotd_t)
|
2019-07-10 11:05:57 +03:00
|
|
|
# Slave replication
|
|
|
|
corenet_tcp_connect_dns_port(knotd_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
|
|
|
|
kernel_read_kernel_sysctls(knotd_t)
|
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
allow knotd_t knot_conf_t:file map;
|
|
|
|
knot_read_config_file(knotd_t)
|
|
|
|
|
|
|
|
manage_dirs_pattern(knotd_t, knot_runtime_t, knot_runtime_t)
|
|
|
|
manage_files_pattern(knotd_t, knot_runtime_t, knot_runtime_t)
|
|
|
|
manage_lnk_files_pattern(knotd_t, knot_runtime_t, knot_runtime_t)
|
|
|
|
manage_sock_files_pattern(knotd_t, knot_runtime_t, knot_runtime_t)
|
|
|
|
files_search_pids(knotd_t) ### Check it
|
|
|
|
files_pid_filetrans(knotd_t, knot_runtime_t, dir)
|
|
|
|
|
|
|
|
allow knotd_t knot_tmp_t:file map;
|
|
|
|
allow knotd_t knot_tmp_t:file manage_file_perms;
|
|
|
|
allow knotd_t knot_tmp_t:dir manage_dir_perms;
|
|
|
|
files_tmp_filetrans(knotd_t, knot_tmp_t, { file dir })
|
|
|
|
|
|
|
|
allow knotd_t knot_var_lib_t:file map;
|
|
|
|
manage_dirs_pattern(knotd_t, knot_var_lib_t, knot_var_lib_t)
|
|
|
|
manage_files_pattern(knotd_t, knot_var_lib_t, knot_var_lib_t)
|
|
|
|
manage_lnk_files_pattern(knotd_t, knot_var_lib_t, knot_var_lib_t)
|
|
|
|
files_search_var_lib(knotd_t)
|
|
|
|
files_var_lib_filetrans(knotd_t, knot_var_lib_t, dir)
|
|
|
|
|
|
|
|
files_map_etc_files(knotd_t)
|
|
|
|
|
2019-05-08 14:53:59 +03:00
|
|
|
fs_getattr_xattr_fs(knotd_t)
|
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
fs_getattr_tmpfs(knotd_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
|
|
|
|
auth_use_nsswitch(knotd_t)
|
|
|
|
|
|
|
|
logging_send_syslog_msg(knotd_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization(knotd_t)
|
|
|
|
|
|
|
|
########################################
|
|
|
|
#
|
|
|
|
# knotc local policy
|
|
|
|
#
|
|
|
|
allow knotc_t self:capability { dac_override dac_read_search };
|
2019-07-10 11:05:57 +03:00
|
|
|
allow knotc_t self:process signal;
|
|
|
|
|
|
|
|
stream_connect_pattern(knotc_t, knot_runtime_t, knot_runtime_t, knotd_t)
|
|
|
|
|
|
|
|
allow knotc_t knot_conf_t:file map;
|
|
|
|
knot_read_config_file(knotc_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
allow knotc_t knot_tmp_t:file map;
|
|
|
|
allow knotc_t knot_tmp_t:file manage_file_perms;
|
|
|
|
allow knotc_t knot_tmp_t:dir manage_dir_perms;
|
|
|
|
files_tmp_filetrans(knotc_t, knot_tmp_t, { file dir })
|
2019-05-08 14:53:59 +03:00
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
allow knotc_t knot_var_lib_t:file map;
|
|
|
|
manage_dirs_pattern(knotc_t, knot_var_lib_t, knot_var_lib_t)
|
|
|
|
manage_files_pattern(knotc_t, knot_var_lib_t, knot_var_lib_t)
|
|
|
|
manage_lnk_files_pattern(knotc_t, knot_var_lib_t, knot_var_lib_t)
|
|
|
|
files_search_var_lib(knotc_t)
|
|
|
|
|
|
|
|
files_read_etc_files(knotc_t)
|
|
|
|
|
|
|
|
fs_getattr_tmpfs(knotc_t)
|
2019-05-08 14:53:59 +03:00
|
|
|
|
|
|
|
domain_use_interactive_fds(knotc_t)
|
|
|
|
|
|
|
|
miscfiles_read_localization(knotc_t)
|
|
|
|
|
2019-07-10 11:05:57 +03:00
|
|
|
userdom_use_user_ptys(knotc_t)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
optional_policy(`
|
|
|
|
gen_require(`
|
|
|
|
type initrc_t;
|
|
|
|
')
|
|
|
|
|
|
|
|
knot_read_config_file(initrc_t)
|
|
|
|
')
|
|
|
|
|
2019-05-08 14:53:59 +03:00
|
|
|
optional_policy(`
|
2019-07-10 11:05:57 +03:00
|
|
|
gen_require(`
|
2019-07-10 11:13:09 +03:00
|
|
|
role sysadm_r;
|
2019-07-10 11:05:57 +03:00
|
|
|
type sysadm_t;
|
|
|
|
')
|
2019-05-08 14:53:59 +03:00
|
|
|
|
2019-07-10 11:21:54 +03:00
|
|
|
knot_admin(sysadm_t, sysadm_r)
|
|
|
|
knot_run_client(sysadm_t, sysadm_r)
|
2019-05-08 14:53:59 +03:00
|
|
|
')
|