Commit graph

4475 commits

Author SHA1 Message Date
Christian Boltz
44ee1d5090
make message about notify-send package cross-distro compatible
References: https://bugzilla.opensuse.org/show_bug.cgi?id=1100779
2018-07-12 22:00:41 +02:00
John Johansen
aa42e33860 kernel-patches: add v4.17-out-of-tree net compatibility patches
Add kernel patches that will NEVER be sent upstream. These provide abi
compatibility with the v2.x network and af_unix rules.

The 4.17 network mediation pull request deliberately broke abi
compatibility with the v2.x rules, and these are provided so that
distros who shipped the v2.x compatible patches can provide new
kernels on older releases that require v2.x network support.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-07-10 22:18:48 -07:00
Steve Beattie
8fc0ff7ffc
utils: cleanup serialize_profile() and its callers
Merge branch 'cboltz-cleanup-serialize-profile'

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
PR: https://gitlab.com/apparmor/apparmor/merge_requests/138
2018-06-29 15:21:24 -07:00
Steve Beattie
640556637f adjust abstractions/python for python 3.7
Merge branch 'cboltz-python-version' into 'master'

Acked-by: Steve Beattie <steve@nxnw.org>
PR: https://gitlab.com/apparmor/apparmor/merge_requests/139/
2018-06-29 18:15:47 +00:00
Christian Boltz
01f41fbff8
adjust abstractions/python for python 3.7
Python 3.7 was released yesterday - and to make the abstraction
future-proof, also cover 3.8 and 3.9 in advance ;-)
2018-06-28 13:34:08 +02:00
Christian Boltz
e5ffa6815c Merge branch 'mesa' into 'master'
Add mesa abstraction

See merge request apparmor/apparmor!137


Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-06-27 19:11:06 +00:00
Christian Boltz
b613860f14
serialize_profile: simplify setting of include_flags
Note that NO_FLAGS was an inverse option, therefore
- NO_FLAGS was changed to FLAGS (also in sync_profile() which is the
  only caller that sets FLAGS)
- the default for include_flags (if FLAGS is not set) is True
2018-06-25 22:55:26 +02:00
Christian Boltz
9865e112f7
serialize_profile(): simplify setting include_metadata 2018-06-25 22:47:30 +02:00
Christian Boltz
5ef95fff4f
serialize_profile(): add type check for options
This makes the "if options:" check superfluous, therefore remove it and
change the whitespace of the following lines
2018-06-25 22:43:39 +02:00
Christian Boltz
7e42135010
fix serialize_profile() calls to always use a dict for options 2018-06-25 21:42:29 +02:00
Christian Boltz
db7983aee5
simplify setting serialize_options 2018-06-25 21:39:47 +02:00
Vincas Dargis
a0c719df73 Add mesa abstraction
Add mesa abstraction to allow writing to the Mesa-specific cache
locations and listing devices. Abstraction is needed for applications
utilizing OpenGL API with Mesa implementation available on the system.
2018-06-23 17:07:05 +03:00
Christian Boltz
b7a4f37cbb Merge branch 'cboltz-nested-child-error' into 'master'
parse_profile_start(): Error out on nested child profiles

See merge request apparmor/apparmor!136

Acked-by: John Johansen <john.johansen@canonical.com> for 2.10..master
2018-06-21 10:20:03 +00:00
Christian Boltz
82eb749b6f Merge branch 'cboltz-view-changes' into 'master'
use serialize_profile() for the new profile in (V)iew Changes

See merge request apparmor/apparmor!131

Acked-by: John Johansen <john.johansen@canonical.com>
2018-06-21 10:19:12 +00:00
Christian Boltz
f7ed8257c3 Merge branch 'cboltz-gitignore' into 'master'
add utils/test/common_test.pyc to gitignore

See merge request apparmor/apparmor!135

Acked-by: John Johansen <john.johansen@canonical.com>
2018-06-20 20:55:30 +00:00
Christian Boltz
48d7692c05 Merge branch 'cboltz-systemd-cache-loc' into 'master'
Adjust cache paths in apparmor.service

See merge request apparmor/apparmor!134

Acked-by: John Johansen <john.johansen@canonical.com>
2018-06-20 20:54:51 +00:00
Christian Boltz
6c8fff099f Merge branch 'cboltz-simplify-write-vars' into 'master'
simplify write_list_vars()

See merge request apparmor/apparmor!130

Acked-by: John Johansen <john.johansen@canonical.com>
2018-06-20 15:52:02 +00:00
Christian Boltz
50aa8204c9 Merge branch 'cboltz-ruleset-tests' into 'master'
add some tests for BaseRule/BaseRuleset

See merge request apparmor/apparmor!132

Acked-by: John Johansen <john.johansen@canonical.com>
2018-06-20 15:51:13 +00:00
Christian Boltz
e5eff3bbee Merge branch 'cboltz-apache-stapling' into 'master'
fix path for apache2 stapling-cache

See merge request apparmor/apparmor!133

Acked-by: John Johansen <john.johansen@canonical.com>
2018-06-20 15:50:28 +00:00
Christian Boltz
8462c39b14
parse_profile_start(): Error out on nested child profiles
The tools can't handle nested child profiles yet. Instead of failing
in funny[tm] ways (parse_profile_start() only returned the first two
segments of the profile name) better error out with a clear message.
2018-06-20 14:43:48 +02:00
Christian Boltz
63d17ecf16
add utils/test/common_test.pyc to gitignore
(cache file that gets created when running the tests with python2)
2018-06-19 15:27:16 +02:00
Christian Boltz
1185df3c65
fix path for apache2 stapling-cache
... to match the default apache settings

See also the discussion on the mailinglist:
https://lists.ubuntu.com/archives/apparmor/2018-June/011688.html
2018-06-17 16:16:22 +02:00
Christian Boltz
3a9b0fd74a
Adjust cache paths in apparmor.service
The initial apparmor.service assumed the profile cache is in
/var/lib/apparmor/ which was an openSUSE-specific path that was chosen
for historical reasons, but was far from perfect.

In the meantime, the profile cache moved to /var/cache/apparmor/ and the
read-only/packaged version was added in /usr/share/apparmor/cache/

This commit adjusts apparmor.service to use these paths.
2018-06-16 23:14:19 +02:00
Christian Boltz
2312873406
add some tests for BaseRule/BaseRuleset
These tests verify that
- _is_equal_aare() really raises an exception when it sees an invalid
  combination of other_value and other_all
- BaseRuleset.__repr__() works as expected

As a side effect, this commit pushes the test coverage of
apparmor/rule/__init__.py to 100% ;-)
2018-06-09 20:53:53 +02:00
Christian Boltz
82fc0b8239
delete now unused serialize_parse_profile_start()
(another function that was only used by
serialize_profile_from_old_profile())

Also delete the tests we had for that function.
2018-06-09 15:27:26 +02:00
Christian Boltz
0eb12a8cbd
delete serialize_profile_from_old_profile()
... which is unused since the last commit.

Also delete several functions that were only used by this function:
- write_change_profile()
- write_rlimits()
- write_capabilities()
- write_netdomain()
- write_dbus()
- write_signal()
- write_ptrace()
- write_file()

Finally, no longer import some functions from profile_storage:
- write_links
- write_mount
- write_pivot_root
- write_unix

BTW: Deleting these 460 lines improves test coverage of aa.py from
38% to 44%, and total test coverage from 63% to 66% :-)
2018-06-09 15:13:50 +02:00
Christian Boltz
469eb444de
use serialize_profile() for the new profile in (V)iew Changes
... instead of serialize_profile_from_old_profile()

This will give a realistic preview of the changes (serialize_profile()
is also used when actually writing the profile) and replaces the
known-buggy serialize_profile_from_old_profile() with known-working
code.

It also fixes the issue reported in
    https://bugs.launchpad.net/ubuntu/+source/apparmor/+bug/1528139
which means we no longer need the workaround of catching AttributeError
(verified in manual before/after test)

References:
- https://bugs.launchpad.net/apparmor/+bug/1394788
- https://bugs.launchpad.net/bugs/1528139
- https://bugs.launchpad.net/apparmor/+bug/1404893
2018-06-09 15:10:07 +02:00
Christian Boltz
af9490556d
get rid of superfluous variables in write_list_vars()
- rename prof_data parameter to ref
- drop empty allow, prefix and tail, and their usage in the format
  string
- inline sep into the format string
- replace usage of fn with the actual function name (var_transform)
2018-05-31 22:09:26 +02:00
Christian Boltz
5ae94391c5
inline set_ref_allow() into write_list_vars()
set_ref_allow() is only used by write_list_vars(). Inline it (actually
only the used, boring if branch) to simplify the code.
2018-05-31 22:00:50 +02:00
Christian Boltz
06eb65eb50
inline write_pair() into write_list_vars()
write_pair() is only used by write_list_vars(), so there's no need to
keep it as a separate function
2018-05-31 22:00:50 +02:00
Christian Boltz
c2a420d32b
let var_transform() sort variable content
This is needed to get a reproducible output.

Also adjust the tests in test-profile-storage.py and add some example
variable to cleanprof.in and cleanprof.out
2018-05-31 22:00:36 +02:00
John Johansen
288ae9049a opensuse 2018 conference presentation
Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-05-31 11:03:01 -07:00
Tyler Hicks
d038eea1be Merge branch 'aa-exec-fixups' into 'master'
aa-exec fixups

See merge request apparmor/apparmor!129
2018-05-31 17:51:36 +00:00
Tyler Hicks
379239b024 Merge branch 'aa-exec-pid' into 'master'
aa-exec: Prepend [PID] to all error, debug, and verbose messages

See merge request apparmor/apparmor!128
2018-05-31 17:44:42 +00:00
Tyler Hicks
95286bb9e7 aa-exec: Clarify ENOENT and EACCES errors when changing profiles
The aa-exec tool was indicating, in an error message, that a profile
didn't exist in cases where aa_change_profile() failed with errno set to
ENOENT or EACCES. However, the EACCES error means that changing to the
target profile is not allowed. This patch fixes the error message in the
cause of EACCES:

 $ ./aa-exec -p dne -- true
 aa-exec: ERROR: profile 'dne' does not exist

 $ ./aa-exec -p /usr/sbin/tcpdump -- ./aa-exec -p unconfined -- true
 aa-exec: ERROR: insufficient permissions to change to the profile 'unconfined'

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2018-05-31 17:37:55 +00:00
Tyler Hicks
652dac0cec aa-exec: Remove extra newline when profile changes fail
An extra newline was being printed when aa_change_profile() failed and
errno was ENOENT or EACCES.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2018-05-31 17:27:00 +00:00
Tyler Hicks
00800cb905 aa-exec: Prepend [PID] to all error, debug, and verbose messages
Add the pid of the process to the error, debug, and verbose output. This
is useful for debugging.

For example,

 $ aa-exec -v -- whoami
 [30389] exec whoami
 tyhicks

 $ aa-exec -p dne -- true
 [30390] aa-exec: ERROR: profile 'dne' does not exist

 $ aa-exec -d -p unconfined -- true
 [30409] aa-exec: DEBUG: 0 = aa_change_onexec("unconfined")

It can also help when multiple aa-exec invocations are used across a
fork and exec. Here's a contrived example:

 $ aa-exec -v -- \
   sh -c 'aa-exec -vp /usr/sbin/tcpdump -- aa-exec -p unconfined -- true'
 [3424] exec sh -c aa-exec -vp /usr/sbin/tcpdump -- aa-exec -p unconfined -- true
 [3425] aa_change_onexec("/usr/sbin/tcpdump")
 [3425] exec aa-exec -p unconfined -- true
 [3425] aa-exec: ERROR: profile 'unconfined' does not exist

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2018-05-31 17:04:20 +00:00
John Johansen
c9d341782e Merge branch 'cboltz-move-write-methods' into 'master'
Cboltz move write methods

See merge request apparmor/apparmor!122
2018-05-25 12:38:12 +00:00
John Johansen
097ff0fa6b Merge branch 'cboltz-drop-safety-nets' into 'master'
Drop some safety nets in aa.py

See merge request apparmor/apparmor!113
2018-05-25 12:34:28 +00:00
Jamie Strandboge
0c7c34c6f1 Merge branch 'vulkan' into 'master'
Add Vulkan abstraction

See merge request apparmor/apparmor!126
2018-05-22 21:45:31 +00:00
Vincas Dargis
47520931be Add Vulkan abstraction
Add abstraction for Vulkan API specific file paths.
2018-05-22 21:48:13 +03:00
Jamie Strandboge
c1431bc2de Merge branch 'nvidia-app-profiles' into 'master'
Update nvidia for reading application profiles

See merge request apparmor/apparmor!125
2018-05-22 18:24:19 +00:00
Vincas Dargis
f2e0fdc72b Update nvidia for reading application profiles
Add file rule to allow reading application profiles for NVIDIA
Linux graphics driver.
2018-05-22 20:43:56 +03:00
John Johansen
8e4ee696c3 Merge branch 'opencl' into 'master'
Add OpenCL abstractions

See merge request apparmor/apparmor!124
2018-05-13 20:14:15 +00:00
Vincas Dargis
8237d6e776 Add OpenCL abstractions 2018-05-13 20:14:15 +00:00
Steve Beattie
ab94074887
misc: add initial gitlab-ci.yml for running build/tests
This commit adds an initial gitlab-ci.yml file to perform test builds
and run tests on each commit.

v2: add liblocale-gettext-perl dependency for parser simple test
v3:
  - set noninteractive prompt to avoid debconf queries when installing
    packages
  - disable profiles test against aa-logprof; even if library and python
    path issues are resolved, aa-logprof early aborts due to being
    unable to find /sbin/apparmor_parser

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
Acked-by: Tyler Hicks <tyler.hicks@canonical.com>
PR: https://gitlab.com/apparmor/apparmor/merge_requests/101
2018-05-11 19:02:36 -07:00
Christian Boltz
79d9ee5c3b
test-libapparmor-test_multi: initialize parent profiles
If a log line contains a denial for a child profile, log_dict will
(obviously) only contain the child profile. However, serialize_profile()
expects that the parent profile is also initialized as ProfileStorage.

This patch makes sure the parent profile gets initialized.

It also removes 26 of the 37 reasons in the TODO note in aa.py :-)
2018-05-10 12:44:04 +02:00
Steve Beattie
3b7c08e2b9
gitignore: add libapparmor/src/PMurHash.{o,lo}
Merge remote-tracking branch 'cboltz/cboltz-libapparmor-gitignore' from
Christian Boltz.

Acked-by: Steve Beattie <steve@nxnw.org>
PR: https://gitlab.com/apparmor/apparmor/merge_requests/123/
2018-05-09 14:43:00 -07:00
Christian Boltz
db92d96e68
add libapparmor/src/PMurHash.{o,lo} to gitignore 2018-05-09 23:03:03 +02:00
Jamie Strandboge
d1984706c8 Merge branch 'cboltz-samba-profiles-boo1092099' into 'master'
Update samba profiles

See merge request apparmor/apparmor!121
2018-05-09 20:48:35 +00:00