@@ -185,6 +185,17 @@ function installQuestions() {
185
185
read -n1 -r -p "Press any key to continue..."
186
186
}
187
187
188
+ function installSELinuxRules() {
189
+ local osid
190
+ osid="$1 "
191
+
192
+ if [[ $osid == 'fedora' ]]; then
193
+ 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
194
+ elif [[ $osid == 'centos' || $osid == 'almalinux' || $osid == 'rocky' ]]; then
195
+ 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
196
+ fi
197
+ }
198
+
188
199
function installWireGuard() {
189
200
# Run setup questions first
190
201
installQuestions
@@ -206,13 +217,15 @@ function installWireGuard() {
206
217
dnf install -y dnf-plugins-core
207
218
dnf copr enable -y jdoss/wireguard
208
219
dnf install -y wireguard-dkms
220
+ dnf install -y checkpolicy
209
221
fi
210
222
dnf install -y wireguard-tools iptables qrencode
211
223
elif [[ ${OS} == 'centos' ]] || [[ ${OS} == 'almalinux' ]] || [[ ${OS} == 'rocky' ]]; then
212
224
if [[ ${VERSION_ID} == 8 * ]]; then
213
225
yum install -y epel-release elrepo-release
214
226
yum install -y kmod-wireguard
215
227
yum install -y qrencode # not available on release 9
228
+ yum install -y checkpolicy
216
229
fi
217
230
yum install -y wireguard-tools iptables
218
231
elif [[ ${OS} == 'oracle' ]]; then
@@ -282,6 +295,8 @@ PostDown = ip6tables -t nat -D POSTROUTING -o ${SERVER_PUB_NIC} -j MASQUERADE" >
282
295
echo "net.ipv4 .ip_forward = 1
283
296
net.ipv6 .conf.all.forwarding = 1 " >/etc/sysctl.d/wg.conf
284
297
298
+ installSELinuxRules ${OS}
299
+
285
300
if [[ ${OS} == 'alpine' ]]; then
286
301
sysctl -p /etc/sysctl.d/wg.conf
287
302
rc-update add sysctl
@@ -496,13 +511,13 @@ function uninstallWg() {
496
511
elif [[ ${OS} == 'debian' ]]; then
497
512
apt-get remove -y wireguard wireguard-tools qrencode
498
513
elif [[ ${OS} == 'fedora' ]]; then
499
- dnf remove -y --noautoremove wireguard-tools qrencode
514
+ dnf remove -y --noautoremove wireguard-tools qrencode checkpolicy
500
515
if [[ ${VERSION_ID} - lt 32 ]]; then
501
516
dnf remove -y --noautoremove wireguard-dkms
502
517
dnf copr disable -y jdoss/wireguard
503
518
fi
504
519
elif [[ ${OS} == 'centos' ]] || [[ ${OS} == 'almalinux' ]] || [[ ${OS} == 'rocky' ]]; then
505
- yum remove -y --noautoremove wireguard-tools
520
+ yum remove -y --noautoremove wireguard-tools checkpolicy
506
521
if [[ ${VERSION_ID} == 8 * ]]; then
507
522
yum remove --noautoremove kmod-wireguard qrencode
508
523
fi
0 commit comments