Debian Codegraph @

python/audit2allow/audit2allow.1

raw
1 .\" Hey, Emacs! This is an -*- nroff -*- source file.
2 .\" Copyright (c) 2005 Manoj Srivastava <[email protected]>
3 .\" Copyright (c) 2010 Dan Walsh <[email protected]>
4 .\"
5 .\" This is free documentation; you can redistribute it and/or
6 .\" modify it under the terms of the GNU General Public License as
7 .\" published by the Free Software Foundation; either version 2 of
8 .\" the License, or (at your option) any later version.
9 .\"
10 .\" The GNU General Public License's references to "object code"
11 .\" and "executables" are to be interpreted as the output of any
12 .\" document formatting or typesetting system, including
13 .\" intermediate and printed output.
14 .\"
15 .\" This manual is distributed in the hope that it will be useful,
16 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
17 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 .\" GNU General Public License for more details.
19 .\"
20 .\" You should have received a copy of the GNU General Public
21 .\" License along with this manual; if not, write to the Free
22 .\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
23 .\" USA.
24 .\"
25 .\"
26 .TH AUDIT2ALLOW "1" "October 2010" "Security Enhanced Linux" NSA
27 .SH NAME
28 .BR audit2allow
29 \- generate SELinux policy allow/dontaudit rules from logs of denied operations
30
31 .BR audit2why
32 \- translates SELinux audit messages into a description of why the access was denied (audit2allow \-w)
33
34 .SH SYNOPSIS
35 .B audit2allow
36 .RI [ options "] "
37 .SH OPTIONS
38 .TP
39 .B "\-a" | "\-\-all"
40 Read input from audit and message log, conflicts with \-i
41 .TP
42 .B "\-b" | "\-\-boot"
43 Read input from audit messages since last boot conflicts with \-i
44 .TP
45 .B "\-d" | "\-\-dmesg"
46 Read input from output of
47 .I /bin/dmesg.
48 Note that all audit messages are not available via dmesg when
49 auditd is running; use "ausearch \-m avc | audit2allow" or "\-a" instead.
50 .TP
51 .B "\-D" | "\-\-dontaudit"
52 Generate dontaudit rules (Default: allow)
53 .TP
54 .B "\-h" | "\-\-help"
55 Print a short usage message
56 .TP
57 .B "\-i <inputfile>" | "\-\-input <inputfile>"
58 read input from
59 .I <inputfile>
60 .TP
61 .B "\-l" | "\-\-lastreload"
62 read input only after last policy reload
63 .TP
64 .B "\-m <modulename>" | "\-\-module <modulename>"
65 Generate module/require output <modulename>
66 .TP
67 .B "\-M <modulename>"
68 Generate loadable module package, conflicts with \-o
69 .TP
70 .B "\-p <policyfile>" | "\-\-policy <policyfile>"
71 Policy file to use for analysis
72 .TP
73 .B "\-o <outputfile>" | "\-\-output <outputfile>"
74 append output to
75 .I <outputfile>
76 .TP
77 .B "\-r" | "\-\-requires"
78 Generate require output syntax for loadable modules.
79 .TP
80 .B "\-N" | "\-\-noreference"
81 Do not generate reference policy, traditional style allow rules.
82 This is the default behavior.
83 .TP
84 .B "\-R" | "\-\-reference"
85 Generate reference policy using installed macros.
86 This attempts to match denials against interfaces and may be inaccurate.
87 .TP
88 .B "\-x" | "\-\-xperms"
89 Generate extended permission access vector rules
90 .TP
91 .B "\-w" | "\-\-why"
92 Translates SELinux audit messages into a description of why the access was denied
93
94 .TP
95 .B "\-v" | "\-\-verbose"
96 Turn on verbose output
97
98 .SH DESCRIPTION
99 .PP
100 This utility scans the logs for messages logged when the system denied
101 permission for operations, and generates a snippet of policy rules
102 which, if loaded into policy, might have allowed those operations to
103 succeed. However, this utility only generates Type Enforcement (TE) allow
104 rules. Certain permission denials may require other kinds of policy changes,
105 e.g. adding an attribute to a type declaration to satisfy an existing
106 constraint, adding a role allow rule, or modifying a constraint. The
107 .BR audit2why (8)
108 utility may be used to diagnose the reason when it is unclear.
109 .PP
110 Care must be exercised while acting on the output of this utility to
111 ensure that the operations being permitted do not pose a security
112 threat. Often it is better to define new domains and/or types, or make other
113 structural changes to narrowly allow an optimal set of operations to
114 succeed, as opposed to blindly implementing the sometimes broad
115 changes recommended by this utility. Certain permission denials are
116 not fatal to the application, in which case it may be preferable to
117 simply suppress logging of the denial via a 'dontaudit' rule rather than
118 an 'allow' rule.
119 .PP
120 .SH EXAMPLE
121 .nf
122 .B NOTE: These examples are for systems using the audit package. If you do
123 .B not use the audit package, the AVC messages will be in /var/log/messages.
124 .B Please substitute /var/log/messages for /var/log/audit/audit.log in the
125 .B examples.
126 .PP
127 .B Using audit2allow to generate module policy
128
129 $ cat /var/log/audit/audit.log | audit2allow \-m local > local.te
130 $ cat local.te
131 module local 1.0;
132
133 require {
134 class file { getattr open read };
135
136
137 type myapp_t;
138 type etc_t;
139 };
140
141
142 allow myapp_t etc_t:file { getattr open read };
143 <review local.te and customize as desired>
144
145 .B Using audit2allow to generate module policy using reference policy
146
147 $ cat /var/log/audit/audit.log | audit2allow \-R \-m local > local.te
148 $ cat local.te
149 policy_module(local, 1.0)
150
151 gen_require(`
152 type myapp_t;
153 type etc_t;
154 };
155
156 files_read_etc_files(myapp_t)
157 <review local.te and customize as desired>
158
159 .B Building module policy using Makefile
160
161 # SELinux provides a policy devel environment under
162 # /usr/share/selinux/devel including all of the shipped
163 # interface files.
164 # You can create a te file and compile it by executing
165
166 $ make \-f /usr/share/selinux/devel/Makefile local.pp
167
168
169 # This make command will compile a local.te file in the current
170 # directory. If you did not specify a "pp" file, the make file
171 # will compile all "te" files in the current directory. After
172 # you compile your te file into a "pp" file, you need to install
173 # it using the semodule command.
174
175 $ semodule \-i local.pp
176
177 .B Building module policy manually
178
179 # Compile the module
180 $ checkmodule \-M \-m \-o local.mod local.te
181
182 # Create the package
183 $ semodule_package \-o local.pp \-m local.mod
184
185 # Load the module into the kernel
186 $ semodule \-i local.pp
187
188 .B Using audit2allow to generate and build module policy
189
190 $ cat /var/log/audit/audit.log | audit2allow \-M local
191 Generating type enforcement file: local.te
192
193 Compiling policy: checkmodule \-M \-m \-o local.mod local.te
194 Building package: semodule_package \-o local.pp \-m local.mod
195
196 ******************** IMPORTANT ***********************
197
198 In order to load this newly created policy package into the kernel,
199 you are required to execute
200
201 semodule \-i local.pp
202
203 .B Using audit2allow to generate monolithic (non\-module) policy
204
205 $ cd /etc/selinux/$SELINUXTYPE/src/policy
206 $ cat /var/log/audit/audit.log | audit2allow >> domains/misc/local.te
207 $ cat domains/misc/local.te
208 allow cupsd_config_t unconfined_t:fifo_file { getattr ioctl };
209 <review domains/misc/local.te and customize as desired>
210 $ make load
211
212 .fi
213 .PP
214 .SH AUTHOR
215 This manual page was written by
216 .I Manoj Srivastava <[email protected]>,
217 for the Debian GNU/Linux system. It was updated by Dan Walsh <[email protected]>
218 .PP
219 The
220 .B audit2allow
221 utility has contributions from several people, including
222 .I Justin R. Smith
223 and
224 .I Yuichi Nakamura.
225 and
226 .I Dan Walsh