Commit graph

46 commits

Author SHA1 Message Date
Zygmunt Krynicki
6fddd31b76 fix typo: aggressive
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-03-29 10:52:25 +01:00
Zygmunt Krynicki
d274eb39d9 fix typo: accumulate
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-03-29 10:52:24 +01:00
Christian Boltz
3ee47af402
Fix typo in apparmor_parser manpage
man apparmor_parser gives examples for the --warn command line option as

             apparmor_parser --warn=rules-not-enforced ...
and
             apparmor_parser --warn=no-rules-not-enforced ...

but the actual --warn options are rule-not-enforced / no-rule-not-enforced
(without s)

Fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1057453
2023-12-05 13:27:09 +01:00
John Johansen
65ba20b955 parser: fix --jobs so job scaling is applied correctly
job scaling allows the parser to resample the number of cpus available
and increase the number of jobs that can be launched if cpu available
increases.

Unfortunately job scaling was being applied even when a fixed number
of jobs was specified. So
  --jobs=2

doesn't actually clamp the compile at 2 jobs.

Instead job scaling should only be applied when --jobs=auto or when
jobs are set to a multiple of the cpus.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/703
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
2021-02-10 19:06:26 -08:00
John Johansen
136502acd9 parser: enable the parser to do some rough tuning based on memory and cpu
The parsers default settings can OOM smaller special use systems
when building or loading policy. Use basic memory info and cpus to
tune the parser for lower resource environments.

Currently this just sets the jobs parameters if the default values
haven't been modified by user config or parameters. But in the
future this could add cache control and compile parameters.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/702
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
2021-02-10 18:51:39 -08:00
John Johansen
3d54324db0 parser: allow specifying --warn=no-XXX to turn off warnings
Some warning flags are enabled by default, allow a warning to
be disbaled by specifying no- infront of the warning.

  Eg.
    --warn=no-deprecated

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/600
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-09-01 19:42:38 -07:00
John Johansen
343024b4a3 parser: Add option --Werror to enable turning warnings into errors
Add basic ability to treat a warning as an error and abort the compile
by specifying the new option --Werror.

  --Werror

will turn all warnings into errors. Where if an warning type is
specified only that type of warning will be turned into an error.

  --Werror=deprecated.

The full list of supported warning types can be found by using

     apparmor_parser --help=warn
   or
     apparmor_parser --help=Werror

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/600
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-09-01 19:42:38 -07:00
John Johansen
dcc2918665 parser: add an option to allow overriding feature ABI rules
Add an option to allow setting/pinning the feature ABI and overriding
of ABI rules if they exist.

  --override-policy-abi

This option is primarily for profile development and testing without
allowing adjusting feature abis temporarily without modifying the
profile.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/579
Signed-off-by: John Johansen <john.johansen@canonical.com>
2020-08-20 01:22:03 -07:00
John Johansen
a29e232831 parser: feature abi: setup parser to intersect policy and kernel features
The features abi adds the ability to track the policy abi separate
from the kernel. This allow the compiler to determine whether policy
was developed with a certain feature in mind, eg. unix rules.

This allows the compiler to know whether it should tell the kernel to
enforce the feature if the kernel supports the rule but the policy
doesn't use it.

To find if a feature is supported we take the intersection of what is
supported by the policy and what is supported by the kernel.

Policy encoding features like whether to diff_encode policy are not
influenced by policy so these remain kernel only features.

In addition to adding the above intersection of policy rename
--compile-features to --policy-features as better represents what it
represents. --compile-features is left as a hidden item for backwards
compatibility.

MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/491
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <sbeattie@ubuntu.com>
2020-05-29 00:23:17 -07:00
John Johansen
c386d93581 docs: update documentation to point bug reporting to gitlab
Move suggested bug reporting from launchpad to gitlab

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
2020-05-05 00:10:53 -07:00
John Johansen
94ff870f78 remove subdomainfs support
It has been over 10 years since transition from subdomainfs to
using securityfs. Lets drop this deprecated code.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/258
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: seth.arnold@canonical.com
2018-11-08 18:23:21 -08:00
Tyler Hicks
eb8975e0cc all: Use HTTPS links for apparmor.net
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2018-09-13 16:41:32 +00:00
John Johansen
af1818c053 parser: update option parsing so --config-file does not have to be first
Requiring --config-file to be first in the option list is not user
friendly fix the option parsing so that --config-file can be specified
anywhere in the option list.

This also fixes a bug where even when the --config-file option is
first the option parsing fails because the detection logic is broken
for some option cases.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/175
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-08-21 23:14:52 -07:00
John Johansen
2c0d7e608c parser: Add fixes to --config-file option
After the config file patch was committed to 2.13 a couple of
improvements were suggested by intrigeri and cboltz. These have
been done as a separate patch so they can be applied to both
dev and 2.13.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/170
Acked-by: Christian Boltz <apparmor@cboltz.de>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-08-17 08:19:39 -07:00
John Johansen
b1967c892a parser: allow specifying the parser config file
The parser config file can affect the parsers behavior during tests.
Allow overriding the default location with the option

  --config-file=

the option must be the first option in the commands argument list.

Also provile a
  --print-config-file

option to display what the parser is using for a config file.

BugLink: http://bugs.launchpad.net/bugs/1277711
Acked-by: Christian Boltz <apparmor@cboltz.de>
Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-08-14 18:31:10 -07:00
intrigeri
3d21cf0e32 Move the cache to /var/cache
Let's not store a bunch of automatically generated binary files in /etc.
AppArmor 3.0 will store the cache in /var/cache and most distros
(openSUSE, Debian, and soon Ubuntu) moved it there already.

Bug-Debian: https://bugs.debian.org/904637
2018-08-02 01:18:04 +00:00
John Johansen
48a32b78b1
parser: Add the ability to turn off jobs to ease with debugging
The parser currently uses a fork model to do job processing. For
consistency even when the number of jobs is set to 1 a single
work process is forked. However this makes using gdb more difficult
and can be even worse for other debugging tools.

Make -j 0 disable all job spawning so all processing happens in the
main process.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/105

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2018-04-25 15:26:11 -07:00
John Johansen
481f59a39b parser: Enable cache overlay in the parser
Allow the parser to use cache overlays by extending the --cache-loc
flag to support multiple locations via a comma separated list.

eg.
  --cache-loc=/var/cache/apparmor/,/etc/apparmor.d/cache.d/

The overlayed cache directories are searched in the order
specified. So in the above example /var/cache/apparmor is searched
before /etc/apparmor.d/

Time stamps are ignored in the search, the first match found wins
regardless if there exists a matching cache file with a newer timestamp
in a directory is later in the search.

Cache writes will only occur to the first dir in the list. So
/var/cache/apparmor/ in the above example.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-04-14 15:51:23 -07:00
Tyler Hicks
1f36505f3e parser, libapparmor: Support multiple policy cache directories
Move the policy cache directory from <cacheloc>/cache/ to
<cacheloc>/cache.d/<features_id>/ where <features_id> is a unique
identifier for a set of aa_features. This allows for multiple AppArmor
policy caches exist on a system. Each policy cache will uniquely
correspond to a specific set of AppArmor kernel features. This means
that a system can reboot into a number of different kernels and the
parser will select the existing policy cache that matches each kernel's
set of AppArmor features.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2018-04-14 15:51:23 -07:00
Tyler Hicks
e9d9395f91 parser: Add option to print the cache directory
The --print-cache-dir option can be used to have the parser print the
value of the cache directory that is specific to the features used (from
the current kernel, the --match-string option, or the --features-file
option). After printing the path, apparmor_parser will exit. This is
helpful because the final component in the path will become
unpredictable because it will be based on arbitrary hash function
output.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
2018-04-14 15:51:23 -07:00
Emerson Bernier
b4fa0cf9f6 Add ".dpkg-remove" to apparmor parser ignored list
References: https://bugs.debian.org/893974
2018-04-02 14:24:44 +00:00
Emerson Bernier
f0876ea92a Add .pacsave/.pacnew to apparmor parser ignored list
Currently there is a list of file extensions which apparmor parser
should ignore which contains rpm and dpkg backup files. The list could
be extended with extensions used by pacman package manager
(Archlinux/Manjaro/Antergos):

.pacsave

.pacnew

https://wiki.archlinux.org/index.php/Pacman/Pacnew_and_Pacsave

References: https://gitlab.com/apparmor/apparmor/issues/3
2018-04-02 14:24:25 +00:00
Emerson Bernier
50ee50f931 Fix typo in apparmor_parser.pod 2018-03-26 19:07:50 +00:00
intrigeri
095e9eea82 Fix typo: s/resonable/reasonable/. 2016-10-15 11:33:50 -05:00
John Johansen
3cb1477f5d parser: add basic support for parallel compiles and loads
This adds a basic support for parallel compiles. It uses a fork()/wait
model due to the parsers current dependence on global variables and
structures. It has been setup in a similar manner to how cilk handles
multithreading to make it easy to port to a managed thread model once
the parser removes the dependence on global compute structures in the
backend.

This patch adds two new command line flags
  -j <n> or --jobs <n>
     which follows the make syntax of specifying parallel jobs currently
     defaults to -jauto
     -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

     Note: unlike make -j must be accompanied by an option

--max-jobs=<n>
    allows setting hard cap on the number of jobs that can be specified
    by --jobs. It defaults to the number of processors in the system * 8.
    It supports the "auto" and "max" keywords, and using x<n> for a
    multiple of the available cpus.

additionally the -d flag has been modified to take an optional parameter
and
  --debug=jobs
will output debug information for the job control logic.

In light testing on one machine the job control logic provides a nice
performance boost.  On an x86 test machine with 60 profiles in the
/etc/apparmor.d/ directory, for the command
  time apparmor_parser -QT /etc/apparmor.d/

  old (equiv of -j1):
     real  0m10.968s
     user  0m10.888s
     sys   0m0.088s

  ubuntu parallel load using xargs:
     real  0m8.003s
     user  0m21.680s
     sys   0m0.216s

  -j:
     real  0m6.547s
     user  0m17.900s
     sys   0m0.132s

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2016-01-13 17:10:57 -08:00
Jamie Strandboge
586806907d parser/apparmor_parser.pod: fix typo "sinlge" should be "single"
Bug: https://launchpad.net/bugs/1485530

Signed-Off-By: Jamie Strandboge <jamie@canonical.com>
2015-08-17 09:03:05 -05:00
Tyler Hicks
631804e8a7 parser: Document the --features-file option in apparmor_parser(8)
This option was previously only documented in the --help output.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2015-06-01 11:29:37 -05:00
John Johansen
71e54288bd Document the ability for apparmor_parser to load profiles from a dir
Update the apparmor_parser documentation for the new ability to load
profiles from a specified directory.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Tyler Hicks <tyhicks@canonical.com>
2014-10-20 13:38:24 -04:00
John Johansen
c2b8a72317 disable downgrade and not enforced rule messages by default
Currently the apparmor parser warns about rules that are not enforced or
downgraded. This is a problem for distros that are not carrying the out of
tree kernel patches, as most profile loads result in warnings.

Change the behavior to not output a message unless a warn flag is passed.
This patch adds 2 different warn flags
  --warn rule-downgraded    	 # warn if a rule is downgraded
  --warn rule-not-enforced	   # warn if a rule is not enforced at all

If the warnings are desired by default the flags can be set in the
parser.conf file.

v2 of patch
- update man page
- add --warn to usage statement
- make --quiet clear warn flags

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-10-08 13:20:20 -07:00
John Johansen
9e93e6eaf5 fix: if the apparmor parser fails to load the cache try rebuilding
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2014-09-23 14:33:54 -07:00
John Johansen
8fb91c8e9d fix: Make the parser behave the same as when driven with xargs -n1
Currently the parser is bailing when it fails to load a profile,
not processing any potential subsequent profiles in the dir or passed
in list. This results in all policy after the first error failing
to load, instead of just the profile(s) with the error.

This is a different behavior than what has been done by initscripts
that have driven it with xargs -n1, passing it a single profile
at a time.

Fix this so that the parser only exits on first error if specifically
told to do so.

Note: this does not fix the various failure points in the parser
that call exit, instead of returning an error.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Steve Beattie <steve@nxnw.org>, thanks.
2014-09-23 14:24:40 -07:00
Christian Boltz
198f660ee8 fix broken URLs in various utils/*.pod files.
(The broken URLs were introduced in r1582.)

for utils/*.pod:
  Acked-by: Steve Beattie <steve@nxnw.org> 

for the other directories:
  Patch by Steve Beattie
  Acked-by: Christian Boltz <apparmor@cboltz.de>
2013-09-19 21:17:39 +02:00
John Johansen
8eb069cce5 apparmor: update apparmor_parser man page
Rework and update the apparmor_parser man page. It reworks some of the
text but mostly just reorganizes the commands and options into logical
grouping to make it easier to sort out how the various commands and
options work.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-By: Steve Beattie <sbeattie@ubuntu.com>
2012-08-13 16:58:46 -07:00
John Johansen
e61b7b9241 Update the copyright dates for the apparmor_parser
Signed-off-by: John Johansen <john.johansen@canonical.com>
2012-02-24 04:21:59 -08:00
John Johansen
5fdf33c689 Add an option to allow setting the cache's location.
Currently the cache location is fixed and links are needed to move it.
Add an option that can be set in the apparmor_parser.conf file so distros
can locate the cache where ever makes sense for them.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Kees Cook <kees@ubuntu.com>
2012-01-11 17:25:18 +01:00
John Johansen
4dec6cab65 Add the ability for the parser to have a basic conf file, that defaults
to /etc/apparmor/parser.conf (NOTE option to allow changing this is not
provided currently).

Signed-off-by: John Johansen <john.johansen@canonical.com>
2011-08-09 06:52:43 -07:00
Kees Cook
723a20ba7d as ACKed on IRC, drop the unused $Id$ tags everywhere 2010-12-20 12:29:10 -08:00
Jamie Strandboge
49f27414e0 update the man pages to:
* add Canonical to the headers of the pod files touched
  * use aa_change_hat() instead of change_hat() (LP: #692216)
  * use http://wiki.apparmor.net in the SEE ALSO
  * use http://https://bugs.launchpad.net/apparmor/+filebug for bugs
  * prefix 'aa-' in SEE ALSO section for utilities (eg, 'aa-complain' for
    'complain')
2010-12-20 13:47:09 -06:00
John Johansen
49530d5fe5 This patch adds back in the -p flag, allowing the dumping of a
flattened profile to stdout.

It currently does not do anymore than flattening the include
files.  The expansions of variables etc can be added later.
2010-06-26 13:13:52 -07:00
John Johansen
b0a9f46bb7 Update parser man page to include dump and optimize flags 2010-04-03 16:24:06 -07:00
Kees Cook
369a280f64 Document the --skip-kernel-load parameter 2010-01-07 10:03:49 -08:00
Kees Cook
8d760811b8 do not load cache when using -S option 2010-01-06 09:04:04 -08:00
Kees Cook
0d2518551f provide kernel version caching, along with ability to test caching subsystem 2009-11-11 10:56:04 -08:00
Kees Cook
bf7c9c8567 document missing options in the apparmor_parser man page 2009-08-19 14:45:05 +00:00
John Johansen
cd79c1ac77 update copyright dates 2007-04-11 08:12:51 +00:00
Steve Beattie
24606ec70b Subject: Add manpages to the parser package
Move the apparmor.d(5), apparmor(7), apparmor_parser(8),
subdomain.conf(5) and apparmor.vim(5) (for lack of a better location)
into the apparmor-parser package.
2007-04-03 19:04:10 +00:00
Renamed from docs/apparmor_parser.pod (Browse further)