Skip to content

Fixing SELinux issues

Guide on how to fix SELinux getting in your way

📅 Created: Jan 9, 2022•🕒 Updated: Apr 24, 2022

SELinux is a mechanism that ties into the Linux kernel to provide hardend security and access control to administrators. It can greatly improve the security of Desktops and Servers and is something really handy, most of the time.

How can SELinux cause issues? ​

As I mentioned it provides access control and sometimes may block or interfere with your processes if misconfigured.

I recently had this happen where I noticed I couldn't connect to my VPN via KDE's network manager on my Fedora 34 system, which has SELinux preinstalled.

After some investigation I found in the the system journal a line indicating something didn't quite work out as intended. You can search for stuff in the systemjournal by exporting it and piping it through grep like this:

bash
journalctl -b | grep <searchterm> # Replace <searchterm> with your issue like "vpn"

Amongst the lines I found this:

bash
audit[16420]: AVC avc:  denied  { open } for  pid=16420 comm="openvpn" path="/home/lukas/.vpn/Windscribe-Frankfurt/ta.key" dev="dm-0" ino=578113 scontext=system_u:system_r:openvpn_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0

which turned out to be an SELinux block.

How to fix it? ​

After you found the line indicating an SELinux block just copy it to your clipboard and insert it into this command like so:

bash
audit2allow -M local << _EOF_
audit[16420]: AVC avc:  denied  { open } for ... # this needs to be the full line like pasted above
_EOF_

after that just execute this to apply the changes:

bash
sudo semodule -i local.pp