Skip to content

Commit 7991005

Browse files
committed
Add support for SELinux-enhanced systems
1 parent cae93aa commit 7991005

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

wireguard-install.sh

+15
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,19 @@ function installQuestions() {
185185
read -n1 -r -p "Press any key to continue..."
186186
}
187187
188+
function installSELinuxRules() {
189+
local osid
190+
osid="$1"
191+
192+
if [[ $osid == 'fedora' ]]; then
193+
dnf install -y checkpolicy
194+
echo "module se_wg 1.0;require { type wireguard_t; class capability { dac_override dac_read_search }; } allow wireguard_t self:capability { dac_override dac_read_search };" >/tmp/se_wg.te && checkmodule -M -m -o /tmp/se_wg.mod /tmp/se_wg.te && semodule_package -o /tmp/se_wg.pp -m /tmp/se_wg.mod && semodule -i /tmp/se_wg.pp
195+
elif [[ $osid == 'centos' || $osid == 'almalinux' || $osid == 'rocky' ]]; then
196+
dnf install -y checkpolicy
197+
echo "module se_wg 1.0; require {type wireguard_t; type cert_t; type firewalld_t; class capability { dac_override dac_read_search }; class dir search; class dbus send_msg;} allow wireguard_t cert_t:dir search; allow wireguard_t firewalld_t:dbus send_msg; allow wireguard_t self:capability { dac_override dac_read_search };" >/tmp/se_wg.te && checkmodule -M -m -o /tmp/se_wg.mod /tmp/se_wg.te && semodule_package -o /tmp/se_wg.pp -m /tmp/se_wg.mod && semodule -i /tmp/se_wg.pp
198+
fi
199+
}
200+
188201
function installWireGuard() {
189202
# Run setup questions first
190203
installQuestions
@@ -282,6 +295,8 @@ PostDown = ip6tables -t nat -D POSTROUTING -o ${SERVER_PUB_NIC} -j MASQUERADE" >
282295
echo "net.ipv4.ip_forward = 1
283296
net.ipv6.conf.all.forwarding = 1" >/etc/sysctl.d/wg.conf
284297
298+
installSELinuxRules ${OS}
299+
285300
if [[ ${OS} == 'alpine' ]]; then
286301
sysctl -p /etc/sysctl.d/wg.conf
287302
rc-update add sysctl

0 commit comments

Comments
 (0)