DEV Community

StarkMan
StarkMan

Posted on

SELinux booleans are policy changes with a persistence flag

SELinux booleans are policy changes with a persistence flag

SELinux booleans are conditional switches inside a policy. An administrator can use one to enable a supported service behavior without editing policy source. That convenience is also a risk: a boolean changes what the policy allows, and a runtime-only change can disappear after reboot while a persistent change can silently widen the host for months.

Identify the policy side effect

Use semanage boolean -l to list booleans and their descriptions, then inspect the current value with getsebool. The Red Hat guide explains that setsebool boolean_name on changes the current state. Add -P only when the change must survive a reboot. The persistence flag is not a confirmation that the change is appropriate; it controls whether the setting is written into policy.

Review a proposed boolean as a permission change. Identify the confined domain, the operation it enables, the daemon that needs it, and the network or file path involved. A boolean such as allowing a web server to connect to the network may be necessary for one deployment and excessive for another. Prefer a narrower custom policy module when the policy language can express the exact rule.

Capture the default and the exception

The default value matters when a host is rebuilt or an administrator resets local settings. Record the default and current state in configuration management, not only the desired state. A host that was enabled for a migration and left enabled after the migration is a policy drift finding. Exceptions should have an owner, a reason, an expiry date, and a test that shows why the standard policy is insufficient.

Runtime changes and persistent changes should be audited separately. An operator can change a boolean for a troubleshooting window and leave the system running for weeks. Use an event or configuration inventory that notices both the value and whether it is local and persistent. Review the SELinux denial stream at the same time. A boolean is not a substitute for correcting mislabeled files or an incorrect service path.

Test the boundary

After changing a boolean, test the intended operation and one operation that should remain denied. Reload or restart only the service that needs the change. Check that the service still starts under enforcing mode and that the audit stream no longer contains the expected denial. Then check that a different confined process cannot use the new permission.

If the application still fails, do not disable SELinux globally. Use the denial evidence to identify the source and target types, then decide whether the correct fix is a file context, a service configuration change, or a policy adjustment. Keep enforcing mode as the default and use permissive mode only for a bounded diagnostic window with logging.

Make the change reproducible

Store the command and the policy result in the host's configuration source. Include setsebool -P only where persistence is intended. Add a post-deployment check that compares the live state with the approved state. A host that has an extra boolean enabled should be visible as drift even if the service is currently healthy.

SELinux booleans are useful because they are small, supported policy decisions. Their value depends on treating those decisions as reviewed permission changes and making the reason for the exception as durable as the setting itself.

References

[1] Red Hat SELinux booleans guide

[2] semanage-boolean manual

Top comments (0)