2
0
mirror of https://gitlab.com/apparmor/apparmor synced 2025-09-01 14:55:10 +00:00

Compare commits

...

94 Commits

Author SHA1 Message Date
John Johansen
7f72fd0fca Release: prepare for 2.12 release
update version and library version

Signed-off-by: John Johansen <john.johansen@canonical.com>
2017-12-24 00:48:31 -08:00
Steve Beattie
0b719e4f86 infrastructure: support make tarball for gitlab patch
This patch supports rolling a tarball for a release, as well as doing
'make tag'. Only stuff that's been committed should get incorporated
into the tarball.

Signed-off-by: John Johansen <john.johansen@canonical.com>
2017-12-24 00:31:34 -08: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
e55583ff27 profile: fix syslog-ng startup for some configurations
buglink: https://bugs.launchpad.net/bugs/1739909

Signed-off-by: John Johansen <john.johansen@canonical.com>
2017-12-24 00:13:58 -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
John Johansen
a3693f56f3 Merge branch 'cboltz-netstat' into 'master'
netstat: allow capability sys_ptrace,

See merge request apparmor/apparmor!46
2017-12-22 20:50:11 +00:00
Christian Boltz
81ca52d948 netstat: allow capability sys_ptrace,
Denying it means netstat -p (actually tested with -tulpen) can't find
out the program name.

sys_ptrace is "only" needed for tracing processes that run under a
different uid.

Also add  ptrace (read),  for systems that support ptrace rules.
2017-12-22 21:43:54 +01:00
John Johansen
4d8fb33335 Merge branch 'cboltz-regex-exception-msg' into 'master'
Improve exception message for #include rules

See merge request apparmor/apparmor!47


Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-22 20:42:47 +00: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
f8b208ee80 Merge branch 'cboltz-dovecot' into 'master'
Update /usr/lib/dovecot/* profiles

See merge request apparmor/apparmor!42

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-22 19:20:07 +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
John Johansen
f2a84e5f1d Merge branch 'cboltz-owner-buttons' into 'master'
Display "owner permissions on/off" buttons in aa-logprof

See merge request apparmor/apparmor!40

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-22 19:06:34 +00:00
John Johansen
bcfb735b9a Merge branch 'cboltz-xauth' into 'master'
abstractions/X: add another location for .Xauthority

See merge request apparmor/apparmor!39

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-22 19:00:36 +00:00
John Johansen
7159538fc8 Merge branch 'cboltz-libapparmor-revision' into 'master'
get libapparmor revision in sync with the 2.11.1 release

See merge request apparmor/apparmor!35

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-22 18:44:17 +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
Tyler Hicks
ebf0cfe838 Merge branch 'update-README-for-python' into 'master'
update README for python on (at least) Ubuntu systems. Setup thanks to tyhicks

See merge request apparmor/apparmor!45

Acked-by: Tyler Hicks <tyhicks@canonical.com>
2017-12-19 00:28:22 +00:00
Jamie Strandboge
b8195dad31 update README for python on (at least) Ubuntu systems. Setup thanks to tyhicks 2017-12-18 16:02:34 -06:00
Christian Boltz
c803c34558 Merge branch 'gitignore-additions' into 'master'
.gitignore additions for libapparmor tests, binutils, and the vim syntax highlighting files

See merge request apparmor/apparmor!43

Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-12-18 16:12:42 +00:00
Christian Boltz
06928db1ce Update /usr/lib/dovecot/* profiles
- dict needs abstractions/openssl (seen with dovecot 2.2.31 since
  using openssl 1.1)
- imap needs to write tempfiles (seen with dovecot 2.2.31)
- managesieve-login needs access to the login-master-notify socket
  (seen with dovecot 2.2.33)
- pop3-login needs access to the anvil socket (reported by pfak on
  IRC some months ago)
2017-12-18 17:00:35 +01:00
Tyler Hicks
426990cfaf .gitignore: Add files to ignore in utils/vim/
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-12-18 15:50:59 +00:00
Tyler Hicks
e325e74b0f .gitignore: Add files to ignore from libapparmor test runs
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-12-18 15:48:59 +00:00
Tyler Hicks
ba0cdbc013 .gitignore: Add files to ignore in binutils/
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-12-18 15:45:48 +00:00
Tyler Hicks
da6db0c2b9 Merge branch 'cboltz-gitignore' into 'master'
.gitignore: add several parser/**.o and utils/**.pyc files

See merge request apparmor/apparmor!37

Acked-by: Tyler Hicks <tyhicks@canonical.com>
2017-12-18 15:42:32 +00:00
Christian Boltz
566218612c remove unused UI_ask_mode_toggles() in aa.py 2017-12-17 17:38:46 +01:00
Christian Boltz
6713f9d94a Merge branch 'fix-pulse-config' into 'master'
Fix local pulseaudio config file access

See merge request apparmor/apparmor!38


Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.9..trunk
2017-12-17 16:19:42 +00:00
Christian Boltz
23220af3b9 .gitignore: add several parser/**.o and utils/**.pyc files
Also ignore parser/libapparmor_re/libapparmor_re.a and the utils
coverage report.
2017-12-17 16:55:10 +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
bb96e38a90 abstractions/X: add another location for .Xauthority
With the latest sddm, .Xauthority is now located at
  @{HOME}/.local/share/sddm/.Xauthority
2017-12-17 15:38:26 +01:00
Vincas Dargis
f73627cbb5 Fix local pulseaudio config file access
Add rules to allow reading .conf files from $HOME/.config/pulse
and $HOME/.config/pulse/client.conf.d directories.
2017-12-17 15:56:21 +02:00
Christian Boltz
6db30f8faf Merge branch 'dovecot-signals' into 'master'
Fix signal sending for usr.sbin.dovecot

See merge request apparmor/apparmor!36

Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.9..trunk
2017-12-16 17:26:08 +00:00
Vincas Dargis
9f24650ef9 Fix signal sending for usr.sbin.dovecot
Add signal rules to allow dovecot master daemon to send signals
to various child daemons (for reloading/restarting).
2017-12-15 18:17:48 +02:00
Christian Boltz
5653697df2 get libapparmor revision in sync with the 2.11.1 release
This commit applies the libapparmor revision set in bzr r3681 (2.11 branch)
  bump release version to 2.11.1
to the master branch.
2017-12-13 20:35:50 +01:00
Christian Boltz
861d8b4349 Update libapparmor testsuite profiles with owner rules
Several log examples result in rules where the 'owner' conditional
should be added. With logparser.py fixed to handle owner-only events, we
need to add the owner conditional to several test_multi/*.profile files.

I verified all log files for the changed profiles and made sure that
- the log line contains fsuid= and ouid=
- fsuid == ouid

I also did a quick check on all log events containing ouid= and for
those with fsuid == ouid, I checked that the profile has the owner
conditional.

Acked-by: Seth Arnold <seth.arnold@canonical.com> for trunk and 2.11
(see mail from 2017-07-31)
2017-12-13 20:19:06 +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
John Johansen
a5e5185e15 Merge branch 'cboltz-useradd' into 'master'
useradd profile: allow audit_write and running pam_tally2

See merge request apparmor/apparmor!24

Acked-by: John Johansen <john.johansen@canonical.com>
2017-12-12 22:38:24 +00:00
Christian Boltz
b24a1c4d54 Merge branch 'zumbi:master' into 'master'
apparmor: support usrmerge in parser simpe_tests

See merge request apparmor/apparmor!33

Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-12-10 15:44:16 +00:00
Héctor Orón Martínez
26431478a6 apparmor: support usrmerge
Allow binaries in /bin to run from /usr/bin as well.
For more information on usrmerge, see
https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/

Signed-off-by: Héctor Orón Martínez <hector.oron@collabora.co.uk>
2017-12-09 23:56:58 +01:00
intrigeri
dcefc1baa4 Update ubuntu-email abstraction for new Thunderbird executable path
See merge request apparmor/apparmor!32

Signed-off-by: Vincas Dargis <vindrg@gmail.com>
Acked-By: intrigeri <intrigeri@boum.org>
2017-12-07 17:06:09 +00:00
Vincas Dargis
7546413b43 Update abstraction for new Thunderbird executable path
* Add -bin suffix to reach new Thunderbird executable.
2017-12-07 16:41:10 +00:00
Jamie Strandboge
c69acb81c9 Merge branch 'update-fonts-abstraction' into 'master'
abstractions/fonts: also allow owner read on ~/.local/share/fonts

See merge request apparmor/apparmor!31
2017-12-06 13:55:14 +00:00
Jamie Strandboge
c4a5e1d554 abstractions/fonts: also allow owner read on ~/.local/share/fonts
The fonts abstraction had owner rules for ~/.fonts, but the current
standard location[1][2] in XDG_DATA_HOME was missing.

[1]https://cgit.freedesktop.org/fontconfig/commit/?id=8c255fb1
[2]https://lists.freedesktop.org/archives/fontconfig/2014-July/005270.html
2017-12-05 15:49:55 -06: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
4b72ba29ed Merge branch 'utils-check-depends-on-parser' into 'master'
Utils check depends on parser

See merge request apparmor/apparmor!25

Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-12-05 17:39:07 +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
5bdacd2432 README: Document that the parser should be built before the utils
The utils have tests that rely on the in-tree parser to be built so it
should be documented that the parser should be built first.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-12-04 23:10:03 +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
13b1c7a5f6 useradd profile: allow audit_write and running pam_tally2
Both seen on openSUSE Leap 42.2
2017-12-04 11:06:09 +01: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
ca983811fb dovecot: allow capability dac_read_search
Merge branch 'cboltz-dovecot-caps' into 'master'

See merge request 
https://gitlab.com/apparmor/apparmor/merge_requests/16
2017-12-01 20:40:29 +00: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
3d40bc6f23 Merge branch 'cboltz-remove-unknown-newline' into 'master'
Don't print a literal '\n' in aa-remove-unknown help

See merge request apparmor/apparmor!21

Acked-by: Tyler Hicks tyhicks@canonical.com for 2.9..trunk
2017-12-01 10:09:28 +00:00
Christian Boltz
4d4228d157 Don't print a literal '\n' in aa-remove-unknown help 2017-12-01 00:26:56 +01:00
Steve Beattie
2aabf0c0f0 Update Java abstraction for version 8 and 9
Merge branch 'update-java' into 'master'

I have discovered denies on Debian Sid by Thunderbird being unable to load IcedTead plugin upon profile creation (can be reproduced by deleteing/moving `$HOME/.thunderbird` directory).

Additionally, profile was tested with (modified) `usr.lib.firefox.firefox` and made it run some random IcedTea applet successfully [0].

There are still denies for `/usr/bin/logger`, but I left this for later patches.

Please note that path to Java 9 binary is different that to previous versions.

Relevant DENIED messages:

```
type=AVC msg=audit(1511099962.556:810): apparmor="DENIED" operation="file_mmap" profile="thunderbird" name="/usr/lib/jvm/java-8-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so" pid=5186 comm="thunderbird" requested_mask="m" denied_mask="m" fsuid=1000 ouid=0
type=SYSCALL msg=audit(1511099962.556:810): arch=c000003e syscall=9 success=no exit=-13 a0=0 a1=296bc8 a2=5 a3=802 items=0 ppid=1541 pid=5186 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=3 comm="thunderbird" exe="/usr/lib/thunderbird/thunderbird" key=(null)
type=PROCTITLE msg=audit(1511099962.556:810): proctitle="/usr/lib/thunderbird/thunderbird"
```

```
type=AVC msg=audit(1511100105.471:1018): apparmor="DENIED" operation="open" profile="/usr/lib/firefox{,-esr}/firefox{,-esr}{,*[^s][^h]}//browser_openjdk" name="/run/user/1000/icedteaplugin-vincas-gHIeGy/6064-icedteanp-plugin-debug-to-appletviewer" pid=6073 comm="java" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
type=SYSCALL msg=audit(1511100105.471:1018): arch=c000003e syscall=2 success=no exit=-13 a0=7f3638000cb0 a1=0 a2=1b6 a3=7f36ae502620 items=0 ppid=6064 pid=6073 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=3 comm="java" exe="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" key=(null)
type=PROCTITLE msg=audit(1511100105.471:1018): proctitle=2F7573722F6C69622F6A766D2F6A6176612D382D6F70656E6A646B2D616D6436342F62696E2F6A617661002D44696365647465612D7765622E62696E2E6C6F636174696F6E3D2F7573722F62696E2F6A6176617773002D44696365647465612D7765622E62696E2E6E616D653D6A6176617773002D58626F6F74636C61737370
```

```
type=AVC msg=audit(1511100105.471:1019): apparmor="DENIED" operation="open" profile="/usr/lib/firefox{,-esr}/firefox{,-esr}{,*[^s][^h]}//browser_openjdk" name="/run/user/1000/icedteaplugin-vincas-gHIeGy/6064-icedteanp-plugin-to-appletviewer" pid=6073 comm="java" requested_mask="r" denied_mask="r" fsuid=1000 ouid=1000
type=SYSCALL msg=audit(1511100105.471:1019): arch=c000003e syscall=2 success=no exit=-13 a0=7f36a822bdc0 a1=0 a2=1b6 a3=10002ae08 items=0 ppid=6064 pid=6073 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=3 comm="java" exe="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" key=(null)
type=PROCTITLE msg=audit(1511100105.471:1019): proctitle=2F7573722F6C69622F6A766D2F6A6176612D382D6F70656E6A646B2D616D6436342F62696E2F6A617661002D44696365647465612D7765622E62696E2E6C6F636174696F6E3D2F7573722F62696E2F6A6176617773002D44696365647465612D7765622E62696E2E6E616D653D6A6176617773002D58626F6F74636C61737370
```

```
type=AVC msg=audit(1511100221.153:1132): apparmor="DENIED" operation="open" profile="/usr/lib/firefox{,-esr}/firefox{,-esr}{,*[^s][^h]}//browser_openjdk" name="/run/user/1000/icedteaplugin-vincas-JY8Sat/6405-icedteanp-appletviewer-to-plugin" pid=6414 comm="java" requested_mask="wc" denied_mask="wc" fsuid=1000 ouid=1000
type=SYSCALL msg=audit(1511100221.153:1132): arch=c000003e syscall=2 success=no exit=-13 a0=7f20e025e280 a1=241 a2=1b6 a3=10002ae08 items=0 ppid=6405 pid=6414 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=3 comm="java" exe="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java" key=(null)
type=PROCTITLE msg=audit(1511100221.153:1132): proctitle=2F7573722F6C69622F6A766D2F6A6176612D382D6F70656E6A646B2D616D6436342F62696E2F6A617661002D44696365647465612D7765622E62696E2E6C6F636174696F6E3D2F7573722F62696E2F6A6176617773002D44696365647465612D7765622E62696E2E6E616D653D6A6176617773002D58626F6F74636C61737370
```

[0] https://centra.tecnico.ulisboa.pt/~amaro/Spline3D.html

See merge request https://gitlab.com/apparmor/apparmor/merge_requests/13/
2017-11-29 23:41:42 +00:00
Christian Boltz
014695786c Merge branch 'cboltz-gitignore' into 'master'
.gitignore: add several libapparmor *.o files

See merge request apparmor/apparmor!18

Acked-by: Tyler Hicks <tyhicks@canonical.com>
2017-11-28 22:08:00 +00:00
Christian Boltz
794d1c4a07 Merge branch 'cboltz-double-read-inactive' into 'master'
Let read_inactive_profiles() do nothing when calling it the second time

See merge request apparmor/apparmor!17
2017-11-28 21:55:17 +00:00
Christian Boltz
d7ffc37011 .gitignore: add several libapparmor *.o files 2017-11-28 22:49:53 +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
4ef505a6e7 dovecot: allow capability dac_read_search
This is needed for /var/spool/postfix/private/ (postfix:root 700)

References: https://bugzilla.opensuse.org/show_bug.cgi?id=1069470#c9
2017-11-28 18:47:26 +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
42bd81df01 Merge branch 'cboltz-dovecot-auth' into 'master'
allow dac_read_search and dac_override for dovecot/auth

See merge request apparmor/apparmor!14


Acked-by: Seth Arnold <seth.arnold@canonical.com> for 2.9, 2.10, 2.11 and trunk
2017-11-27 21:36:30 +00:00
Christian Boltz
6f6b3c57fb allow dac_read_search and dac_override for dovecot/auth
This is needed for:
- /var/spool/postfix/private/ (postfix:root 700) -> dac_read_search
- /run/dovecot/auth-worker (dovecot:root 600) -> dac_override

References: https://bugzilla.opensuse.org/show_bug.cgi?id=1069470
2017-11-26 16:38:06 +01:00
Vincas Dargis
d662c2be72 Update Java abstraction for version 8 and up
* Alter paths to allow Java version 8 and up.
* Add file rules to fix IcedTea browser plugin.
* Refactor to keep path consistensy against parent and child profile,
reduce repetitive rules.
2017-11-25 16:04:24 +02:00
Christian Boltz
4b8b08562a Merge branch 'patch-1' into 'master'
Allow to read pulseaudio config subdirectories

See merge request apparmor/apparmor!12


Acked-by: Christian Boltz <apparmor@cboltz.de> for 2.9, 2.10, 2.11 and trunk
2017-11-18 17:24:24 +00:00
Vincas Dargis
9658471d38 Allow to read pulseaudio config subdirectories
Fixes denied "/etc/pulse/client.conf.d/00-disable-autospawn.conf" read on Debian Sid
2017-11-18 14:20:07 +00:00
Christian Boltz
852d26de6c Merge branch 'utils_save_profiles' into 'master'
utils: fix and improve "save profiles"

See merge request apparmor/apparmor!10


Acked-by: Tyler Hicks <tyhicks@canonical.com> for master and 2.11
2017-11-14 20:03:15 +00: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
21bc71e576 Merge branch 'google-chrome-unstable' into 'master'
ubuntu-browsers, ubuntu-helpers: add support for Google Chrome unstable (LP: #1730536).

See merge request apparmor/apparmor!9


Acked-by: Christian Boltz <apparmor@cboltz.de>
2017-11-12 18:41:18 +00:00
intrigeri
2b02d7df83 ubuntu-browsers, ubuntu-helpers: add support for Google Chrome unstable (LP: #1730536). 2017-11-12 13:39:54 +00:00
John Johansen
543a6a6fed Merge branch 'google-chrome-beta' into 'master'
ubuntu-browsers, ubuntu-helpers: add support for Google Chrome beta

See merge request apparmor/apparmor!7

Acked-by: John Johansen <john@jjmx.net>
2017-11-05 19:13:34 +00:00
intrigeri
92752f56da ubuntu-browsers, ubuntu-helpers: add support for Google Chrome beta
Bug-Debian: https://bugs.debian.org/880923
2017-11-05 18:55:23 +00:00
John Johansen
745aa4d342 Merge branch 'regression-test-warnings' into 'master'
Fix regression test build warnings

See merge request apparmor/apparmor!2

Acked-by: John Johansen <john@jjmx.net>
2017-11-03 20:57:47 +00:00
Tyler Hicks
aa05cbdd1e Fix regression test build warnings 2017-11-03 20:57:46 +00:00
John Johansen
ddbf6c24bb Merge branch 'cscope' into 'master'
gitignore: Add cscope files to ignored list

See merge request apparmor/apparmor!3
2017-11-03 20:51:32 +00:00
John Johansen
51764eda98 Merge branch 'unref-errno' into 'master'
libapparmor: Preserve errno across aa_*_unref() functions

See merge request apparmor/apparmor!6


Acked-by: John Johansen <john@jjmx.net>
2017-11-03 20:36:40 +00:00
John Johansen
59a5bc088c Merge branch 'kernel-interface-man-typos' into 'master'
libapparmor: Fix typos in aa_kernel_interface(3) man page

See merge request apparmor/apparmor!5
2017-11-03 20:20:42 +00:00
Tyler Hicks
b813beeb1b libapparmor: Fix typos in aa_kernel_interface(3) man page
The RETURN VALUE section contained two typos where "kernel_features" was
used instead of "kernel_interface".

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-11-03 15:38:54 +00:00
Tyler Hicks
7fad3512f0 libapparmor: Preserve errno across aa_*_unref() functions
Callers of aa_features_unref(), aa_kernel_interface_unref(), and
aa_policy_cache_unref() had to store off errno and restore it after
calling those functions in error paths. This patch preserves errno
across those *_unref() functions so that callers don't have to.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-11-03 15:34:26 +00:00
Tyler Hicks
29c5c6b621 gitignore: Add cscope files to ignored list
Ignoring cscope.* files allows users of cscope to not be bothered by
`git status` reporting that an unknown file is in the source tree.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-11-02 16:40:09 +00:00
Seth Arnold
56394f8def Merge branch 'make-variable' into 'master'
all: Use the MAKE variable

See merge request apparmor/apparmor!1
2017-11-02 00:38:48 +00:00
Tyler Hicks
19c6c3310b all: Use the MAKE variable
https://www.gnu.org/software/make/manual/html_node/MAKE-Variable.html

We should be using the $(MAKE) variable when calling the make command
from Makefiles since we use Makefile recursion.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
2017-11-01 23:22:53 +00:00
Steve Beattie
29b20fd688 git conversion: move .bzrignore to .gitignore
Signed-off-by: Steve Beattie <steve.beattie@canonical.com>
2017-10-27 22:46:03 -07:00
69 changed files with 587 additions and 194 deletions

View File

@@ -1,4 +1,10 @@
apparmor-*
cscope.*
binutils/aa-enabled
binutils/aa-enabled.1
binutils/aa-exec
binutils/aa-exec.1
binutils/po/*.mo
parser/po/*.mo
parser/af_names.h
parser/cap_names.h
@@ -13,6 +19,37 @@ parser/parser_version.h
parser/parser_yacc.c
parser/parser_yacc.h
parser/pod2htm*.tmp
parser/af_rule.o
parser/af_unix.o
parser/common_optarg.o
parser/dbus.o
parser/lib.o
parser/libapparmor_re/aare_rules.o
parser/libapparmor_re/chfa.o
parser/libapparmor_re/expr-tree.o
parser/libapparmor_re/hfa.o
parser/libapparmor_re/libapparmor_re.a
parser/libapparmor_re/parse.o
parser/mount.o
parser/network.o
parser/parser_alias.o
parser/parser_common.o
parser/parser_include.o
parser/parser_interface.o
parser/parser_lex.o
parser/parser_main.o
parser/parser_merge.o
parser/parser_misc.o
parser/parser_policy.o
parser/parser_regex.o
parser/parser_symtab.o
parser/parser_variable.o
parser/parser_yacc.o
parser/policy_cache.o
parser/profile.o
parser/ptrace.o
parser/rule.o
parser/signal.o
parser/*.7
parser/*.5
parser/*.8
@@ -60,14 +97,22 @@ libraries/libapparmor/src/Makefile.in
libraries/libapparmor/src/af_protos.h
libraries/libapparmor/src/change_hat.lo
libraries/libapparmor/src/features.lo
libraries/libapparmor/src/features.o
libraries/libapparmor/src/grammar.lo
libraries/libapparmor/src/grammar.o
libraries/libapparmor/src/kernel.lo
libraries/libapparmor/src/kernel.o
libraries/libapparmor/src/kernel_interface.lo
libraries/libapparmor/src/kernel_interface.o
libraries/libapparmor/src/libaalogparse.lo
libraries/libapparmor/src/libaalogparse.o
libraries/libapparmor/src/libimmunix_warning.lo
libraries/libapparmor/src/policy_cache.lo
libraries/libapparmor/src/policy_cache.o
libraries/libapparmor/src/private.lo
libraries/libapparmor/src/private.o
libraries/libapparmor/src/scanner.lo
libraries/libapparmor/src/scanner.o
libraries/libapparmor/src/libapparmor.pc
libraries/libapparmor/src/libapparmor.la
libraries/libapparmor/src/libimmunix.la
@@ -75,7 +120,19 @@ libraries/libapparmor/src/grammar.c
libraries/libapparmor/src/grammar.h
libraries/libapparmor/src/scanner.c
libraries/libapparmor/src/scanner.h
libraries/libapparmor/src/test-suite.log
libraries/libapparmor/src/tst_aalogmisc
libraries/libapparmor/src/tst_aalogmisc.log
libraries/libapparmor/src/tst_aalogmisc.o
libraries/libapparmor/src/tst_aalogmisc.trs
libraries/libapparmor/src/tst_features
libraries/libapparmor/src/tst_features.log
libraries/libapparmor/src/tst_features.o
libraries/libapparmor/src/tst_features.trs
libraries/libapparmor/src/tst_kernel
libraries/libapparmor/src/tst_kernel.log
libraries/libapparmor/src/tst_kernel.o
libraries/libapparmor/src/tst_kernel.trs
libraries/libapparmor/swig/Makefile
libraries/libapparmor/swig/Makefile.in
libraries/libapparmor/swig/perl/LibAppArmor.bs
@@ -89,6 +146,7 @@ libraries/libapparmor/swig/perl/MYMETA.json
libraries/libapparmor/swig/perl/MYMETA.yml
libraries/libapparmor/swig/perl/blib
libraries/libapparmor/swig/perl/libapparmor_wrap.c
libraries/libapparmor/swig/perl/libapparmor_wrap.o
libraries/libapparmor/swig/perl/pm_to_blib
libraries/libapparmor/swig/python/LibAppArmor.py
libraries/libapparmor/swig/python/build/
@@ -98,6 +156,10 @@ libraries/libapparmor/swig/python/Makefile.in
libraries/libapparmor/swig/python/setup.py
libraries/libapparmor/swig/python/test/Makefile
libraries/libapparmor/swig/python/test/Makefile.in
libraries/libapparmor/swig/python/test/test-suite.log
libraries/libapparmor/swig/python/test/test_python.py
libraries/libapparmor/swig/python/test/test_python.py.log
libraries/libapparmor/swig/python/test/test_python.py.trs
libraries/libapparmor/swig/ruby/Makefile
libraries/libapparmor/swig/ruby/Makefile.in
libraries/libapparmor/testsuite/.deps
@@ -115,6 +177,7 @@ libraries/libapparmor/testsuite/lib/Makefile.in
libraries/libapparmor/testsuite/libaalogparse.test/Makefile
libraries/libapparmor/testsuite/libaalogparse.test/Makefile.in
libraries/libapparmor/testsuite/test_multi/out
libraries/libapparmor/testsuite/test_multi_multi-test_multi.o
changehat/mod_apparmor/.libs
utils/*.8
utils/*.8.html
@@ -122,6 +185,14 @@ utils/*.5
utils/*.5.html
utils/*.tmp
utils/po/*.mo
utils/apparmor/*.pyc
utils/apparmor/rule/*.pyc
utils/test/.coverage
utils/test/htmlcov/
utils/vim/apparmor.vim
utils/vim/apparmor.vim.5
utils/vim/apparmor.vim.5.html
utils/vim/pod2htmd.tmp
tests/regression/apparmor/access
tests/regression/apparmor/changehat
tests/regression/apparmor/changehat_fail

View File

@@ -17,12 +17,9 @@ DIRS=libraries/libapparmor \
profiles \
tests
#REPO_URL?=lp:apparmor
# --per-file-timestamps is failing over SSH, https://bugs.launchpad.net/bzr/+bug/1257078
REPO_URL?=https://code.launchpad.net/~apparmor-dev/apparmor/master
# alternate possibilities to export from
#REPO_URL=.
#REPO_URL="bzr+ssh://bazaar.launchpad.net/~sbeattie/+junk/apparmor-dev/"
# with conversion to git, we don't export from the remote
REPO_URL?=git@gitlab.com:apparmor/apparmor.git
REPO_BRANCH?=master
COVERITY_DIR=cov-int
RELEASE_DIR=apparmor-${VERSION}
@@ -31,7 +28,9 @@ __SETUP_DIR?=.
# We create a separate version for tags because git can't handle tags
# with embedded ~s in them. No spaces around '-' or they'll get
# embedded in ${VERSION}
TAG_VERSION=$(subst ~,-,${VERSION})
# apparmor version tag format 'vX.Y.ZZ'
# apparmor branch name format 'apparmor-X.Y'
TAG_VERSION="v$(subst ~,-,${VERSION})"
# Add exclusion entries arguments for tar here, of the form:
# --exclude dir_to_exclude --exclude other_dir
@@ -40,49 +39,48 @@ TAR_EXCLUSIONS=
.PHONY: tarball
tarball: clean
REPO_VERSION=`$(value REPO_VERSION_CMD)` && \
make export_dir __EXPORT_DIR=${RELEASE_DIR} __REPO_VERSION=$${REPO_VERSION} && \
make setup __SETUP_DIR=${RELEASE_DIR} && \
$(MAKE) export_dir __EXPORT_DIR=${RELEASE_DIR} __REPO_VERSION=$${REPO_VERSION} && \
$(MAKE) setup __SETUP_DIR=${RELEASE_DIR} && \
tar ${TAR_EXCLUSIONS} -cvzf ${RELEASE_DIR}.tar.gz ${RELEASE_DIR}
.PHONY: snapshot
snapshot: clean
$(eval REPO_VERSION:=$(shell $(value REPO_VERSION_CMD)))
$(eval SNAPSHOT_NAME=apparmor-$(VERSION)~$(REPO_VERSION))
make export_dir __EXPORT_DIR=${SNAPSHOT_NAME} __REPO_VERSION=${REPO_VERSION} && \
make setup __SETUP_DIR=${SNAPSHOT_NAME} && \
$(eval SNAPSHOT_NAME=apparmor-$(VERSION)~$(shell echo $(REPO_VERSION) | cut -d '-' -f 2-))
$(MAKE) export_dir __EXPORT_DIR=${SNAPSHOT_NAME} __REPO_VERSION=${REPO_VERSION} && \
$(MAKE) setup __SETUP_DIR=${SNAPSHOT_NAME} && \
tar ${TAR_EXCLUSIONS} -cvzf ${SNAPSHOT_NAME}.tar.gz ${SNAPSHOT_NAME}
.PHONY: coverity
coverity: snapshot
cd $(SNAPSHOT_NAME)/libraries/libapparmor && ./configure --with-python
$(foreach dir, $(filter-out utils profiles tests, $(DIRS)), \
cov-build --dir $(COVERITY_DIR) -- make -C $(SNAPSHOT_NAME)/$(dir);)
cov-build --dir $(COVERITY_DIR) -- $(MAKE) -C $(SNAPSHOT_NAME)/$(dir);)
tar -cvzf $(SNAPSHOT_NAME)-$(COVERITY_DIR).tar.gz $(COVERITY_DIR)
.PHONY: export_dir
export_dir:
mkdir $(__EXPORT_DIR)
/usr/bin/bzr export --per-file-timestamps -r $(__REPO_VERSION) $(__EXPORT_DIR) $(REPO_URL)
echo "$(REPO_URL) $(__REPO_VERSION)" > $(__EXPORT_DIR)/common/.stamp_rev
/usr/bin/git archive --prefix=$(__EXPORT_DIR)/ --format tar $(__REPO_VERSION) | tar xv
echo "$(REPO_URL) $(REPO_BRANCH) $(__REPO_VERSION)" > $(__EXPORT_DIR)/common/.stamp_rev
.PHONY: clean
clean:
-rm -rf ${RELEASE_DIR} ./apparmor-${VERSION}~* ${COVERITY_DIR}
for dir in $(DIRS); do \
make -C $$dir clean; \
$(MAKE) -C $$dir clean; \
done
.PHONY: setup
setup:
cd $(__SETUP_DIR)/libraries/libapparmor && ./autogen.sh
# parser has an extra doc to build
make -C $(__SETUP_DIR)/parser extra_docs
$(MAKE) -C $(__SETUP_DIR)/parser extra_docs
# libraries/libapparmor needs configure to have run before
# building docs
$(foreach dir, $(filter-out libraries/libapparmor tests, $(DIRS)), \
make -C $(__SETUP_DIR)/$(dir) docs;)
$(MAKE) -C $(__SETUP_DIR)/$(dir) docs;)
.PHONY: tag
tag:
bzr tag apparmor_${TAG_VERSION}
git tag -m 'AppArmor $(VERSION)' -s $(TAG_VERSION)

21
README
View File

@@ -57,7 +57,14 @@ Building and Installing AppArmor Userspace
------------------------------------------
To build and install AppArmor userspace on your system, build and install in
the following order.
the following order. Some systems may need to export various python-related
environment variables to complete the build. For example, before building
anything on these systems, use something along the lines of:
$ export PYTHONPATH=$(realpath libraries/libapparmor/swig/python)
$ export PYTHON=/usr/bin/python3
$ export PYTHON_VERSION=3
$ export PYTHON_VERSIONS=python3
libapparmor:
@@ -79,16 +86,16 @@ $ make check
$ make install
Utilities:
$ cd utils
$ make
parser:
$ cd parser
$ make # depends on libapparmor having been built first
$ make check
$ make install
parser:
$ cd parser
$ make # depends on libapparmor having been built first
Utilities:
$ cd utils
$ make
$ make check
$ make install

View File

@@ -114,7 +114,7 @@ $(LIBAPPARMOR_A):
echo "error: $@ is missing. Pick one of these possible solutions:" 1>&2; \
echo " 1) Build against the in-tree libapparmor by building it first and then trying again. See the top-level README for help." 1>&2; \
echo " 2) Build against the system libapparmor by adding USE_SYSTEM=1 to your make command." 1>&2;\
return 1; \
exit 1; \
fi
endif

View File

@@ -8,14 +8,14 @@ msgstr ""
"Project-Id-Version: apparmor\n"
"Report-Msgid-Bugs-To: AppArmor list <apparmor@lists.ubuntu.com>\n"
"POT-Creation-Date: 2015-11-28 10:23-0800\n"
"PO-Revision-Date: 2017-03-31 10:44+0000\n"
"Last-Translator: Tobias Bannert <tobannert@gmail.com>\n"
"PO-Revision-Date: 2017-12-21 12:20+0000\n"
"Last-Translator: Christian Boltz <Unknown>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2017-04-05 05:23+0000\n"
"X-Generator: Launchpad (build 18335)\n"
"X-Launchpad-Export-Date: 2017-12-22 05:12+0000\n"
"X-Generator: Launchpad (build 18521)\n"
"Language: de\n"
#: ../aa_enabled.c:26
@@ -26,6 +26,10 @@ msgid ""
" -q | --quiet Don't print out any messages\n"
" -h | --help Print help\n"
msgstr ""
"%s: [Optionen]\n"
" Optionen:\n"
" -q | --quiet Keine Nachrichten anzeigen\n"
" -h | --help Hilfetext anzeigen\n"
#: ../aa_enabled.c:45
#, c-format
@@ -61,6 +65,7 @@ msgstr ""
#, c-format
msgid "Maybe - insufficient permissions to determine availability.\n"
msgstr ""
"Vielleicht - ungenügende Berechtigungen, um die Verfügbarkeit zu prüfen\n"
#: ../aa_enabled.c:84
#, c-format

View File

@@ -87,7 +87,7 @@ docs: ${MANPAGES} ${HTMLMANPAGES}
install: ${TARGET} ${MANPAGES}
mkdir -p ${DESTDIR}/${APXS_INSTALL_DIR}
install -m 755 $< ${DESTDIR}/${APXS_INSTALL_DIR}
make install_manpages DESTDIR=${DESTDIR}
$(MAKE) install_manpages DESTDIR=${DESTDIR}
.PHONY: clean
clean: pod_clean

View File

@@ -42,10 +42,9 @@ endif
define nl
endef
REPO_VERSION_CMD=[ -x /usr/bin/bzr ] && /usr/bin/bzr version-info --custom --template="{revno}" . 2> /dev/null || awk '{ print $2 }' common/.stamp_rev
REPO_VERSION_CMD=[ -x /usr/bin/git ] && /usr/bin/git describe --tags --long --abbrev=16 --match 'v*' 2> /dev/null || awk '{ print $2 }' common/.stamp_rev
ifndef PYTHON_VERSIONS
PYTHON_VERSIONS = $(call map, pathsearch, python2 python3)

View File

@@ -1 +1 @@
2.11.95
2.12

View File

@@ -136,6 +136,9 @@ I<aa_features> family of functions that return -1 on error.
All aa_features functions described above are present in libapparmor version
2.10 and newer.
aa_features_unref() saves the value of errno when called and restores errno
before exiting in libapparmor version 2.12 and newer.
=head1 BUGS
None known. If you find any, please report them at

View File

@@ -133,7 +133,7 @@ I<*kernel_interface> will point to an I<aa_kernel_interface> object that must
be freed by aa_kernel_interface_unref(). -1 is returned on error, with errno
set appropriately, and I<*kernel_interface> will be set to NULL.
aa_kernel_features_ref() returns the value of I<kernel_features>.
aa_kernel_interface_ref() returns the value of I<kernel_interface>.
The aa_kernel_interface_load() family of functions, the
aa_kernel_interface_replace() family of functions,
@@ -150,6 +150,9 @@ I<aa_kernel_interface> family of functions that return -1 on error.
All aa_kernel_interface functions described above are present in libapparmor
version 2.10 and newer.
aa_kernel_interface_unref() saves the value of errno when called and restores
errno before exiting in libapparmor version 2.12 and newer.
=head1 BUGS
None known. If you find any, please report them at

View File

@@ -112,6 +112,9 @@ I<aa_policy_cache> family of functions that return -1 on error.
All aa_policy_cache functions described above are present in libapparmor
version 2.10 and newer.
aa_policy_cache_unref() saves the value of errno when called and restores errno
before exiting in libapparmor version 2.12 and newer.
=head1 BUGS
None known. If you find any, please report them at

View File

@@ -27,7 +27,7 @@ INCLUDES = $(all_includes)
# http://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html
#
AA_LIB_CURRENT = 5
AA_LIB_REVISION = 0
AA_LIB_REVISION = 2
AA_LIB_AGE = 4
SUFFIXES = .pc.in .pc

View File

@@ -404,10 +404,7 @@ int aa_features_new(aa_features **features, int dirfd, const char *path)
load_features_dir(dirfd, path, f->string, STRING_SIZE) :
load_features_file(dirfd, path, f->string, STRING_SIZE);
if (retval == -1) {
int save = errno;
aa_features_unref(f);
errno = save;
return -1;
}
@@ -482,8 +479,12 @@ aa_features *aa_features_ref(aa_features *features)
*/
void aa_features_unref(aa_features *features)
{
int save = errno;
if (features && atomic_dec_and_test(&features->ref_count))
free(features);
errno = save;
}
/**

View File

@@ -229,10 +229,7 @@ int aa_kernel_interface_new(aa_kernel_interface **kernel_interface,
if (kernel_features) {
aa_features_ref(kernel_features);
} else if (aa_features_new_from_kernel(&kernel_features) == -1) {
int save = errno;
aa_kernel_interface_unref(ki);
errno = save;
return -1;
}
ki->supports_setload = aa_features_supports(kernel_features, set_load);
@@ -240,11 +237,8 @@ int aa_kernel_interface_new(aa_kernel_interface **kernel_interface,
if (!apparmorfs) {
if (find_iface_dir(&alloced_apparmorfs) == -1) {
int save = errno;
alloced_apparmorfs = NULL;
aa_kernel_interface_unref(ki);
errno = save;
return -1;
}
/* alloced_apparmorfs will be autofree'ed */
@@ -253,10 +247,7 @@ int aa_kernel_interface_new(aa_kernel_interface **kernel_interface,
ki->dirfd = open(apparmorfs, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (ki->dirfd < 0) {
int save = errno;
aa_kernel_interface_unref(ki);
errno = save;
return -1;
}
@@ -283,12 +274,16 @@ aa_kernel_interface *aa_kernel_interface_ref(aa_kernel_interface *kernel_interfa
*/
void aa_kernel_interface_unref(aa_kernel_interface *kernel_interface)
{
int save = errno;
if (kernel_interface &&
atomic_dec_and_test(&kernel_interface->ref_count)) {
if (kernel_interface->dirfd >= 0)
close(kernel_interface->dirfd);
free(kernel_interface);
}
errno = save;
}
/**

View File

@@ -159,8 +159,6 @@ int aa_policy_cache_new(aa_policy_cache **policy_cache,
open:
pc->dirfd = openat(dirfd, path, O_RDONLY | O_CLOEXEC | O_DIRECTORY);
if (pc->dirfd < 0) {
int save;
/* does the dir exist? */
if (create && errno == ENOENT) {
if (mkdirat(dirfd, path, 0700) == 0)
@@ -172,28 +170,20 @@ open:
PDEBUG("Cache directory '%s' does not exist\n", path);
}
save = errno;
aa_policy_cache_unref(pc);
errno = save;
return -1;
}
if (kernel_features) {
aa_features_ref(kernel_features);
} else if (aa_features_new_from_kernel(&kernel_features) == -1) {
int save = errno;
aa_policy_cache_unref(pc);
errno = save;
return -1;
}
pc->kernel_features = kernel_features;
if (init_cache_features(pc, kernel_features, create)) {
int save = errno;
aa_policy_cache_unref(pc);
errno = save;
return -1;
}
@@ -220,6 +210,8 @@ aa_policy_cache *aa_policy_cache_ref(aa_policy_cache *policy_cache)
*/
void aa_policy_cache_unref(aa_policy_cache *policy_cache)
{
int save = errno;
if (policy_cache && atomic_dec_and_test(&policy_cache->ref_count)) {
aa_features_unref(policy_cache->features);
aa_features_unref(policy_cache->kernel_features);
@@ -227,6 +219,8 @@ void aa_policy_cache_unref(aa_policy_cache *policy_cache)
close(policy_cache->dirfd);
free(policy_cache);
}
errno = save;
}
/**

View File

@@ -1,4 +1,4 @@
/usr/sbin/cupsd {
/boot/ r,
owner /boot/ r,
}

View File

@@ -1,4 +1,4 @@
/home/ubuntu/bzr/apparmor/tests/regression/apparmor/mkdir {
/tmp/sdtest.7283-14445-r31VAP/tmpdir/ w,
owner /tmp/sdtest.7283-14445-r31VAP/tmpdir/ w,
}

View File

@@ -1,4 +1,4 @@
/home/ubuntu/bzr/apparmor/tests/regression/apparmor/link {
/tmp/sdtest.19088-12382-HWH57d/linkfile l,
owner /tmp/sdtest.19088-12382-HWH57d/linkfile l,
}

View File

@@ -1,4 +1,4 @@
"/home/steve/tmp/my prog.sh" {
"/home/steve/tmp/my prog.sh" r,
owner "/home/steve/tmp/my prog.sh" r,
}

View File

@@ -1,4 +1,4 @@
profile "test space" {
/lib/x86_64-linux-gnu/libdl-2.13.so r,
owner /lib/x86_64-linux-gnu/libdl-2.13.so r,
}

View File

@@ -1,4 +1,4 @@
/home/ubuntu/bzr/apparmor/tests/regression/apparmor/link {
/tmp/sdtest.19088-12382-HWH57d/linkfile l,
owner /tmp/sdtest.19088-12382-HWH57d/linkfile l,
}

View File

@@ -1,4 +1,4 @@
/usr/sbin/vsftpd {
/home/bane/foo r,
owner /home/bane/foo r,
}

View File

@@ -179,7 +179,7 @@ $(LIBAPPARMOR_A):
echo "error: $@ is missing. Pick one of these possible solutions:" 1>&2; \
echo " 1) Build against the in-tree libapparmor by building it first and then trying again. See the top-level README for help." 1>&2; \
echo " 2) Build against the system libapparmor by adding USE_SYSTEM=1 to your make command." 1>&2;\
return 1; \
exit 1; \
fi
endif

View File

@@ -57,7 +57,7 @@ valgrind: $(PARSER) gen_xtrans gen_dbus
LANG=C ./valgrind_simple.py -p "$(PARSER)" -v simple_tests
$(PARSER):
make -C $(PARSER_DIR) $(PARSER_BIN)
$(MAKE) -C $(PARSER_DIR) $(PARSER_BIN)
clean:
find $(GEN_TRANS_DIRS) -type f | xargs rm -f

View File

@@ -4,11 +4,11 @@
# vim:syntax=apparmor
#
/usr/bin/foo {
allow /bin/cat a,
allow /bin/true ra,
allow /bin/false ma,
allow /{usr/,}bin/cat a,
allow /{usr/,}bin/true ra,
allow /{usr/,}bin/false ma,
allow /lib/libc.so la,
allow /bin/less ixa,
allow /bin/more pxa,
allow /{usr/,}bin/less ixa,
allow /{usr/,}bin/more pxa,
allow /a uxa,
}

View File

@@ -2,6 +2,6 @@
#=EXRESULT PASS
# vim:syntax=apparmor
/bin/foo {
/{usr/,}bin/foo {
allow "/abc\ def" r,
}

View File

@@ -2,6 +2,6 @@
#=EXRESULT PASS
# vim:syntax=apparmor
/bin/foo {
/{usr/,}bin/foo {
allow "/abc def" r,
}

View File

@@ -4,15 +4,15 @@
# vim:syntax=apparmor
#
/usr/bin/foo {
allow /bin/a k,
allow /bin/b rk,
allow /bin/c wk,
allow /bin/d ak,
allow /bin/e lk,
allow /bin/e mk,
allow /bin/f pxk,
allow /bin/g Pxk,
allow /bin/h ixk,
allow /bin/i uxk,
allow /bin/j Uxk,
allow /{usr/,}bin/a k,
allow /{usr/,}bin/b rk,
allow /{usr/,}bin/c wk,
allow /{usr/,}bin/d ak,
allow /{usr/,}bin/e lk,
allow /{usr/,}bin/e mk,
allow /{usr/,}bin/f pxk,
allow /{usr/,}bin/g Pxk,
allow /{usr/,}bin/h ixk,
allow /{usr/,}bin/i uxk,
allow /{usr/,}bin/j Uxk,
}

View File

@@ -4,10 +4,10 @@
# vim:syntax=apparmor
#
/usr/bin/foo {
allow /bin/cat mix,
allow /bin/true mpx,
allow /bin/false mux,
allow /{usr/,}bin/cat mix,
allow /{usr/,}bin/true mpx,
allow /{usr/,}bin/false mux,
allow /lib/libc.so rwlm,
allow /bin/less mUx,
allow /bin/more mPx,
allow /{usr/,}bin/less mUx,
allow /{usr/,}bin/more mPx,
}

View File

@@ -4,12 +4,12 @@
# vim:syntax=apparmor
#
/usr/bin/foo {
allow /bin/cat rm,
allow /bin/cat ix,
allow /bin/true px,
allow /bin/true m,
allow /bin/false m,
allow /bin/false ux,
allow /{usr/,}bin/cat rm,
allow /{usr/,}bin/cat ix,
allow /{usr/,}bin/true px,
allow /{usr/,}bin/true m,
allow /{usr/,}bin/false m,
allow /{usr/,}bin/false ux,
allow /lib/libc.so rwl,
allow /lib/libc.so m,
}

View File

@@ -17,6 +17,7 @@
# .Xauthority files required for X connections, per user
owner @{HOME}/.Xauthority r,
owner @{HOME}/.local/share/sddm/.Xauthority r,
owner /{,var/}run/gdm{,3}/*/database r,
owner /{,var/}run/lightdm/authority/[0-9]* r,
owner /{,var/}run/lightdm/*/xauthority r,

View File

@@ -49,7 +49,7 @@ owner @{HOME}/.cache/event-sound-cache.* rwk,
# pulse
/etc/pulse/ r,
/etc/pulse/* r,
/etc/pulse/** r,
/{run,dev}/shm/ r,
owner /{run,dev}/shm/pulse-shm* rwk,
owner @{HOME}/.pulse-cookie rwk,
@@ -57,6 +57,8 @@ owner @{HOME}/.pulse/ rw,
owner @{HOME}/.pulse/* rwk,
owner /{,var/}run/user/*/pulse/ rw,
owner /{,var/}run/user/*/pulse/{native,pid} rwk,
owner @{HOME}/.config/pulse/*.conf r,
owner @{HOME}/.config/pulse/client.conf.d/{,*.conf} r,
owner @{HOME}/.config/pulse/cookie rwk,
owner /tmp/pulse-*/ rw,
owner /tmp/pulse-*/* rw,

View File

@@ -39,6 +39,8 @@
owner @{HOME}/.fonts.conf r,
owner @{HOME}/.fonts/ r,
owner @{HOME}/.fonts/** r,
owner @{HOME}/.local/share/fonts/ r,
owner @{HOME}/.local/share/fonts/** r,
owner @{HOME}/.fonts.cache-2 mr,
owner @{HOME}/.{,cache/}fontconfig/ r,
owner @{HOME}/.{,cache/}fontconfig/** mrl,

View File

@@ -39,4 +39,4 @@
# some unpackaged, but popular browsers
/usr/lib/icecat-*/icecat Cx -> sanitized_helper,
/usr/bin/opera Cx -> sanitized_helper,
/opt/google/chrome/google-chrome Cx -> sanitized_helper,
/opt/google/chrome{,-beta,-unstable}/google-chrome{,-beta,-unstable} Cx -> sanitized_helper,

View File

@@ -4,11 +4,10 @@
owner @{HOME}/.java/deployment/deployment.properties k,
/etc/java-*/ r,
/etc/java-*/** r,
/usr/lib/jvm/java-{6,7}-openjdk*/jre/lib/*/IcedTeaPlugin.so mr,
/usr/lib/jvm/java-6-openjdk/jre/bin/java cx -> browser_openjdk,
/usr/lib/jvm/java-6-openjdk-{amd64,armel,armhf,i386,powerpc}/jre/bin/java cx -> browser_openjdk,
/usr/lib/jvm/java-7-openjdk/jre/bin/java cx -> browser_openjdk,
/usr/lib/jvm/java-7-openjdk-{amd64,armel,armhf,i386,powerpc}/jre/bin/java cx -> browser_openjdk,
/usr/lib/jvm/java-[1-9]{,[0-9]}-openjdk/{,jre/}lib/*/IcedTeaPlugin.so mr,
/usr/lib/jvm/java-[1-9]{,[0-9]}-openjdk-{amd64,armel,armhf,i386,powerpc}/{,jre/}lib/*/IcedTeaPlugin.so mr,
/usr/lib/jvm/java-[1-9]{,[0-9]}-openjdk/{,jre/}bin/java cx -> browser_openjdk,
/usr/lib/jvm/java-[1-9]{,[0-9]}-openjdk-{amd64,armel,armhf,i386,powerpc}/{,jre/}bin/java cx -> browser_openjdk,
/usr/lib/jvm/java-*-sun-1.*/jre/bin/java{,_vm} cx -> browser_java,
/usr/lib/jvm/java-*-sun-1.*/jre/lib/*/libnp*.so cx -> browser_java,
/usr/lib/j2*-ibm/jre/bin/java cx -> browser_java,
@@ -48,12 +47,15 @@
/var/lib/dbus/machine-id r,
/usr/bin/env ix,
/usr/lib/jvm/java-{6,7}-openjdk*/jre/bin/java ix,
/usr/lib/jvm/java-[1-9]{,[0-9]}-openjdk/{,jre/}bin/java ix,
/usr/lib/jvm/java-[1-9]{,[0-9]}-openjdk-{amd64,armel,armhf,i386,powerpc}/{,jre/}bin/java ix,
/usr/lib/jvm/java-{6,7}-openjdk*/jre/lib/i386/client/classes.jsa m,
# Why would java need this?
deny /usr/bin/gconftool-2 x,
owner /{,var/}run/user/[0-9]*/icedteaplugin-*-*/[0-9]*-icedteanp-appletviewer-to-plugin rw,
owner /{,var/}run/user/[0-9]*/icedteaplugin-*-*/[0-9]*-icedteanp-plugin-{,debug-}to-appletviewer r,
owner @{HOME}/ r,
owner @{HOME}/** rwk,
}

View File

@@ -20,5 +20,5 @@
/usr/bin/sylpheed Cx -> sanitized_helper,
/usr/bin/tkrat Cx -> sanitized_helper,
/usr/lib/thunderbird*/thunderbird{,.sh} Cx -> sanitized_helper,
/usr/lib/thunderbird*/thunderbird{,.sh,-bin} Cx -> sanitized_helper,

View File

@@ -44,6 +44,9 @@ profile sanitized_helper {
#include <abstractions/dbus-strict>
dbus,
# Needed for Google Chrome
ptrace (trace) peer=**//sanitized_helper,
# Allow exec of anything, but under this profile. Allow transition
# to other profiles if they exist.
/{usr/,}bin/* Pixr,
@@ -66,10 +69,10 @@ profile sanitized_helper {
# paths (man ld.so)).
/usr/lib/chromium-browser/chromium-browser-sandbox PUxr,
/usr/lib/chromium{,-browser}/chrome-sandbox PUxr,
/opt/google/chrome/chrome-sandbox PUxr,
/opt/google/chrome/google-chrome Pixr,
/opt/google/chrome/chrome Pixr,
/opt/google/chrome/lib*.so{,.*} m,
/opt/google/chrome{,-beta,-unstable}/chrome-sandbox PUxr,
/opt/google/chrome{,-beta,-unstable}/google-chrome Pixr,
/opt/google/chrome{,-beta,-unstable}/chrome Pixr,
/opt/google/chrome{,-beta,-unstable}/{,**/}lib*.so{,.*} m,
# Full access
/ r,

View File

@@ -38,6 +38,7 @@ profile syslog-ng /{usr/,}sbin/syslog-ng {
/dev/syslog w,
/dev/tty10 rw,
/dev/xconsole rw,
/dev/kmsg r,
/etc/machine-id r,
/etc/syslog-ng/* r,
/etc/syslog-ng/conf.d/ r,

View File

@@ -22,6 +22,8 @@
#include <abstractions/dovecot-common>
capability audit_write,
capability dac_override,
capability dac_read_search,
capability setuid,
/etc/my.cnf r,

View File

@@ -15,6 +15,7 @@
#include <abstractions/base>
#include <abstractions/mysql>
#include <abstractions/nameservice>
#include <abstractions/openssl>
#include <abstractions/dovecot-common>
capability setuid,

View File

@@ -32,6 +32,8 @@
/etc/dovecot/conf.d/ r,
/etc/dovecot/conf.d/** r,
owner /tmp/dovecot.imap.* rw,
/usr/bin/doveconf rix,
/usr/lib/dovecot/imap mrix,
/usr/share/dovecot/** r,

View File

@@ -27,6 +27,7 @@
network inet6 stream,
/usr/lib/dovecot/managesieve-login mr,
/{,var/}run/dovecot/login-master-notify* rw,
/{,var/}run/dovecot/login/ r,
/{,var/}run/dovecot/login/* rw,

View File

@@ -23,6 +23,7 @@
capability sys_chroot,
/usr/lib/dovecot/pop3-login mr,
/{,var/}run/dovecot/anvil rw,
/{,var/}run/dovecot/login/ r,
/{,var/}run/dovecot/login/* rw,

View File

@@ -23,6 +23,7 @@
capability chown,
capability dac_override,
capability dac_read_search,
capability fsetid,
capability kill,
capability net_bind_service,
@@ -30,6 +31,8 @@
capability sys_chroot,
capability sys_resource,
signal send set=(int,quit) peer=/usr/lib/dovecot/*,
/etc/dovecot/** r,
/etc/mtab r,
/etc/lsb-release r,

View File

@@ -22,7 +22,9 @@ profile netstat /{usr/,}bin/netstat {
capability dac_override,
capability dac_read_search,
deny capability sys_ptrace,
capability sys_ptrace,
ptrace (read),
/{usr/,}bin/netstat rmix,
/etc/networks r,

View File

@@ -20,6 +20,7 @@
#include <abstractions/nameservice>
#include <abstractions/wutmp>
capability audit_write,
capability chown,
capability dac_override,
capability fowner,
@@ -51,9 +52,22 @@
/usr/lib*/pwdutils/*so* mr,
/usr/sbin/adduser rmix,
/usr/sbin/nscd rPix,
/{,usr/}sbin/pam_tally2 Cx -> pam_tally2,
/usr/sbin/useradd rmix,
/usr/sbin/useradd.local rmix,
/var/log/faillog rw,
/{,var/}run/nscd.pid rw,
/var/spool/mail/* rw,
profile pam_tally2 {
#include <abstractions/base>
#include <abstractions/consoles>
#include <abstractions/nameservice>
capability audit_write,
/sbin/pam_tally2 mr,
/var/log/tallylog rw,
}
}

View File

@@ -3,5 +3,5 @@ SUBDIRS=regression stress
.PHONY: clean
clean:
for dir in $(SUBDIRS) ; do \
make clean -C $${dir} ; \
$(MAKE) clean -C $${dir} ; \
done

View File

@@ -3,5 +3,5 @@ SUBDIRS=apparmor
.PHONY: clean
clean:
for dir in $(SUBDIRS) ; do \
make clean -C $${dir} ; \
$(MAKE) clean -C $${dir} ; \
done

View File

@@ -23,8 +23,6 @@
#define FALSE 0
#define TRUE !FALSE
#define max(x,y) (x) > (y) ? (x) : (y)
#define MAX_FILES 5
int (*pass)[MAX_FILES];
@@ -60,7 +58,12 @@ int main(int argc, char *argv[])
return 1;
}
num_files = max(argc - 1, MAX_FILES);
num_files = argc - 1;
if (num_files > MAX_FILES) {
fprintf(stderr, "ERROR: a maximum of %d files is supported\n",
MAX_FILES);
return 1;
}
shmid = shmget(IPC_PRIVATE, sizeof(int[2][MAX_FILES]), IPC_CREAT);
if (shmid == -1) {
@@ -81,11 +84,11 @@ int main(int argc, char *argv[])
int status;
int allpassed = TRUE;
test_files(argc - 1, &argv[1], 0);
test_files(num_files, &argv[1], 0);
while (wait(&status) != pid) ;
for (i = 0; i < argc - 1; i++) {
for (i = 0; i < num_files; i++) {
if (pass[0][i] != pass[1][i] ||
pass[0][i] == -1 || pass[1][i] == -1) {
if (allpassed) {
@@ -108,7 +111,7 @@ int main(int argc, char *argv[])
shmctl(shmid, IPC_RMID, &shm_desc);
} else {
test_files(argc - 1, &argv[1], 1);
test_files(num_files, &argv[1], 1);
}
return 0;

View File

@@ -31,7 +31,7 @@
int main (int argc, char * argv[]) {
int sock, in_sock, fd;
struct sockaddr_un local, remote;
int len, exec_now, pfd_ret;
int len, pfd_ret;
socklen_t len2;
char comparison_buffer[17];
char inbound_buffer[17];
@@ -40,9 +40,6 @@ int main (int argc, char * argv[]) {
struct cmsghdr *ctrl_mesg;
struct pollfd pfd;
exec_now = 0;
if (argc < 4 || argc > 5 || (argc == 5 && (strcmp(argv[4], "delete_file") != 0))) {
fprintf(stderr, "Usage: %s <file>\n", argv[0]);
return(1);

View File

@@ -3,5 +3,5 @@ SUBDIRS=subdomain
.PHONY: clean
clean:
for dir in $(SUBDIRS) ; do \
make clean -C $${dir} ; \
$(MAKE) clean -C $${dir} ; \
done

View File

@@ -70,7 +70,7 @@ fi
while read line ; do
# check if line contains encoded name= or profile=
if [[ "$line" =~ \ (name|profile)=[0-9a-fA-F] ]]; then
if [[ "$line" =~ \ (name|profile|proctitle)=[0-9a-fA-F] ]]; then
# cut the encoded filename/profile name out of the line and decode it
ne=`echo "$line" | sed 's/.* name=\([^ ]*\).*$/\\1/g'`
@@ -79,9 +79,13 @@ while read line ; do
pe=`echo "$line" | sed 's/.* profile=\([^ ]*\).*$/\\1/g'`
pd="$(decode ${pe/\'/\\\'})"
pce=`echo "$line" | sed 's/.* proctitle=\([^ ]*\).*$/\\1/g'`
pcd="$(decode ${pce/\'/\\\'})"
# replace encoded name and profile with its decoded counterparts (only if it was encoded)
test -n "$nd" && line="${line/name=$ne/name=\"$nd\"}"
test -n "$pd" && line="${line/profile=$pe/profile=\"$pd\"}"
test -n "$pcd" && line="${line/proctitle=$pce/proctitle=\"$pcd\"}"
fi

View File

@@ -165,7 +165,10 @@ class Merge(object):
options = []
for inc in other.filelist[other.filename]['include'].keys():
if not inc in self.user.filelist[self.user.filename]['include'].keys():
options.append('#include <%s>' %inc)
if inc.startswith('/'):
options.append('#include "%s"' %inc)
else:
options.append('#include <%s>' %inc)
default_option = 1

View File

@@ -27,7 +27,8 @@ DRY_RUN=0
usage() {
local progname="$1"
local rc="$2"
local msg="usage: ${progname} [options]\n
local msg="usage: ${progname} [options]
Remove profiles unknown to the system
Options:

View File

@@ -1191,8 +1191,8 @@ def handle_children(profile, hat, root):
ans = 'INVALID'
if exec_mode and 'i' in exec_mode:
# For inherit we need r
file_perm = 'r'
# For inherit we need mr
file_perm = 'mr'
else:
if ans == 'CMD_DENY':
aa[profile][hat]['file'].add(FileRule(exec_target, None, 'x', FileRule.ALL, owner=False, log_event=True, deny=True))
@@ -1315,10 +1315,6 @@ def UI_ask_to_upload_profiles():
# To-Do
pass
def UI_ask_mode_toggles(audit_toggle, owner_toggle, oldmode):
# To-Do
return (audit_toggle, owner_toggle)
def parse_repo_profile(fqdbin, repo_url, profile):
# To-Do
pass
@@ -1432,7 +1428,10 @@ def ask_the_questions(log_dict):
options = []
for inc in log_dict[aamode][profile][hat]['include'].keys():
if not inc in aa[profile][hat]['include'].keys():
options.append('#include <%s>' %inc)
if inc.startswith('/'):
options.append('#include "%s"' %inc)
else:
options.append('#include <%s>' %inc)
default_option = 1
@@ -1521,6 +1520,16 @@ def ask_the_questions(log_dict):
options = set_options_audit_mode(rule_obj, options)
elif ans.startswith('CMD_USER_'):
if ans == 'CMD_USER_ON':
rule_obj.owner = True
rule_obj.raw_rule = None
else:
rule_obj.owner = False
rule_obj.raw_rule = None
options = set_options_owner_mode(rule_obj, options)
elif ans == 'CMD_ALLOW':
done = True
changed[profile] = True
@@ -1605,6 +1614,16 @@ def set_options_audit_mode(rule_obj, options):
'''change audit state in options (proposed rules) to audit state in rule_obj.
#include options will be kept unchanged
'''
return set_options_mode(rule_obj, options, 'audit')
def set_options_owner_mode(rule_obj, options):
'''change owner state in options (proposed rules) to owner state in rule_obj.
#include options will be kept unchanged
'''
return set_options_mode(rule_obj, options, 'owner')
def set_options_mode(rule_obj, options, what):
''' helper function for set_options_audit_mode() and set_options_owner_mode'''
new_options = []
for rule in options:
@@ -1612,7 +1631,13 @@ def set_options_audit_mode(rule_obj, options):
new_options.append(rule)
else:
parsed_rule = selection_to_rule_obj(rule_obj, rule)
parsed_rule.audit = rule_obj.audit
if what == 'audit':
parsed_rule.audit = rule_obj.audit
elif what == 'owner':
parsed_rule.owner = rule_obj.owner
else:
raise AppArmorBug('Unknown "what" value given to set_options_mode: %s' % what)
parsed_rule.raw_rule = None
new_options.append(parsed_rule.get_raw())
@@ -1640,6 +1665,12 @@ def available_buttons(rule_obj):
else:
buttons += ['CMD_AUDIT_NEW']
if rule_obj.can_owner:
if rule_obj.owner:
buttons += ['CMD_USER_OFF']
else:
buttons += ['CMD_USER_ON']
buttons += ['CMD_ABORT', 'CMD_FINISHED']
return buttons
@@ -1699,6 +1730,11 @@ def ask_conflict_mode(profile, hat, old_profile, merge_profile):
done = True
def get_include_path(incname):
if incname.startswith('/'):
return incname
return profile_dir + '/' + incname
def match_includes(profile, rule_type, rule_obj):
newincludes = []
for incname in include.keys():
@@ -1719,6 +1755,8 @@ def valid_include(profile, incname):
if incname.startswith('abstractions/') and os.path.isfile(profile_dir + '/' + incname):
return True
elif incname.startswith('/') and os.path.isfile(incname):
return True
return False
@@ -1823,16 +1861,20 @@ def save_profiles():
if not changed:
return
q.options = sorted(changed.keys())
options = sorted(changed.keys())
q.options = options
ans, arg = q.promptUser()
q.selected = arg # remember selection
which = options[arg]
if ans == 'CMD_SAVE_SELECTED':
profile_name = list(changed.keys())[arg]
write_profile_ui_feedback(profile_name)
reload_base(profile_name)
write_profile_ui_feedback(which)
reload_base(which)
q.selected = 0 # saving the selected profile removes it from the list, therefore reset selection
elif ans == 'CMD_VIEW_CHANGES':
which = list(changed.keys())[arg]
oldprofile = None
if aa[which][which].get('filename', False):
oldprofile = aa[which][which]['filename']
@@ -1848,7 +1890,6 @@ def save_profiles():
aaui.UI_Changes(oldprofile, newprofile, comments=True)
elif ans == 'CMD_VIEW_CHANGES_CLEAN':
which = list(changed.keys())[arg]
oldprofile = serialize_profile(original_aa[which], which, '')
newprofile = serialize_profile(aa[which], which, '')
@@ -2021,6 +2062,13 @@ def read_profiles():
read_profile(profile_dir + '/' + file, True)
def read_inactive_profiles():
if hasattr(read_inactive_profiles, 'already_read'):
# each autodep() run calls read_inactive_profiles, but that's a) superfluous and b) triggers a conflict because the inactive profiles are already loaded
# therefore don't do anything if the inactive profiles were already loaded
return
read_inactive_profiles.already_read = True
if not os.path.exists(extra_profile_dir):
return None
try:
@@ -2288,7 +2336,7 @@ def parse_profile_data(data, file, do_include):
filelist[file] = hasher()
filelist[file]['include'][include_name] = True
# If include is a directory
if os.path.isdir(profile_dir + '/' + include_name):
if os.path.isdir(get_include_path(include_name)):
for file_name in include_dir_filelist(profile_dir, include_name):
if not include.get(file_name, False):
load_include(file_name)
@@ -2558,7 +2606,13 @@ def write_single(prof_data, depth, allow, name, prefix, tail):
if ref.get(name, False):
for key in sorted(ref[name].keys()):
qkey = quote_if_needed(key)
if name == 'include':
if key.startswith('/'):
qkey = '"%s"' % key
else:
qkey = '<%s>' % quote_if_needed(key)
else:
qkey = quote_if_needed(key)
data.append('%s%s%s%s%s' % (pre, allow, prefix, qkey, tail))
if ref[name].keys():
data.append('')
@@ -2597,7 +2651,7 @@ def write_pair(prof_data, depth, allow, name, prefix, sep, tail, fn):
return data
def write_includes(prof_data, depth):
return write_single(prof_data, depth, '', 'include', '#include <', '>')
return write_single(prof_data, depth, '', 'include', '#include ', '')
def write_change_profile(prof_data, depth):
data = []
@@ -3324,7 +3378,7 @@ def is_known_rule(profile, rule_type, rule_obj):
incname = includelist.pop(0)
checked.append(incname)
if os.path.isdir(profile_dir + '/' + incname):
if os.path.isdir(get_include_path(incname)):
includelist += include_dir_filelist(profile_dir, incname)
else:
if include[incname][incname].get(rule_type, False):
@@ -3352,7 +3406,7 @@ def get_file_perms(profile, path, audit, deny):
continue
checked.append(incname)
if os.path.isdir(profile_dir + '/' + incname):
if os.path.isdir(get_include_path(incname)):
includelist += include_dir_filelist(profile_dir, incname)
else:
incperms = include[incname][incname]['file'].get_perms_for_path(path, audit, deny)
@@ -3433,7 +3487,8 @@ def reload(bin_path):
def get_include_data(filename):
data = []
filename = profile_dir + '/' + filename
if not filename.startswith('/'):
filename = profile_dir + '/' + filename
if os.path.exists(filename):
with open_file_read(filename) as f_in:
data = f_in.readlines()
@@ -3442,15 +3497,21 @@ def get_include_data(filename):
return data
def include_dir_filelist(profile_dir, include_name):
'''returns a list of files in the given profile_dir/include_name directory, except skippable files'''
'''returns a list of files in the given profile_dir/include_name directory,
except skippable files. If include_name is an absolute path, ignore
profile_dir.
'''
files = []
for path in os.listdir(profile_dir + '/' + include_name):
include_name_abs = get_include_path(include_name)
for path in os.listdir(include_name_abs):
path = path.strip()
if is_skippable_file(path):
continue
if os.path.isfile(profile_dir + '/' + include_name + '/' + path):
if os.path.isfile(include_name_abs + '/' + path):
file_name = include_name + '/' + path
file_name = file_name.replace(profile_dir + '/', '')
# strip off profile_dir for non-absolute paths
if not include_name.startswith('/'):
file_name = file_name.replace(profile_dir + '/', '')
files.append(file_name)
return files
@@ -3459,17 +3520,18 @@ def load_include(incname):
load_includeslist = [incname]
while load_includeslist:
incfile = load_includeslist.pop(0)
incfile_abs = get_include_path(incfile)
if include.get(incfile, {}).get(incfile, False):
pass # already read, do nothing
elif os.path.isfile(profile_dir + '/' + incfile):
data = get_include_data(incfile)
elif os.path.isfile(incfile_abs):
data = get_include_data(incfile_abs)
incdata = parse_profile_data(data, incfile, True)
attach_profile_data(include, incdata)
#If the include is a directory means include all subfiles
elif os.path.isdir(profile_dir + '/' + incfile):
elif os.path.isdir(incfile_abs):
load_includeslist += include_dir_filelist(profile_dir, incfile)
else:
raise AppArmorException("Include file %s not found" % (profile_dir + '/' + incfile) )
raise AppArmorException("Include file %s not found" % (incfile_abs))
return 0
@@ -3567,4 +3629,3 @@ def init_aa(confdir="/etc/apparmor"):
parser = conf.find_first_file(cfg['settings'].get('parser')) or '/sbin/apparmor_parser'
if not os.path.isfile(parser) or not os.access(parser, os.EX_OK):
raise AppArmorException('Can\'t find apparmor_parser at %s' % (parser))

View File

@@ -118,6 +118,10 @@ class ReadLog:
ev['protocol'] = event.net_protocol
ev['sock_type'] = event.net_sock_type
if event.ouid != 18446744073709551615: # 2^64 - 1
ev['fsuid'] = event.fsuid
ev['ouid'] = event.ouid
if ev['operation'] and ev['operation'] == 'signal':
ev['signal'] = event.signal
ev['peer'] = event.peer
@@ -268,6 +272,13 @@ class ReadLog:
if not validate_log_mode(hide_log_mode(dmask)):
raise AppArmorException(_('Log contains unknown mode %s') % dmask)
if e.get('ouid') is not None and e['fsuid'] == e['ouid']:
# mark as "owner" event
if '::' not in rmask:
rmask = '%s::' % rmask
if '::' not in dmask:
dmask = '%s::' % dmask
# convert rmask and dmask to mode arrays
e['denied_mask'], e['name2'] = log_str_to_mode(e['profile'], dmask, e['name2'])
e['request_mask'], e['name2'] = log_str_to_mode(e['profile'], rmask, e['name2'])

View File

@@ -133,7 +133,7 @@ def parse_profile_start_line(line, filename):
return result
RE_INCLUDE = re.compile('^\s*#?include\s*<(?P<magicpath>.*)>' + RE_EOL)
RE_INCLUDE = re.compile('^\s*#?include\s*(<(?P<magicpath>.*)>|"(?P<quotedpath>.*)"|(?P<unquotedpath>[^<>"]*))' + RE_EOL)
def re_match_include(line):
"""Matches the path for include and returns the include path"""
@@ -142,10 +142,29 @@ def re_match_include(line):
if not matches:
return None
if not matches.group('magicpath').strip():
path = None
if matches.group('magicpath'):
path = matches.group('magicpath').strip()
elif matches.group('unquotedpath'):
# LP: #1738879 - parser doesn't handle unquoted paths everywhere
# path = matches.group('unquotedpath').strip()
raise AppArmorException(_('Syntax error: #include must use quoted path or <...>'))
elif matches.group('quotedpath'):
path = matches.group('quotedpath')
# LP: 1738880 - parser doesn't handle relative paths everywhere, and
# neither do we (see aa.py)
if len(path) > 0 and path[0] != '/':
raise AppArmorException(_('Syntax error: #include must use quoted path or <...>'))
# if path is empty or the empty string
if path is None or path == "":
raise AppArmorException(_('Syntax error: #include rule with empty filename'))
return matches.group('magicpath')
# LP: #1738877 - parser doesn't handle files with spaces in the name
if re.search('\s', path):
raise AppArmorException(_('Syntax error: #include rule filename cannot contain spaces'))
return path
def strip_parenthesis(data):
'''strips parenthesis from the given string and returns the strip()ped result.

View File

@@ -46,6 +46,9 @@ class BaseRule(object):
# defines if the (N)ew option is displayed
can_edit = False
# defines if the '(O)wner permissions on/off' option is displayed
can_owner = False
def __init__(self, audit=False, deny=False, allow_keyword=False,
comment='', log_event=None):
'''initialize variables needed by all rule types'''

View File

@@ -104,6 +104,7 @@ class FileRule(BaseRule):
if type(owner) is not bool:
raise AppArmorBug('non-boolean value passed to owner flag')
self.owner = owner
self.can_owner = owner # offer '(O)wner permissions on/off' buttons only if the rule has the owner flag
if type(file_keyword) is not bool:
raise AppArmorBug('non-boolean value passed to file keyword flag')
@@ -241,9 +242,9 @@ class FileRule(BaseRule):
if not self._is_covered_aare(self.path, self.all_paths, other_rule.path, other_rule.all_paths, 'path'):
return False
# TODO: check 'a' vs. 'w'
# perms can be empty if only exec_perms are specified, therefore disable the sanity check in _is_covered_list()...
if not self._is_covered_list(self.perms, self.all_perms, other_rule.perms, other_rule.all_perms, 'perms', sanity_check=False):
# 'w' covers 'a', therefore use perms_with_a() to temporarily add 'a' if 'w' is present
if not self._is_covered_list(perms_with_a(self.perms), self.all_perms, perms_with_a(other_rule.perms), other_rule.all_perms, 'perms', sanity_check=False):
return False
# ... and do our own sanity check
@@ -533,3 +534,15 @@ def split_perms(perm_string, deny):
raise AppArmorException(_('permission contains unknown character(s) %s' % perm_string))
return perms, exec_mode
def perms_with_a(perms):
'''if perms includes 'w', add 'a' perms
- perms: the original permissions
'''
perms_with_a = set()
if perms:
perms_with_a = set(perms)
if 'w' in perms_with_a:
perms_with_a.add('a')
return perms_with_a

View File

@@ -185,7 +185,9 @@ class Severity(object):
# If any includes, load variables from them first
match = re_match_include(line)
if match:
new_path = self.PROF_DIR + '/' + match
new_path = match
if not new_path.startswith('/'):
new_path = self.PROF_DIR + '/' + match
self.load_variables(new_path)
else:
# Remove any comments

View File

@@ -38,7 +38,7 @@ sub check_po_for_shortcuts {
$msgid = $_;
}
if ( /^.*msgstr*/ && $looking_for_msgstr ) {
unless (/^.*msgstr.*\(\w{1}?\)*/) {
unless (/^.*msgstr.*\(\w{1}?\)*/ or /^msgstr ""$/) {
$errors->{$filename}{$line} = {
"msgid" => $msgid,
"msgstr" => $_,

View File

@@ -7,14 +7,14 @@ msgstr ""
"Project-Id-Version: apparmor-utils\n"
"Report-Msgid-Bugs-To: <apparmor@lists.ubuntu.com>\n"
"POT-Creation-Date: 2014-09-14 19:29+0530\n"
"PO-Revision-Date: 2017-04-20 12:04+0000\n"
"Last-Translator: Christian Boltz <Unknown>\n"
"PO-Revision-Date: 2017-12-20 02:04+0000\n"
"Last-Translator: Tobias Bannert <tobannert@gmail.com>\n"
"Language-Team: German <de@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2017-04-21 05:29+0000\n"
"X-Generator: Launchpad (build 18359)\n"
"X-Launchpad-Export-Date: 2017-12-21 05:12+0000\n"
"X-Generator: Launchpad (build 18511)\n"
"Language: de\n"
#: ../aa-genprof:56
@@ -312,7 +312,7 @@ msgstr "Netzwerkzugriff %(family)s %(type)s wird dem Profil verweigert."
#: ../aa-autodep:23
msgid "Generate a basic AppArmor profile by guessing requirements"
msgstr "Erstelle ein Basis AppArmor Profil nach erwarteten Anforderungen"
msgstr "Ein Basis-AppArmor-Profil nach erwarteten Anforderungen erstellen"
#: ../aa-autodep:24
msgid "overwrite existing profile"
@@ -340,7 +340,7 @@ msgstr "Das angegebene Programm in den Erzwingenmodus versetzen"
#: ../aa-disable:23
msgid "Disable the profile for the given programs"
msgstr "Deaktiviere das Profil für die genannten Programme"
msgstr "Das Profil für die angegebenen Programme deaktivieren"
#: ../aa-unconfined:28
msgid "Lists unconfined processes having tcp or udp ports"
@@ -348,7 +348,7 @@ msgstr "Zeigt uneingeschränkte Prozesse mit tcp oder udp Ports"
#: ../aa-unconfined:29
msgid "scan all processes from /proc"
msgstr "Durchsuche alle Prozesse von /proc"
msgstr "alle Prozesse aus /proc durchsuchen"
#: ../aa-unconfined:81
#, python-format
@@ -394,7 +394,7 @@ msgstr "%s wird in den Erzwingen-Modus versetzt."
#: ../apparmor/aa.py:286
#, python-format
msgid "Unable to find basename for %s."
msgstr ""
msgstr "Basisname für %s kann nicht gefunden werden."
#: ../apparmor/aa.py:301
#, python-format
@@ -640,7 +640,7 @@ msgstr "Protokolleinträge von %s werden gelesen."
#: ../apparmor/aa.py:2254
#, python-format
msgid "Updating AppArmor profiles in %s."
msgstr "Aktualisiere AppArmor-Profile in %s."
msgstr "AppArmor-Profile in %s werden aktualisiert."
#: ../apparmor/aa.py:2323
msgid ""
@@ -1038,11 +1038,11 @@ msgstr ""
#: ../apparmor/ui.py:229
msgid "(O)wner permissions on"
msgstr "(B)esitzerberechtigungen an"
msgstr "Be(s)itzerberechtigungen an"
#: ../apparmor/ui.py:230
msgid "(O)wner permissions off"
msgstr "(B)esitzerberechtigungen aus"
msgstr "Be(s)itzerberechtigungen aus"
#: ../apparmor/ui.py:231
msgid "(D)eny"

View File

@@ -8,14 +8,14 @@ msgstr ""
"Project-Id-Version: apparmor\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2014-09-14 19:29+0530\n"
"PO-Revision-Date: 2017-05-02 14:26+0000\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"PO-Revision-Date: 2017-11-24 13:01+0000\n"
"Last-Translator: Rodrigo <rodhos_hp@hotmail.com>\n"
"Language-Team: Spanish <es@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2017-05-03 05:19+0000\n"
"X-Generator: Launchpad (build 18366)\n"
"X-Launchpad-Export-Date: 2017-11-25 05:12+0000\n"
"X-Generator: Launchpad (build 18509)\n"
#: ../aa-genprof:56
msgid "Generate profile for the given program"
@@ -304,7 +304,7 @@ msgstr ""
#: ../aa-complain:23
msgid "Switch the given program to complain mode"
msgstr ""
msgstr "Cambia el programa dado al modo reclamar"
#: ../aa-enforce:23
msgid "Switch the given program to enforce mode"
@@ -355,7 +355,7 @@ msgstr ""
#: ../apparmor/aa.py:264 ../apparmor/aa.py:548
#, python-format
msgid "Setting %s to complain mode."
msgstr ""
msgstr "Estableciendo %s al modo reclamar."
#: ../apparmor/aa.py:271
#, python-format

View File

@@ -36,14 +36,24 @@ else
PARSER=../../parser/apparmor_parser
endif
.PHONY: __libapparmor
.PHONY: __libapparmor __parser
__libapparmor:
ifndef USE_SYSTEM
@if [ ! -f $(LD_LIBRARY_PATH)libapparmor.so ]; then \
echo "error: $(LD_LIBRARY_PATH)libapparmor.so is missing. Pick one of these possible solutions:" 1>&2; \
echo " 1) Build against the in-tree libapparmor by building it first and then trying again. See the top-level README for help." 1>&2; \
echo " 2) Build against the system libapparmor by adding USE_SYSTEM=1 to your make command." 1>&2; \
return 1; \
exit 1; \
fi
endif
__parser:
ifndef USE_SYSTEM
@if [ ! -f $(PARSER) ]; then \
echo "error: $(PARSER) is missing. Pick one of these possible solutions:" 1>&2; \
echo " 1) Test using the in-tree parser by building it first and then trying again. See the top-level README for help." 1>&2; \
echo " 2) Test using the system parser by adding USE_SYSTEM=1 to your make command." 1>&2; \
exit 1; \
fi
endif
@@ -67,10 +77,10 @@ endif
clean:
rm -rf __pycache__/ .coverage htmlcov
check: __libapparmor
check: __libapparmor __parser
export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C __AA_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) __AA_PARSER=$(PARSER) ; $(foreach test, $(wildcard test-*.py), echo ; echo === $(test) === ; $(call pyalldo, $(test)))
.coverage: $(wildcard ../aa-* ../apparmor/*.py test-*.py) __libapparmor
.coverage: $(wildcard ../aa-* ../apparmor/*.py test-*.py) __libapparmor __parser
export PYTHONPATH=$(PYTHONPATH) LD_LIBRARY_PATH=$(LD_LIBRARY_PATH) LC_ALL=C __AA_CONFDIR=$(CONFDIR) __AA_BASEDIR=$(BASEDIR) __AA_PARSER=$(PARSER) ; $(COVERAGE_IGNORE_FAILURES_CMD) ; $(foreach test, $(wildcard test-*.py), echo ; echo === $(test) === ; $(PYTHON) -m coverage run --branch -p $(test); )
$(PYTHON) -m coverage combine

View File

@@ -19,7 +19,7 @@ import sys
import apparmor.aa # needed to set global vars in some tests
from apparmor.aa import (check_for_apparmor, get_output, get_reqs, get_interpreter_and_abstraction, create_new_profile,
get_profile_flags, set_profile_flags, set_options_audit_mode, is_skippable_file, is_skippable_dir,
get_profile_flags, set_profile_flags, set_options_audit_mode, set_options_owner_mode, is_skippable_file, is_skippable_dir,
parse_profile_start, parse_profile_data, separate_vars, store_list_var, write_header,
var_transform, serialize_parse_profile_start, get_file_perms, propose_file_rules)
from apparmor.aare import AARE
@@ -414,6 +414,20 @@ class AaTest_set_options_audit_mode(AATest):
new_options = set_options_audit_mode(rule_obj, options)
self.assertEqual(new_options, expected)
class AaTest_set_options_owner_mode(AATest):
tests = [
((FileRule.parse('owner /foo/bar r,'), ['/foo/bar r,', '/foo/* r,', '/** r,'] ), ['owner /foo/bar r,', 'owner /foo/* r,', 'owner /** r,']),
((FileRule.parse('owner /foo/bar r,'), ['/foo/bar r,', 'owner /foo/* r,', 'owner /** r,'] ), ['owner /foo/bar r,', 'owner /foo/* r,', 'owner /** r,']),
((FileRule.parse('/foo/bar r,'), ['/foo/bar r,', '/foo/* r,', '/** r,'] ), ['/foo/bar r,', '/foo/* r,', '/** r,']),
((FileRule.parse('/foo/bar r,'), ['owner /foo/bar r,', 'owner /foo/* r,', 'owner /** r,'] ), ['/foo/bar r,', '/foo/* r,', '/** r,']),
((FileRule.parse('audit owner /foo/bar r,'),['audit /foo/bar r,', 'audit /foo/* r,', '#include <abstractions/base>']), ['audit owner /foo/bar r,', 'audit owner /foo/* r,', '#include <abstractions/base>']),
]
def _run_test(self, params, expected):
rule_obj, options = params
new_options = set_options_owner_mode(rule_obj, options)
self.assertEqual(new_options, expected)
class AaTest_is_skippable_file(AATest):
def test_not_skippable_01(self):
self.assertFalse(is_skippable_file('bin.ping'))
@@ -859,6 +873,59 @@ class AaTest_propose_file_rules(AATest):
proposals = propose_file_rules(profile, rule_obj)
self.assertEqual(proposals, expected)
class AaTest_propose_file_rules_with_absolute_includes(AATest):
tests = [
# log event path and perms expected proposals
(['/not/found/anywhere', 'r'], ['/not/found/anywhere r,']),
(['/dev/null', 'w'], ['/dev/null rw,']),
(['/some/random/include', 'r'], ['/some/random/include rw,']),
(['/some/other/include', 'w'], ['/some/other/* rw,', '/some/other/inc* rw,', '/some/other/include rw,']),
]
def _run_test(self, params, expected):
self.createTmpdir()
#copy the local profiles to the test directory
self.profile_dir = '%s/profiles' % self.tmpdir
shutil.copytree('../../profiles/apparmor.d/', self.profile_dir, symlinks=True)
# load the abstractions we need in the test
apparmor.aa.profiledir = self.profile_dir
apparmor.aa.load_include('abstractions/base')
abs_include1 = write_file(self.tmpdir, 'test-abs1', "/some/random/include rw,")
apparmor.aa.load_include(abs_include1)
abs_include2 = write_file(self.tmpdir, 'test-abs2', "/some/other/* rw,")
apparmor.aa.load_include(abs_include2)
abs_include3 = write_file(self.tmpdir, 'test-abs3', "/some/other/inc* rw,")
apparmor.aa.load_include(abs_include3)
profile = apparmor.aa.ProfileStorage('/test', '/test', 'test-aa.py')
profile['include']['abstractions/base'] = False
profile['include'][abs_include1] = False
profile['include'][abs_include2] = False
profile['include'][abs_include3] = False
rule_obj = FileRule(params[0], params[1], None, FileRule.ALL, owner=False, log_event=True)
proposals = propose_file_rules(profile, rule_obj)
self.assertEqual(proposals, expected)
class AaTest_nonexistent_includes(AATest):
def test_bad_includes(self):
tests = [
"/nonexistent/absolute/path",
"nonexistent/relative/path",
]
for i in tests:
with self.assertRaises(AppArmorException):
apparmor.aa.load_include(i)
setup_aa(apparmor.aa)
setup_all_loops(__name__)
if __name__ == '__main__':

View File

@@ -585,6 +585,28 @@ class FileCoveredTest_05(FileCoveredTest):
('/foo mrwPx -> bar,' , [ False , False , False , False ]),
]
class FileCoveredTest_06(FileCoveredTest):
rule = 'deny /foo w,'
tests = [
# rule equal strict equal covered covered exact
('/foo w,' , [ False , False , False , False ]),
('/foo a,' , [ False , False , False , False ]),
('deny /foo w,' , [ True , True , True , True ]),
('deny /foo a,' , [ False , False , True , True ]),
]
class FileCoveredTest_07(FileCoveredTest):
rule = '/foo w,'
tests = [
# rule equal strict equal covered covered exact
('/foo w,' , [ True , True , True , True ]),
('/foo a,' , [ False , False , True , True ]),
('deny /foo w,' , [ False , False , False , False ]),
('deny /foo a,' , [ False , False , False , False ]),
]
class FileCoveredTest_ManualOrInvalid(AATest):
def AASetup(self):
#FileRule# path, perms, exec_perms, target, owner, file_keyword, leading_perms

View File

@@ -73,11 +73,13 @@ class TestParseEvent(unittest.TestCase):
'attr': None,
'denied_mask': 'r',
'error_code': 13,
'fsuid': 1002,
'info': 'Failed name lookup - disconnected path',
'magic_token': 0,
'name': 'var/run/nscd/passwd',
'name2': None,
'operation': 'file_mmap',
'ouid': 0,
'parent': 0,
'pid': 25333,
'profile': '/sbin/klogd',

View File

@@ -437,17 +437,27 @@ class TestInvalid_parse_profile_start_line(AATest):
class Test_re_match_include(AATest):
tests = [
('#include <abstractions/base>', 'abstractions/base' ),
('#include <abstractions/base>', 'abstractions/base' ), # magic path
('#include <abstractions/base> # comment', 'abstractions/base' ),
('#include<abstractions/base>#comment', 'abstractions/base' ),
(' #include <abstractions/base> ', 'abstractions/base' ),
('include <abstractions/base>', 'abstractions/base' ), # not supported by parser
# ('include foo', 'foo' ), # XXX not supported in tools yet
# ('include /foo/bar', '/foo/bar' ), # XXX not supported in tools yet
# ('include "foo"', 'foo' ), # XXX not supported in tools yet
# ('include "/foo/bar"', '/foo/bar' ), # XXX not supported in tools yet
(' some #include <abstractions/base>', None, ),
('#include "/foo/bar"', '/foo/bar' ), # absolute path
('#include "/foo/bar" # comment', '/foo/bar' ),
('#include "/foo/bar"#comment', '/foo/bar' ),
(' #include "/foo/bar" ', '/foo/bar' ),
('include <abstractions/base>', 'abstractions/base' ), # magic path
('include <abstractions/base> # comment', 'abstractions/base' ),
('include<abstractions/base>#comment', 'abstractions/base' ),
(' include <abstractions/base> ', 'abstractions/base' ),
('include "/foo/bar"', '/foo/bar' ), # absolute path
('include "/foo/bar" # comment', '/foo/bar' ),
('include "/foo/bar"#comment', '/foo/bar' ),
(' include "/foo/bar" ', '/foo/bar' ),
(' some #include <abstractions/base>', None, ), # non-matching
(' /etc/fstab r,', None, ),
('/usr/include r,', None, ),
('/include r,', None, ),
]
def _run_test(self, params, expected):
@@ -455,8 +465,53 @@ class Test_re_match_include(AATest):
class TestInvalid_re_match_include(AATest):
tests = [
('#include <>', AppArmorException ),
('#include <>', AppArmorException ), # '#include'
('#include < >', AppArmorException ),
('#include ""', AppArmorException ),
('#include " "', AppArmorException ),
('#include', AppArmorException ),
('#include ', AppArmorException ),
('#include "foo"', AppArmorException ), # LP: 1738880 (relative)
('#include "foo" # comment', AppArmorException ),
('#include "foo"#comment', AppArmorException ),
(' #include "foo" ', AppArmorException ),
('#include "foo/bar"', AppArmorException ),
('#include "foo/bar" # comment', AppArmorException ),
('#include "foo/bar"#comment', AppArmorException ),
(' #include "foo/bar" ', AppArmorException ),
('#include foo', AppArmorException ), # LP: 1738879 (no quotes)
('#include foo/bar', AppArmorException ),
('#include /foo/bar', AppArmorException ),
('#include foo bar', AppArmorException ), # LP: 1738877 (space in name)
('#include foo bar/baz', AppArmorException ),
('#include "foo bar"', AppArmorException ),
('#include /foo bar', AppArmorException ),
('#include "/foo bar"', AppArmorException ),
('#include "foo bar/baz"', AppArmorException ),
('include <>', AppArmorException ), # 'include'
('include < >', AppArmorException ),
('include ""', AppArmorException ),
('include " "', AppArmorException ),
('include', AppArmorException ),
('include ', AppArmorException ),
('include "foo"', AppArmorException ), # LP: 1738880 (relative)
('include "foo" # comment', AppArmorException ),
('include "foo"#comment', AppArmorException ),
(' include "foo" ', AppArmorException ),
('include "foo/bar"', AppArmorException ),
('include "foo/bar" # comment', AppArmorException ),
('include "foo/bar"#comment', AppArmorException ),
(' include "foo/bar" ', AppArmorException ),
('include foo', AppArmorException ), # LP: 1738879 (no quotes)
('include foo/bar', AppArmorException ),
('include /foo/bar', AppArmorException ),
('include foo bar', AppArmorException ), # LP: 1738877 (space in name)
('include foo bar/baz', AppArmorException ),
('include "foo bar"', AppArmorException ),
('include /foo bar', AppArmorException ),
('include "/foo bar"', AppArmorException ),
('include "foo bar/baz"', AppArmorException ),
]
def _run_test(self, params, expected):

View File

@@ -23,6 +23,10 @@ class TestHotkeyConflicts(AATest):
tests = [
(['CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_OFF', 'CMD_ABORT', 'CMD_FINISHED'], True), # aa.py available_buttons() with CMD_AUDIT_OFF
(['CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_NEW', 'CMD_ABORT', 'CMD_FINISHED'], True), # aa.py available_buttons() with CMD_AUDIT_NEW
(['CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_OFF', 'CMD_USER_ON', 'CMD_ABORT', 'CMD_FINISHED'], True), # aa.py available_buttons() with CMD_AUDIT_OFF and CMD_USER_ON
(['CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_OFF', 'CMD_USER_OFF', 'CMD_ABORT', 'CMD_FINISHED'], True), # aa.py available_buttons() with CMD_AUDIT_OFF and CMD_USER_OFF
(['CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_NEW', 'CMD_USER_ON', 'CMD_ABORT', 'CMD_FINISHED'], True), # aa.py available_buttons() with CMD_AUDIT_NEW and CMD_USER_ON
(['CMD_ALLOW', 'CMD_DENY', 'CMD_IGNORE_ENTRY', 'CMD_GLOB', 'CMD_GLOBEXT', 'CMD_NEW', 'CMD_AUDIT_NEW', 'CMD_USER_OFF', 'CMD_ABORT', 'CMD_FINISHED'], True), # aa.py available_buttons() with CMD_AUDIT_NEW and CMD_USER_OFF
(['CMD_SAVE_CHANGES', 'CMD_SAVE_SELECTED', 'CMD_VIEW_CHANGES', 'CMD_VIEW_CHANGES_CLEAN', 'CMD_ABORT'], True), # aa.py save_profiles()
(['CMD_VIEW_PROFILE', 'CMD_USE_PROFILE', 'CMD_CREATE_PROFILE', 'CMD_ABORT'], True), # aa.py get_profile()
(['CMD_UPLOAD_CHANGES', 'CMD_VIEW_CHANGES', 'CMD_ASK_LATER', 'CMD_ASK_NEVER', 'CMD_ABORT'], True), # aa.py console_select_and_upload_profiles()