Commit graph

1119 commits

Author SHA1 Message Date
Christian Boltz
f910cb5559
parse_profile_data(): error out on alias inside profile
Defining an alias is only allowed outside of a profile.

Also add a parser test with an alias inside a profile.
2018-05-06 14:27:32 +02:00
Christian Boltz
5b9497a8c6
is_skippable_dir(): add 'cache.d' to exclude list
This excludes the /etc/apparmor.d/cache.d/ directory from aa-logprof
parsing because parsing the binary cache, well, takes a while :-/

Reported on the opensuse-factory mailinglist by Frank Krüger and
confirmed by others.
2018-04-30 00:57:52 +02:00
John Johansen
aa7dc70de3 translations: sync from launchpad translations
Signed-off-by: John Johansen <john.johansen@canonical.com>
2018-04-15 06:54:44 -07:00
Christian Boltz
f472b6bb34 fix regression in {get,set}_profile_flags()
Since the latest change, calling {get,set}_profile_flags() with the
profile name failed when attachment was specified ("profile foo /bar").

Catched by the unittests.

Also fix a whitespace issue.
2018-04-14 21:26:34 +00:00
Christian Boltz
e28d0a922a
Merge branch 'goldwynr/apparmor-fixes'
See https://gitlab.com/apparmor/apparmor/merge_requests/91

Acked-by: Christian Boltz <apparmor@cboltz.de>
2018-04-14 21:16:16 +02:00
Goldwyn
5e187daa0b Set flags for profiles represented by a glob
Getting and Setting profile represented by a glob does not work correctly
because they are checked for equality. Use a glob match to check for them.
Also, add a warning stating that the profile being set represents multiple programs.

traceroute is an example whose profile name is represented as
/usr/{sbin/traceroute,bin/traceroute.db} and exhibits the issue:

Setting /usr/sbin/traceroute to enforce mode.

ERROR: /etc/apparmor.d/usr.sbin.traceroute contains no profile

Signed-off-by: Goldwyn <goldwyn@fiona.lan>
2018-04-12 05:57:27 -05:00
Christian Boltz
45922c6d21
make utils tests less verbose
Given the big number of tests, printing a dot for each test (instead of
multiple lines) is enough ;-)
2018-04-08 20:18:30 +02: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
Christian Boltz
86ec3dd658
comment out use_group to remove group restrictions
use_group is only honored if it is defined.

The "real" permission check is reading the logfile - the group check
in aa-notify is just an annoying additional check, and the default
"admin" only works on Ubuntu (other distributions typically use
"wheel").

This commit comments out use_group in the default config, which allows
everybody to use aa-notify. Permissions for reading the log file are of
course still needed.

References: https://bugzilla.opensuse.org/show_bug.cgi?id=1058787
2018-03-18 19:56:29 +01:00
Christian Boltz
dc7c702188 utils tests: ignore tests for 'include if exists'
... and some exotic includes that are not supported by the tools yet
2018-03-16 21:37:17 +00:00
Christian Boltz
f9eb3fea0f ignore .git in is_skippable_dir()
References: https://bugs.launchpad.net/apparmor/+bug/1440273
2018-03-16 21:34:38 +00:00
Tyler Hicks
46f88f5f0d utils: Properly identify empty ouid/fsuid fields in logs
libaalogparse uses (unsigned long) -1 to indicate that a log entry does
not contain ouid and/or fsuid fields. The utils logparser was
incorrectly using 2^64 - 1 to detect such a condition but that wasn't
sufficient for 32 bit environments.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2018-03-07 15:26:26 +00:00
John Johansen
ccef9161a8 Merge branch 'master' into 'master'
Add custom notification

See merge request apparmor/apparmor!72

Acked-by: John Johansen <john.johansen@canonical.com>
2018-03-06 07:42:37 +00:00
Kees Cook
735afbc947 aa-status: split profile from exec name
Right now, if you have a named profile with regular expressions to
match binaries, the profile will be shown in aa-status under the
"process list", which doesn't make sense. Instead, show the actual
executable name, and if the profile name differs, report it at the
end (or as a separate field in the json output mode).

Signed-off-by: Kees Cook <keescook@chromium.org>
2018-03-01 14:17:57 -08:00
Nicolas Videla
1c3839c39a Update man page and default configuration for notify.conf 2018-02-26 14:43:19 +11:00
Nicolas Videla
86db2263b8 Adding custom notification on AppArmor. 2018-02-26 14:34:58 +11:00
Christian Boltz
0eefeeb0e7 Merge branch 'cboltz-notify-dbus-env' into 'master'
set DBUS_SESSION_BUS_ADDRESS, needed by notify-send

See merge request apparmor/apparmor!53


Acked-by: intrigeri <intrigeri@debian.org> for 2.9..master
2018-02-17 16:03:23 +00:00
Christian Boltz
705ce5ca3e
simplify write_include() and drop write_single()
write_include() was the only user of write_single(), and write_single()
had some include-specific code. This patch gets rid of write_single().

write_include() gets a simplified version of the code instead of calling
write_single().
2018-01-28 15:55:41 +01:00
Christian Boltz
7f1007d13e
change 'profile_changes' and 'serialize_opts' to dict()
The global 'profile_changes' and 'serialize_opts' in sync_profile() are
both used as a dict() - no need to make them a hasher()
2018-01-24 22:04:16 +01:00
John Johansen
f8a174c08b Merge branch 'cboltz-rename-profs' into 'master'
rename 'profs' variable to 'profiles' in two functions

See merge request apparmor/apparmor!60

Acked-by: John Johansen <john.johansen@canonical.com>
2018-01-24 08:24:42 +00:00
Christian Boltz
26af640fda
tools: Mark profiles with multiple rules in one line as known-failing
The tools don't support having multiple rules in one line (they expect
\n after each rule), therefore mark some of the bare_include_tests as
known failures.
2018-01-23 22:40:07 +01:00
Christian Boltz
1bac9d2d79
rename 'profs' variable to 'profiles' in two functions
console_select_and_upload_profiles() and set_profiles_local_only() both
use a local variable named 'profs'. Rename it to 'profiles'.

This is the first baby step for rewriting how aa.py stores the profiles
internally. I plan to use 'profs' as variable name instead of 'aa', and
this commit gets the result for "grep -r profs" down to 0.
2018-01-23 22:09:22 +01:00
Christian Boltz
cb5cdf2656
set DBUS_SESSION_BUS_ADDRESS, needed by notify-send
This is needed by new versions of notify-send, as found on openSUSE
Tumbleweed. Without this, desktop notifications don't work anymore, and
notify-send starts to eat up CPU.

If DBUS_SESSION_BUS_ADDRESS is already set, it won't be changed.
2018-01-18 10:57:50 +01:00
John Johansen
3afbfed9ee aa-decode: add the ability to support PROCTITLE string
buglink: https://bugs.launchpad.net/apparmor/+bug/1736841

Signed-off-by: John Johansen <john.johansen@canonical.com>
2017-12-24 00:22:24 -08:00
John Johansen
b5808e8aa8 Import translations from launchpad translations
Signed-off-by: John Johansen <john.johansen@canonical.com>
2017-12-24 00:08:28 -08:00
Christian Boltz
60f71930cd
Improve exception message for #include rules
This fixes one of the remaining issues in
https://gitlab.com/apparmor/apparmor/merge_requests/44
2017-12-22 21:40:18 +01:00
Christian Boltz
22fa0a3a77 Merge branch 'lp-1733700-fix-include-for-non-magicpath' into 'master'
update python tools to support includes with absolute paths

See merge request apparmor/apparmor!44

Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-12-22 20:38:14 +00:00
John Johansen
c3b0a3e512 Merge branch 'cboltz-logprof-owner' into 'master'
let aa-logprof detect 'owner' events (again)

See merge request apparmor/apparmor!34
2017-12-22 20:16:16 +00:00
John Johansen
118ea834fd Merge branch 'cboltz-unused-UI_ask_mode_toggles' into 'master'
remove unused UI_ask_mode_toggles() in aa.py

See merge request apparmor/apparmor!41

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-22 19:18:23 +00:00
Jamie Strandboge
99f144f8c2 clarify error message in regex.py (thanks to cboltz) 2017-12-21 15:29:52 -06:00
Jamie Strandboge
5c95e3bf39 don't strip() a quoted path (thanks to cboltz) 2017-12-21 15:27:09 -06:00
Jamie Strandboge
515e40ec7f abstract out abs path include to get_include_path() (thanks to cboltz) 2017-12-21 15:07:21 -06:00
Jamie Strandboge
a7e79ffa3d rename vague 'dir' variables (thanks to cboltz) 2017-12-21 14:36:35 -06:00
Jamie Strandboge
9bbef8e307 update python tools to support includes with absolute paths
For now we only allow quoted absolute paths without spaces in the name
due to:
- 1738877: include rules don't handle files with spaces in the name
- 1738879: include rules don't handle absolute paths without quotes in
  some versions of parser
- 1738880: include rules don't handle relative paths in some versions of
  the parser
2017-12-20 17:21:21 -06:00
Christian Boltz
566218612c
remove unused UI_ask_mode_toggles() in aa.py 2017-12-17 17:38:46 +01:00
Christian Boltz
2431b1884a
Display "owner permissions on/off" buttons in aa-logprof
- extend available_buttons() to display an "owner permissions on/off"
  button if the rule supports it
- extend ask_the_questions() to handle these buttons
- add some tests to test-translations.py to avoid hotkey conflicts with
  the newly added buttons
2017-12-17 16:45:49 +01:00
Christian Boltz
11147f965a
split set_options_audit_mode() and add set_options_owner_mode()
- move the code of set_options_audit_mode() to a new function
  set_options_mode() and make set_options_audit_mode() a wrapper for it.
- add set_options_owner_mode() as another wrapper for set_options_mode()
  and add code to switch the owner flag to set_options_mode()
- add tests for set_options_owner_mode()
2017-12-17 16:42:12 +01:00
Christian Boltz
24eaea19e3
Add 'can_owner' flag to *Rule
This flag defines if the "Owner permissions on/off" button gets
displayed in aa-logprof.

False by default for all rule types (most of them don't support the
owner conditional). Also false for non-owner FileRule.

True only for FileRule if owner=True.
2017-12-17 16:31:05 +01:00
Christian Boltz
56b55aa0dd
support 'owner' file events in logparser.py
logparser.py failed to notice if file events are owner-only in modern
audit.log (using fsuid=... and ouid=...).

This patch adds a comparison of fsuid and ouid and marks file events
as 'owner' if they match.

Note that log events without fsuid=... or ouid=... will have
18446744073709551615 as fsuid / ouid value (that's 2^64 - 1).
'None' would clearly be better ;-)

References: https://bugs.launchpad.net/apparmor/+bug/1538340
2017-12-13 20:16:29 +01:00
John Johansen
b2df42f55b Merge branch 'cboltz-inherit-mr' into 'master'
handle_children(): automatically add m permissions on ix rules

See merge request apparmor/apparmor!22

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-12 22:45:53 +00:00
John Johansen
6483c627d2 Merge branch 'cboltz-file-w-covered-by-a' into 'master'
FileRule: detect that 'a' is covered by 'w'

See merge request apparmor/apparmor!23

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-12 22:40:49 +00:00
Tyler Hicks
debc4e3ffe Merge branch 'exit-from-Makefile-shell-snippets' into 'master'
binutils, parser, utils: Exit from Makefile shell snippets

See merge request apparmor/apparmor!27

Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-12-05 17:44:48 +00:00
Tyler Hicks
2c04f44a80 binutils, parser, utils: Exit from Makefile shell snippets
Exit rather than returning from shell snippets in Makefiles. It is
reported that returning causes the following error message with bash:

 /bin/sh: line 4: return: can only `return' from a function or sourced script

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Christian Boltz <apparmor@cboltz.de>
2017-12-04 23:28:10 +00:00
Tyler Hicks
20e7f523ca utils: Gracefully handle a missing parser in the check target
The test-aa-easyprof.py script relies on the parser to be built so the
check target of the utils/test/Makefile should detect if the parser
exists before running any tests.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Reported-by: Christian Boltz <apparmor@cboltz.de>
2017-12-04 23:10:03 +00:00
Christian Boltz
a0d4e246ab
FileRule: detect that 'a' is covered by 'w'
References: https://bugs.launchpad.net/apparmor/+bug/1385474
2017-12-03 17:51:04 +01:00
Christian Boltz
1857f07d08
test-file.py: Document that w doesn't cover a yet
This is the code "translation" of
https://bugs.launchpad.net/apparmor/+bug/1385474
2017-12-03 17:34:04 +01:00
Christian Boltz
7a49f37c24
handle_children(): automatically add m permissions on ix rules
Since some kernel versions, inherit (ix) needs mmap permissions. Instead
of annoying the user with an avoidable question after adding an ix rule,
always add m permissions.

Together with the already existing code, this means newly added inherit
rules will now have 'mrix' permissions.
2017-12-03 14:39:46 +01:00
Steve Beattie
a1bad3a293 Ignore untranslated texts in check_po.pl
Merge branch 'cboltz-check_po' into 'master'

See merge request 
https://gitlab.com/apparmor/apparmor/merge_requests/15
2017-12-01 19:52:55 +00:00
Christian Boltz
4d4228d157
Don't print a literal '\n' in aa-remove-unknown help 2017-12-01 00:26:56 +01:00