Commit graph

1153 commits

Author SHA1 Message Date
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
Christian Boltz
b307e535fa
Let read_inactive_profiles() do nothing when calling it the second time
autodep() calls read_inactive_profiles() each time it's called (= for
each binary). The result is a "Conflicting profile" error (showing the
same filename twice) if autodep() runs more than once. This can easily
happen when using "aa-autodep /usr/bin/*".

This patch adds an attribute to read_inactive_profiles() that lets the
function return without doing anything if was called before.
2017-11-28 21:46:36 +01:00
Christian Boltz
455489c9fe
Ignore untranslated texts in check_po.pl
check_po.pl lists lots of false positives saying that
    msgstr ""
does not have the (h)otkey translated.

This patch whitelists those untranslated strings.

I also tested (by manually "breaking" a translation) that missing
hotkeys still get noticed.

This bug probably exists since forever, therefore I propose this patch
for 2.9..trunk. (OTOH, nobody noticed it, so maybe trunk is enough ;-)

Note: I still get a few false positives for ru.po (no idea why, similar
texts in the other languages don't cause this) - ideas and fixes welcome.
2017-11-27 23:47:52 +01:00
Christian Boltz
051be5dec0
Remember selected profile in save_profiles()
After using "view changes", the selection got reset to the first changed
profile. This could mislead the user into saving the wrong profile.

This patch ensures the selection is kept.

I propose this patch for trunk and 2.11.
(2.11 will need different indentation again.)

I'm not sure if we should also apply this in 2.10 and 2.9 - they have
the same behaviour, but OTOH I'm not sure if changing behaviour (even if
it's an improvement) in those old releases is a good idea.
Opinions?
2017-11-12 20:23:30 +01:00
Christian Boltz
fe1fb7caa3
Fix sorted() regression in save_profiles()
The last change in save_profiles() sorted() the order in which the
changed profiles get displayed. However, it did not honor the sorting
when displaying changes or saving the selected profile, leading to the
wrong profile displayed or saved.

This patch fixes picking the selected profile, and at the same time
replaces the duplicated code for doing this with a single instance.

I propose this patch for trunk and 2.11.
Note that the 2.11 branch needs a slightly different patch (different
indentation).

Also note that this regression made it into 2.11.1, so distributions
shipping 2.11.1 should add this patch.
2017-11-12 20:22:49 +01:00
Christian Boltz
7aeebcbb60 Keep JSON version at 2.12
We never did a release with the JSON code, and YaST (the only known user
of the JSON interface) will work with the added 'changes' dialog type
from r3721 without needing changes.

Also add a better comment/reason why a response for 'changes' is
expected, but gets ignored.


Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Acked-by: Steve Beattie <steve@nxnw.org>
2017-10-26 18:49:32 +02:00
Steve Beattie
62e91696ee utils: stop rewriting shbang lines in setup script
The python setup tools script is set to rewrite the shbang line of
scripts installed in ${PREFIX}/bin/ if the PYTHON environment variable
is set. Unfortunately, this (a) only covers the aa-easyprof script
as the rest are installed in ${PREFIX}/sbin/, and (b) we've deprecated
python 2 support, and hardcoded python3 as the interpreter for all of
the python scripts in the utils/ directory.

The only use for this feature would be if for some reason the utils did
not work properly with the default python3 interpreter and a specific
version was needed to be set, but I don't think that warrants keeping
the extra bit of code complexity around (and indeed, the snippet that
does this is forcibly disabled in Debian/Ubuntu).

Therefore, drop the shbang rewriting entirely.

Signed-off-by: Steve Beattie <steve@nxnw.org>
Acked-by: John Johansen <john.johansen@canonical.com>
2017-10-26 00:52:31 -07:00
Goldwyn Rodrigues
9a69ec2c48 [2/2] Add JSON interface to UI_Changes
Provides the filename in the json format, which can be
directly read by Yast. Increased the protocol version; perhaps
it should go in the next release.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>


[cboltz] fix "unused variable" warning and add a comment about ignoring
         the JSON response



Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-10-26 00:36:48 +02:00
Goldwyn Rodrigues
6ce2768115 [1/2] Introduce UI_Changes functions
This is a preparation patch to use for JSON mode of conveying
diff filename. In this patch we move diff generation functions to UI.
In the process, I have cleaned up the code to reduce code and enable reuse.

Remove unused function get_profile_diff().

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>


Acked-by: Christian Boltz <apparmor@cboltz.de>




[cboltz] Also adjust aa-mergeprof to the new function name/location

Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-10-26 00:34:40 +02:00
Goldwyn Rodrigues
4961fcb6ba Fix crash in serialize_profile_from_old_profile()
The crash was caused by the more strict ProfileStorage in bzr trunk
(older versions use hasher() which is more forgiving, but also very
 "useful" to hide quite some bugs)


Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-10-25 21:54:57 +02:00
intrigeri
a32a9aa6d1 Add python3.6 line to utils/logprof.conf.
Patch by Adam Conrad <adconrad@ubuntu.com>.
2017-10-23 16:31:25 +02:00
Christian Boltz
fce8d81d7f Fix save_profiles() for YaST
YaST has two issues in the "save changed profiles" dialog:
- when using "save selected", the list of profiles doesn't get updated.
  Update q.options inside the loop to fix this.
- the list of profiles is displayed as "["/usr/bin/foo", true]" instead
  of just "/usr/bin/foo". Use changed.keys() instead of changed to fix
  this. (text-mode aa-logprof doesn't change, it always displayed
  "/usr/bin/foo" and continues to do so.)

References: https://bugzilla.opensuse.org/show_bug.cgi?id=1062667 part a)


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.11.

Note that 2.11 needs a slightly different patch (whitespace diff).
2017-10-12 13:27:47 +02:00
Launchpad Translations on behalf of apparmor-dev
49ec85b4fa Launchpad automatic translations update. 2017-10-11 05:15:02 +00:00
Launchpad Translations on behalf of apparmor-dev
860c880454 Launchpad automatic translations update. 2017-10-10 05:13:52 +00:00
Steve Beattie
f2831c875e merge from apparmor trunk 2017-10-05 16:52:55 -07:00
Christian Boltz
347715da30 Add network 'smc' keyword in NetworkRule and apparmor.d manpage
'smc' seems to be new in kernel 4.12.


Note that the 2.10 apparmor.d manpage also misses the 'kcm' keyword, so
the patch also adds it there.


Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk, 2.11 and 2.10.
2017-08-30 11:06:19 +02:00
Christian Boltz
ae692bfb3b Drop 'log' parameter from ReadLog
This parameter is always [], so we can simplify the ReadLog __init__()
parameters.

Note that some tests handed over '' instead of []. This was a bug, but
didn't matter because those tests only use a small portion of ReadLog.


Acked-by: Seth Arnold <seth.arnold@canonical.com>
2017-08-28 23:15:51 +02:00