SELinux Booleans and Troubleshooting
What you'll learn: How to safely adjust SELinux behavior using booleans and systematically resolve permission denials without compromising security.
Understanding SELinux Booleans
SELinux booleans are on/off switches that modify policy behavior without rewriting the entire policy. Think of them as feature flags for security—they let you enable or disable specific capabilities (like allowing a web server to send email or connect to databases) while keeping the overall mandatory access control system intact.
Checking and Setting Booleans
Use getsebool to view current boolean states:
getsebool httpd_can_network_connect
# httpd_can_network_connect --> off
getsebool -a # List all booleans
Use setsebool to change them:
# Temporary change (until reboot)
setsebool httpd_can_network_connect on
# Permanent change
setsebool -P httpd_can_network_connect on
Troubleshooting Permission Denials
When SELinux blocks an operation, check /var/log/audit/audit.log for AVC (Access Vector Cache) denials. The audit2allow tool analyzes these denials and suggests policy adjustments:
# See what's being denied
audit2allow -w -a
# Generate a policy module to allow it
audit2allow -a -M mypolicy
semodule -i mypolicy.pp
Warning: Don't blindly apply audit2allow suggestions—they may be too permissive. First check if a boolean exists for your use case, verify the denial is legitimate, and ensure you're not working around a misconfiguration (like incorrect file contexts).
Systematic Approach
- Identify the denial in audit logs
- Check if a boolean addresses the issue (
getsebool -a | grep <service>) - If no boolean exists, verify contexts are correct
- Only then consider custom policy rules
Key Takeaway: SELinux booleans provide safe, predefined policy adjustments; use getsebool/setsebool first, and treat audit2allow as a last resort after verifying legitimate access needs.