1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
|
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>apparmor_parser - loads AppArmor profiles into the kernel</title>
<link rel="stylesheet" href="apparmor.css" type="text/css" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>
<body>
<table border="0" width="100%" cellspacing="0" cellpadding="3">
<tr><td class="_podblock_" valign="middle">
<big><strong><span class="_podblock_"> apparmor_parser - loads AppArmor profiles into the kernel</span></strong></big>
</td></tr>
</table>
<ul id="index">
<li><a href="#NAME">NAME</a></li>
<li><a href="#SYNOPSIS">SYNOPSIS</a></li>
<li><a href="#DESCRIPTION">DESCRIPTION</a></li>
<li><a href="#COMMANDS">COMMANDS</a></li>
<li><a href="#Unprivileged-commands">Unprivileged commands</a></li>
<li><a href="#Unprivileged-profile-commands">Unprivileged profile commands</a></li>
<li><a href="#Privileged-commands">Privileged commands</a></li>
<li><a href="#Privileged-profile-commands">Privileged profile commands</a></li>
<li><a href="#OPTIONS">OPTIONS</a></li>
<li><a href="#CONFIG-FILE">CONFIG FILE</a></li>
<li><a href="#BUGS">BUGS</a></li>
<li><a href="#SEE-ALSO">SEE ALSO</a></li>
</ul>
<h1 id="NAME">NAME</h1>
<p>apparmor_parser - loads AppArmor profiles into the kernel</p>
<h1 id="SYNOPSIS">SYNOPSIS</h1>
<p><b>apparmor_parser [options] <command> [profiles]...</b></p>
<p><b>apparmor_parser [options] <command></b></p>
<p><b>apparmor_parser [-hv] [--help] [--version]</b></p>
<h1 id="DESCRIPTION">DESCRIPTION</h1>
<p><b>apparmor_parser</b> is used as a general tool to compile, and manage AppArmor policy, including loading new apparmor.d(5) profiles into the Linux kernel.</p>
<p>AppArmor profiles restrict the operations available to processes.</p>
<p>The <b>profiles</b> are loaded into the Linux kernel by the <b>apparmor_parser</b> program. The <b>profiles</b> may be specified by file name or a directory name containing a set of profiles. If a directory is specified then the <b>apparmor_parser</b> will try to do a profile load for each file in the directory that is not a dot file, or explicitly black listed (*.dpkg-new, *.dpkg-old, *.dpkg-dist, *.dpkg-bak, *.dpkg-remove, *.pacsave, *.pacnew, *.rpmnew, *.rpmsave, *.orig, *.rej, *~). The <b>apparmor_parser</b> will fall back to taking input from standard input if a profile or directory is not supplied.</p>
<p>The input supplied to <b>apparmor_parser</b> should be in the format described in apparmor.d(5).</p>
<h1 id="COMMANDS">COMMANDS</h1>
<p>The command set is broken into four subcategories.</p>
<dl>
<dt id="unprivileged-commands">unprivileged commands</dt>
<dd>
<p>Commands that don't require any privilege and don't operate on profiles.</p>
</dd>
<dt id="unprivileged-profile-commands">unprivileged profile commands</dt>
<dd>
<p>Commands that operate on a profile either specified on the command line or read from stdin if no profile was specified.</p>
</dd>
<dt id="privileged-commands">privileged commands</dt>
<dd>
<p>Commands that require the MAC_ADMIN capability within the affected AppArmor namespace to load policy into the kernel or filesystem write permissions to update the affected privileged files (cache etc).</p>
</dd>
<dt id="privileged-profile-commands">privileged profile commands</dt>
<dd>
<p>Commands that require privilege and operate on profiles.</p>
</dd>
</dl>
<h1 id="Unprivileged-commands">Unprivileged commands</h1>
<dl>
<dt id="V---version">-V, --version</dt>
<dd>
<p>Print the version number and exit.</p>
</dd>
<dt id="h---help">-h, --help</dt>
<dd>
<p>Give a quick reference guide.</p>
</dd>
</dl>
<h1 id="Unprivileged-profile-commands">Unprivileged profile commands</h1>
<dl>
<dt id="N---names">-N, --names</dt>
<dd>
<p>Produce a list of policies from a given set of profiles (implies -K).</p>
</dd>
<dt id="p---preprocess">-p, --preprocess</dt>
<dd>
<p>Apply preprocessing to the input profile(s) by flattening includes into the output profile and dump to stdout.</p>
</dd>
<dt id="S---stdout">-S, --stdout</dt>
<dd>
<p>Writes a binary (cached) profile to stdout (implies -K and -T).</p>
</dd>
<dt id="o-file---ofile-file">-o file, --ofile file</dt>
<dd>
<p>Writes a binary (cached) profile to the specified file (implies -K and -T)</p>
</dd>
</dl>
<h1 id="Privileged-commands">Privileged commands</h1>
<dl>
<dt id="purge-cache">--purge-cache</dt>
<dd>
<p>Unconditionally clear out cached profiles.</p>
</dd>
</dl>
<h1 id="Privileged-profile-commands">Privileged profile commands</h1>
<dl>
<dt id="a---add">-a, --add</dt>
<dd>
<p>Insert the AppArmor definitions given into the kernel. This is the default action. This gives an error message if a AppArmor definition by the same name already exists in the kernel, or if the parser doesn't understand its input. It reports when an addition succeeded.</p>
</dd>
<dt id="r---replace">-r, --replace</dt>
<dd>
<p>This flag is required if an AppArmor definition by the same name already exists in the kernel; used to replace the definition already in the kernel with the definition given on standard input.</p>
</dd>
<dt id="R---remove">-R, --remove</dt>
<dd>
<p>This flag is used to remove an AppArmor definition already in the kernel. Note that it still requires a complete AppArmor definition as described in apparmor.d(5) even though the contents of the definition aren't used.</p>
</dd>
</dl>
<h1 id="OPTIONS">OPTIONS</h1>
<dl>
<dt id="B---binary">-B, --binary</dt>
<dd>
<p>Treat the profile files specified on the command line (or stdin if none specified) as binary cache files, produced with the -S or -o options, and load to the kernel as specified by -a, -r, and -R (implies -K and -T).</p>
</dd>
<dt id="C---Complain">-C, --Complain</dt>
<dd>
<p>Force the profile to load in complain mode.</p>
</dd>
<dt id="b-n---base-n">-b n, --base n</dt>
<dd>
<p>Set the base directory for resolving #include directives defined as relative paths.</p>
</dd>
<dt id="I-n---Include-n">-I n, --Include n</dt>
<dd>
<p>Add element n to the search path when resolving #include directives defined as an absolute paths.</p>
</dd>
<dt id="f-n---apparmorfs-n">-f n, --apparmorfs n</dt>
<dd>
<p>Set the location of the apparmor security filesystem (default is "/sys/kernel/security/apparmor").</p>
</dd>
<dt id="policy-features-n">--policy-features n</dt>
<dd>
<p>Specify the feature set that the policy was developed under. This does not override feature ABI rules.</p>
</dd>
<dt id="override-policy-abi-n">--override-policy-abi n</dt>
<dd>
<p>Specify the feature set that the policy was developed under and override any feature ABI rules that the policy may be using.</p>
</dd>
<dt id="kernel-features-n">--kernel-features n</dt>
<dd>
<p>Specify the feature set of the kernel that the policy is being compiled for. If not specified this will be determined by the system's kernel.</p>
</dd>
<dt id="M-n---features-file-n">-M n, --features-file n</dt>
<dd>
<p>Use the features file located at path "n" (default is /etc/apparmor.d/cache/.features). If the --cache-loc option is present, the ".features" file in the specified cache directory is used.</p>
<p>Note: this sets both the --kernel-features and --policy-features to be the same.</p>
</dd>
<dt id="m-n---match-string-n">-m n, --match-string n</dt>
<dd>
<p>Only use match features "n".</p>
<p>Note: this sets both the --kernel-features and --policy-features to be the same.</p>
</dd>
<dt id="n-n---namespace-string-n">-n n, --namespace-string n</dt>
<dd>
<p>Force a profile to load in the namespace "n".</p>
</dd>
<dt id="X---readimpliesX">-X, --readimpliesX</dt>
<dd>
<p>In the case of profiles that are loading on systems were READ_IMPLIES_EXEC is set in the kernel for a given process, load the profile so that any "r" flags are processed as "mr".</p>
</dd>
<dt id="k---show-cache">-k, --show-cache</dt>
<dd>
<p>Report the cache processing (hit/miss details) when loading or saving cached profiles.</p>
</dd>
<dt id="K---skip-cache">-K, --skip-cache</dt>
<dd>
<p>Perform no caching at all: disables -W, implies -T.</p>
</dd>
<dt id="T---skip-read-cache">-T, --skip-read-cache</dt>
<dd>
<p>By default, if a profile's cache is found in the location specified by --cache-loc and the timestamp is newer than the profile, it will be loaded from the cache. This option disables this cache loading behavior.</p>
</dd>
<dt id="W---write-cache">-W, --write-cache</dt>
<dd>
<p>Write out cached profiles to the location specified in --cache-loc. Off by default. In cases where abstractions have been changed, and the parser is running with "--replace", it may make sense to also use "--skip-read-cache" with the "--write-cache" option.</p>
</dd>
<dt id="skip-bad-cache">--skip-bad-cache</dt>
<dd>
<p>Skip updating the cache if it contains cached profiles in a bad or inconsistent state</p>
</dd>
<dt id="L---cache-loc">-L, --cache-loc</dt>
<dd>
<p>Set the location(s) of the cache directory. This option can accept a comma separated list of directories, which will be searched in order to find a matching cache. The first matching cache file found is used even if a directory later in the search order may contain a newer cache file.</p>
<p>If multiple directories are specified and --write-cache has been specified then cache writes will be made to the first directory in the list, all other directories will be treated as read only.</p>
<p>If a cache directory name needs to have a comma as part of the name, it can be specified by using a backslash to escape the comma character in the directory name.</p>
<p>If not specified the cache location defaults to /var/cache/apparmor</p>
</dd>
<dt id="print-cache-dir">--print-cache-dir</dt>
<dd>
<p>Print the cache directory location. This path will be a subdirectory of the directory specified by --cache-loc. The subdirectory used will be influenced by the features available in the currently running kernel or by the features specified with the --match-string or --features-file options.</p>
</dd>
<dt id="Q---skip-kernel-load">-Q, --skip-kernel-load</dt>
<dd>
<p>Perform all actions except the actual loading of a profile into the kernel. This is useful for testing profile generation, caching, etc, without making changes to the running kernel profiles.</p>
<p>This also removes the need for privilege to execute the commands that manage policy in the kernel</p>
</dd>
<dt id="q---quiet">-q, --quiet</dt>
<dd>
<p>Do not report on the profiles as they are loaded, and not show warnings.</p>
</dd>
<dt id="v---verbose">-v, --verbose</dt>
<dd>
<p>Report on the profiles as they are loaded, and show warnings.</p>
</dd>
<dt id="warn-n">--warn=n</dt>
<dd>
<p>Enable various warnings during policy compilation. A single warn flag can be specified per --warn option, but the --warn flag can be passed multiple times.</p>
<pre><code>apparmor_parser --warn=rule-not-enforced ...</code></pre>
<p>A specific warning can be disabled by prepending <i>no</i>- to the flag</p>
<pre><code>apparmor_parser --warn=no-rule-not-enforced ...</code></pre>
<p>Use --help=warn to see a full list of which warn flags are supported.</p>
</dd>
<dt id="Werror-n">--Werror[=n]</dt>
<dd>
<p>Convert warnings into errors during policy compilation. If the optional flag is not specified all warnings become errors. If the optional flag is specified only the class of warnings specified will become errors. A single flag can be specified per --Werror option, but the --Werror flag can be passed multiple times.</p>
<pre><code>apparmor_parser --Werror=deprecated ...</code></pre>
<p>Use --help=warn or --help=Werror to see a full list of which warn flags are supported.</p>
</dd>
<dt id="d---debug">-d, --debug</dt>
<dd>
<p>Given once, only checks the profiles to ensure syntactic correctness. Given twice, dumps its interpretation of the profile for checking.</p>
</dd>
<dt id="D-n---dump-n">-D n, --dump=n</dt>
<dd>
<p>Debug flag for dumping various structures and passes of policy compilation. A single dump flag can be specified per --dump option, but the dump flag can be passed multiple times. Note progress flags tend to also imply the matching stats flag.</p>
<pre><code>apparmor_parser --dump=dfa-stats --dump=trans-stats <file></code></pre>
<p>Use --help=dump to see a full list of which dump flags are supported</p>
</dd>
<dt id="j-n---jobs-n">-j n, --jobs=n</dt>
<dd>
<p>Set the number of jobs used to compile the specified policy. Where n can be</p>
<pre><code>0 - disable jobs and use the main process for all compilation
# - a specific number of jobs
auto - the # of cpus in the in the system
x# - # * number of cpus</code></pre>
<p>Eg. -j8 OR --jobs=8 allows for 8 parallel jobs -jauto OR --jobs=auto sets the jobs to the # of cpus -jx4 OR --jobs=x4 sets the jobs to # of cpus * 4 -jx1 is equivalent to -jauto</p>
<p>The default value is the number of cpus in the system. Note that if jobs is a positive integer number the --jobs-max parameter is automatically set to the same value.</p>
</dd>
<dt id="max-jobs-n">--max-jobs n</dt>
<dd>
<p>When --jobs is set to a scaling value (ie. auto or xN) the specify a hard cap on the value that can be specified by the --jobs flag. It takes the same set of options available to the --jobs option, and defaults to 8*cpus</p>
</dd>
<dt id="O-n---optimize-n">-O n, --optimize=n</dt>
<dd>
<p>Set the optimization flags used by policy compilation. A single optimization flag can be toggled per -O option, but the optimize flag can be passed multiple times. Turning off some phases of the optimization can make it so that policy can't complete compilation due to size constraints (it is entirely possible to create a dfa with millions of states that will take days or longer to compile).</p>
<p>Note: The parser is set to use a balanced default set of flags, that will result in reasonable compression but not take excessive amounts of time to complete.</p>
<p>Use --help=optimize to see a full list of which optimization flags are supported.</p>
</dd>
<dt id="abort-on-error-Abort-processing-of-profiles-on-the-first-error-encountered-otherwise-the-parser-will-continue-to-try-to-compile-other-profiles-if-specified">--abort-on-error Abort processing of profiles on the first error encountered, otherwise the parser will continue to try to compile other profiles if specified.</dt>
<dd>
<p>Note: If an error is encountered while processing profiles the last error encountered will be used to set the exit code.</p>
</dd>
<dt id="skip-bad-cache-rebuild-The-default-behavior-of-the-parser-is-to-check-if-a-cached-version-of-a-profile-exists-and-if-it-does-it-attempt-to-load-it-into-the-kernel.-If-that-load-is-rejected-then-the-parser-will-attempt-to-rebuild-the-cache-file-and-load-again">--skip-bad-cache-rebuild The default behavior of the parser is to check if a cached version of a profile exists and if it does it attempt to load it into the kernel. If that load is rejected, then the parser will attempt to rebuild the cache file, and load again.</dt>
<dd>
<p>This option tells the parser to not attempt to rebuild the cache on failure, instead the parser continues on with processing the remaining profiles.</p>
</dd>
<dt id="estimated-compile-size-Adjust-the-internal-parameter-used-to-estimate-how-aggressive-the-parser-can-be-when-compiling-policy.-This-may-include-changes-to-how-or-when-caches-are-dropped-or-how-many-compile-units-jobs-are-launched.-The-value-should-slightly-larger-than-the-largest-Resident-Set-Size-RSS-encountered-for-the-type-of-policy-being-compiled">--estimated-compile-size Adjust the internal parameter used to estimate how aggressive the parser can be when compiling policy. This may include changes to how or when caches are dropped or how many compile units (jobs) are launched. The value should slightly larger than the largest Resident Set Size (RSS) encountered for the type of policy being compiled.</dt>
<dd>
<p>A value that is too small may result in the parser exhausting system resources when compiling large policy. A value too large may slow policy compiles down.</p>
<p>The value specified may include a suffix of <i>KB</i>, <i>MB</i>, <i>GB</i>, to make it easier to adjust the size.</p>
<p>Note: config-file and command line options will override values chosen by tuning affected by the option.</p>
</dd>
<dt id="config-file">--config-file</dt>
<dd>
<p>Specify the config file to use instead of /etc/apparmor/parser.conf. This option will be processed early before regular options regardless of the order it is specified in.</p>
</dd>
<dt id="print-config-file">--print-config-file</dt>
<dd>
<p>Print the config file location that will be used.</p>
</dd>
</dl>
<h1 id="CONFIG-FILE">CONFIG FILE</h1>
<p>An optional config file /etc/apparmor/parser.conf can be used to specify the default options for the parser, which then can be overridden using the command line options.</p>
<p>The config file ignores leading whitespace and treats lines that begin with # as comments. Config options are specified one per line using the same format as the longform command line options (without the preceding --).</p>
<p>Eg. #comment</p>
<pre><code>optimize=no-expr-tree
optimize=compress-fast</code></pre>
<p>As with the command line some options accumulate and others override, ie. when there are conflicting versions of switch the last option is the one chosen.</p>
<p>Eg. Optimize=no-minimize Optimize=minimize</p>
<p>would result in Optimize=minimize being set.</p>
<p>The Include, Dump, and Optimize options accumulate except for the inversion option (no-X vs. X), and a couple options that work by setting/clearing multiple options (compress-small). In that case the option will override the flags it sets but will may accumulate with others.</p>
<p>All other options override previously set values.</p>
<h1 id="BUGS">BUGS</h1>
<p>If you find any bugs, please report them at <a href="https://gitlab.com/apparmor/apparmor/-/issues">https://gitlab.com/apparmor/apparmor/-/issues</a>.</p>
<h1 id="SEE-ALSO">SEE ALSO</h1>
<p>apparmor(7), apparmor.d(5), aa_change_hat(2), and <a href="https://wiki.apparmor.net">https://wiki.apparmor.net</a>.</p>
<table border="0" width="100%" cellspacing="0" cellpadding="3">
<tr><td class="_podblock_" valign="middle">
<big><strong><span class="_podblock_"> apparmor_parser - loads AppArmor profiles into the kernel</span></strong></big>
</td></tr>
</table>
</body>
</html>
|