Stop setting SELinux to Permissive just because you are annoyed
By Saket Jain Published Linux/Unix
Stop setting SELinux to Permissive just because you are annoyed
Technical Briefing | 9/17/2026
We have all been there. You deploy a custom application, the service fails to bind to a port, and you check audit.log. It is a wall of confusing denial messages. After twenty minutes of banging your head against context labels, you run setenforce 0 and move on with your life. I did that for years until a breach showed me exactly how much that five-second fix costs.
Why your policy writes are likely garbage
Most sysadmins rely on audit2allow to generate policy modules. If you are doing this, you are effectively automating your own security holes. Audit2allow just takes the denial log and builds a policy that allows that specific action, regardless of whether that action makes any sense for your process. It is a lazy shortcut that expands your attack surface without you even realizing it.
grep denied /var/log/audit/audit.log | audit2why
- Audit2why actually explains the logic behind the denial rather than just giving you a fix
- Look for the type enforcement rule that makes sense rather than the catch-all allow rule
- Use restorecon -Rv on your directories before writing a custom policy to ensure the base filesystem labels are even correct
Fixing the context instead of killing the guard
If your web server cannot read a log file, the answer is rarely changing the server policy. Usually, you just forgot to apply the correct context to the log directory. Check the parent directory labels and work your way down. If you keep hitting issues, stop and ask why your app needs to write to that location in the first place.
The next time you are tempted to flip that global switch, remember that you are effectively turning off the only thing preventing a basic RCE from turning into a root-level takeover. Take ten minutes to debug the context, or expect to spend ten hours cleaning up the aftermath of a root compromise.
