Commit graph

4756 commits

Author SHA1 Message Date
Christian Boltz
04c91d5256
Drop unused activate_repo_profiles() 2018-11-18 17:20:30 +01:00
Christian Boltz
739b5d6cd3 Merge branch 'fix-make-clean-stress-tests' into 'master'
tests: fix make clean target

See merge request apparmor/apparmor!272

Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-11-17 18:44:57 +00:00
Steve Beattie
2e3fa8b830 Drop APPARMOR_ENABLE_AAEVENTD
Merge branch 'cboltz-eventd' into 'master'

PR: https://gitlab.com/apparmor/apparmor/merge_requests/269
Acked-by: Steve Beattie <steve.beattie@canonical.com>
2018-11-16 23:15:36 +00:00
Steve Beattie
7496fad27f
tests: fix make clean target
Make the tests/stress 'make clean' target cope with the rename from
subdomain to apparmor.

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2018-11-16 14:16:07 -08:00
John Johansen
9db669a0ef Merge branch 'cboltz-parse-remainder' into 'master'
parse_profile_data(): Ensure last line in a profile is valid

'lastline' gets merged into 'line' (and reset to None) when reading the
next line. If 'lastline' isn't empty after reading the whole profile,
this means there's something unparseable at the end of the profile,
therefore parse_profile_data() should error out.

Also remove some simple_tests testcases from the 'exception_not_raised'
list - they only didn't raise the exception because the invalid rule was
the last line in the affected profile.

Thanks to Eric Chiang for accidently (and maybe even unnoticedly ;-)
discovering this bug while adding some xattr testcases that surprisingly
didn't fail in the tools.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/271
Acked-by: John Johansen <john.johansen@canonical.com>
2018-11-13 23:58:54 +00:00
Christian Boltz
4efff35bf8
parse_profile_data(): Ensure last line in a profile is valid
'lastline' gets merged into 'line' (and reset to None) when reading the
next line. If 'lastline' isn't empty after reading the whole profile,
this means there's something unparseable at the end of the profile,
therefore parse_profile_data() should error out.

Also remove some simple_tests testcases from the 'exception_not_raised'
list - they only didn't raise the exception because the invalid rule was
the last line in the affected profile.

Thanks to Eric Chiang for accidently (and maybe even unnoticedly ;-)
discovering this bug while adding some xattr testcases that surprisingly
didn't fail in the tools.
2018-11-13 17:59:40 +01:00
Christian Boltz
7ba8dc7e2e
Drop APPARMOR_ENABLE_AAEVENTD
This is another trace of aa-eventd which is deprecated since years.
2018-11-12 15:51:15 +01:00
Christian Boltz
273e45a4af Merge branch 'cboltz-profile-list' into 'master'
Replace "existing_profiles" & fix minitools for named profiles

See merge request apparmor/apparmor!249

Acked-by: John Johansen <john.johansen@canonical.com>
2018-11-11 13:17:00 +00:00
John Johansen
2809060bec parser: limit the number of passes expr tree simplification does
Expr tree simplification makes multiple passes at simplifying the
expression tree trying to use fatoring rules and heuristics to achieve
the minimum tree, so that dfa construction has fewer nodes to deal
with.

Unfortunately expr tree simplification can slow some policy compiles,
dependent on the type of expressions generated, down, and even worse
is currently subject to never terminating on some expressions as the
left and right passes keep undoing each others work.

Limiting the number of passes that expr tree simplification does can
provide most of its benefits (later passes generally have diminishing
returns), reduces the overhead it has on simple policy where it is of
little benefit, and insures that simplifications can not get stuck in
an infinite loop due to the left and right passes ping-ponging on each
others factoring.

Note: This also results in a performance improvement in evince
compiles, and general policy compiles because it achieves a better
balance between time spent on simplifying the tree to remove nodes and
time the dfa build requires to build with extra nodes and then
eliminate with minimization.

$ time apparmor_parser -QT /etc/apparmor.d/usr.bin.evince
real	0m2.744s
user	0m2.714s
sys	0m0.028s

vs.

$ time apparmor_parser -QT /etc/apparmor.d/usr.bin.evince
real	0m2.992s
user	0m2.979s
sys	0m0.012s

and

$ time apparmor_parser -QT /etc/apparmor.d/
real	0m3.568s
user	0m14.529s
sys	0m0.152s

vs.

$ time apparmor_parser -QT /etc/apparmor.d/
real	0m3.741s
user	0m15.400s
sys	0m0.179s

PR: https://gitlab.com/apparmor/apparmor/merge_requests/246
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-11-09 13:01:01 -08:00
John Johansen
3318f660e3 Merge branch 'cboltz-eventd' into 'master'
Remove traces of aa-eventd

aa-eventd and its initscripts have been moved to deprecated/ in 2014 and didn't get any serious updates for several more years, so it's most probably useless and/or broken nowadays.

This also means we don't need to keep the AA_EV_BIN and AA_EV_PIDFILE variables in rc.apparmor.functions anymore.

(In theory I could move these variables to deprecated/rc.aaeventd.* - but in practise that sounds more than superfluous ;-)

PR: https://gitlab.com/apparmor/apparmor/merge_requests/263
Acked-by: John Johansen <john.johansen@canonical.com>
2018-11-09 17:02:22 +00:00
Christian Boltz
3a89e9811f
Remove traces of aa-eventd
aa-eventd and its initscripts have been moved to deprecated/ in 2014 and
didn't get any serious updates for several more years, so it's most
probably useless and/or broken nowadays.

This also means we don't need to keep the AA_EV_BIN and AA_EV_PIDFILE
variables in rc.apparmor.functions anymore.
2018-11-09 17:22:17 +01: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
John Johansen
0d5ab43d59 rc.apparmor.functions: drop module loading support
The apparmor kernel "module" has not been a loadable module for more
than a decade, it must be built into the kernel and due configuration
requirements it will never go back to being a loadable module.

Remove the long unfunctioning load_module support from the init script.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/257
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: seth.arnold@canonical.com
2018-11-08 18:22:09 -08:00
John Johansen
e657ca67d7 Merge branch 'use-sys' into 'master'
Use @{sys} tunable in profiles and abstractions

Commit aa065287 made @{sys} tunable available by default.

Update profiles and abstractions to actually use @{sys} tunable for better confinement in the future (when @{sys} becomes kernel var).

Closes LP#1728551

PR: https://gitlab.com/apparmor/apparmor/merge_requests/262
Acked-by: John Johansen <john.johansen@canonical.com>
2018-11-09 01:45:18 +00:00
Vincas Dargis
2438179b76 Use @{sys} tunable in profiles and abstractions
Commit aa06528790 made @{sys} tunable
available by default.

Update profiles and abstractions to actually use @{sys} tunable for
better confinement in the future (when @{sys} becomes kernel var).

Closes LP#1728551
2018-11-08 20:04:46 +02:00
Steve Beattie
5888a50a0f parser/libapparmor_re: expand comment of firstpos, lastpos, followpos
Merge branch 'regex-dragon-book' into 'master'

PR: https://gitlab.com/apparmor/apparmor/merge_requests/261
Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2018-11-07 21:36:32 +00:00
Eric Chiang
197b5d63fe parser/libapparmor_re: expand comment of firstpos, lastpos, followpos
Elaborate in class comment of firstpos, lastpos, followpos, and nullable
fields beyond just referencing the Dragon book. Also add the section of
the book these are explained in.
2018-11-06 19:08:28 -08:00
Christian Boltz
39a2031487 Merge branch 'cboltz-strict-todo-check' into 'master'
error out on superfluous TODOs

See merge request apparmor/apparmor!197

Acked-by: John Johansen <john.johansen@canonical.com>
2018-11-06 21:14:40 +00:00
Christian Boltz
4b26850e14
error out on superfluous TODOs
If a test is marked as TODO, but matches its EXRESULT, this means the
TODO is superfluous and (probably) a change fixed what the TODO was for.

Instead of more or less ignoring such superfluous TODOs, error out to
make the change visible instantly.
2018-11-06 21:44:40 +01:00
Christian Boltz
608af94dff Merge branch 'cboltz-disable-some-abi-tests' into 'master'
disable abi/ok_10 and abi/ok_12 tests

See merge request apparmor/apparmor!259
2018-11-06 20:43:04 +00:00
Christian Boltz
a3305b512d
disable abi/ok_10 and abi/ok_12 tests
Both result in "superfluous TODO" (for unknown reason), but fail after
removing the TODO.

Disable the tests until we find out why they have this strange
behaviour, to unblock merging the "error out on superfluous TODO" patch.
2018-11-06 21:33:12 +01:00
Christian Boltz
c98d8570ee Merge branch 'cboltz-fixed-todos' into 'master'
Remove TODO notes from no-longer-failing tests

See merge request apparmor/apparmor!180

Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: intrigeri <intrigeri@debian.org>
2018-11-06 17:33:49 +00:00
intrigeri
7416138b43 Merge remote-tracking branch 'origin/merge-requests/251'
apparmor(7): Document various debugging options.

Bug-Debian: https://bugs.debian.org/826218
PR: https://gitlab.com/apparmor/apparmor/merge_requests/251
2018-11-04 12:01:38 +00:00
intrigeri
b95f9bdd3b apparmor(7): Document various debugging options.
Credits go to John Johansen <john@jjmx.net> for most of the information
and the initial phrasing.

Bug-Debian: https://bugs.debian.org/826218
2018-11-04 11:43:04 +00:00
John Johansen
607e185d0c Merge branch 'cboltz-minus-one' into 'master'
replace -1 return codes with 255

Technically "return -1" returns 255, so we should write it that way.
(found by shellcheck)

PR: https://gitlab.com/apparmor/apparmor/merge_requests/256
Acked-by: John Johansen <john.johansen@canonical.com>
2018-11-03 14:08:25 +00:00
Christian Boltz
29da17310e
replace -1 return codes with 255
Technically "return -1" returns 255, so we should write it that way.

(found by shellcheck)
2018-11-02 17:00:33 +01:00
Christian Boltz
473d1f5daa Merge branch 'cboltz-postalias' into 'master'
allow locking /etc/aliases.db

See merge request apparmor/apparmor!250

Acked-by: intrigeri <intrigeri@debian.org>
2018-10-26 14:39:31 +00:00
Christian Boltz
f74edd5d5a
allow locking /etc/aliases.db
This is needed for "newaliases" on current openSUSE Tumbleweed / postfix 3.3.1
2018-10-25 20:59:25 +02:00
Christian Boltz
4d722f1839
Replace existing_profiles & fix minitools for named profiles
Technical stuff first:

Replace existing_profiles (a dict with the filenames for both active and
inactive profiles) with active_profiles and extra_profiles which are
ProfileList()s and store the active profiles and those in the extra
directory separately. Thanks to ProfileList, now also the relation
between attachments and filenames is easily available.

Also replace all usage of existing_profiles with active_profiles and
extra_profiles, and adjust it to the ProfileList syntax everywhere.

With this change, several bugs in aa-complain and the other minitools
get fixed:
- aa-complain etc. never found profiles that have a profile name
  (the attachment wasn't checked)
- even if the profile name was given as parameter to aa-complain, it
  first did "which $parameter" so it never matched on named profiles
- profile names with alternations (without attachment specification)
  also never matched because the old code didn't use AARE.

References: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=882047#92
(search for "As usual" ;-)

Just for completeness - the matching still doesn't honor/expand
variables in the profile name.
2018-10-23 00:28:37 +02:00
Christian Boltz
789c4658e2
add ProfileList class to store list of profiles
ProfileList is meant to store the list of profiles (both name and
attachment) and in which files they live.

Also add unittests to make sure everything works as expected.
2018-10-23 00:28:37 +02:00
Christian Boltz
8809218ac8
Move updating existing_profiles out of parse_profile_data()
parse_profile_data() returns the parsed profiles, but writes to
existing_profiles directly.

read_profiles() calls parse_profile_data() and already handles adding
the parsed profiles to aa, original_aa or extras, which means updating
existing_profiles there is a much better place.

This commit also includes a hidden change: Previously, when parsing
include files, they were also added to existing_profiles. This is
superfluous, only real profiles need to be stored there.
2018-10-23 00:28:37 +02:00
Christian Boltz
a6b8d14908
split off get_new_profile_filename()
... and call it from get_profile_filename_* if get_new is True
(= always with the current code)
2018-10-23 00:28:37 +02:00
Christian Boltz
ec741424f8
split get_profile_filename into .._from_profile_name and .._from_attachment
Split get_profile_filename() into
- get_profile_filename_from_profile_name() (parameter: a profile name)
- get_profile_filename_from_attachment() (parameter: an attachment)

Currently both functions call get_profile_filename_orig() (formerly
get_profile_filename()) so the behaviour doesn't change yet.

The most important part of this commit is changing all
get_profile_filename() calls to use one of the new functions to make
clear if they specify a profile or an attachment/executable as
parameter.

As promised, the is_attachment parameter starts to get used in this
patch ;-)

Note: The get_new parameter (which I'll explain in the patch actually
using it) is set to True in all calls to the new functions.
The long term plan is to get rid of it in most cases (hence defaulting
to False), but that will need more testing.
2018-10-23 00:28:37 +02:00
Christian Boltz
bc783372b8
Add is_attachment parameter to write_profile
The minitools call write_profile(), write_profile_feedback_ui() and
serialize_profile() with the _attachment_ as parameter.

However, aa-logprof etc. call them with the _profile name_ as parameter.

This patch adds an is_attachment parameter to write_profile() and
write_profile_feedback_ui(). It also passes it through to
serialize_profile() via the options parameter.

If is_attachment is True, the parameter will be handled as attachment,
otherwise it is expected to be a profile name.

tools.py gets changed to set is_attachment to True when calling the
functions listed above to make clear that the parameter is an attachment.

Note: This patch only adds the is_attachment parameter/option, but
doesn't change any behaviour. That will happen in the next patch.
2018-10-23 00:18:04 +02:00
Christian Boltz
fd68a5eb64 Merge branch 'cboltz-profile-names' into 'master'
Add profile names to all profiles with {bin,sbin} attachment

See merge request apparmor/apparmor!242

Acked-by: intrigeri <intrigeri@debian.org>
2018-10-21 10:34:59 +00:00
John Johansen
d87b6a5f6e Merge branch 'dont-hard-code-libc-header-location' into 'master'
Don't hard code the location of netinet/in.h.

This "will break with non-glibc libcs on Debian and with glibc headers moved to
multiarch locations" (https://bugs.debian.org/798955). Patch based on the one
proposed by Helmut Grohne helmut@subdivi.de, amended to replace hard coded
"gcc" with "$(CC)".

Bug-Debian: https://bugs.debian.org/909966

nominated for 2.13.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/245
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-21 06:29:05 +00:00
intrigeri
2d91211842 Don't hard code the location of netinet/in.h.
This "will break with non-glibc libcs on Debian and with glibc headers moved to
multiarch locations" (https://bugs.debian.org/798955). Patch based on the one
proposed by Helmut Grohne <helmut@subdivi.de>, amended to replace hard coded
"gcc" with "$(CC)".

Bug-Debian: https://bugs.debian.org/909966
2018-10-20 20:49:26 +00:00
intrigeri
f0dfb3cd74 Merge branch 'cboltz-rc-syntax-fix' into 'master'
Fix syntax error in rc.apparmor.functions

See merge request apparmor/apparmor!240
2018-10-20 16:00:07 +00:00
Christian Boltz
2863e20f37 Merge branch 'test-includes' into 'master'
profiles/Makefile: test abstractions against apparmor_parser

See merge request apparmor/apparmor!237

Acked-by: Christian Boltz <apparmor@cboltz.de> for trunk and 2.13.

Pre-acked for 2.10..2.12 after removing the --config-file option which is not supported in these branches.
2018-10-17 22:20:51 +00:00
Vincas Dargis
dc7ae28de0 profiles/Makefile: test abstractions against apparmor_parser
Update Makefile to test abstractions by generating temporary profile, to
check for missing (not backported) abstractions or other issues.
2018-10-17 20:05:51 +03:00
Christian Boltz
f920915dd3 Merge branch 'aa-notify-manpage' into 'master'
aa-notify man page: update user's configuration file path

See merge request apparmor/apparmor!239

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.10..master
2018-10-16 15:55:44 +00:00
Christian Boltz
b77116e6af
Add profile names to all profiles with {bin,sbin} attachment
Also adjust the signal rules in the dovecot-common and apache2-common
abstractions to match the profile names, and to really do that
(peer=...{bin,sbin}... didn't work, the correct syntax would have been
peer=...\{bin,sbin\}...)

This fixes the regression introduced by !149 / commit
4200932d8f
2018-10-15 20:57:33 +02:00
nl6720
2209e09aef aa-notify man page: update user's configuration file path
Signed-off-by: nl6720 <nl6720@gmail.com>
2018-10-15 16:44:00 +03:00
Christian Boltz
3bf11cee3e
Fix syntax error in rc.apparmor.functions
This bug was introduced in
- https://gitlab.com/apparmor/apparmor/merge_requests/230
- commit c974dd0d07 (master)
- commit 9987a7ec9c (2.13 branch)
2018-10-14 18:10:46 +02:00
John Johansen
4a2dad336a library: bump library version to keep it in sync with 2.13.1 release
Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-10-13 16:40:05 -07:00
John Johansen
6242051a1c Merge branch 'cboltz-abi-exceptions' into 'master'
Add most abi/bad_*.sd tests to "exception not raised" list

Interestingly, abi/bad_6.sd is detected as invalid, and therefore not
added to the list.

I propose this for all branches that g[eo]t support for abi rules and the abi testcases.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/238
Acked-by: John Johansen <john.johansen@canonical.com>
2018-10-13 21:31:31 +00:00
Christian Boltz
5c54f66279
Add most abi/bad_*.sd tests to "exception not raised" list
Interestingly, abi/bad_6.sd is detected as invalid, and therefore not
added to the list.
2018-10-13 20:23:57 +02:00
John Johansen
83df7c4747 parser: ignore feature abi rules
AppArmor 3.0 requires policy to use a feature abi rule for access to
new features. However some policy may start using abi rules even if
they don't have rules that require new features.  This is especially
true for out of tree policy being shipped in other packages.

Add enough support to older releases that the parser will ignore the
abi rule and warn that it is falling back to the apparmor 2.x
technique of using the system abi.

If the profile contains rules that the older parser does not
understand it will fail policy compilation at the unknown rule instead
of the abi rule.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00
John Johansen
4153663c42 parser: fix: ensure that a quotedid actually has both quotes
The handling for quotedid checked for the first quote but failed
to ensure the trailing quote was present.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00
John Johansen
04beee7633 parser: combine INCLUDE cases together and support escape sequences
We can reduce the INCLUDE/INCLUDE_EXISTS code dup by using a
variable for whether the name was enclosed by '<' and using
processid() to handle the whether the id is quoted or not.

In addition using processid allows include names to contain
escaoe sequences like \n and have them handled correctly.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/196
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2018-10-12 22:14:38 -07:00