policy_module(ifplugd, 1.1.0)

########################################
#
# Declarations
#

type ifplugd_t;
type ifplugd_exec_t;
init_daemon_domain(ifplugd_t, ifplugd_exec_t)

type ifplugd_etc_t;
files_config_file(ifplugd_etc_t)

type ifplugd_initrc_exec_t;
init_script_file(ifplugd_initrc_exec_t)

type ifplugd_var_run_t;
files_pid_file(ifplugd_var_run_t)

########################################
#
# Local policy
#

allow ifplugd_t self:capability { net_admin sys_nice net_bind_service };
dontaudit ifplugd_t self:capability sys_tty_config;
allow ifplugd_t self:process { signal signull };
allow ifplugd_t self:fifo_file rw_fifo_file_perms;
allow ifplugd_t self:tcp_socket { accept listen };
allow ifplugd_t self:packet_socket create_socket_perms;
allow ifplugd_t self:netlink_route_socket nlmsg_write;

read_files_pattern(ifplugd_t, ifplugd_etc_t, ifplugd_etc_t)
exec_files_pattern(ifplugd_t, ifplugd_etc_t, ifplugd_etc_t)

manage_files_pattern(ifplugd_t, ifplugd_var_run_t, ifplugd_var_run_t)
manage_sock_files_pattern(ifplugd_t, ifplugd_var_run_t, ifplugd_var_run_t)
files_pid_filetrans(ifplugd_t, ifplugd_var_run_t, { file sock_file })

kernel_read_kernel_sysctls(ifplugd_t)
kernel_read_network_state(ifplugd_t)
kernel_read_system_state(ifplugd_t)
kernel_rw_net_sysctls(ifplugd_t)

corecmd_exec_bin(ifplugd_t)
corecmd_exec_shell(ifplugd_t)

dev_read_sysfs(ifplugd_t)

domain_read_confined_domains_state(ifplugd_t)

auth_use_nsswitch(ifplugd_t)

logging_send_syslog_msg(ifplugd_t)

netutils_domtrans(ifplugd_t)

sysnet_domtrans_ifconfig(ifplugd_t)
sysnet_domtrans_dhcpc(ifplugd_t)
sysnet_delete_dhcpc_pid(ifplugd_t)
sysnet_read_dhcpc_pid(ifplugd_t)
sysnet_signal_dhcpc(ifplugd_t)

optional_policy(`
	consoletype_exec(ifplugd_t)
')
