Chris PeBenito b11a75
Chris PeBenito b11a75
policy_module(ntp,1.0)
Chris PeBenito b11a75
Chris PeBenito b11a75
########################################
Chris PeBenito b11a75
#
Chris PeBenito b11a75
# Declarations
Chris PeBenito b11a75
#
Chris PeBenito b11a75
Chris PeBenito b11a75
type ntp_drift_t;
Chris PeBenito b11a75
files_type(ntp_drift_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
type ntpd_t;
Chris PeBenito b11a75
type ntpd_exec_t;
Chris PeBenito b11a75
init_daemon_domain(ntpd_t,ntpd_exec_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
type ntpd_log_t;
Chris PeBenito b11a75
logging_log_file(ntpd_log_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
type ntpd_tmp_t;
Chris PeBenito b11a75
files_tmp_file(ntpd_tmp_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
type ntpd_var_run_t;
Chris PeBenito b11a75
files_pid_file(ntpd_var_run_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
type ntpdate_exec_t;
Chris PeBenito b11a75
init_system_domain(ntpd_t,ntpdate_exec_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
########################################
Chris PeBenito b11a75
#
Chris PeBenito b11a75
# Local policy
Chris PeBenito b11a75
#
Chris PeBenito b11a75
Chris PeBenito a08248
allow ntpd_t self:capability { chown dac_override kill setgid setuid sys_time ipc_lock sys_chroot };
Chris PeBenito b11a75
# ntpdate wants sys_nice
Chris PeBenito b11a75
dontaudit ntpd_t self:capability { net_admin sys_tty_config fsetid sys_nice };
Chris PeBenito b11a75
allow ntpd_t self:process { signal_perms setcap setsched };
Chris PeBenito b11a75
allow ntpd_t self:fifo_file { read write getattr };
Chris PeBenito b11a75
allow ntpd_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito b11a75
allow ntpd_t self:unix_stream_socket create_socket_perms;
Chris PeBenito b11a75
allow ntpd_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito b11a75
allow ntpd_t self:tcp_socket create_stream_socket_perms;
Chris PeBenito b11a75
allow ntpd_t self:udp_socket { create_socket_perms sendto recvfrom };
Chris PeBenito b11a75
Chris PeBenito b11a75
allow ntpd_t ntp_drift_t:dir rw_dir_perms;
Chris PeBenito b11a75
allow ntpd_t ntp_drift_t:file create_file_perms;
Chris PeBenito b11a75
Chris PeBenito b11a75
can_exec(ntpd_t,ntpd_exec_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
allow ntpd_t ntpd_log_t:file create_file_perms;
Chris PeBenito b11a75
allow ntpd_t ntpd_log_t:dir { rw_dir_perms setattr };
Chris PeBenito b11a75
logging_create_log(ntpd_t,ntpd_log_t,{ file dir })
Chris PeBenito b11a75
Chris PeBenito b11a75
# for some reason it creates a file in /tmp
Chris PeBenito b11a75
allow ntpd_t ntpd_tmp_t:dir create_dir_perms;
Chris PeBenito b11a75
allow ntpd_t ntpd_tmp_t:file create_file_perms;
Chris PeBenito b11a75
files_create_tmp_files(ntpd_t, ntpd_tmp_t, { file dir })
Chris PeBenito b11a75
Chris PeBenito b11a75
allow ntpd_t ntpd_var_run_t:file create_file_perms;
Chris PeBenito b11a75
files_create_pid(ntpd_t,ntpd_var_run_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
kernel_read_kernel_sysctl(ntpd_t)
Chris PeBenito b11a75
kernel_read_system_state(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
corenet_tcp_sendrecv_all_if(ntpd_t)
Chris PeBenito b11a75
corenet_udp_sendrecv_all_if(ntpd_t)
Chris PeBenito b11a75
corenet_raw_sendrecv_all_if(ntpd_t)
Chris PeBenito b11a75
corenet_tcp_sendrecv_all_nodes(ntpd_t)
Chris PeBenito b11a75
corenet_udp_sendrecv_all_nodes(ntpd_t)
Chris PeBenito b11a75
corenet_raw_sendrecv_all_nodes(ntpd_t)
Chris PeBenito b11a75
corenet_tcp_sendrecv_all_ports(ntpd_t)
Chris PeBenito b11a75
corenet_udp_sendrecv_all_ports(ntpd_t)
Chris PeBenito b11a75
corenet_tcp_bind_all_nodes(ntpd_t)
Chris PeBenito b11a75
corenet_udp_bind_all_nodes(ntpd_t)
Chris PeBenito b11a75
corenet_udp_bind_ntp_port(ntpd_t)
Chris PeBenito 0907bd
corenet_tcp_connect_ntp_port(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
dev_read_sysfs(ntpd_t)
Chris PeBenito b11a75
# for SSP
Chris PeBenito b11a75
dev_read_urand(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
fs_getattr_all_fs(ntpd_t)
Chris PeBenito b11a75
fs_search_auto_mountpoints(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
term_dontaudit_use_console(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
corecmd_exec_bin(ntpd_t)
Chris PeBenito b11a75
corecmd_exec_sbin(ntpd_t)
Chris PeBenito b11a75
corecmd_exec_ls(ntpd_t)
Chris PeBenito b11a75
corecmd_exec_shell(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
domain_use_wide_inherit_fd(ntpd_t)
Chris PeBenito b11a75
domain_dontaudit_list_all_domains_proc(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
files_read_etc_files(ntpd_t)
Chris PeBenito b11a75
files_read_etc_runtime_files(ntpd_t)
Chris PeBenito b11a75
files_read_usr_files(ntpd_t)
Chris PeBenito b11a75
files_list_var_lib(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
init_exec_script(ntpd_t)
Chris PeBenito b11a75
init_use_fd(ntpd_t)
Chris PeBenito b11a75
init_use_script_pty(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
libs_use_ld_so(ntpd_t)
Chris PeBenito b11a75
libs_use_shared_libs(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
logging_send_syslog_msg(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
miscfiles_read_localization(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
sysnet_read_config(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
userdom_dontaudit_use_unpriv_user_fd(ntpd_t)
Chris PeBenito b11a75
userdom_dontaudit_list_sysadm_home_dir(ntpd_t)
Chris PeBenito b11a75
Chris PeBenito b11a75
ifdef(`targeted_policy', `
Chris PeBenito b11a75
	term_dontaudit_use_unallocated_tty(ntpd_t)
Chris PeBenito b11a75
	term_dontaudit_use_generic_pty(ntpd_t)
Chris PeBenito b11a75
	files_dontaudit_read_root_file(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito 71fe0f
optional_policy(`cron.te',`
Chris PeBenito b11a75
	# for cron jobs
Chris PeBenito b11a75
	# system_crond_t is not right, cron is not doing what it should
Chris PeBenito 71fe0f
	cron_system_entry(ntpd_t,ntpd_exec_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
optional_policy(`firstboot.te',`
Chris PeBenito b11a75
	firstboot_dontaudit_use_fd(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
optional_policy(`logrotate.te',`
Chris PeBenito b11a75
	logrotate_exec(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
optional_policy(`mount.te',`
Chris PeBenito b11a75
	mount_send_nfs_client_request(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
optional_policy(`nis.te',`
Chris PeBenito b11a75
	nis_use_ypbind(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
optional_policy(`nscd.te',`
Chris PeBenito b11a75
	nscd_use_socket(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
optional_policy(`selinuxutil.te',`
Chris PeBenito b11a75
	seutil_sigchld_newrole(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
optional_policy(`udev.te', `
Chris PeBenito b11a75
	udev_read_db(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
Chris PeBenito b11a75
ifdef(`TODO',`
Chris PeBenito b11a75
optional_policy(`rhgb.te',`
Chris PeBenito b11a75
	rhgb_domain(ntpd_t)
Chris PeBenito b11a75
')
Chris PeBenito b11a75
allow ntpd_t sysadm_t:udp_socket sendto;
Chris PeBenito b11a75
allow sysadm_t ntpd_t:udp_socket recvfrom;
Chris PeBenito b11a75
Chris PeBenito b11a75
allow sysadm_t ntpd_t:udp_socket sendto;
Chris PeBenito b11a75
allow ntpd_t sysadm_t:udp_socket recvfrom;
Chris PeBenito b11a75
Chris PeBenito b11a75
ifdef(`winbind.te', `
Chris PeBenito b11a75
allow ntpd_t winbind_var_run_t:dir r_dir_perms;
Chris PeBenito b11a75
allow ntpd_t winbind_var_run_t:sock_file rw_file_perms;
Chris PeBenito b11a75
')
Chris PeBenito b11a75
') dnl end TODO