Pcornel
Linux · SELinux

SELinux Troubleshooting

Cheat sheet · https://pcornel.dk/topic.php?topic=2860

Back to the Topic

Answer

SELinux troubleshooting reads AVC denials and applies the smallest fix: correct the label, enable a boolean, label a port, or as a last resort create a local policy module.

Remember

Use sealert or audit2why to explain denials. Only use audit2allow to build a module after confirming no label or boolean fixes it — review the generated rules. dontaudit rules can hide denials (semodule -DB temporarily).

First checks

  • audit2why -a — explain denials
  • getenforce / sestatus — mode and policy
  • ls -Z <path> — file context
  • ps -eZ | grep <proc> — process context
  • ausearch -m AVC -ts recent — recent denials
  • semanage fcontext -l | grep <path> — context rules for a path

Verify in this order

operation denied → AVC logged → cause classified (label, boolean, port, policy) → smallest fix → enforcing works

Where it usually breaks

First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2860

Confirmation

Confirm action

Continue?