Commit graph

5072 commits

Author SHA1 Message Date
John Johansen
daa10d3ce1 parser: rework backend to allow for more transitions
As a step in preparing for out of band transitions and double walk
transitions rework the backend from using a char index to a class
with an larger range than char.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-26 21:32:08 -08:00
John Johansen
e958da7678 Nnp unconfined exception tests
Add nnp tests around the unconfined exception.

An unconfined task is allowed changing to a profile under nnp restrictions. However this has implications when the task has stacked confinement.

  profile//&unconfined

  profile//&:ns:unconfined

  ...

will not be caught by the unconfined test. Instead the unconfined exception needs to be tested as part of the subset test. Add tests to ensure we can catch regressions around a stacked unconfined profile.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/424
Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-11-27 05:29:13 +00:00
Christian Boltz
663546c284 Merge branch 'cboltz-abstractions-kerberos' into 'master'
abstractions/kerberosclient: allow reading /etc/krb5.conf.d/

See merge request apparmor/apparmor!425

Acked-by: Steve Beattie <steve@nxnw.org> for 2.10..master
Acked-by: John Johansen <john.johansen@canonical.com> for 2.10..master
2019-11-18 21:35:29 +00:00
Christian Boltz
b017f8f8a9 Merge branch 'cboltz-drop-localinclude' into 'master'
Drop 'localinclude' in parse_profile_data() and ProfileStorage

See merge request apparmor/apparmor!427

Acked-by: John Johansen <john.johansen@canonical.com> for 2.12..master
Acked-by: Steve Beattie <steve@nxnw.org> for 2.12..master
2019-11-18 21:32:24 +00:00
Christian Boltz
3db14e8e49 Merge branch 'fix-autoconf-check-for-python-3.8' into 'master'
Fix a Python 3.8 autoconf check

See merge request apparmor/apparmor!430

Acked-by: Christian Boltz <apparmor@cboltz.de> for master and 2.13
Acked-by: Steve Beattie <steve@nxnw.org> for master and 2.13
2019-11-18 20:16:33 +00:00
John Johansen
095efb821f docs: update apparmor.d language description
Update the language description to provide some over arching
principles, such as the policy is declarative.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
Acked-by: Steve Beattie <steve.beattie@canonical.com>
2019-11-09 14:05:22 -08:00
John Johansen
d6384641c2 added missing functions to slackware init script
There where some functions missing in the Slackware init script which has been added with this commit.

PR: https://gitlab.com/apparmor/apparmor/merge_requests/432
Acked-by: John Johansen <john.johansen@canonical.com>
2019-11-09 11:00:01 +00:00
lmoeller
32105d0816 added missing functions to slackware init script 2019-11-08 13:49:48 +01:00
intrigeri
ccbf1e0bf1 Fix a Python 3.8 autoconf check
Bug-Debian: https://bugs.debian.org/943657

Author: Matthias Klose <doko@debian.org>
2019-10-29 17:53:11 +00:00
Christian Boltz
1567ea6f4c Merge branch 'cboltz-pyflakes-version' into 'master'
README: add PYFLAKES=/usr/bin/pyflakes3 env variable

See merge request apparmor/apparmor!429

Acked-by: John Johansen <john.johansen@canonical.com> for 2.11..master
2019-10-24 21:08:28 +00:00
Christian Boltz
556bb94aa5
README: add PYFLAKES=/usr/bin/pyflakes3 env variable
pyflakes 2.x nowadays complains about
    aa-genprof:60: undefined name 'PermissionError'

We already deprecated py2 support in 2.11 (and obviously nobody tests
with py2 anymore), therefore recommending pyflakes3 makes sense.

Maybe we should also change our Makefiles to use py3 and pyflakes3 by
default, but that will be another (master-only) commit.
2019-10-24 15:36:22 +02:00
Christian Boltz
001ea9e3af
Drop 'localinclude' in parse_profile_data() and ProfileStorage
'localinclude' is/was meant to have 'local/*' includes separate, but
it's write-only and never used, which makes it useless.

Additionally, it causes a crash in the aa-* tools which gets fixed by
removing all the 'localinclude'-related code (what a big word for two
lines ;-)

References: https://bugs.launchpad.net/apparmor/+bug/1848227
2019-10-16 21:30:43 +02:00
Christian Boltz
5066dc6195 Merge branch 'profile-usr.sbin.winbindd' into 'master'
Update usr.sbin.winbindd profile

Winbind requires access to `/var/cache/samba/msg.lock/*`.

On Arch Linux Winbind's pid is set to `/run/winbindd.pid` ( https://git.archlinux.org/svntogit/packages.git/tree/trunk/winbindd.service?h=packages/samba ).

See merge request apparmor/apparmor!411

Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Christian Boltz <apparmor@cboltz.de>
2019-10-03 17:53:21 +00:00
Christian Boltz
a2d43e7546 Merge branch 'avoid-blhc-false-positive' into 'master'
Avoid blhc "CPPFLAGS missing" false positive.

See merge request apparmor/apparmor!403

Acked-by: John Johansen <john.johansen@canonical.com>
2019-09-30 21:53:50 +00:00
John Johansen
cb5aeec433 regression tests: add unconfined exception tests to nnp.sh
The unconfined exception needs to be applied even when a stack is
being used. When a stack is in use it prevents the unconfined
test from being used and instead it must be done as part of the
subset test.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-09-29 19:58:02 -04:00
Christian Boltz
dffed83161
abstractions/kerberosclient: allow reading /etc/krb5.conf.d/
Permit the use of /etc/krb5.conf.d configuration snippets

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>

Originally submitted as https://build.opensuse.org/request/show/733763
2019-09-28 17:25:39 +02:00
Christian Boltz
0b94cbe516 Merge branch 'cboltz-drop-deprecated' into 'master'
drop deprecated perl code

* drop repair_obsolete_profiles (updated profiles for abstraction renames pre-2006)
* drop ancient perl aa-* tools and their modules (rewritten to python in 2.9)
* drop rc.aaeventd.{redhat,suse} initscripts (aaeventd was dropped long ago, therefore we don't need to keep its initscripts)

See merge request apparmor/apparmor!423

Acked-by: John Johansen <john.johansen@canonical.com>
2019-09-25 20:32:20 +00:00
Christian Boltz
523f21fb20
drop rc.aaeventd.{redhat,suse} initscripts
aaeventd was dropped long ago, therefore we don't need to keep its
initscripts.
2019-09-23 21:46:16 +02:00
Christian Boltz
12488fcc9a
drop ancient perl aa-* tools and their modules
They were rewritten to python in 2.9.
2019-09-23 21:43:58 +02:00
Christian Boltz
506f51e6fd
drop repair_obsolete_profiles
(updated profiles for abstraction renames pre-2006)
2019-09-23 21:40:27 +02:00
Christian Boltz
98fde52998 Merge branch 'drop-perl' into 'master'
drop deprecated perl code
* aa-repo.pl
* convert-profile.pl

See merge request apparmor/apparmor!416

Acked-by: Christian Boltz <apparmor@cboltz.de>
2019-09-23 19:35:58 +00:00
Christian Boltz
b76567ce10 Merge branch 'cboltz-status-parenthesis' into 'master'
aa-status: handle profile names containing '('

Closes #51

See merge request apparmor/apparmor!415

Acked-by: John Johansen <john.johansen@canonical.com> for 2.10..master
2019-09-23 18:55:22 +00:00
John Johansen
094f9727fa Merge branch 'dont-allow-fontconfig-cache-write' into 'master'
abstractions/fonts: don't allow write of fontconfig cache files

See merge request apparmor/apparmor!420
2019-09-20 09:42:53 +00:00
John Johansen
c9fcc18b9a Fix setfcap Cap mispelling
PR: https://gitlab.com/apparmor/apparmor/merge_requests/421
Acked-by: John Johansen <john.johansen@canonical.com>
2019-09-17 10:01:03 +00:00
Paulo Gomes
2d19d4d159
Fix capability mispelling. 2019-09-17 10:38:09 +01:00
John Johansen
59e799a9ba abstractions/X: allow reading the Xauth file mutter passes to Xwayland.
Applications running under Xwayland in a GNOME+Wayland session need read access to this file since:

a8984a81c2

… that was first included in mutter 3.33.3.

This rule is presumably only needed for GNOME+Wayland sessions, so one could argue that it should live in abstractions/wayland instead, but Jamie argued that it should be in the X abstraction because Xwayland is a X server.

MR: https://gitlab.com/apparmor/apparmor/merge_requests/419
Bug-Debian: https://bugs.debian.org/935058
Acked-by: John Johansen <john.johansen@canonical.com>
2019-09-16 15:08:40 +00:00
Jamie Strandboge
c5968c70d0 abstractions/fonts: don't allow write of fontconfig cache files
879531b36ec3dfc7f9b72475c68c30e4f4b7b6af changed access for
@{HOME}/.{,cache/}fontconfig/** to include 'w'rite. Fontconfig has been
a source of CVEs. Confined applications should absolutely have read
access, but write access could lead to breaking out of the sandbox if a
confined application can write a malformed font cache file since
unconfined applications could then pick them up and be controlled via
the malformed cache. The breakout is dependent on the fontconfig
vulnerability, but this is the sort of thing AppArmor is meant to help
guard against.
2019-09-09 15:52:40 -05:00
intrigeri
c006f79141 abstractions/X: allow reading the Xauth file mutter passes to Xwayland.
Bug-Debian: https://bugs.debian.org/935058

Applications running under Xwayland in a GNOME+Wayland session need read access
to this file since:

  a8984a81c2

… that was first included in mutter 3.33.3.

This rule is presumably only needed for GNOME+Wayland sessions, so one could
argue that it should live in abstractions/wayland instead, but Jamie argued that
it should be in the X abstraction because Xwayland is a X server.
2019-09-08 07:41:36 +00:00
intrigeri
33c5f61c75 Merge branch 'utab' into 'master'
profiles/gnome: Allow access of /run/mount/utab

See merge request apparmor/apparmor!412
2019-09-08 06:58:44 +00:00
intrigeri
9acb17adf0 Merge branch 'cboltz-whitespace' into 'master'
fix whitespace and indentation in several files

See merge request apparmor/apparmor!413
2019-09-08 06:48:27 +00:00
John Johansen
a00ac89be8 drop deprecated perl code
With the effort to remove perl, it makes no sense to keep the depracted
perl code around for new releases.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2019-08-21 18:31:34 -07:00
Christian Boltz
41d26b0197
aa-status: handle profile names containing '('
aa-status crashed if a profile name contains an opening parenthesis
because the regex enforces (simplified) '^[^(]* \(.*\)' when reading
/sys/kernel/security/apparmor/profiles

This obviously doesn't match if a profile name contains '(' which is
rare and strange, but still allowed, and the match result "None" then
crashes aa-status.

Adjust the regex to allow all chars instead of all except '(' to handle
these corner cases.

Note that '(enforce)' and '(complain)' still get read correctly because
the regex ends with '\((\w+)\)$' and therefore enforces matching
"something inside parenthesis at the end of the line".

This bug exists since aa-status was rewritten into python, and even
existed in the perl version before. However, in the perl version, the
regex matching was protected with an if so profile names with '(' were
skipped and hidden from the aa-status output.

Fixes: https://gitlab.com/apparmor/apparmor/issues/51
2019-08-16 22:10:36 +02:00
Christian Boltz
e246568819
fix whitespace and indentation in several files 2019-08-12 23:58:04 +02:00
Jörg Sommer
cd3532f792 profiles/gnome: Allow access of /run/mount/utab
When a filesystem is mounted with the option *user*, the file selection
dialogue, e.g. in *Evince*, triggers an access of */run/mount/utab*, which
comes from *libmount* and should be allowed.
2019-08-09 10:11:37 +02:00
nl6720
54dc60ff5b Update usr.sbin.winbindd profile
Winbind requires access to /var/cache/samba/msg.lock/*.
Move msg.lock/ to abstractions/samba.
On Arch Linux Winbind's pid is set to /run/winbindd.pid.

Signed-off-by: nl6720 <nl6720@gmail.com>
2019-08-08 19:37:37 +03:00
Christian Boltz
2e304f82fc Merge branch 'cboltz-logparser-simplify-prefilter' into 'master'
Simplify log prefilter in logparser.py

See merge request apparmor/apparmor!400

Acked-by: John Johansen <john.johansen@canonical.com>
2019-08-05 20:01:59 +00:00
Christian Boltz
095d65f4ae
Simplify log prefilter in logparser.py
As discussed in https://gitlab.com/apparmor/apparmor/merge_requests/395
RE_LOG_ALL should be more broad so that it doesn't accidently
overlook/ignore valid log events.

Instead of adding more and more known log formats to logparser.py,
simplify the regex to do only a basic check.

If we really hand over a line to libapparmor that isn't an AppArmor log
event, worst thing that can happen is that we waste a few milliseconds
for handing over that line to libapparmor, and get AA_RECORD_INVALID as a
result.
2019-08-05 21:42:59 +02:00
Tyler Hicks
167e9207be Merge branch 'lp1838991' into 'master'
parser: Fix typoed example dbus rule in apparmor.d(5) man page

See merge request apparmor/apparmor!410

Bug: https://launchpad.net/bugs/1838991
Acked-by: Christian Boltz <apparmor@cboltz.de>
2019-08-05 16:56:50 +00:00
Tyler Hicks
7df48adae5 parser: Fix typoed example dbus rule in apparmor.d(5) man page
Remove extra closing parenthesis.

Bug: https://launchpad.net/bugs/1838991
Fixes: 46586a6334 ("parser: Add example dbus rule for unconfined peers")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-05 15:14:35 +00:00
Christian Boltz
39ac1e8ca3 Merge branch 'cboltz-exec-without-target' into 'master'
logparser.py: don't error out on exec events without target

See merge request apparmor/apparmor!405

Acked-by: John Johansen <john.johansen@canonical.com>
2019-08-02 12:00:44 +00:00
Tyler Hicks
5bd75cd0b7 Merge branch 'test-policy-cache-old-libapparmor' into 'master'
tests: Allow aa_policy_cache.c to build against old libapparmors

See merge request apparmor/apparmor!407

Acked-by: John Johansen <john.johansen@canonical.com>
2019-08-01 22:46:58 +00:00
Tyler Hicks
2893a6af05 Merge branch 'nnp-test' into 'master'
tests: Add NO_NEW_PRIVS regression tests

See merge request apparmor/apparmor!408

Acked-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
2019-08-01 22:41:15 +00:00
Tyler Hicks
7670336a82 libapparmor, tests: Be explicit about value-if-true in ternary operator
Improve readability by being explicit about the value to use when the
conditional evaluates to true.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Suggested-by: John Johansen <john.johansen@canonical.com>
2019-08-01 22:31:07 +00:00
Tyler Hicks
83d0b99729 Merge branch 'parser-cachedir-usage-typo' into 'master'
parser: Fix minor typo in usage

See merge request apparmor/apparmor!406

Acked-by: John Johansen <john.johansen@canonical.com>
2019-08-01 21:11:19 +00:00
Tyler Hicks
a77ba80838 tests: Allow aa_policy_cache.c to build against old libapparmors
Commit ad81ea0e67 ("tests: Add option to dump policy cache dir with
the libapparmor wrapper") modified aa_policy_cache.c to call
aa_policy_cache_dir_path_preview(). That added a hard dependency on
libapparmor >= 2.13, which is the first version to add
policy_cache_dir_path_preview() to libapparmor. The dependency makes it
impossible to build and run the upstream regression tests against an
installed libapparmor older than 2.13 due to aa_policy_cache.c failing
to build.

Add a compatible aa_policy_cache_dir_path_preview() when building
aa_policy_cache.c against a libapparmor older than 2.13 and newer than
or equal to 2.10.

Fixes: ad81ea0e67 ("tests: Add option to dump policy cache dir with the libapparmor wrapper")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-01 16:40:14 +00:00
Tyler Hicks
50e34b45c2 parser: Fix minor typo in usage
Correct the long option used to print the cache directory.

Fixes: e9d9395f91 ("parser: Add option to print the cache directory")
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-01 15:04:49 +00:00
Tyler Hicks
9160204008 tests: Add NO_NEW_PRIVS regression tests
Test the profile transition limits imposed by NO_NEW_PRIVS to ensure
that behavior doesn't unexpectedly change.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2019-08-01 14:58:32 +00:00
Christian Boltz
a0c1eb0abd
logparser.py: don't error out on exec events without target
commit 7297e2f6a8 assumed that exec events
always have a "target=...", but this is only true for events in complain
mode. In enforce mode, the log line doesn't include "target=...".

This commits sets an empty target instead of erroring out on every exec
event in enforce mode.

Also adjust ask_exec() in aa.py to only update
hashlog[aamode][target_profile]['final_name'] if target_profile is set
(hashlog[aamode][''] doesn't exist and trying to write to it would error
out)
2019-07-27 22:48:30 +02:00
Christian Boltz
dc3d11bf0a
add log testcases for exec with and without target=
- in complain mode, exec events include target=...
- in enforce mode, the log message doesn't include target=...

Note that the utils tests skip exec events (they'd be interactive),
therefore exec*.profile doesn't contain an exec rule.
2019-07-27 22:23:15 +02:00
intrigeri
c9b8cfa4a9 Avoid blhc "CPPFLAGS missing" false positive. 2019-07-17 20:51:48 +00:00