Skip to contentSkip to conversation

my latest efforts for dhcp client and server

DISCUSSION Russell Coker 1 participant 1 message Mar 21, 2002 SELinux security module

lore
Share & tools
lore
#0 lore raw

The file_contexts is below and the .te files are attached.

/var/lib/dhcp                   system_u:object_r:dhcp_state_t
/var/lib/dhcp/dhclient.*        system_u:object_r:dhcpc_state_t
/var/lib/dhcp/dhcpd.leases.*    system_u:object_r:dhcpd_state_t
/etc/dhcpc.*(|/.*)              system_u:object_r:etc_dhcpc_t
/etc/dhclient.conf              system_u:object_r:etc_dhcpc_t
/etc/dhclient-script            system_u:object_r:etc_dhcpc_t
/etc/dhcpd.conf                 system_u:object_r:etc_dhcpd_t
/sbin/dhcpcd                    system_u:object_r:dhcpc_exec_t
/sbin/dhclient.*                system_u:object_r:dhcpc_exec_t
/usr/sbin/dhcpd(|-.*)           system_u:object_r:dhcpd_exec_t
Signature · 4 lines
If you send email to me or to a mailing list that I use which has >4 lines
of legalistic junk at the end then you are specifically authorizing me to do
whatever I wish with the message and all other messages from your domain, by
posting the message you agree that your long legalistic sig is void.

#
# Authors: Wayne Salamon (NAI Labs) <[email protected]> #

#################################
#
# Rules for the dhcpc_t domain.
#

# dhcpc_t is the domain for the client side of DHCP. dhcpcd, the DHCP 
# network configurator daemon started by /etc/sysconfig/network-scripts 
# rc scripts, runs in this domain.
# dhcpc_exec_t is the type of the dhcpcd executable.
# The dhcpc_t can be used for other DHCPC related files as well.
#
type dhcpc_t, domain, privlog;
role system_r types dhcpc_t;
every_domain(dhcpc_t)
type dhcpc_exec_t, file_type, sysadmfile, exec_type;
domain_auto_trans(initrc_t, dhcpc_exec_t, dhcpc_t)
type_transition init_t dhcpc_exec_t:process dhcpc_t;

# Type for files created during execution of dhcpcd. type dhcpc_var_run_t, file_type, sysadmfile; type dhcpc_state_t, file_type, sysadmfile;
type etc_dhcpc_t, file_type, sysadmfile; file_type_auto_trans(dhcpc_t, var_run_t, dhcpc_var_run_t)

# Inherit and use descriptors from init.
allow dhcpc_t init_t:fd inherit_fd_perms;

# Use the network.
can_network(dhcpc_t)

# Use capabilities
allow dhcpc_t dhcpc_t:capability { net_admin net_raw };

# Allow read/write to /etc/resolv.conf. Note that any files in /etc

# created by dhcpcd will be labelled resolv_conf_t. As of RH 7.2, no
# other files are accessed in the /etc dir, only in /etc/dhcpc dir.
allow dhcpc_t resolv_conf_t:file rw_file_perms;
file_type_auto_trans(dhcpc_t, etc_t, resolv_conf_t)

# Allow access to the dhcpc file types
allow dhcpc_t etc_dhcpc_t:file rw_file_perms;
allow dhcpc_t etc_dhcpc_t:dir rw_dir_perms;
can_exec(dhcpc_t, etc_dhcpc_t)

# Allow dhcpc_t to use packet sockets
allow dhcpc_t dhcpc_t:packet_socket create_socket_perms; allow dhcpc_t netmsg_eth0_t:packet_socket { recvfrom };

can_exec(dhcpc_t, { bin_t shell_exec_t })

#
# Authors: Russell Coker <[email protected]>

# based on the dhcpc_t policy from:
#          Wayne Salamon (NAI Labs) <[email protected]>
#

#################################
#
# Rules for the dhcpd_t domain.
#

# dhcpd_t is the domain for the server side of DHCP. dhcpd, the DHCP 
# server daemon rc scripts, runs in this domain.
# dhcpd_exec_t is the type of the dhcpdd executable.
# The dhcpd_t can be used for other DHCPC related files as well.
#
type dhcpd_t, domain, privlog;
type dhcpd_exec_t, file_type, sysadmfile, exec_type;

role system_r types dhcpd_t;

# Type for files created during execution of dhcpdd. type dhcpd_var_run_t, file_type, sysadmfile; type etc_dhcpd_t, file_type, sysadmfile; file_type_auto_trans(dhcpd_t, var_run_t, dhcpd_var_run_t) allow dhcpd_t { var_t var_lib_t }:dir r_dir_perms;

# Inherit and use descriptors from init, and send SIGCHLD. allow dhcpd_t init_t:fd inherit_fd_perms;
allow dhcpd_t init_t:process sigchld;

# Use the network.
can_network(dhcpd_t)
allow dhcpd_t dhcpd_t:unix_dgram_socket create_socket_perms;

# Use capabilities
allow dhcpd_t dhcpd_t:capability { net_raw net_bind_service };

# Allow access to the dhcpd file types
type dhcp_state_t, file_type, sysadmfile;
type dhcpd_state_t, file_type, sysadmfile;
allow dhcpd_t etc_dhcpd_t:file r_file_perms; file_type_auto_trans(dhcpd_t, dhcp_state_t, dhcpd_state_t)

# Allow dhcpd_t programs to execute themselves and bin_t (uname etc) can_exec(dhcpd_t, { dhcpd_exec_t bin_t })

# Allow dhcpd_t to use packet sockets
allow dhcpd_t dhcpd_t:packet_socket create_socket_perms; allow dhcpd_t dhcpd_t:rawip_socket create_socket_perms; allow dhcpd_t netmsg_eth0_t:packet_socket { recvfrom }; allow dhcpd_t netmsg_eth0_t:packet_socket { recvfrom };

# allow to run utilities and scripts
allow dhcpd_t { ld_so_t bin_t sbin_t }:dir r_dir_perms;
allow dhcpd_t { ld_so_t bin_t sbin_t }:{ file lnk_file } rx_file_perms;
allow dhcpd_t dhcpd_t:fifo_file { read write getattr };
allow dhcpd_t dhcpd_t:process { sigchld fork };
# allow reading /proc
allow dhcpd_t proc_t:dir r_dir_perms;
allow dhcpd_t proc_t:{ file lnk_file } r_file_perms;

domain_auto_trans(initrc_t, dhcpd_exec_t, dhcpd_t)