1From 67394d078c2e1438293b25d08cf408b0b0d55755 Mon Sep 17 00:00:00 2001
2From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
3Date: Wed, 22 Sep 2021 23:55:59 +0200
4Subject: [PATCH] policy/modules/services/wireguard.te: make iptables optional
5
6Make iptables optional to avoid the following build failure raised since
7version 2.20210908 and
8https://github.com/SELinuxProject/refpolicy/commit/7f1a7b1cacd5d211077ce62fbb4e91890e65c820:
9
10 Compiling targeted policy.33
11 env LD_LIBRARY_PATH="/tmp/instance-0/output-1/host/lib:/tmp/instance-0/output-1/host/usr/lib" /tmp/instance-0/output-1/host/usr/bin/checkpolicy -c 33 -U deny -S -O -E policy.conf -o policy.33
12 policy/modules/services/wireguard.te:66:ERROR 'type iptables_exec_t is not within scope' at token ';' on line 591892:
13 #line 66
14	allow wireguard_t iptables_exec_t:file { getattr open map read execute ioctl };
15 checkpolicy:  error(s) encountered while parsing configuration
16 make[1]: *** [Rules.monolithic:79: policy.33] Error 1
17
18Fixes:
19 - http://autobuild.buildroot.org/results/a4223accc6adb70b06fd4e74ca4f28484446b6fa
20
21Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
22[Upstream status: https://github.com/SELinuxProject/refpolicy/pull/408]
23---
24 policy/modules/services/wireguard.te | 10 ++++++----
25 1 file changed, 6 insertions(+), 4 deletions(-)
26
27diff --git a/policy/modules/services/wireguard.te b/policy/modules/services/wireguard.te
28index 7241f65e6..33fd3c55d 100644
29--- a/policy/modules/services/wireguard.te
30+++ b/policy/modules/services/wireguard.te
31@@ -61,10 +61,6 @@ corecmd_exec_shell(wireguard_t)
32
33 domain_use_interactive_fds(wireguard_t)
34
35-# wg-quick can be configured to run iptables and other networking
36-# config tools when bringing up/down the wg interfaces
37-iptables_domtrans(wireguard_t)
38-
39 # wg-quick tries to read /proc/filesystem when running "stat" and "mv" commands
40 kernel_dontaudit_read_system_state(wireguard_t)
41 kernel_dontaudit_search_kernel_sysctl(wireguard_t)
42@@ -75,3 +71,9 @@ miscfiles_read_localization(wireguard_t)
43 sysnet_run_ifconfig(wireguard_t, wireguard_roles)
44
45 userdom_use_user_terminals(wireguard_t)
46+
47+# wg-quick can be configured to run iptables and other networking
48+# config tools when bringing up/down the wg interfaces
49+optional_policy(`
50+	iptables_domtrans(wireguard_t)
51+')
52--
532.33.0
54
55