2008-08-19 19:30:36 +00:00
|
|
|
.\" Hey, Emacs! This is an -*- nroff -*- source file.
|
|
|
|
.\" Copyright (c) 2005 Manoj Srivastava <srivasta@debian.org>
|
2010-12-22 20:08:33 +00:00
|
|
|
.\" Copyright (c) 2010 Dan Walsh <dwalsh@redhat.com>
|
2008-08-19 19:30:36 +00:00
|
|
|
.\"
|
|
|
|
.\" This is free documentation; you can redistribute it and/or
|
|
|
|
.\" modify it under the terms of the GNU General Public License as
|
|
|
|
.\" published by the Free Software Foundation; either version 2 of
|
|
|
|
.\" the License, or (at your option) any later version.
|
|
|
|
.\"
|
|
|
|
.\" The GNU General Public License's references to "object code"
|
|
|
|
.\" and "executables" are to be interpreted as the output of any
|
|
|
|
.\" document formatting or typesetting system, including
|
|
|
|
.\" intermediate and printed output.
|
|
|
|
.\"
|
|
|
|
.\" This manual is distributed in the hope that it will be useful,
|
|
|
|
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
.\" GNU General Public License for more details.
|
|
|
|
.\"
|
|
|
|
.\" You should have received a copy of the GNU General Public
|
|
|
|
.\" License along with this manual; if not, write to the Free
|
|
|
|
.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
|
|
|
|
.\" USA.
|
|
|
|
.\"
|
|
|
|
.\"
|
2010-12-22 20:08:33 +00:00
|
|
|
.TH AUDIT2ALLOW "1" "October 2010" "Security Enhanced Linux" NSA
|
2008-08-19 19:30:36 +00:00
|
|
|
.SH NAME
|
|
|
|
.BR audit2allow
|
2010-03-08 19:33:03 +00:00
|
|
|
\- generate SELinux policy allow/dontaudit rules from logs of denied operations
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
.BR audit2why
|
2013-05-10 12:45:21 +00:00
|
|
|
\- translates SELinux audit messages into a description of why the access was denied (audit2allow \-w)
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B audit2allow
|
|
|
|
.RI [ options "] "
|
|
|
|
.SH OPTIONS
|
|
|
|
.TP
|
|
|
|
.B "\-a" | "\-\-all"
|
2013-05-10 12:45:21 +00:00
|
|
|
Read input from audit and message log, conflicts with \-i
|
2008-08-19 19:30:36 +00:00
|
|
|
.TP
|
2010-03-12 17:58:02 +00:00
|
|
|
.B "\-b" | "\-\-boot"
|
2013-05-10 12:45:21 +00:00
|
|
|
Read input from audit messages since last boot conflicts with \-i
|
2010-03-12 17:58:02 +00:00
|
|
|
.TP
|
2008-08-19 19:30:36 +00:00
|
|
|
.B "\-d" | "\-\-dmesg"
|
|
|
|
Read input from output of
|
|
|
|
.I /bin/dmesg.
|
|
|
|
Note that all audit messages are not available via dmesg when
|
2013-05-10 12:45:21 +00:00
|
|
|
auditd is running; use "ausearch \-m avc | audit2allow" or "\-a" instead.
|
2008-08-19 19:30:36 +00:00
|
|
|
.TP
|
2010-03-08 19:33:03 +00:00
|
|
|
.B "\-D" | "\-\-dontaudit"
|
|
|
|
Generate dontaudit rules (Default: allow)
|
|
|
|
.TP
|
2008-08-19 19:30:36 +00:00
|
|
|
.B "\-h" | "\-\-help"
|
|
|
|
Print a short usage message
|
|
|
|
.TP
|
|
|
|
.B "\-i <inputfile>" | "\-\-input <inputfile>"
|
|
|
|
read input from
|
|
|
|
.I <inputfile>
|
|
|
|
.TP
|
|
|
|
.B "\-l" | "\-\-lastreload"
|
|
|
|
read input only after last policy reload
|
|
|
|
.TP
|
|
|
|
.B "\-m <modulename>" | "\-\-module <modulename>"
|
|
|
|
Generate module/require output <modulename>
|
|
|
|
.TP
|
|
|
|
.B "\-M <modulename>"
|
2013-05-10 12:45:21 +00:00
|
|
|
Generate loadable module package, conflicts with \-o
|
2008-08-19 19:30:36 +00:00
|
|
|
.TP
|
2011-09-08 21:25:22 +00:00
|
|
|
.B "\-p <policyfile>" | "\-\-policy <policyfile>"
|
|
|
|
Policy file to use for analysis
|
|
|
|
.TP
|
2008-08-19 19:30:36 +00:00
|
|
|
.B "\-o <outputfile>" | "\-\-output <outputfile>"
|
|
|
|
append output to
|
|
|
|
.I <outputfile>
|
|
|
|
.TP
|
|
|
|
.B "\-r" | "\-\-requires"
|
|
|
|
Generate require output syntax for loadable modules.
|
|
|
|
.TP
|
|
|
|
.B "\-N" | "\-\-noreference"
|
|
|
|
Do not generate reference policy, traditional style allow rules.
|
|
|
|
This is the default behavior.
|
|
|
|
.TP
|
|
|
|
.B "\-R" | "\-\-reference"
|
|
|
|
Generate reference policy using installed macros.
|
|
|
|
This attempts to match denials against interfaces and may be inaccurate.
|
|
|
|
.TP
|
|
|
|
.B "\-w" | "\-\-why"
|
2008-11-07 21:50:34 +00:00
|
|
|
Translates SELinux audit messages into a description of why the access was denied
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
.TP
|
|
|
|
.B "\-v" | "\-\-verbose"
|
|
|
|
Turn on verbose output
|
|
|
|
|
|
|
|
.SH DESCRIPTION
|
|
|
|
.PP
|
|
|
|
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
|
|
|
|
.BR audit2why (8)
|
|
|
|
utility may be used to diagnose the reason when it is unclear.
|
|
|
|
.PP
|
|
|
|
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.
|
|
|
|
.PP
|
|
|
|
.SH EXAMPLE
|
|
|
|
.nf
|
|
|
|
.B NOTE: These examples are for systems using the audit package. If you do
|
|
|
|
.B not use the audit package, the AVC messages will be in /var/log/messages.
|
|
|
|
.B Please substitute /var/log/messages for /var/log/audit/audit.log in the
|
|
|
|
.B examples.
|
|
|
|
.PP
|
|
|
|
.B Using audit2allow to generate module policy
|
|
|
|
|
2013-05-10 12:45:21 +00:00
|
|
|
$ cat /var/log/audit/audit.log | audit2allow \-m local > local.te
|
2008-08-19 19:30:36 +00:00
|
|
|
$ cat local.te
|
|
|
|
module local 1.0;
|
|
|
|
|
|
|
|
require {
|
2010-12-22 20:08:33 +00:00
|
|
|
class file { getattr open read };
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
|
2010-12-22 20:08:33 +00:00
|
|
|
type myapp_t;
|
|
|
|
type etc_t;
|
|
|
|
};
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
|
2010-12-22 20:08:33 +00:00
|
|
|
allow myapp_t etc_t:file { getattr open read };
|
|
|
|
<review local.te and customize as desired>
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2010-12-22 20:08:33 +00:00
|
|
|
.B Using audit2allow to generate module policy using reference policy
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2013-05-10 12:45:21 +00:00
|
|
|
$ cat /var/log/audit/audit.log | audit2allow \-R \-m local > local.te
|
2010-12-22 20:08:33 +00:00
|
|
|
$ cat local.te
|
|
|
|
policy_module(local, 1.0)
|
|
|
|
|
|
|
|
gen_require(`
|
|
|
|
type myapp_t;
|
|
|
|
type etc_t;
|
|
|
|
};
|
|
|
|
|
|
|
|
files_read_etc_files(myapp_t)
|
2008-08-19 19:30:36 +00:00
|
|
|
<review local.te and customize as desired>
|
|
|
|
|
2010-12-22 20:08:33 +00:00
|
|
|
.B Building module policy using Makefile
|
|
|
|
|
|
|
|
# SELinux provides a policy devel environment under /usr/share/selinux/devel
|
|
|
|
# You can create a te file and compile it by executing
|
2013-05-10 12:45:21 +00:00
|
|
|
$ make \-f /usr/share/selinux/devel/Makefile
|
|
|
|
$ semodule \-i local.pp
|
2010-12-22 20:08:33 +00:00
|
|
|
|
2008-08-19 19:30:36 +00:00
|
|
|
.B Building module policy manually
|
|
|
|
|
|
|
|
# Compile the module
|
2013-05-10 12:45:21 +00:00
|
|
|
$ checkmodule \-M \-m \-o local.mod local.te
|
2008-08-19 19:30:36 +00:00
|
|
|
# Create the package
|
2013-05-10 12:45:21 +00:00
|
|
|
$ semodule_package \-o local.pp \-m local.mod
|
2008-08-19 19:30:36 +00:00
|
|
|
# Load the module into the kernel
|
2013-05-10 12:45:21 +00:00
|
|
|
$ semodule \-i local.pp
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
.B Using audit2allow to generate and build module policy
|
2013-05-10 12:45:21 +00:00
|
|
|
$ cat /var/log/audit/audit.log | audit2allow \-M local
|
2008-08-19 19:30:36 +00:00
|
|
|
Generating type enforcment file: local.te
|
2013-05-10 12:45:21 +00:00
|
|
|
Compiling policy: checkmodule \-M \-m \-o local.mod local.te
|
|
|
|
Building package: semodule_package \-o local.pp \-m local.mod
|
2008-08-19 19:30:36 +00:00
|
|
|
|
|
|
|
******************** IMPORTANT ***********************
|
|
|
|
|
|
|
|
In order to load this newly created policy package into the kernel,
|
|
|
|
you are required to execute
|
|
|
|
|
2013-05-10 12:45:21 +00:00
|
|
|
semodule \-i local.pp
|
2008-08-19 19:30:36 +00:00
|
|
|
|
2010-12-22 20:08:33 +00:00
|
|
|
.B 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
|
|
|
|
|
2008-08-19 19:30:36 +00:00
|
|
|
.fi
|
|
|
|
.PP
|
|
|
|
.SH AUTHOR
|
|
|
|
This manual page was written by
|
|
|
|
.I Manoj Srivastava <srivasta@debian.org>,
|
|
|
|
for the Debian GNU/Linux system. It was updated by Dan Walsh <dwalsh@redhat.com>
|
|
|
|
.PP
|
|
|
|
The
|
|
|
|
.B audit2allow
|
|
|
|
utility has contributions from several people, including
|
|
|
|
.I Justin R. Smith
|
|
|
|
and
|
|
|
|
.I Yuichi Nakamura.
|
|
|
|
and
|
|
|
|
.I Dan Walsh
|