Chris PeBenito d83fda
Chris PeBenito 10b1f3
policy_module(bind,0.9)
Chris PeBenito d83fda
Chris PeBenito d83fda
########################################
Chris PeBenito d83fda
#
Chris PeBenito d83fda
# Declarations
Chris PeBenito d83fda
#
Chris PeBenito d83fda
Chris PeBenito d83fda
# for DNSSEC key files
Chris PeBenito a2868f
type dnssec_t;
Chris PeBenito a2868f
files_security_file(dnssec_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
type named_t;
Chris PeBenito d83fda
type named_exec_t;
Chris PeBenito d83fda
init_daemon_domain(named_t,named_exec_t)
Chris PeBenito d83fda
role system_r types named_t;
Chris PeBenito d83fda
Chris PeBenito 98a8ea
type named_checkconf_exec_t;
Chris PeBenito 98a8ea
init_system_domain(named_t,named_checkconf_exec_t)
Chris PeBenito 98a8ea
Chris PeBenito d83fda
# A type for configuration files of named.
Chris PeBenito d83fda
type named_conf_t;
Chris PeBenito d83fda
files_type(named_conf_t)
Chris PeBenito d8636f
files_mountpoint(named_conf_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
# for secondary zone files
Chris PeBenito d83fda
type named_cache_t;
Chris PeBenito d83fda
files_type(named_cache_t)
Chris PeBenito d83fda
Chris PeBenito 98a8ea
type named_log_t;
Chris PeBenito 98a8ea
logging_log_file(named_log_t)
Chris PeBenito 98a8ea
Chris PeBenito d83fda
type named_tmp_t;
Chris PeBenito d83fda
files_tmp_file(named_tmp_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
type named_var_run_t;
Chris PeBenito d83fda
files_pid_file(named_var_run_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
# for primary zone files
Chris PeBenito d83fda
type named_zone_t;
Chris PeBenito d83fda
files_type(named_zone_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
type ndc_t;
Chris PeBenito d83fda
type ndc_exec_t;
Chris PeBenito d83fda
init_system_domain(ndc_t,ndc_exec_t)
Chris PeBenito d83fda
role system_r types ndc_t;
Chris PeBenito d83fda
Chris PeBenito d83fda
########################################
Chris PeBenito d83fda
#
Chris PeBenito d83fda
# Named local policy
Chris PeBenito d83fda
#
Chris PeBenito d83fda
Chris PeBenito d83fda
allow named_t self:capability { chown dac_override fowner setgid setuid sys_chroot sys_nice sys_resource };
Chris PeBenito d83fda
dontaudit named_t self:capability sys_tty_config;
Chris PeBenito d83fda
allow named_t self:process { setsched setcap setrlimit };
Chris PeBenito d83fda
allow named_t self:fifo_file rw_file_perms;
Chris PeBenito d83fda
allow named_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito d83fda
allow named_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito d83fda
allow named_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito d83fda
allow named_t self:udp_socket create_socket_perms;
Chris PeBenito d83fda
allow named_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito d83fda
Chris PeBenito d83fda
allow named_t dnssec_t:file { getattr read };
Chris PeBenito d83fda
Chris PeBenito d83fda
# read configuration
Chris PeBenito d83fda
allow named_t named_conf_t:dir r_dir_perms;
Chris PeBenito d83fda
allow named_t named_conf_t:file r_file_perms;
Chris PeBenito d83fda
allow named_t named_conf_t:lnk_file r_file_perms;
Chris PeBenito d83fda
Chris PeBenito d83fda
# write cache for secondary zones
Chris PeBenito d83fda
allow named_t named_cache_t:dir rw_dir_perms;
Chris PeBenito d83fda
allow named_t named_cache_t:file create_file_perms;
Chris PeBenito d83fda
allow named_t named_cache_t:lnk_file create_lnk_perms;
Chris PeBenito d83fda
Chris PeBenito d83fda
can_exec(named_t, named_exec_t)
Chris PeBenito d83fda
Chris PeBenito 98a8ea
allow named_t named_log_t:file create_file_perms;
Chris PeBenito 98a8ea
allow named_t named_log_t:dir rw_dir_perms;
Chris PeBenito 98a8ea
logging_create_log(named_t,named_log_t,{ file dir })
Chris PeBenito 98a8ea
Chris PeBenito d83fda
allow named_t named_tmp_t:dir create_dir_perms;
Chris PeBenito d83fda
allow named_t named_tmp_t:file create_file_perms;
Chris PeBenito d83fda
files_create_tmp_files(named_t, named_tmp_t, { file dir })
Chris PeBenito d83fda
Chris PeBenito d83fda
allow named_t named_var_run_t:file create_file_perms;
Chris PeBenito d83fda
allow named_t named_var_run_t:sock_file create_file_perms;
Chris PeBenito d83fda
files_create_pid(named_t,named_var_run_t,{ file sock_file })
Chris PeBenito d83fda
Chris PeBenito d83fda
# read zone files
Chris PeBenito d83fda
allow named_t named_zone_t:dir r_dir_perms;
Chris PeBenito d83fda
allow named_t named_zone_t:file r_file_perms;
Chris PeBenito d83fda
allow named_t named_zone_t:lnk_file r_file_perms;
Chris PeBenito d83fda
Chris PeBenito d83fda
allow named_t ndc_t:tcp_socket { acceptfrom recvfrom };
Chris PeBenito d83fda
Chris PeBenito d83fda
kernel_read_kernel_sysctl(named_t)
Chris PeBenito d83fda
kernel_read_system_state(named_t)
Chris PeBenito d83fda
kernel_read_network_state(named_t)
Chris PeBenito d83fda
kernel_tcp_recvfrom(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
corenet_tcp_sendrecv_all_if(named_t)
Chris PeBenito d83fda
corenet_raw_sendrecv_all_if(named_t)
Chris PeBenito d83fda
corenet_udp_sendrecv_all_if(named_t)
Chris PeBenito d83fda
corenet_tcp_sendrecv_all_nodes(named_t)
Chris PeBenito d83fda
corenet_udp_sendrecv_all_nodes(named_t)
Chris PeBenito d83fda
corenet_raw_sendrecv_all_nodes(named_t)
Chris PeBenito d83fda
corenet_tcp_sendrecv_all_ports(named_t)
Chris PeBenito d83fda
corenet_udp_sendrecv_all_ports(named_t)
Chris PeBenito d83fda
corenet_tcp_bind_all_nodes(named_t)
Chris PeBenito d83fda
corenet_udp_bind_all_nodes(named_t)
Chris PeBenito d83fda
corenet_tcp_bind_dns_port(named_t)
Chris PeBenito d83fda
corenet_udp_bind_dns_port(named_t)
Chris PeBenito 98a8ea
corenet_tcp_bind_rndc_port(named_t)
Chris PeBenito 98a8ea
corenet_tcp_connect_all_ports(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
dev_read_sysfs(named_t)
Chris PeBenito d83fda
dev_read_rand(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
fs_getattr_all_fs(named_t)
Chris PeBenito d83fda
fs_search_auto_mountpoints(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
term_dontaudit_use_console(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
corecmd_search_sbin(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
domain_use_wide_inherit_fd(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
files_read_etc_files(named_t)
Chris PeBenito d83fda
files_read_etc_runtime_files(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
init_use_fd(named_t)
Chris PeBenito d83fda
init_use_script_pty(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
libs_use_ld_so(named_t)
Chris PeBenito d83fda
libs_use_shared_libs(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
logging_send_syslog_msg(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
miscfiles_read_localization(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
sysnet_read_config(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
userdom_dontaudit_use_unpriv_user_fd(named_t)
Chris PeBenito d83fda
userdom_dontaudit_search_sysadm_home_dir(named_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
ifdef(`targeted_policy',`
Chris PeBenito d83fda
	term_dontaudit_use_unallocated_tty(named_t)
Chris PeBenito d83fda
	term_dontaudit_use_generic_pty(named_t)
Chris PeBenito d83fda
	files_dontaudit_read_root_file(named_t)
Chris PeBenito d83fda
	#dontaudit ndc_t unlabeled_t:file { getattr read };	
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d8636f
optional_policy(`dbus.te',`
Chris PeBenito d8636f
	gen_require(`
Chris PeBenito d8636f
		class dbus send_msg;
Chris PeBenito d8636f
	')
Chris PeBenito d8636f
Chris PeBenito d8636f
	allow named_t self:dbus send_msg;
Chris PeBenito d8636f
	dbus_system_bus_client_template(named,named_t)
Chris PeBenito d8636f
	dbus_connect_system_bus(named_t)
Chris PeBenito d8636f
	dbus_send_system_bus_msg(named_t)
Chris PeBenito d8636f
')
Chris PeBenito d8636f
Chris PeBenito d83fda
optional_policy(`nis.te',`
Chris PeBenito d83fda
	nis_use_ypbind(named_t)
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d83fda
optional_policy(`nscd.te',`
Chris PeBenito d83fda
	nscd_use_socket(named_t)
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d83fda
optional_policy(`selinuxutil.te',`
Chris PeBenito d83fda
	seutil_sigchld_newrole(named_t)
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d83fda
optional_policy(`udev.te',`
Chris PeBenito d83fda
	udev_read_db(named_t)
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito c0d156
ifdef(`TODO',`
Chris PeBenito c0d156
can_udp_send(domain, named_t)
Chris PeBenito c0d156
can_udp_send(named_t, domain)
Chris PeBenito c0d156
can_tcp_connect(domain, named_t)
Chris PeBenito c0d156
optional_policy(`rhgb.te',`
Chris PeBenito c0d156
	rhgb_domain(named_t)
Chris PeBenito c0d156
')
Chris PeBenito c0d156
')
Chris PeBenito c0d156
Chris PeBenito d83fda
########################################
Chris PeBenito d83fda
#
Chris PeBenito d83fda
# NDC local policy
Chris PeBenito d83fda
#
Chris PeBenito d83fda
Chris PeBenito d83fda
# cjp: why net_admin?!
Chris PeBenito d83fda
allow ndc_t self:capability { dac_override net_admin };
Chris PeBenito d83fda
allow ndc_t self:process { fork signal_perms };
Chris PeBenito d83fda
allow ndc_t self:fifo_file { read write getattr ioctl };
Chris PeBenito d83fda
allow ndc_t self:unix_stream_socket { connect create_stream_socket_perms };
Chris PeBenito d83fda
allow ndc_t self:tcp_socket create_socket_perms;
Chris PeBenito d83fda
allow ndc_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito d83fda
Chris PeBenito d83fda
allow ndc_t dnssec_t:file { getattr read };
Chris PeBenito d83fda
Chris PeBenito d83fda
allow ndc_t named_t:tcp_socket { connectto recvfrom };
Chris PeBenito d83fda
allow ndc_t named_t:unix_stream_socket connectto;
Chris PeBenito d83fda
Chris PeBenito d83fda
allow ndc_t named_conf_t:file { getattr read };
Chris PeBenito d83fda
Chris PeBenito d83fda
allow ndc_t named_var_run_t:sock_file rw_file_perms;
Chris PeBenito d83fda
Chris PeBenito d83fda
allow ndc_t named_zone_t:dir search;
Chris PeBenito d83fda
Chris PeBenito d83fda
kernel_read_kernel_sysctl(ndc_t)
Chris PeBenito d83fda
kernel_tcp_recvfrom(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
corenet_tcp_sendrecv_all_if(ndc_t)
Chris PeBenito d83fda
corenet_raw_sendrecv_all_if(ndc_t)
Chris PeBenito d83fda
corenet_tcp_sendrecv_all_nodes(ndc_t)
Chris PeBenito d83fda
corenet_raw_sendrecv_all_nodes(ndc_t)
Chris PeBenito d83fda
corenet_tcp_sendrecv_all_ports(ndc_t)
Chris PeBenito d83fda
corenet_tcp_bind_all_nodes(ndc_t)
Chris PeBenito 98a8ea
corenet_tcp_connect_rndc_port(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
fs_getattr_xattr_fs(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
domain_use_wide_inherit_fd(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
files_read_etc_files(ndc_t)
Chris PeBenito d83fda
files_search_pids(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
init_use_fd(ndc_t)
Chris PeBenito d83fda
init_use_script_pty(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
libs_use_ld_so(ndc_t)
Chris PeBenito d83fda
libs_use_shared_libs(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
logging_send_syslog_msg(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
miscfiles_read_localization(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
sysnet_read_config(ndc_t)
Chris PeBenito 98a8ea
sysnet_dns_name_resolve(ndc_t)
Chris PeBenito d83fda
Chris PeBenito d83fda
# for /etc/rndc.key
Chris PeBenito d83fda
ifdef(`distro_redhat',`
Chris PeBenito d83fda
	allow ndc_t named_conf_t:dir search;
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d83fda
tunable_policy(`named_write_master_zones',`
Chris PeBenito d83fda
	allow named_t named_zone_t:dir create_dir_perms;
Chris PeBenito d83fda
	allow named_t named_zone_t:file create_file_perms;
Chris PeBenito d83fda
	allow named_t named_zone_t:lnk_file create_lnk_perms;
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d83fda
optional_policy(`mount.te',`
Chris PeBenito d83fda
	mount_send_nfs_client_request(named_t)
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d83fda
optional_policy(`nis.te',`
Chris PeBenito d83fda
	nis_use_ypbind(ndc_t)
Chris PeBenito d83fda
')
Chris PeBenito d83fda
Chris PeBenito d83fda
optional_policy(`nscd.te',`
Chris PeBenito d83fda
	nscd_use_socket(ndc_t)
Chris PeBenito d83fda
')
Chris PeBenito 239db5
Chris PeBenito 239db5
###########################################################
Chris PeBenito 239db5
#
Chris PeBenito 239db5
# Partially converted rules.  THESE ARE ONLY TEMPORARY
Chris PeBenito 239db5
#
Chris PeBenito 239db5
Chris PeBenito 239db5
# cjp: this whole block was originally in networkmanager
Chris PeBenito 239db5
optional_policy(`networkmanager.te',`
Chris PeBenito 239db5
	gen_require(`
Chris PeBenito 239db5
		type NetworkManager_t;
Chris PeBenito 239db5
	')
Chris PeBenito 239db5
Chris PeBenito 239db5
	bind_domtrans(NetworkManager_t)
Chris PeBenito 239db5
Chris PeBenito 239db5
	allow NetworkManager_t named_zone_t:dir search;
Chris PeBenito 239db5
Chris PeBenito 239db5
	allow NetworkManager_t named_cache_t:dir rw_dir_perms;
Chris PeBenito 239db5
	allow NetworkManager_t named_cache_t:file create_file_perms;
Chris PeBenito 239db5
	allow NetworkManager_t named_cache_t:lnk_file create_lnk_perms;
Chris PeBenito 239db5
Chris PeBenito 239db5
	allow named_t NetworkManager_t:udp_socket { read write };
Chris PeBenito 239db5
	allow named_t NetworkManager_t:netlink_route_socket { read write };
Chris PeBenito 239db5
Chris PeBenito 239db5
	allow NetworkManager_t named_t:process signal;
Chris PeBenito 239db5
	allow named_t NetworkManager_t:packet_socket { read write };
Chris PeBenito 239db5
')