Commit graph

4686 commits

Author SHA1 Message Date
Simon Deziel
fa30238293 usr.bin.dumpcap: drop useless/redundant rules 2018-07-17 17:12:44 -04:00
Simon Deziel
e0ba7a4609 usr.bin.wireshark: fix access to configuration profiles 2018-07-17 17:02:28 -04:00
Simon Deziel
bf8222a361 usr.bin.wireshark: add a comment for QtProject.conf rules 2018-07-17 06:15:51 -04:00
Steve Beattie
fed101920b
coverity build: capture separate log files for each coverity invocation
Each coverity command writes its debugging output to
cov-int/build-log.txt, which means that multiple runs of cov-build
overwrite previous logs, resulting in only the last invocation's output
remaining at the end of the build, making debugging why failures to
capture coverity output difficult. Fix this by renaming the build-log to
per-directory log files.

(This would still be an issue even if we had a single build command
for the entire tree, as capturing python and other interpreted
files requires a second invocation of cov-build to scan for those
file types.)

Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
PR: https://gitlab.com/apparmor/apparmor/merge_requests/145
2018-07-13 11:35:45 -07:00
Christian Boltz
c437e9d4a5
add missing 'break' in load_profile()
'case OPTION_OFILE' missed the 'break', which means if did fallthrough
to the default case.

Adding the 'break' means no longer executing another PERROR, and no
longer executing the 'exit(1)' in the default branch.

References: coverity #55994
2018-07-13 15:21:24 +02:00
Simon Deziel
0e38f51aad usr.bin.wireshark: mention that dri rules were backported from abstraction/dri-enumerate 2018-07-13 04:56:42 -04:00
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
Simon Deziel
5a8453fbe0 usr.bin.dumpcap: incorporate feedback from Talkless an cboltz 2018-07-12 05:13:55 -04:00
Simon Deziel
0c0a90be0b usr.bin.wireshark: refresh for 18.04 2018-07-11 12:29:36 -04:00
Simon Deziel
b765dab52e usr.bin.dumpcap: new profile 2018-07-11 12:29:12 -04: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
Christian Boltz
0dca959c6b
set_profile_flags(): allow named profiles without attachment
Named profiles can come without an attachment path specified, for
example
    profile foo {...}

This patch fixes set_profile_flags() to actually allow that instead of
erroring out.

References:
- https://bugzilla.opensuse.org/show_bug.cgi?id=1096269 comment #3 and #4
- https://bugs.launchpad.net/apparmor/+bug/1775591
2018-07-10 01:00:00 +02:00
Christian Boltz
73b33bdf36
Fix unsetting filename in get_profile()
When creating a new profile with aa-genprof, get_profile() searches for
an inactive ("extra") profile and, if it finds one, removes the filename
from that profile so that it gets stored in /etc/apparmor.d/ later.

However, it used .pop() to remove the filename, which explodes since
ProfileStorage is a class now.

This patch fixes this (tested manually).
2018-07-03 18:34:23 +02: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