Chris PeBenito 960373
# Copyright (C) 2005 Tresys Technology, LLC
Chris PeBenito 960373
Chris PeBenito 960373
policy_module(sysnetwork,1.0)
Chris PeBenito 960373
Chris PeBenito 0d7ad3
########################################
Chris PeBenito 0d7ad3
#
Chris PeBenito 0d7ad3
# Declarations
Chris PeBenito 0d7ad3
#
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
type dhcpc_t;
Chris PeBenito 0d7ad3
type dhcpc_exec_t;
Chris PeBenito ff3138
init_make_daemon_domain(dhcpc_t,dhcpc_exec_t)
Chris PeBenito bbd6a6
role system_r types dhcpc_t;
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
type dhcpc_state_t;
Chris PeBenito 0d7ad3
files_make_file(dhcpc_state_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
type dhcpc_tmp_t;
Chris PeBenito 38e24a
files_make_temporary_file(dhcpc_tmp_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
type dhcpc_var_run_t;
Chris PeBenito d25dd9
files_make_daemon_runtime_file(dhcpc_var_run_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
type ifconfig_t;
Chris PeBenito 0d7ad3
type ifconfig_exec_t;
Chris PeBenito ff3138
init_make_system_domain(ifconfig_t, ifconfig_exec_t)
Chris PeBenito bbd6a6
role system_r types ifconfig_t;
Chris PeBenito 0d7ad3
Chris PeBenito 549180
type net_conf_t alias resolv_conf_t;
Chris PeBenito 549180
files_make_file(net_conf_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
########################################
Chris PeBenito 0d7ad3
#
Chris PeBenito 0d7ad3
# DHCP client local policy
Chris PeBenito 0d7ad3
#
Chris PeBenito 0d7ad3
allow dhcpc_t self:capability { dac_override fsetid net_admin net_raw net_bind_service sys_resource sys_tty_config };
Chris PeBenito 0d7ad3
dontaudit dhcpc_t self:capability sys_tty_config;
Chris PeBenito 0d7ad3
# for access("/etc/bashrc", X_OK) on Red Hat
Chris PeBenito 0d7ad3
dontaudit dhcpc_t self:capability { dac_read_search sys_module };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# create pid file
Chris PeBenito 0d7ad3
allow dhcpc_t dhcpc_var_run_t:file { getattr create read write append setattr unlink };
Chris PeBenito 0d7ad3
files_create_daemon_runtime_data(dhcpc_t,dhcpc_var_run_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# transition to ifconfig
Chris PeBenito 0d7ad3
allow dhcpc_t ifconfig_exec_t:file { getattr read execute };
Chris PeBenito 0d7ad3
allow dhcpc_t ifconfig_t:process transition;
Chris PeBenito 0d7ad3
dontaudit dhcpc_t ifconfig_t:process { noatsecure siginh rlimitinh };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# Allow read/write to /etc/resolv.conf and /etc/ntp.conf. Note that any files
Chris PeBenito 0d7ad3
# in /etc created by dhcpcd will be labelled net_conf_t.
Chris PeBenito 0d7ad3
allow dhcpc_t net_conf_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 0d7ad3
files_create_private_config(dhcpc_t,net_conf_t,file)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# create temp files
Chris PeBenito 0d7ad3
allow dhcpc_t dhcpc_tmp_t:dir { create read getattr lock setattr ioctl link unlink rename search add_name remove_name reparent write rmdir };
Chris PeBenito 0d7ad3
allow dhcpc_t dhcpc_tmp_t:file { create ioctl read getattr lock write setattr append link unlink rename };
Chris PeBenito 0d7ad3
files_create_private_tmp_data(dhcpc_t, dhcpc_tmp_t, { file dir })
Chris PeBenito 0d7ad3
Chris PeBenito efd8ed
allow dhcpc_t self:tcp_socket { create ioctl read getattr write setattr append bind getopt setopt shutdown };
Chris PeBenito efd8ed
allow dhcpc_t self:udp_socket { create ioctl read getattr write setattr append bind getopt setopt shutdown };
Chris PeBenito 0d7ad3
allow dhcpc_t self:packet_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito 0d7ad3
allow dhcpc_t self:netlink_route_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown nlmsg_read };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow dhcpc_t self:fifo_file { ioctl read getattr lock write append };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow dhcpc_t dhcpc_exec_t:file { getattr read execute execute_no_trans };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
kernel_read_system_state(dhcpc_t)
Chris PeBenito 0d7ad3
kernel_read_network_state(dhcpc_t)
Chris PeBenito 0d7ad3
kernel_read_kernel_sysctl(dhcpc_t)
Chris PeBenito 0d7ad3
kernel_read_hardware_state(dhcpc_t)
Chris PeBenito 0d7ad3
kernel_use_file_descriptors(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
corenetwork_network_tcp_on_all_interfaces(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_network_raw_on_all_interfaces(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_network_udp_on_all_interfaces(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_network_tcp_on_all_nodes(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_network_raw_on_all_nodes(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_network_udp_on_all_nodes(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_network_tcp_on_all_ports(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_network_udp_on_all_ports(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_bind_tcp_on_all_nodes(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_bind_udp_on_all_nodes(dhcpc_t)
Chris PeBenito 0d7ad3
corenetwork_bind_udp_on_dhcpc_port(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# for SSP
Chris PeBenito 0d7ad3
devices_get_pseudorandom_data(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
filesystem_get_all_filesystems_attributes(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
terminal_ignore_use_console(dhcpc_t)
Chris PeBenito b16c6b
terminal_ignore_use_all_private_physical_terminals(dhcpc_t)
Chris PeBenito b16c6b
terminal_ignore_use_all_private_pseudoterminals(dhcpc_t)
Chris PeBenito 0d7ad3
terminal_ignore_use_general_physical_terminal(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito daa0e0
corecommands_execute_general_programs(dhcpc_t)
Chris PeBenito daa0e0
corecommands_execute_system_programs(dhcpc_t)
Chris PeBenito daa0e0
corecommands_execute_shell(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
domain_use_widely_inheritable_file_descriptors(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
files_read_general_system_config(dhcpc_t)
Chris PeBenito 0d7ad3
files_read_runtime_system_config(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito daa0e0
init_use_file_descriptors(dhcpc_t)
Chris PeBenito daa0e0
init_script_use_pseudoterminal(dhcpc_t)
Chris PeBenito daa0e0
init_script_modify_runtime_data(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
logging_send_system_log_message(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
libraries_use_dynamic_loader(dhcpc_t)
Chris PeBenito dd14d0
libraries_use_shared_libraries(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
miscfiles_read_localization(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito daa0e0
modutils_insmod_transition(dhcpc_t)
Chris PeBenito daa0e0
Chris PeBenito 0d7ad3
tunable_policy(`targeted_policy', `
Chris PeBenito 0d7ad3
terminal_ignore_use_general_physical_terminal(dhcpc_t)
Chris PeBenito 0d7ad3
terminal_ignore_use_general_pseudoterminal(dhcpc_t)
Chris PeBenito 0d7ad3
files_ignore_read_rootfs_file(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
optional_policy(`consoletype.te',`
Chris PeBenito 0d7ad3
consoletype_transition(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
optional_policy(`hostname.te',`
Chris PeBenito 0d7ad3
hostname_transition(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 1e5c2a
optional_policy(`nscd.te',`
Chris PeBenito 1e5c2a
nscd_transition(dhcpc_t)
Chris PeBenito 1e5c2a
')
Chris PeBenito 1e5c2a
Chris PeBenito 0d7ad3
optional_policy(`selinux.te',`
Chris PeBenito 0d7ad3
selinux_newrole_sigchld(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
optional_policy(`udev.te',`
Chris PeBenito 0d7ad3
udev_read_database(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito daa0e0
optional_policy(`userdomain.te',`
Chris PeBenito daa0e0
userdomain_use_all_users_file_descriptors(dhcpc_t)
Chris PeBenito daa0e0
')
Chris PeBenito daa0e0
Chris PeBenito 0d7ad3
#
Chris PeBenito 1e5c2a
# dhclient sometimes starts ypbind and ntpd
Chris PeBenito 0d7ad3
#
Chris PeBenito 0d7ad3
init_script_execute(dhcpc_t)
Chris PeBenito 0d7ad3
optional_policy(`ypbind.te',`
Chris PeBenito 0d7ad3
ypbind_transition(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
optional_policy(`ntpd.te',`
Chris PeBenito 0d7ad3
ntpd_transition(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
ifdef(`TODO',`
Chris PeBenito 0d7ad3
allow dhcpc_t autofs_t:dir { search getattr };
Chris PeBenito 0d7ad3
dontaudit dhcpc_t sysadm_home_dir_t:dir search;
Chris PeBenito 1e5c2a
Chris PeBenito 0d7ad3
optional_policy(`rhgb.te', `
Chris PeBenito 0d7ad3
allow dhcpc_t rhgb_t:process sigchld;
Chris PeBenito 0d7ad3
allow dhcpc_t rhgb_t:fd use;
Chris PeBenito 0d7ad3
allow dhcpc_t rhgb_t:fifo_file { read write };
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
can_ypbind(dhcpc_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
ifdef(`cardmgr.te', `
Chris PeBenito 0d7ad3
domain_auto_trans(cardmgr_t, dhcpc_exec_t, dhcpc_t)
Chris PeBenito 0d7ad3
allow cardmgr_t dhcpc_var_run_t:file { getattr read };
Chris PeBenito 0d7ad3
allow cardmgr_t dhcpc_t:process signal_perms;
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
ifdef(`hotplug.te', `
Chris PeBenito 0d7ad3
domain_auto_trans(hotplug_t, dhcpc_exec_t, dhcpc_t)
Chris PeBenito 0d7ad3
allow hotplug_t dhcpc_t:process signal_perms;
Chris PeBenito 0d7ad3
allow hotplug_t dhcpc_var_run_t:file { getattr read };
Chris PeBenito 0d7ad3
allow hotplug_t dhcp_etc_t:file rw_file_perms;
Chris PeBenito 0d7ad3
allow dhcpc_t hotplug_etc_t:dir { getattr search };
Chris PeBenito 0d7ad3
tunable_policy(`distro_redhat', `
Chris PeBenito 0d7ad3
logging_syslogd_transition(dhcpc_t)
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
')dnl end hotplug.te
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# for the dhcp client to run ping to check IP addresses
Chris PeBenito 0d7ad3
ifdef(`ping.te', `
Chris PeBenito 0d7ad3
domain_auto_trans(dhcpc_t, ping_exec_t, ping_t)
Chris PeBenito 0d7ad3
ifdef(`hotplug.te',`
Chris PeBenito 0d7ad3
allow ping_t hotplug_t:fd use;
Chris PeBenito 0d7ad3
') dnl end if hotplug
Chris PeBenito 0d7ad3
ifdef(`cardmgr.te', `
Chris PeBenito 0d7ad3
allow ping_t cardmgr_t:fd use;
Chris PeBenito 0d7ad3
') dnl end if cardmgr
Chris PeBenito 0d7ad3
') dnl end if ping
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
ifdef(`dhcpd.te', `', `
Chris PeBenito f66a1a
#type dhcp_state_t, file_type, sysadmfile;
Chris PeBenito f66a1a
#type dhcp_etc_t, file_type, sysadmfile, usercanread; 
Chris PeBenito f66a1a
#typealias dhcp_etc_t alias { etc_dhcp_t etc_dhcpc_t etc_dhcpd_t };
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow dhcpc_t dhcp_etc_t:dir { getattr read search };
Chris PeBenito 0d7ad3
allow dhcpc_t dhcp_etc_t:file { read getattr };
Chris PeBenito 0d7ad3
allow dhcpc_t dhcp_etc_t:lnk_file { getattr read };
Chris PeBenito 0d7ad3
allow dhcpc_t dhcp_etc_t:file { getattr read execute execute_no_trans };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
ifdef(`distro_redhat', `
Chris PeBenito 0d7ad3
files_execute_system_config_script(dhcpc_t)
Chris PeBenito 0d7ad3
allow initrc_t dhcp_etc_t:file rw_file_perms;
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow dhcpc_t var_lib_t:dir search;
Chris PeBenito 0d7ad3
file_type_auto_trans(dhcpc_t, dhcp_state_t, dhcpc_state_t, file)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow dhcpc_t home_root_t:dir search;
Chris PeBenito 0d7ad3
allow initrc_t dhcpc_state_t:file { getattr read };
Chris PeBenito 0d7ad3
dontaudit dhcpc_t var_lock_t:dir search;
Chris PeBenito 0d7ad3
dontaudit dhcpc_t selinux_config_t:dir search;
Chris PeBenito 0d7ad3
dontaudit dhcpc_t domain:dir getattr;
Chris PeBenito 0d7ad3
') dnl endif TODO
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
########################################
Chris PeBenito 0d7ad3
#
Chris PeBenito 0d7ad3
# Ifconfig local policy
Chris PeBenito 0d7ad3
#
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow ifconfig_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem dyntransition };
Chris PeBenito 0d7ad3
allow ifconfig_t self:capability net_admin;
Chris PeBenito 0d7ad3
dontaudit ifconfig_t self:capability sys_module;
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow ifconfig_t self:fd use;
Chris PeBenito 0d7ad3
allow ifconfig_t self:fifo_file { read getattr lock ioctl write append };
Chris PeBenito 0d7ad3
allow ifconfig_t self:unix_dgram_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito 0d7ad3
allow ifconfig_t self:unix_stream_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown listen accept };
Chris PeBenito 0d7ad3
allow ifconfig_t self:unix_dgram_socket sendto;
Chris PeBenito 0d7ad3
allow ifconfig_t self:unix_stream_socket connectto;
Chris PeBenito 0d7ad3
allow ifconfig_t self:shm { associate getattr setattr create destroy read write lock unix_read unix_write };
Chris PeBenito 0d7ad3
allow ifconfig_t self:sem { associate getattr setattr create destroy read write unix_read unix_write };
Chris PeBenito 0d7ad3
allow ifconfig_t self:msgq { associate getattr setattr create destroy read write enqueue unix_read unix_write };
Chris PeBenito 0d7ad3
allow ifconfig_t self:msg { send receive };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# Create UDP sockets, necessary when called from dhcpc
Chris PeBenito 0d7ad3
allow ifconfig_t self:udp_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# for /sbin/ip
Chris PeBenito 0d7ad3
allow ifconfig_t self:netlink_route_socket { create ioctl read getattr write setattr append bind connect getopt setopt shutdown nlmsg_read nlmsg_write };
Chris PeBenito 0d7ad3
allow ifconfig_t self:tcp_socket { create ioctl };
Chris PeBenito 0d7ad3
files_read_general_system_config(ifconfig_t);
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
kernel_use_file_descriptors(ifconfig_t)
Chris PeBenito 0d7ad3
kernel_read_system_state(ifconfig_t)
Chris PeBenito 0d7ad3
kernel_read_network_state(ifconfig_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
filesystem_get_persistent_filesystem_attributes(ifconfig_t)
Chris PeBenito 0d7ad3
Chris PeBenito b16c6b
terminal_ignore_use_all_private_physical_terminals(ifconfig_t)
Chris PeBenito b16c6b
terminal_ignore_use_all_private_pseudoterminals(ifconfig_t)
Chris PeBenito 1e5c2a
Chris PeBenito 0d7ad3
domain_use_widely_inheritable_file_descriptors(ifconfig_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
files_ignore_read_rootfs_file(ifconfig_t)
Chris PeBenito 0d7ad3
Chris PeBenito 8623d5
init_use_file_descriptors(ifconfig_t)
Chris PeBenito 8623d5
init_script_use_pseudoterminal(ifconfig_t)
Chris PeBenito 8623d5
Chris PeBenito 0d7ad3
libraries_use_dynamic_loader(ifconfig_t)
Chris PeBenito dd14d0
libraries_use_shared_libraries(ifconfig_t)
Chris PeBenito f5c42b
libraries_read_library_resources(ifconfig_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
logging_send_system_log_message(ifconfig_t)
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
miscfiles_read_localization(ifconfig_t)
Chris PeBenito 0d7ad3
Chris PeBenito 8623d5
selinux_run_init_use_file_descriptors(ifconfig_t)
Chris PeBenito 8623d5
Chris PeBenito daa0e0
userdomain_use_all_users_file_descriptors(ifconfig_t)
Chris PeBenito daa0e0
Chris PeBenito 0d7ad3
ifdef(`TODO',`
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
can_ypbind(ifconfig_t)
Chris PeBenito 0d7ad3
ifdef(`automount.te', `
Chris PeBenito 0d7ad3
allow ifconfig_t autofs_t:dir { search getattr };
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# Access terminals.
Chris PeBenito 0d7ad3
ifdef(`gnome-pty-helper.te', `allow ifconfig_t sysadm_gph_t:fd use;')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
allow ifconfig_t tun_tap_device_t:chr_file { read write };
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
# ifconfig attempts to search some sysctl entries.
Chris PeBenito 0d7ad3
# Do not audit those attempts; comment out these rules if it is desired to
Chris PeBenito 0d7ad3
# see the denials.
Chris PeBenito 0d7ad3
dontaudit ifconfig_t { sysctl_t sysctl_net_t }:dir search;
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
optional_policy(`rhgb.te', `
Chris PeBenito 0d7ad3
allow ifconfig_t rhgb_t:process sigchld;
Chris PeBenito 0d7ad3
allow ifconfig_t rhgb_t:fd use;
Chris PeBenito 0d7ad3
allow ifconfig_t rhgb_t:fifo_file { read write };
Chris PeBenito 0d7ad3
')
Chris PeBenito 0d7ad3
Chris PeBenito 0d7ad3
') dnl endif TODO