WireGuard is a fast, modern, secure VPN tunnel, according to https://www.wireguard.com/. In order to install it, the mostly documented way consists in building and installing an out-of-tree kernel module and using userland tools to configure this module (wg and wg-quick). * WireGuard is like "ip": the userland tool communicates with the kernel module through a netlink socket. * WireGuard is like "iptables": there is no daemon, but some distributions ship systemd units that restores a WireGuard configuration when started. * WireGuard is like other services: its configuration files are in /etc, and it can use /run and /tmp. Create a new policy module which handles all of this. Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
73 lines
2.0 KiB
Plaintext
73 lines
2.0 KiB
Plaintext
policy_module(wireguard, 1.0.0)
|
|
|
|
########################################
|
|
#
|
|
# Declarations
|
|
#
|
|
|
|
attribute_role wireguard_roles;
|
|
roleattribute system_r wireguard_roles;
|
|
|
|
type wireguard_t;
|
|
type wireguard_exec_t;
|
|
init_system_domain(wireguard_t, wireguard_exec_t)
|
|
role wireguard_roles types wireguard_t;
|
|
|
|
type wireguard_etc_t;
|
|
files_config_file(wireguard_etc_t)
|
|
|
|
type wireguard_initrc_exec_t;
|
|
init_unit_file(wireguard_initrc_exec_t)
|
|
|
|
type wireguard_runtime_t;
|
|
files_pid_file(wireguard_runtime_t)
|
|
|
|
type wireguard_unit_t;
|
|
init_unit_file(wireguard_unit_t)
|
|
|
|
type wireguard_tmp_t;
|
|
files_tmp_file(wireguard_tmp_t)
|
|
|
|
########################################
|
|
#
|
|
# Local policy
|
|
#
|
|
|
|
allow wireguard_t self:capability net_admin;
|
|
allow wireguard_t self:process getsched;
|
|
|
|
allow wireguard_t self:fifo_file rw_fifo_file_perms;
|
|
allow wireguard_t self:netlink_generic_socket create_socket_perms;
|
|
allow wireguard_t self:netlink_route_socket r_netlink_socket_perms;
|
|
allow wireguard_t self:udp_socket create_socket_perms;
|
|
allow wireguard_t self:unix_stream_socket create_socket_perms;
|
|
|
|
manage_files_pattern(wireguard_t, wireguard_etc_t, wireguard_etc_t);
|
|
files_read_etc_files(wireguard_t)
|
|
|
|
manage_files_pattern(wireguard_t, wireguard_runtime_t, wireguard_runtime_t)
|
|
files_pid_filetrans(wireguard_t, wireguard_runtime_t, dir)
|
|
|
|
manage_dirs_pattern(wireguard_t, wireguard_tmp_t, wireguard_tmp_t)
|
|
manage_files_pattern(wireguard_t, wireguard_tmp_t, wireguard_tmp_t)
|
|
files_tmp_filetrans(wireguard_t, wireguard_tmp_t, file)
|
|
|
|
# wg-quick can execute wg
|
|
can_exec(wireguard_t, wireguard_exec_t)
|
|
|
|
# wg-quick is a shell script
|
|
corecmd_exec_bin(wireguard_t)
|
|
corecmd_exec_shell(wireguard_t)
|
|
|
|
domain_use_interactive_fds(wireguard_t)
|
|
|
|
# wg-quick tries to read /proc/filesystem when running "stat" and "mv" commands
|
|
kernel_dontaudit_read_system_state(wireguard_t)
|
|
|
|
miscfiles_read_localization(wireguard_t)
|
|
|
|
# wg-quick runs /usr/bin/ip to configure the network
|
|
sysnet_run_ifconfig(wireguard_t, wireguard_roles)
|
|
|
|
userdom_use_user_terminals(wireguard_t)
|