---
name: "audit2allow"
section: "1"
platform: "linux"
package: "policycoreutils-python-utils"
version: "3.8.1-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/audit2allow"
---

# audit2allow(1)

generate SELinux policy allow/dontaudit rules from logs of denied operations audit2why - translates SELinux audit messages into a description of why the access was denied (audit2allow -w)

## NAME

**audit2allow** - generate SELinux policy allow/dontaudit rules from logs of denied operations

**audit2why** - translates SELinux audit messages into a description of why the access was denied (audit2allow -w)

## SYNOPSIS

**audit2allow** \[*options*\]

## OPTIONS

- **-a \| --all**

  Read input from audit and message log, conflicts with -i

- **-b \| --boot**

  Read input from audit messages since last boot, conflicts with -i

- **-d \| --dmesg**

  Read input from output of */bin/dmesg.* Note that all audit messages are not available via dmesg when auditd is running; use "ausearch -m avc \| audit2allow"  or "-a" instead.

- **-D \| --dontaudit**

  Generate dontaudit rules (Default: allow)

- **-e \| --explain**

  Fully explain generated output

- **-h \| --help**

  Print a short usage message

- **-i \<inputfile\> \| --input \<inputfile\>**

  Read input from *\<inputfile\>*

- **--interface-info=\<interface\_info\_file\>**

  Read interface information from *\<interface\_info\_file\>*

- **-l \| --lastreload**

  Read input only after last policy reload

- **-m \<modulename\> \| --module \<modulename\>**

  Generate module/require output \<modulename\>

- **-M \<modulename\>**

  Generate loadable module package, conflicts with -o

- **-C**

  Generate CIL output, conflicts with -M

- **-p \<policyfile\> \| --policy \<policyfile\>**

  Policy file to use for analysis

- **--perm-map \<perm\_map\_file\>**

  Read permission map from *\<perm\_map\_file\>*

- **-o \<outputfile\> \| --output \<outputfile\>**

  Append output to *\<outputfile\>*

- **-r \| --requires**

  Generate require output syntax for loadable modules.

- **-N \| --noreference**

  Do not generate reference policy, traditional style allow rules. This is the default behavior.

- **-R \| --reference**

  Generate reference policy using installed macros. This attempts to match denials against interfaces and may be inaccurate.

- **-t \<type\_regex\> \| --type=\<type\_regex\>**

  Only process messages with a type that matches this regex

- **-x \| --xperms**

  Generate extended permission access vector rules

- **-w \| --why**

  Translates SELinux audit messages into a description of why the access was denied

- **-v \| --verbose**

  Turn on verbose output

## DESCRIPTION

This utility scans the logs for messages logged when the system denied permission for operations, and generates a snippet of policy rules which, if loaded into policy, might have allowed those operations to succeed. However, this utility only generates Type Enforcement (TE) allow  rules.  Certain permission denials may require other kinds of policy changes, e.g. adding an attribute to a type declaration to satisfy an existing constraint, adding a role allow rule, or modifying a constraint.  The [**audit2why**(8)](/audit2why/8.md) utility may be used to diagnose the reason when it is unclear.

Care must be exercised while acting on the output of this utility to ensure that the operations being permitted do not pose a security threat. Often it is better to define new domains and/or types, or make other structural changes to narrowly allow an optimal set of operations to succeed, as opposed to blindly implementing the sometimes broad changes recommended by this utility.   Certain permission denials are  not fatal to the application, in which case it may be preferable to simply suppress logging of the denial via a 'dontaudit' rule rather than an 'allow' rule.

## EXAMPLE

```
NOTE: These examples are for systems using the audit package. If you do
not use the audit package, the AVC messages will be in /var/log/messages.
Please substitute /var/log/messages for /var/log/audit/audit.log in the
examples.
```

**Using audit2allow to generate module policy**

$ cat /var/log/audit/audit.log \| audit2allow -m local \> local.te $ cat local.te module local 1.0;

require {\
         class file {  getattr open read };

        type myapp\_t;\
         type etc\_t;\
  };

allow myapp\_t etc\_t:file { getattr open read }; \<review local.te and customize as desired\>

**Using audit2allow to generate module policy using reference policy**

$ cat /var/log/audit/audit.log \| audit2allow -R -m local \> local.te $ cat local.te policy\_module(local, 1.0)

gen\_require(\`\
         type myapp\_t;\
         type etc\_t; ')

files\_read\_etc\_files(myapp\_t) \<review local.te and customize as desired\>

**Building module policy using Makefile**

\# SELinux provides a policy devel environment under # /usr/share/selinux/devel including all of the shipped # interface files. # You can create a te file and compile it by executing

$ make -f /usr/share/selinux/devel/Makefile local.pp

\# This make command will compile a local.te file in the current # directory. If you did not specify a "pp" file, the make file # will compile all "te" files in the current directory.  After # you compile your te file into a "pp" file, you need to install # it using the semodule command.

$ semodule -i local.pp

**Building module policy manually**

\# Compile the module $ checkmodule -M -m -o local.mod local.te

\# Create the package  $ semodule\_package -o local.pp -m local.mod

\# Load the module into the kernel $ semodule -i local.pp

**Using audit2allow to generate and build module policy**

$ cat /var/log/audit/audit.log \| audit2allow -M local Generating type enforcement file: local.te

Compiling policy: checkmodule -M -m -o local.mod local.te Building package: semodule\_package -o local.pp -m local.mod

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* IMPORTANT \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

In order to load this newly created policy package into the kernel, you are required to execute

semodule -i local.pp

**Using audit2allow to generate monolithic (non-module) policy**

$ cd /etc/selinux/$SELINUXTYPE/src/policy $ cat /var/log/audit/audit.log \| audit2allow \>\> domains/misc/local.te $ cat domains/misc/local.te allow cupsd\_config\_t unconfined\_t:fifo\_file { getattr ioctl }; \<review domains/misc/local.te and customize as desired\> $ make load

## AUTHOR

This manual page was written by  *Manoj Srivastava \<srivasta@debian.org\>,* for the Debian GNU/Linux system. It was updated by Dan Walsh \<dwalsh@redhat.com\>

The  **audit2allow** utility has contributions from several people, including  *Justin R. Smith* and  *Yuichi Nakamura.* and  *Dan Walsh*
