Chris PeBenito ab58ad
#DESC DHCPC - DHCP client
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Authors:  Wayne Salamon (NAI Labs) <wsalamon@tislabs.com>
Chris PeBenito ab58ad
#           Russell Coker <russell@coker.com.au>
Chris PeBenito ab58ad
# X-Debian-Packages: pump dhcp-client udhcpc
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
Chris PeBenito ab58ad
#################################
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# Rules for the dhcpc_t domain.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# dhcpc_t is the domain for the client side of DHCP. dhcpcd, the DHCP 
Chris PeBenito ab58ad
# network configurator daemon started by /etc/sysconfig/network-scripts 
Chris PeBenito ab58ad
# rc scripts, runs in this domain.
Chris PeBenito ab58ad
# dhcpc_exec_t is the type of the dhcpcd executable.
Chris PeBenito ab58ad
# The dhcpc_t can be used for other DHCPC related files as well.
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
daemon_domain(dhcpc)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for SSP
Chris PeBenito ab58ad
allow dhcpc_t urandom_device_t:chr_file read;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
can_network(dhcpc_t)
Chris PeBenito ab58ad
allow dhcpc_t port_type:tcp_socket name_connect;
Chris PeBenito ab58ad
can_ypbind(dhcpc_t)
Chris PeBenito ab58ad
allow dhcpc_t self:unix_dgram_socket create_socket_perms;
Chris PeBenito ab58ad
allow dhcpc_t self:unix_stream_socket create_socket_perms;
Chris PeBenito ab58ad
allow dhcpc_t self:fifo_file rw_file_perms;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow dhcpc_t devpts_t:dir search;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for localization
Chris PeBenito ab58ad
allow dhcpc_t lib_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`consoletype.te', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, consoletype_exec_t, consoletype_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
ifdef(`nscd.te', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, nscd_exec_t, nscd_t)
Chris PeBenito ab58ad
allow dhcpc_t nscd_var_run_t:file { getattr read };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
ifdef(`cardmgr.te', `
Chris PeBenito ab58ad
domain_auto_trans(cardmgr_t, dhcpc_exec_t, dhcpc_t)
Chris PeBenito ab58ad
allow cardmgr_t dhcpc_var_run_t:file { getattr read };
Chris PeBenito ab58ad
allow cardmgr_t dhcpc_t:process signal_perms;
Chris PeBenito ab58ad
allow cardmgr_t dhcpc_var_run_t:file unlink;
Chris PeBenito ab58ad
allow dhcpc_t cardmgr_dev_t:chr_file { read write };
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
ifdef(`hotplug.te', `
Chris PeBenito ab58ad
domain_auto_trans(hotplug_t, dhcpc_exec_t, dhcpc_t)
Chris PeBenito ab58ad
allow hotplug_t dhcpc_t:process signal_perms;
Chris PeBenito ab58ad
allow hotplug_t dhcpc_var_run_t:file { getattr read };
Chris PeBenito ab58ad
allow hotplug_t dhcp_etc_t:file rw_file_perms;
Chris PeBenito ab58ad
allow dhcpc_t hotplug_etc_t:dir { getattr search };
Chris PeBenito ab58ad
ifdef(`distro_redhat', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, syslogd_exec_t, syslogd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
')dnl end hotplug.te
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for the dhcp client to run ping to check IP addresses
Chris PeBenito ab58ad
ifdef(`ping.te', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, ping_exec_t, ping_t)
Chris PeBenito ab58ad
ifdef(`hotplug.te', `
Chris PeBenito ab58ad
allow ping_t hotplug_t:fd use;
Chris PeBenito ab58ad
') dnl end if hotplug
Chris PeBenito ab58ad
ifdef(`cardmgr.te', `
Chris PeBenito ab58ad
allow ping_t cardmgr_t:fd use;
Chris PeBenito ab58ad
') dnl end if cardmgr
Chris PeBenito ab58ad
', `
Chris PeBenito ab58ad
allow dhcpc_t self:capability setuid;
Chris PeBenito ab58ad
allow dhcpc_t self:rawip_socket create_socket_perms;
Chris PeBenito ab58ad
') dnl end if ping
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`dhcpd.te', `', `
Chris PeBenito ab58ad
type dhcp_state_t, file_type, sysadmfile;
Chris PeBenito ab58ad
type dhcp_etc_t, file_type, sysadmfile, usercanread; 
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
type dhcpc_state_t, file_type, sysadmfile;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow dhcpc_t etc_t:lnk_file read;
Chris PeBenito ab58ad
allow dhcpc_t { etc_t etc_runtime_t }:file { getattr read };
Chris PeBenito ab58ad
allow dhcpc_t proc_net_t:dir search;
Chris PeBenito ab58ad
allow dhcpc_t { proc_t proc_net_t }:file { getattr read };
Chris PeBenito ab58ad
allow dhcpc_t self:file { getattr read };
Chris PeBenito ab58ad
read_sysctl(dhcpc_t)
Chris PeBenito ab58ad
allow dhcpc_t userdomain:fd use;
Chris PeBenito ab58ad
ifdef(`run_init.te', `
Chris PeBenito ab58ad
allow dhcpc_t run_init_t:fd use;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Use capabilities
Chris PeBenito ab58ad
allow dhcpc_t self:capability { dac_override fsetid net_admin net_raw net_bind_service sys_resource sys_tty_config };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for access("/etc/bashrc", X_OK) on Red Hat
Chris PeBenito ab58ad
dontaudit dhcpc_t self:capability { dac_read_search sys_module };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# for udp port 68
Chris PeBenito ab58ad
allow dhcpc_t dhcpc_port_t:udp_socket name_bind;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow read/write to /etc/resolv.conf and /etc/ntp.conf. Note that any files
Chris PeBenito ab58ad
# in /etc created by dhcpcd will be labelled net_conf_t.
Chris PeBenito ab58ad
file_type_auto_trans(dhcpc_t, etc_t, net_conf_t, file)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow access to the dhcpc file types
Chris PeBenito ab58ad
r_dir_file(dhcpc_t, dhcp_etc_t)
Chris PeBenito ab58ad
allow dhcpc_t sbin_t:dir search;
Chris PeBenito ab58ad
can_exec(dhcpc_t, { dhcpc_exec_t dhcp_etc_t sbin_t })
Chris PeBenito ab58ad
ifdef(`distro_redhat', `
Chris PeBenito ab58ad
can_exec(dhcpc_t, etc_t)
Chris PeBenito ab58ad
allow initrc_t dhcp_etc_t:file rw_file_perms;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
ifdef(`ifconfig.te', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, ifconfig_exec_t, ifconfig_t)
Chris PeBenito ab58ad
')dnl end if def ifconfig
Chris PeBenito ab58ad
Chris PeBenito ab58ad
Chris PeBenito ab58ad
tmp_domain(dhcpc)
Chris PeBenito ab58ad
Chris PeBenito ab58ad
# Allow dhcpc_t to use packet sockets
Chris PeBenito ab58ad
allow dhcpc_t self:packet_socket create_socket_perms;
Chris PeBenito ab58ad
allow dhcpc_t var_lib_t:dir search;
Chris PeBenito ab58ad
file_type_auto_trans(dhcpc_t, dhcp_state_t, dhcpc_state_t, file)
Chris PeBenito ab58ad
allow dhcpc_t dhcp_state_t:file { getattr read };
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow dhcpc_t bin_t:dir { getattr search };
Chris PeBenito ab58ad
allow dhcpc_t bin_t:lnk_file read;
Chris PeBenito ab58ad
can_exec(dhcpc_t, { bin_t shell_exec_t })
Chris PeBenito ab58ad
Chris PeBenito ab58ad
ifdef(`hostname.te', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, hostname_exec_t, hostname_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
dontaudit dhcpc_t { devpts_t ttyfile ptyfile tty_device_t }:chr_file rw_file_perms;
Chris PeBenito ab58ad
allow dhcpc_t { userdomain kernel_t }:fd use;
Chris PeBenito ab58ad
Chris PeBenito ab58ad
allow dhcpc_t home_root_t:dir search;
Chris PeBenito ab58ad
allow initrc_t dhcpc_state_t:file { getattr read };
Chris PeBenito ab58ad
dontaudit dhcpc_t var_lock_t:dir search;
Chris PeBenito ab58ad
allow dhcpc_t self:netlink_route_socket r_netlink_socket_perms;
Chris PeBenito ab58ad
dontaudit dhcpc_t domain:dir getattr;
Chris PeBenito ab58ad
allow dhcpc_t initrc_var_run_t:file rw_file_perms;
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
# dhclient sometimes starts ypbind and ntdp
Chris PeBenito ab58ad
#
Chris PeBenito ab58ad
can_exec(dhcpc_t, initrc_exec_t)
Chris PeBenito ab58ad
ifdef(`ypbind.te', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, ypbind_exec_t, ypbind_t)
Chris PeBenito ab58ad
allow dhcpc_t ypbind_var_run_t:file { r_file_perms unlink };
Chris PeBenito ab58ad
allow dhcpc_t ypbind_t:process signal;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
ifdef(`ntpd.te', `
Chris PeBenito ab58ad
domain_auto_trans(dhcpc_t, ntpd_exec_t, ntpd_t)
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
role sysadm_r types dhcpc_t;
Chris PeBenito ab58ad
domain_auto_trans(sysadm_t, dhcpc_exec_t, dhcpc_t)
Chris PeBenito ab58ad
ifdef(`dbusd.te', `
Chris PeBenito ab58ad
dbusd_client(system, dhcpc)
Chris PeBenito ab58ad
domain_auto_trans(system_dbusd_t, dhcpc_exec_t, dhcpc_t)
Chris PeBenito ab58ad
allow dhcpc_t system_dbusd_t:dbus { acquire_svc send_msg };
Chris PeBenito ab58ad
allow dhcpc_t self:dbus send_msg;
Chris PeBenito ab58ad
allow { NetworkManager_t initrc_t } dhcpc_t:dbus send_msg;
Chris PeBenito ab58ad
allow dhcpc_t { NetworkManager_t initrc_t }:dbus send_msg;
Chris PeBenito ab58ad
ifdef(`unconfined.te', `
Chris PeBenito ab58ad
allow unconfined_t dhcpc_t:dbus send_msg;
Chris PeBenito ab58ad
allow dhcpc_t unconfined_t:dbus send_msg;
Chris PeBenito ab58ad
')
Chris PeBenito ab58ad
')
Chris PeBenito 8967bf
ifdef(`netutils.te', `domain_auto_trans(dhcpc_t, netutils_exec_t, netutils_t)')
Chris PeBenito ab58ad
allow dhcpc_t locale_t:file write;