Chris PeBenito ab58ad
#DESC NTPD - Time synchronisation daemon
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Author:  Russell Coker <russell@coker.com.au>
Chris PeBenito ab58ad
# X-Debian-Packages: ntp ntp-simple
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the ntpd_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
daemon_domain(ntpd, `, nscd_client_domain')
Chris PeBenito ab58ad
type ntp_drift_t, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
type ntpdate_exec_t, file_type, sysadmfile, exec_type;
Chris PeBenito ab58ad
domain_auto_trans(initrc_t, ntpdate_exec_t, ntpd_t)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
logdir_domain(ntpd)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow ntpd_t var_lib_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow ntpd_t usr_t:file r_file_perms;
Chris PeBenito ab58ad
# reading  /usr/share/ssl/cert.pem requires
Chris PeBenito ab58ad
allow ntpd_t usr_t:lnk_file read;
Chris PeBenito ab58ad
allow ntpd_t ntp_drift_t:dir rw_dir_perms;
Chris PeBenito ab58ad
allow ntpd_t ntp_drift_t:file create_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for SSP
Chris PeBenito ab58ad
allow ntpd_t urandom_device_t:chr_file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# sys_resource and setrlimit is for locking memory
Chris PeBenito ab58ad
allow ntpd_t self:capability { chown dac_override kill setgid setuid sys_time net_bind_service ipc_lock sys_chroot sys_nice sys_resource };
Chris PeBenito ab58ad
dontaudit ntpd_t self:capability { fsetid net_admin };
Chris PeBenito ab58ad
allow ntpd_t self:process { setcap setsched setrlimit };
Chris PeBenito ab58ad
# ntpdate wants sys_nice
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for some reason it creates a file in /tmp
Chris PeBenito ab58ad
tmp_domain(ntpd)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow ntpd_t etc_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow ntpd_t etc_t:file { read getattr };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use the network.
Chris PeBenito ab58ad
can_network(ntpd_t)
Chris PeBenito ab58ad
allow ntpd_t ntp_port_t:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind(ntpd_t)
Chris PeBenito ab58ad
allow ntpd_t ntp_port_t:udp_socket name_bind;
Chris PeBenito ab58ad
allow sysadm_t ntp_port_t:udp_socket name_bind;
Chris PeBenito ab58ad
allow ntpd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow ntpd_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow ntpd_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# so the start script can change firewall entries
Chris PeBenito ab58ad
allow initrc_t net_conf_t:file { getattr read ioctl };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for cron jobs
Chris PeBenito ab58ad
# system_crond_t is not right, cron is not doing what it should
Chris PeBenito ab58ad
ifdef(`crond.te', `
Chris PeBenito ab58ad
system_crond_entry(ntpdate_exec_t, ntpd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_exec(ntpd_t, initrc_exec_t)
Chris PeBenito ab58ad
allow ntpd_t self:fifo_file { read write getattr };
Chris PeBenito ab58ad
allow ntpd_t etc_runtime_t:file r_file_perms;
Chris PeBenito ab58ad
can_exec(ntpd_t, { bin_t shell_exec_t sbin_t ls_exec_t ntpd_exec_t })
Chris PeBenito ab58ad
allow ntpd_t { sbin_t bin_t }:dir search;
Chris PeBenito ab58ad
allow ntpd_t bin_t:lnk_file read;
Chris PeBenito ab58ad
read_sysctl(ntpd_t);
Chris PeBenito ab58ad
allow ntpd_t proc_t:file r_file_perms;
Chris PeBenito ab58ad
allow ntpd_t sysadm_home_dir_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow ntpd_t self:file { getattr read };
Chris PeBenito ab58ad
dontaudit ntpd_t domain:dir search;
Chris PeBenito ab58ad
ifdef(`logrotate.te', `
Chris PeBenito ab58ad
can_exec(ntpd_t, logrotate_exec_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow ntpd_t devtty_t:chr_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_udp_send(ntpd_t, sysadm_t)
Chris PeBenito ab58ad
can_udp_send(sysadm_t, ntpd_t)
Chris PeBenito ab58ad
can_udp_send(ntpd_t, ntpd_t)
Chris PeBenito ab58ad
ifdef(`firstboot.te', `
Chris PeBenito ab58ad
dontaudit ntpd_t firstboot_t:fd use;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
ifdef(`winbind.te', `
Chris PeBenito ab58ad
allow ntpd_t winbind_var_run_t:dir r_dir_perms;
Chris PeBenito ab58ad
allow ntpd_t winbind_var_run_t:sock_file rw_file_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
# For clock devices like wwvb1
Chris PeBenito ab58ad
allow ntpd_t device_t:lnk_file read;