policy_module(usernetctl, 1.7.0)

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

attribute_role usernetctl_roles;
roleattribute system_r usernetctl_roles;

type usernetctl_t;
type usernetctl_exec_t;
application_domain(usernetctl_t, usernetctl_exec_t)
domain_interactive_fd(usernetctl_t)

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

allow usernetctl_t self:capability { setuid setgid dac_read_search  };
allow usernetctl_t self:process ~{ ptrace setcurrent setexec setfscreate setrlimit execmem execstack execheap };
allow usernetctl_t self:fd use;
allow usernetctl_t self:fifo_file rw_fifo_file_perms;
allow usernetctl_t self:unix_dgram_socket sendto;
allow usernetctl_t self:unix_stream_socket { accept connectto listen };

can_exec(usernetctl_t, usernetctl_exec_t)

kernel_read_system_state(usernetctl_t)
kernel_read_kernel_sysctls(usernetctl_t)

corecmd_list_bin(usernetctl_t)
corecmd_exec_bin(usernetctl_t)
corecmd_exec_shell(usernetctl_t)

domain_dontaudit_read_all_domains_state(usernetctl_t)

files_exec_etc_files(usernetctl_t)
files_read_etc_runtime_files(usernetctl_t)
files_list_pids(usernetctl_t)
files_list_home(usernetctl_t)

fs_search_auto_mountpoints(usernetctl_t)

auth_use_nsswitch(usernetctl_t)

logging_send_syslog_msg(usernetctl_t)

seutil_read_config(usernetctl_t)

sysnet_read_config(usernetctl_t)

sysnet_run_ifconfig(usernetctl_t, usernetctl_roles)
sysnet_run_dhcpc(usernetctl_t, usernetctl_roles)

userdom_use_inherited_user_terminals(usernetctl_t)

optional_policy(`
	hostname_exec(usernetctl_t)
')

optional_policy(`
	iptables_run(usernetctl_t, usernetctl_roles)
')

optional_policy(`
	modutils_run_kmod(usernetctl_t, usernetctl_roles)
')

optional_policy(`
	nis_use_ypbind(usernetctl_t)
')

optional_policy(`
	ppp_run(usernetctl_t, usernetctl_roles)
')
