policy_module(djbdns)

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

attribute djbdns_domain;

djbdns_daemontools_domain_template(axfrdns)
ucspitcp_service_domain(djbdns_axfrdns_t, djbdns_axfrdns_exec_t)

djbdns_daemontools_domain_template(dnscache)
djbdns_daemontools_domain_template(tinydns)

########################################
#
# Common local policy
#

allow djbdns_domain self:capability { setgid setuid sys_chroot };
allow djbdns_domain self:process signal;
allow djbdns_domain self:fifo_file rw_fifo_file_perms;
allow djbdns_domain self:tcp_socket create_stream_socket_perms;
allow djbdns_domain self:udp_socket create_socket_perms;

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

corenet_sendrecv_dns_server_packets(djbdns_domain)
corenet_tcp_bind_dns_port(djbdns_domain)
corenet_udp_bind_dns_port(djbdns_domain)

corenet_sendrecv_dns_client_packets(djbdns_domain)
corenet_tcp_connect_dns_port(djbdns_domain)

corenet_sendrecv_generic_server_packets(djbdns_domain)
corenet_tcp_bind_generic_port(djbdns_domain)
corenet_udp_bind_generic_port(djbdns_domain)

files_search_var(djbdns_domain)

########################################
#
# axfrdns local policy
#

allow djbdns_axfrdns_t { djbdns_tinydns_t djbdns_tinydns_conf_t }:dir list_dir_perms;
allow djbdns_axfrdns_t { djbdns_tinydns_t djbdns_tinydns_conf_t }:file read_file_perms;

########################################
#
# tinydns local policy
#

init_dontaudit_use_script_fds(djbdns_tinydns_t)
