selinux-refpolicy/policy/modules/services/wireguard.if
Nicolas Iooss a7c9634eca
Add a policy module for WireGuard VPN
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>
2019-09-06 22:20:40 +02:00

78 lines
1.6 KiB
Plaintext

## <summary>WireGuard VPN.</summary>
########################################
## <summary>
## Execute WireGuard in the wireguard domain.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
#
interface(`wireguard_domtrans',`
gen_require(`
type wireguard_t, wireguard_exec_t;
')
corecmd_search_bin($1)
domtrans_pattern($1, wireguard_exec_t, wireguard_t)
')
########################################
## <summary>
## Execute WireGuard in the wireguard domain, and
## allow the specified role the wireguard domain.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed to transition.
## </summary>
## </param>
## <param name="role">
## <summary>
## Role allowed access.
## </summary>
## </param>
## <rolecap/>
#
interface(`wireguard_run',`
gen_require(`
attribute_role wireguard_roles;
')
wireguard_domtrans($1)
roleattribute $2 wireguard_roles;
')
########################################
## <summary>
## All of the rules required to
## administrate a WireGuard
## environment.
## </summary>
## <param name="domain">
## <summary>
## Domain allowed access.
## </summary>
## </param>
## <param name="role">
## <summary>
## Role allowed access.
## </summary>
## </param>
## <rolecap/>
#
interface(`wireguard_admin',`
gen_require(`
type wireguard_t, wireguard_etc_t, wireguard_initrc_exec_t, wireguard_unit_t;
')
admin_process_pattern($1, wireguard_t)
init_startstop_service($1, $2, wireguard_t, wireguard_initrc_exec_t, wireguard_unit_t)
files_search_etc($1)
admin_pattern($1, wireguard_etc_t)
')