Chris PeBenito ab58ad
#DESC BIND - Name server
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Yuichi Nakamura <ynakam@ori.hitachi-sk.co.jp>,
Chris PeBenito ab58ad
#           Russell Coker
Chris PeBenito ab58ad
# X-Debian-Packages: bind bind9
Chris PeBenito ab58ad
# 
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the named_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
daemon_domain(named, `, nscd_client_domain')
Chris PeBenito ab58ad
tmp_domain(named)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
type named_checkconf_exec_t, file_type, exec_type, sysadmfile;
Chris PeBenito ab58ad
domain_auto_trans(initrc_t, named_checkconf_exec_t, named_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# For /var/run/ndc used in BIND 8
Chris PeBenito ab58ad
file_type_auto_trans(named_t, var_run_t, named_var_run_t, sock_file)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# ndc_t is the domain for the ndc program
Chris PeBenito ab58ad
type ndc_t, domain, privlog, nscd_client_domain;
Chris PeBenito ab58ad
role sysadm_r types ndc_t;
Chris PeBenito ab58ad
role system_r types ndc_t;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`targeted_policy', `
Chris PeBenito ab58ad
dontaudit ndc_t root_t:file { getattr read };
Chris PeBenito ab58ad
dontaudit ndc_t unlabeled_t:file { getattr read };	
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_exec(named_t, named_exec_t)
Chris PeBenito ab58ad
allow named_t sbin_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow named_t self:process { setsched setcap setrlimit };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# A type for configuration files of named.
Chris PeBenito ab58ad
type named_conf_t, file_type, sysadmfile, mount_point;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for primary zone files
Chris PeBenito ab58ad
type named_zone_t, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for secondary zone files
Chris PeBenito ab58ad
type named_cache_t, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for DNSSEC key files
Chris PeBenito ab58ad
type dnssec_t, file_type, sysadmfile, secure_file_type;
Chris PeBenito ab58ad
allow { ndc_t named_t } dnssec_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities. Surplus capabilities may be allowed.
Chris PeBenito ab58ad
allow named_t self:capability { chown dac_override fowner setgid setuid net_bind_service sys_chroot sys_nice sys_resource };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow named_t etc_t:file { getattr read };
Chris PeBenito ab58ad
allow named_t etc_runtime_t:{ file lnk_file } { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#Named can use network
Chris PeBenito ab58ad
can_network(named_t)
Chris PeBenito ab58ad
allow named_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind(named_t)
Chris PeBenito ab58ad
# allow UDP transfer to/from any program
Chris PeBenito ab58ad
can_udp_send(domain, named_t)
Chris PeBenito ab58ad
can_udp_send(named_t, domain)
Chris PeBenito ab58ad
can_tcp_connect(domain, named_t)
Chris PeBenito ab58ad
log_domain(named)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Bind to the named port.
Chris PeBenito ab58ad
allow named_t dns_port_t:udp_socket name_bind;
Chris PeBenito ab58ad
allow named_t { dns_port_t rndc_port_t }:tcp_socket name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
bool named_write_master_zones false;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#read configuration files
Chris PeBenito ab58ad
r_dir_file(named_t, named_conf_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
if (named_write_master_zones) {
Chris PeBenito ab58ad
#create and modify zone files
Chris PeBenito ab58ad
create_dir_file(named_t, named_zone_t)
Chris PeBenito ab58ad
}
Chris PeBenito ab58ad
#read zone files
Chris PeBenito ab58ad
r_dir_file(named_t, named_zone_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#write cache for secondary zones
Chris PeBenito ab58ad
rw_dir_create_file(named_t, named_cache_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow named_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
allow named_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow named_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read sysctl kernel variables.
Chris PeBenito ab58ad
read_sysctl(named_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /proc/cpuinfo and /proc/net
Chris PeBenito ab58ad
r_dir_file(named_t, proc_t)
Chris PeBenito ab58ad
r_dir_file(named_t, proc_net_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read /dev/random.
Chris PeBenito ab58ad
allow named_t device_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow named_t random_device_t:chr_file r_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use a pipe created by self.
Chris PeBenito ab58ad
allow named_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Enable named dbus support:
Chris PeBenito ab58ad
ifdef(`dbusd.te', `
Chris PeBenito ab58ad
dbusd_client(system, named)
Chris PeBenito ab58ad
domain_auto_trans(system_dbusd_t, named_exec_t, named_t)
Chris PeBenito ab58ad
allow named_t system_dbusd_t:dbus { acquire_svc send_msg };
Chris PeBenito ab58ad
allow named_t self:dbus send_msg;
Chris PeBenito ab58ad
allow { NetworkManager_t dhcpc_t initrc_t } named_t:dbus send_msg;
Chris PeBenito ab58ad
allow named_t { NetworkManager_t dhcpc_t initrc_t }:dbus send_msg;
Chris PeBenito ab58ad
ifdef(`unconfined.te', `
Chris PeBenito ab58ad
allow unconfined_t named_t:dbus send_msg;
Chris PeBenito ab58ad
allow named_t unconfined_t:dbus send_msg;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Set own capabilities.
Chris PeBenito ab58ad
#A type for /usr/sbin/ndc
Chris PeBenito ab58ad
type ndc_exec_t, file_type,sysadmfile, exec_type;
Chris PeBenito ab58ad
domain_auto_trans({ sysadm_t initrc_t }, ndc_exec_t, ndc_t)
Chris PeBenito ab58ad
uses_shlib(ndc_t)
Chris PeBenito ab58ad
can_network_client_tcp(ndc_t)
Chris PeBenito ab58ad
allow ndc_t rndc_port_t:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind(ndc_t)
Chris PeBenito ab58ad
can_resolve(ndc_t)
Chris PeBenito ab58ad
read_locale(ndc_t)
Chris PeBenito ab58ad
can_tcp_connect(ndc_t, named_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`distro_redhat', `
Chris PeBenito ab58ad
# for /etc/rndc.key
Chris PeBenito ab58ad
allow { ndc_t initrc_t } named_conf_t:dir search;
Chris PeBenito ab58ad
# Allow init script to cp localtime to named_conf_t
Chris PeBenito ab58ad
allow initrc_t named_conf_t:file { setattr write };
Chris PeBenito ab58ad
allow initrc_t named_conf_t:dir create_dir_perms;
Chris PeBenito ab58ad
allow initrc_t var_run_t:lnk_file create_file_perms;
Chris PeBenito ab58ad
ifdef(`automount.te', `
Chris PeBenito ab58ad
# automount has no need to search the /proc file system for the named chroot
Chris PeBenito ab58ad
dontaudit automount_t named_zone_t:dir search;
Chris PeBenito ab58ad
')dnl end ifdef automount.te
Chris PeBenito ab58ad
')dnl end ifdef distro_redhat
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow { ndc_t initrc_t } named_conf_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow ndc_t etc_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow ndc_t etc_t:file r_file_perms;
Chris PeBenito ab58ad
allow ndc_t self:unix_stream_socket create_stream_socket_perms;
Chris PeBenito ab58ad
allow ndc_t self:unix_stream_socket connect;
Chris PeBenito ab58ad
allow ndc_t self:capability { dac_override net_admin };
Chris PeBenito ab58ad
allow ndc_t var_t:dir search;
Chris PeBenito ab58ad
allow ndc_t var_run_t:dir search;
Chris PeBenito ab58ad
allow ndc_t named_var_run_t:sock_file rw_file_perms;
Chris PeBenito ab58ad
allow ndc_t named_t:unix_stream_socket connectto;
Chris PeBenito ab58ad
allow ndc_t { privfd init_t }:fd use;
Chris PeBenito ab58ad
# seems to need read as well for some reason
Chris PeBenito ab58ad
allow ndc_t { admin_tty_type initrc_devpts_t }:chr_file { getattr read write };
Chris PeBenito ab58ad
allow ndc_t fs_t:filesystem getattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Read sysctl kernel variables.
Chris PeBenito ab58ad
read_sysctl(ndc_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow ndc_t self:process { fork signal_perms };
Chris PeBenito ab58ad
allow ndc_t self:fifo_file { read write getattr ioctl };
Chris PeBenito ab58ad
allow ndc_t named_zone_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for chmod in start script
Chris PeBenito ab58ad
dontaudit initrc_t named_var_run_t:dir setattr;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for ndc_t to be used for restart shell scripts
Chris PeBenito ab58ad
ifdef(`ndc_shell_script', `
Chris PeBenito ab58ad
system_crond_entry(ndc_exec_t, ndc_t)
Chris PeBenito ab58ad
allow ndc_t devtty_t:chr_file { read write ioctl };
Chris PeBenito ab58ad
allow ndc_t etc_runtime_t:file { getattr read };
Chris PeBenito ab58ad
allow ndc_t proc_t:dir search;
Chris PeBenito ab58ad
allow ndc_t proc_t:file { getattr read };
Chris PeBenito ab58ad
can_exec(ndc_t, { bin_t sbin_t shell_exec_t })
Chris PeBenito ab58ad
allow ndc_t named_var_run_t:file getattr;
Chris PeBenito ab58ad
allow ndc_t named_zone_t:dir { read getattr };
Chris PeBenito ab58ad
allow ndc_t named_zone_t:file getattr;
Chris PeBenito ab58ad
dontaudit ndc_t sysadm_home_t:dir { getattr search read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
allow ndc_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito ab58ad
dontaudit ndc_t sysadm_tty_device_t:chr_file { ioctl };
Chris PeBenito ab58ad
Chris PeBenito ab58ad