$linuxjunkies
>

audit2allow(1)

Generate SELinux policy allow rules from audit logs of denied access attempts.

UbuntuDebianFedoraArch

Synopsis

audit2allow [-a] [-d] [-l] [-r] [-t type] [-M module_name] [-o output_file]

Description

audit2allow generates SELinux policy allow rules by analyzing audit logs (typically from /var/log/audit/audit.log) that contain AVC (Access Vector Cache) denial messages. It converts these denials into corresponding policy rules that can be compiled and loaded to permit the blocked operations.

This tool is commonly used when SELinux denies legitimate application behavior. Instead of disabling SELinux entirely, you can use audit2allow to generate targeted policy rules that allow specific operations while maintaining overall system security.

The tool can output rules in human-readable format, generate loadable modules, or both. Generated modules can be compiled with checkmodule and semodule_package, then installed with semodule.

Common options

FlagWhat it does
-aRead input from audit daemon and analyze all current denials in the audit log
-dUse dmesg instead of audit log (for systems without auditd running)
-lList all possible avcs in the current policy. Useful for policy development
-rRemove an installed module (requires -M flag for module name)
-M module_nameCreate a compilable module with the given name; generates .pp policy package
-o output_fileWrite output to specified file instead of stdout
-t typeOnly process rules for the specified domain type
-RGenerate reference policy rules (requires refpolicy installed)

Examples

Analyze all denials in the audit log and print allow rules to stdout

audit2allow -a

Generate a compilable SELinux module named myapp_policy from audit denials

audit2allow -a -M myapp_policy

Read denials from kernel dmesg (useful when auditd is not running)

audit2allow -d

Generate a module and immediately install it (after semodule_package compiles it)

audit2allow -a -M custom && semodule -i custom.pp

Write generated allow rules to a file for review before applying

audit2allow -a -o /tmp/rules.txt

Generate rules only for denials involving the httpd_t domain type

audit2allow -a -t httpd_t

Generate a module from the last 100 audit log entries (piped input)

tail -100 /var/log/audit/audit.log | audit2allow -M temp_fix

Related commands