AUDIT2ALLOW(1)
π AUDIT2ALLOW π
okay bestie, welcome to audit2allow β it lives in section 1 of the General Commands Manual and it's genuinely iconic.
β¨ NAME β¨
audit2allow β generate SELinux policy allow/dontaudit rules from logs of denied operations π«Ά
also in the house: audit2why β translates SELinux audit messages into a description of why the access was denied. plot twist: it's literally just audit2allow -w. no cap.
πΈ SYNOPSIS πΈ
audit2allow [options]
π OPTIONS π
one bullet per flag, no skips, we eat every single one π
-a|--allβ read input from the audit and message log. heads up, this conflicts with-iπ-b|--bootβ read input from audit messages since the last boot. also beefs with-i.-d|--dmesgβ read input from the output of/bin/dmesg. lowkey important: whenauditdis running, not all audit messages show up viadmesg, so use"ausearch -m avc | audit2allow"or-ainstead π-D|--dontauditβ generatedontauditrules. default isallow, so this flips the vibe.-e|--explainβ fully explain the generated output. give us the whole story bestie.-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 from after the last policy reload-m<modulename> |--module<modulename> β generate module/require output<modulename>-M<modulename> β generate a 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 the permission map from<perm_map_file>-o<outputfile> |--output<outputfile> β append output to<outputfile>-r|--requiresβ generaterequireoutput syntax for loadable modules-N|--noreferenceβ do not generate reference policy, traditional styleallowrules instead. this is the default behavior, so it's giving "if it ain't broke" π-R|--referenceβ generate reference policy using installed macros. it tries to match denials against interfaces and may be inaccurate β so double check, queen π-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 π¦
so here's the tea. this utility scans the logs for messages that got logged when the system denied permission for operations, and it generates a snippet of policy rules which, if loaded into policy, might have allowed those operations to succeed. however β and this is the part we do NOT skip β this utility only generates Type Enforcement (TE) allow rules. certain permission denials may need other kinds of policy changes, like adding an attribute to a type declaration to satisfy an existing constraint, adding a role allow rule, or modifying a constraint. and if the reason is unclear, the audit2why(8) utility may be used to diagnose it. iykyk π
bestie, be careful. π care must be exercised while acting on the output of this utility, to make sure 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. periodt. π
π 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/messagesfor/var/log/audit/audit.login 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.
and that's the whole page, bestie β¨ this one's from Security Enhanced Linux, dated October 2010, and it's AUDIT2ALLOW(1) in the manual. go forth and audit responsibly π
π¦
π¦ where this page comes from
- centos-stream 10: policycoreutils-python-utils 3.10-2.el10 Β· GPL-2.0-or-later
- centos-stream 10: policycoreutils-python-utils 3.11-1.el10 Β· GPL-2.0-or-later
- debian trixie: policycoreutils-python-utils 3.8.1-2 Β· GPL-2.0-or-later
- fedora 43: policycoreutils-python-utils 3.9-5.fc43 Β· GPL-2.0-or-later
- fedora 43: policycoreutils-python-utils 3.9-7.fc43 Β· GPL-2.0-or-later
- fedora 44: policycoreutils-python-utils 3.10-1.fc44 Β· GPL-2.0-or-later
- fedora 44: policycoreutils-python-utils 3.11-2.fc44 Β· GPL-2.0-or-later
- nixos 26.05: selinux-python 3.10
- nixpkgs unstable: selinux-python 3.10
- opensuse-leap 16.0: policycoreutils-python-utils 3.8.1-160000.5.1 Β· GPL-2.0-or-later
- ubuntu questing: policycoreutils-python-utils 3.8.1-2
- ubuntu resolute: policycoreutils-python-utils 3.9-2 Β· GPL-2.0-or-later
- ubuntu stonking: policycoreutils-python-utils 3.11-2 Β· GPL-2.0-or-later
- Copyright (c) 2005 Manoj Srivastava <srivasta@debian.org>
- Copyright (c) 2010 Dan Walsh <dwalsh@redhat.com>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms